// 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.

import Foundation
import GoogleCloudWkt

/// An Anthos cluster running on customer own infrastructure.
public struct AttachedCluster: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The name of this resource.
  ///
  /// Cluster names are formatted as
  /// `projects/<project-number>/locations/<region>/attachedClusters/<cluster-id>`.
  ///
  /// See [Resource Names](https://cloud.google.com/apis/design/resource_names)
  /// for more details on Google Cloud Platform resource names.
  public var name: Swift.String = Swift.String()

  /// Optional. A human readable description of this cluster.
  /// Cannot be longer than 255 UTF-8 encoded bytes.
  public var description: Swift.String = Swift.String()

  /// Required. OpenID Connect (OIDC) configuration for the cluster.
  public var oidcConfig: AttachedOidcConfig? = nil

  /// Required. The platform version for the cluster (e.g. `1.19.0-gke.1000`).
  ///
  /// You can list all supported versions on a given Google Cloud region by
  /// calling
  /// [GetAttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig].
  ///
  /// [google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig]: <doc:AttachedClusters/getAttachedServerConfig(request:)>
  public var platformVersion: Swift.String = Swift.String()

  /// Required. The Kubernetes distribution of the underlying attached cluster.
  ///
  /// Supported values: ["eks", "aks", "generic"].
  public var distribution: Swift.String = Swift.String()

  /// Output only. The region where this cluster runs.
  ///
  /// For EKS clusters, this is a AWS region. For AKS clusters,
  /// this is an Azure region.
  public var clusterRegion: Swift.String = Swift.String()

  /// Required. Fleet configuration.
  public var fleet: Fleet? = nil

  /// Output only. The current state of the cluster.
  public var state: AttachedCluster.State = AttachedCluster.State()

  /// Output only. A globally unique identifier for the cluster.
  public var uid: Swift.String = Swift.String()

  /// Output only. If set, there are currently changes in flight to the cluster.
  public var reconciling: Swift.Bool = Swift.Bool()

  /// Output only. The time at which this cluster was registered.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time at which this cluster was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Allows clients to perform consistent read-modify-writes
  /// through optimistic concurrency control.
  ///
  /// Can be sent on update and delete requests to ensure the
  /// client has an up-to-date value before proceeding.
  public var etag: Swift.String = Swift.String()

  /// Output only. The Kubernetes version of the cluster.
  public var kubernetesVersion: Swift.String = Swift.String()

  /// Optional. Annotations on the cluster.
  ///
  /// This field has the same restrictions as Kubernetes annotations.
  /// The total size of all keys and values combined is limited to 256k.
  /// Key can have 2 segments: prefix (optional) and name (required),
  /// separated by a slash (/).
  /// Prefix must be a DNS subdomain.
  /// Name must be 63 characters or less, begin and end with alphanumerics,
  /// with dashes (-), underscores (_), dots (.), and alphanumerics between.
  public var annotations: [Swift.String: Swift.String] = [:]

  /// Output only. Workload Identity settings.
  public var workloadIdentityConfig: WorkloadIdentityConfig? = nil

  /// Optional. Logging configuration for this cluster.
  public var loggingConfig: LoggingConfig? = nil

  /// Output only. A set of errors found in the cluster.
  public var errors: [AttachedClusterError] = []

  /// Optional. Configuration related to the cluster RBAC settings.
  public var authorization: AttachedClustersAuthorization? = nil

  /// Optional. Monitoring configuration for this cluster.
  public var monitoringConfig: MonitoringConfig? = nil

  /// Optional. Proxy configuration for outbound HTTP(S) traffic.
  public var proxyConfig: AttachedProxyConfig? = nil

  /// Optional. Binary Authorization configuration for this cluster.
  public var binaryAuthorization: BinaryAuthorization? = nil

  /// Optional. Security Posture configuration for this cluster.
  public var securityPostureConfig: SecurityPostureConfig? = nil

  /// Optional. Input only. Tag keys and values directly bound to this resource.
  ///
  /// The tag key must be specified in the format
  /// `<tag namespace>/<tag key name>,`
  /// where the tag namespace is the ID of the organization or name of the
  /// project that the tag key is defined in. The short name of a tag key or
  /// value can have a maximum length of 256 characters. The permitted character
  /// set for the short name includes UTF-8 encoded Unicode characters except
  /// single quotation marks (`'`), double quotation marks (`"`), backslashes
  /// (`\`), and forward slashes (`/`).
  ///
  /// See
  /// [Tags](https://cloud.google.com/resource-manager/docs/tags/tags-overview)
  /// for more details on Google Cloud Platform tags.
  public var tags: [Swift.String: Swift.String] = [:]

  /// Optional. Kubernetes configurations for auto-installed components on the
  /// cluster.
  public var systemComponentsConfig: SystemComponentsConfig? = nil

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

  /// The lifecycle state of the cluster.
  public enum State: Codable, Equatable, Sendable {
    /// Not set.
    case unspecified
    /// The PROVISIONING state indicates the cluster is being registered.
    case provisioning
    /// The RUNNING state indicates the cluster has been register and is fully
    /// usable.
    case running
    /// The RECONCILING state indicates that some work is actively being done on
    /// the cluster, such as upgrading software components.
    case reconciling
    /// The STOPPING state indicates the cluster is being de-registered.
    case stopping
    /// The ERROR state indicates the cluster is in a broken unrecoverable
    /// state.
    case error
    /// The DEGRADED state indicates the cluster requires user action to
    /// restore full functionality.
    case degraded
    /// Encodes an unknown integer value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownIntValue(Int)
    /// Encodes an unknown string value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownStringValue(String)

    public init() {
      self = .unspecified
    }

    /// Returns the integer value associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown string value, this returns `nil`.
    public var intValue: Int? {
      switch self {
      case .unspecified: return 0
      case .provisioning: return 1
      case .running: return 2
      case .reconciling: return 3
      case .stopping: return 4
      case .error: return 5
      case .degraded: return 6
      case .unknownIntValue(let v): return v
      case .unknownStringValue: return nil
      }
    }

    /// Returns the string value (or name) associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
    public var stringValue: Swift.String? {
      switch self {
      case .unspecified: return "STATE_UNSPECIFIED"
      case .provisioning: return "PROVISIONING"
      case .running: return "RUNNING"
      case .reconciling: return "RECONCILING"
      case .stopping: return "STOPPING"
      case .error: return "ERROR"
      case .degraded: return "DEGRADED"
      case .unknownIntValue: return nil
      case .unknownStringValue(let v): return v
      }
    }

    /// Initialize from a string value.
    ///
    /// If the value is unknown, this initializes to [`unknownStringValue`](doc:State/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "STATE_UNSPECIFIED": self = .unspecified
      case "PROVISIONING": self = .provisioning
      case "RUNNING": self = .running
      case "RECONCILING": self = .reconciling
      case "STOPPING": self = .stopping
      case "ERROR": self = .error
      case "DEGRADED": self = .degraded
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:State/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .provisioning
      case 2: self = .running
      case 3: self = .reconciling
      case 4: self = .stopping
      case 5: self = .error
      case 6: self = .degraded
      default: self = .unknownIntValue(intValue)
      }
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.singleValueContainer()
      if let v = try? container.decode(Int.self) {
        self.init(intValue: v)
        return
      }
      if let s = try? container.decode(String.self) {
        if let v = Int(s) {
          self.init(intValue: v)
        } else {
          self.init(stringValue: s)
        }
        return
      }
      throw DecodingError.dataCorruptedError(
        in: container, debugDescription: "Expected enum value, must be integer or string.")
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.singleValueContainer()
      switch self {
      case .unspecified: return try container.encode(0)
      case .provisioning: return try container.encode(1)
      case .running: return try container.encode(2)
      case .reconciling: return try container.encode(3)
      case .stopping: return try container.encode(4)
      case .error: return try container.encode(5)
      case .degraded: return try container.encode(6)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

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