// 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 FeatureRegistryService
  import Foundation
  import GoogleCloudWkt

  /// Vertex AI Feature Group.
  public struct FeatureGroup: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Identifier. Name of the FeatureGroup. Format:
    /// `projects/{project}/locations/{location}/featureGroups/{featureGroup}`
    public var name: Swift.String = Swift.String()

    /// Output only. Timestamp when this FeatureGroup was created.
    public var createTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. Timestamp when this FeatureGroup was last updated.
    public var updateTime: GoogleCloudWkt.Timestamp? = nil

    /// Optional. Used to perform consistent read-modify-write updates. If not set,
    /// a blind "overwrite" update happens.
    public var etag: Swift.String = Swift.String()

    /// Optional. The labels with user-defined metadata to organize your
    /// FeatureGroup.
    ///
    /// Label keys and values can be no longer than 64 characters
    /// (Unicode codepoints), can only contain lowercase letters, numeric
    /// characters, underscores and dashes. International characters are allowed.
    ///
    /// See https://goo.gl/xmQnxf for more information on and examples of labels.
    /// No more than 64 user labels can be associated with one
    /// FeatureGroup(System labels are excluded)." System reserved label keys
    /// are prefixed with "aiplatform.googleapis.com/" and are immutable.
    public var labels: [Swift.String: Swift.String] = [:]

    /// Optional. Description of the FeatureGroup.
    public var description: Swift.String = Swift.String()

    public var source: OneOf_Source? = nil

    /// Initialize a new instance of `FeatureGroup`.
    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 = FeatureGroup().with { $0.bigQuery = ... }
    /// ```
    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 bigQuery = "bigQuery"
      case name = "name"
      case createTime = "createTime"
      case updateTime = "updateTime"
      case etag = "etag"
      case labels = "labels"
      case description = "description"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.name = try container.decode(Swift.String.self, forKey: .name)
      self.createTime = try container.decodeIfPresent(
        GoogleCloudWkt.Timestamp.self, forKey: .createTime)
      self.updateTime = try container.decodeIfPresent(
        GoogleCloudWkt.Timestamp.self, forKey: .updateTime)
      self.etag = try container.decode(Swift.String.self, forKey: .etag)
      self.labels = try container.decode([Swift.String: Swift.String].self, forKey: .labels)
      self.description = try container.decode(Swift.String.self, forKey: .description)

      var source: OneOf_Source? = nil
      let sourceCheckAndSet = {
        if source != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'source'"))
        }
        source = $0
      }
      if let bigQuery = try container.decodeIfPresent(
        FeatureGroup.BigQuery?.self, forKey: .bigQuery)
      {
        try sourceCheckAndSet(.bigQuery(bigQuery))
      }
      self.source = source
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.name, forKey: .name)
      try container.encode(self.createTime, forKey: .createTime)
      try container.encode(self.updateTime, forKey: .updateTime)
      try container.encode(self.etag, forKey: .etag)
      try container.encode(self.labels, forKey: .labels)
      try container.encode(self.description, forKey: .description)

      if let choice = self.source {
        switch choice {
        case .bigQuery(let value):
          try container.encode(value, forKey: .bigQuery)
        }
      }
    }

    /// Input source type for BigQuery Tables and Views.
    public struct BigQuery: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. Immutable. The BigQuery source URI that points to either a
      /// BigQuery Table or View.
      public var bigQuerySource: BigQuerySource? = nil

      /// Optional. Columns to construct entity_id / row keys.
      /// If not provided defaults to `entity_id`.
      public var entityIdColumns: [Swift.String] = []

      /// Optional. Set if the data source is not a time-series.
      public var staticDataSource: Swift.Bool = Swift.Bool()

      /// Optional. If the source is a time-series source, this can be set to
      /// control how downstream sources (ex:
      /// [FeatureView][google.cloud.aiplatform.v1.FeatureView] ) will treat
      /// time-series sources. If not set, will treat the source as a time-series
      /// source with `feature_timestamp` as timestamp column and no scan boundary.
      ///
      /// [google.cloud.aiplatform.v1.FeatureView]: <doc:FeatureView>
      public var timeSeries: FeatureGroup.BigQuery.TimeSeries? = nil

      /// Optional. If set, all feature values will be fetched
      /// from a single row per unique entityId including nulls.
      /// If not set, will collapse all rows for each unique entityId into a singe
      /// row with any non-null values if present, if no non-null values are
      /// present will sync null.
      /// ex: If source has schema
      /// `(entity_id, feature_timestamp, f0, f1)` and the following rows:
      /// `(e1, 2020-01-01T10:00:00.123Z, 10, 15)`
      /// `(e1, 2020-02-01T10:00:00.123Z, 20, null)`
      /// If dense is set, `(e1, 20, null)` is synced to online stores. If dense is
      /// not set, `(e1, 20, 15)` is synced to online stores.
      public var dense: Swift.Bool = Swift.Bool()

      /// Initialize a new instance of `BigQuery`.
      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 = BigQuery().with { $0.bigQuerySource = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public struct TimeSeries: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Optional. Column hosting timestamp values for a time-series source.
        /// Will be used to determine the latest `feature_values` for each entity.
        /// Optional. If not provided, column named `feature_timestamp` of
        /// type `TIMESTAMP` will be used.
        public var timestampColumn: Swift.String = Swift.String()

        /// Initialize a new instance of `TimeSeries`.
        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 = TimeSeries().with { $0.timestampColumn = ... }
        /// ```
        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.FeatureGroup.BigQuery.TimeSeries"
        }
        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 static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.aiplatform.v1.FeatureGroup.BigQuery"
      }
      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_Source: Codable, Equatable, Sendable {
      /// Indicates that features for this group come from BigQuery Table/View.
      /// By default treats the source as a sparse time series source. The BigQuery
      /// source table or view must have at least one entity ID column and a column
      /// named `feature_timestamp`.
      indirect case bigQuery(FeatureGroup.BigQuery?)
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.aiplatform.v1.FeatureGroup"
    }
    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
