// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if FeaturestoreService
  import Foundation
  import GoogleCloudWkt

  /// Request message for
  /// [FeaturestoreService.BatchReadFeatureValues][google.cloud.aiplatform.v1.FeaturestoreService.BatchReadFeatureValues].
  ///
  /// [google.cloud.aiplatform.v1.FeaturestoreService.BatchReadFeatureValues]: <doc:FeaturestoreService/batchReadFeatureValues(request:)>
  public struct BatchReadFeatureValuesRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. The resource name of the Featurestore from which to query Feature
    /// values. Format:
    /// `projects/{project}/locations/{location}/featurestores/{featurestore}`
    public var featurestore: Swift.String = Swift.String()

    /// Required. Specifies output location and format.
    public var destination: FeatureValueDestination? = nil

    /// When not empty, the specified fields in the *_read_instances source will be
    /// joined as-is in the output, in addition to those fields from the
    /// Featurestore Entity.
    ///
    /// For BigQuery source, the type of the pass-through values will be
    /// automatically inferred. For CSV source, the pass-through values will be
    /// passed as opaque bytes.
    public var passThroughFields: [BatchReadFeatureValuesRequest.PassThroughField] = []

    /// Required. Specifies EntityType grouping Features to read values of and
    /// settings.
    public var entityTypeSpecs: [BatchReadFeatureValuesRequest.EntityTypeSpec] = []

    /// Optional. Excludes Feature values with feature generation timestamp before
    /// this timestamp. If not set, retrieve oldest values kept in Feature Store.
    /// Timestamp, if present, must not have higher than millisecond precision.
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    public var readOption: OneOf_ReadOption? = nil

    /// Initialize a new instance of `BatchReadFeatureValuesRequest`.
    public init() {}

    /// Use `config` to return a new instance of this object, with some fields updated.
    ///
    /// Commonly used to initialize the value, for example:
    ///
    /// ```
    /// let value = BatchReadFeatureValuesRequest().with { $0.csvReadInstances = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    private enum CodingKeys: Swift.String, CodingKey {
      case csvReadInstances = "csvReadInstances"
      case bigqueryReadInstances = "bigqueryReadInstances"
      case featurestore = "featurestore"
      case destination = "destination"
      case passThroughFields = "passThroughFields"
      case entityTypeSpecs = "entityTypeSpecs"
      case startTime = "startTime"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.featurestore = try container.decode(Swift.String.self, forKey: .featurestore)
      self.destination = try container.decodeIfPresent(
        FeatureValueDestination.self, forKey: .destination)
      self.passThroughFields = try container.decode(
        [BatchReadFeatureValuesRequest.PassThroughField].self, forKey: .passThroughFields)
      self.entityTypeSpecs = try container.decode(
        [BatchReadFeatureValuesRequest.EntityTypeSpec].self, forKey: .entityTypeSpecs)
      self.startTime = try container.decodeIfPresent(
        GoogleCloudWkt.Timestamp.self, forKey: .startTime)

      var readOption: OneOf_ReadOption? = nil
      let readOptionCheckAndSet = {
        if readOption != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'readOption'"))
        }
        readOption = $0
      }
      if let csvReadInstances = try container.decodeIfPresent(
        CsvSource?.self, forKey: .csvReadInstances)
      {
        try readOptionCheckAndSet(.csvReadInstances(csvReadInstances))
      }
      if let bigqueryReadInstances = try container.decodeIfPresent(
        BigQuerySource?.self, forKey: .bigqueryReadInstances)
      {
        try readOptionCheckAndSet(.bigqueryReadInstances(bigqueryReadInstances))
      }
      self.readOption = readOption
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.featurestore, forKey: .featurestore)
      try container.encode(self.destination, forKey: .destination)
      try container.encode(self.passThroughFields, forKey: .passThroughFields)
      try container.encode(self.entityTypeSpecs, forKey: .entityTypeSpecs)
      try container.encode(self.startTime, forKey: .startTime)

      if let choice = self.readOption {
        switch choice {
        case .csvReadInstances(let value):
          try container.encode(value, forKey: .csvReadInstances)
        case .bigqueryReadInstances(let value):
          try container.encode(value, forKey: .bigqueryReadInstances)
        }
      }
    }

    /// Describe pass-through fields in read_instance source.
    public struct PassThroughField: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. The name of the field in the CSV header or the name of the
      /// column in BigQuery table. The naming restriction is the same as
      /// [Feature.name][google.cloud.aiplatform.v1.Feature.name].
      ///
      /// [google.cloud.aiplatform.v1.Feature.name]: <doc:Feature/name>
      public var fieldName: Swift.String = Swift.String()

      /// Initialize a new instance of `PassThroughField`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = PassThroughField().with { $0.fieldName = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest.PassThroughField"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Selects Features of an EntityType to read values of and specifies read
    /// settings.
    public struct EntityTypeSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. ID of the EntityType to select Features. The EntityType id is
      /// the
      /// [entity_type_id][google.cloud.aiplatform.v1.CreateEntityTypeRequest.entity_type_id]
      /// specified during EntityType creation.
      ///
      /// [google.cloud.aiplatform.v1.CreateEntityTypeRequest.entity_type_id]: <doc:CreateEntityTypeRequest/entityTypeId>
      public var entityTypeId: Swift.String = Swift.String()

      /// Required. Selectors choosing which Feature values to read from the
      /// EntityType.
      public var featureSelector: FeatureSelector? = nil

      /// Per-Feature settings for the batch read.
      public var settings: [DestinationFeatureSetting] = []

      /// Initialize a new instance of `EntityTypeSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = EntityTypeSpec().with { $0.entityTypeId = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest.EntityTypeSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    public enum OneOf_ReadOption: Codable, Equatable, Sendable {
      /// Each read instance consists of exactly one read timestamp and one or more
      /// entity IDs identifying entities of the corresponding EntityTypes whose
      /// Features are requested.
      ///
      /// Each output instance contains Feature values of requested entities
      /// concatenated together as of the read time.
      ///
      /// An example read instance may be `foo_entity_id, bar_entity_id,
      /// 2020-01-01T10:00:00.123Z`.
      ///
      /// An example output instance may be `foo_entity_id, bar_entity_id,
      /// 2020-01-01T10:00:00.123Z, foo_entity_feature1_value,
      /// bar_entity_feature2_value`.
      ///
      /// Timestamp in each read instance must be millisecond-aligned.
      ///
      /// `csv_read_instances` are read instances stored in a plain-text CSV file.
      /// The header should be:
      ///     [ENTITY_TYPE_ID1], [ENTITY_TYPE_ID2], ..., timestamp
      ///
      /// The columns can be in any order.
      ///
      /// Values in the timestamp column must use the RFC 3339 format, e.g.
      /// `2012-07-30T10:43:17.123Z`.
      indirect case csvReadInstances(CsvSource?)
      /// Similar to csv_read_instances, but from BigQuery source.
      indirect case bigqueryReadInstances(BigQuerySource?)
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest"
    }
    public init(fromAny any: GoogleCloudWkt.`Any`) throws {
      self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
    }
    public func _pack() throws -> GoogleCloudWkt.Struct {
      return try GoogleCloudWkt._slowAnySerialize(message: self)
    }
  }
#endif
