// 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
import GoogleRpc

/// This operation resource represents operations that may have happened or are
/// happening on the cluster. All fields are output only.
public struct Operation: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Output only. The server-assigned ID for the operation.
  public var name: Swift.String = Swift.String()

  /// Output only. The name of the Google Compute Engine
  /// [zone](https://cloud.google.com/compute/docs/zones#available)
  /// in which the operation is taking place. This field is deprecated, use
  /// location instead.
  @available(*, deprecated)
  public var zone: Swift.String = Swift.String()

  /// Output only. The operation type.
  public var operationType: Operation.Type_ = Operation.Type_()

  /// Output only. The current status of the operation.
  public var status: Operation.Status = Operation.Status()

  /// Output only. Detailed operation progress, if available.
  public var detail: Swift.String = Swift.String()

  /// Output only. If an error has occurred, a textual description of the error.
  /// Deprecated. Use the field error instead.
  @available(*, deprecated)
  public var statusMessage: Swift.String = Swift.String()

  /// Output only. Server-defined URI for the operation. Example:
  /// `https://container.googleapis.com/v1alpha1/projects/123/locations/us-central1/operations/operation-123`.
  public var selfLink: Swift.String = Swift.String()

  /// Output only. Server-defined URI for the target of the operation. The format
  /// of this is a URI to the resource being modified (such as a cluster, node
  /// pool, or node). For node pool repairs, there may be multiple nodes being
  /// repaired, but only one will be the target.
  ///
  /// Examples:
  ///
  /// -
  /// ##
  /// `https://container.googleapis.com/v1/projects/123/locations/us-central1/clusters/my-cluster`
  ///
  /// ##
  /// `https://container.googleapis.com/v1/projects/123/zones/us-central1-c/clusters/my-cluster/nodePools/my-np`
  ///
  /// `https://container.googleapis.com/v1/projects/123/zones/us-central1-c/clusters/my-cluster/nodePools/my-np/node/my-node`
  public var targetLink: Swift.String = Swift.String()

  /// Output only. The name of the Google Compute Engine
  /// [zone](https://cloud.google.com/compute/docs/regions-zones/regions-zones#available)
  /// or
  /// [region](https://cloud.google.com/compute/docs/regions-zones/regions-zones#available)
  /// in which the cluster resides.
  public var location: Swift.String = Swift.String()

  /// Output only. The time the operation started, in
  /// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
  public var startTime: Swift.String = Swift.String()

  /// Output only. The time the operation completed, in
  /// [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
  public var endTime: Swift.String = Swift.String()

  /// Output only. Progress information for an operation.
  public var progress: OperationProgress? = nil

  /// Which conditions caused the current cluster state.
  /// Deprecated. Use field error instead.
  @available(*, deprecated)
  public var clusterConditions: [StatusCondition] = []

  /// Which conditions caused the current node pool state.
  /// Deprecated. Use field error instead.
  @available(*, deprecated)
  public var nodepoolConditions: [StatusCondition] = []

  /// The error result of the operation in case of failure.
  public var error: GoogleRpc.Status? = nil

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

  /// Current status of the operation.
  public enum Status: Codable, Equatable, Sendable {
    /// Not set.
    case unspecified
    /// The operation has been created.
    case pending
    /// The operation is currently running.
    case running
    /// The operation is done, either cancelled or completed.
    case done
    /// The operation is aborting.
    case aborting
    /// 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 .pending: return 1
      case .running: return 2
      case .done: return 3
      case .aborting: return 4
      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 "STATUS_UNSPECIFIED"
      case .pending: return "PENDING"
      case .running: return "RUNNING"
      case .done: return "DONE"
      case .aborting: return "ABORTING"
      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:Status/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "STATUS_UNSPECIFIED": self = .unspecified
      case "PENDING": self = .pending
      case "RUNNING": self = .running
      case "DONE": self = .done
      case "ABORTING": self = .aborting
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Status/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .pending
      case 2: self = .running
      case 3: self = .done
      case 4: self = .aborting
      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 .pending: return try container.encode(1)
      case .running: return try container.encode(2)
      case .done: return try container.encode(3)
      case .aborting: return try container.encode(4)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  /// Operation type categorizes the operation.
  public enum Type_: Codable, Equatable, Sendable {
    /// Not set.
    case unspecified
    /// The cluster is being created. The cluster should be assumed to be
    /// unusable until the operation finishes.
    ///
    /// In the event of the operation failing, the cluster will enter the
    /// [ERROR state][google.container.v1.Cluster.Status.ERROR] and eventually be
    /// deleted.
    ///
    /// [google.container.v1.Cluster.Status.ERROR]: <doc:Cluster/Status/error>
    case createCluster
    /// The cluster is being deleted. The cluster should be assumed to be
    /// unusable as soon as this operation starts.
    ///
    /// In the event of the operation failing, the cluster will enter the
    /// [ERROR state][google.container.v1.Cluster.Status.ERROR] and the deletion
    /// will be automatically retried until completed.
    ///
    /// [google.container.v1.Cluster.Status.ERROR]: <doc:Cluster/Status/error>
    case deleteCluster
    /// The [cluster
    /// version][google.container.v1.ClusterUpdate.desired_master_version] is
    /// being updated. Note that this includes "upgrades" to the same version,
    /// which are simply a recreation. This also includes
    /// [auto-upgrades](https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-upgrades#upgrading_automatically).
    /// For more details, see [documentation on cluster
    /// upgrades](https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-upgrades#cluster_upgrades).
    ///
    /// [google.container.v1.ClusterUpdate.desired_master_version]: <doc:ClusterUpdate/desiredMasterVersion>
    case upgradeMaster
    /// A node pool is being updated. Despite calling this an "upgrade", this
    /// includes most forms of updates to node pools. This also includes
    /// [auto-upgrades](https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-upgrades).
    ///
    /// This operation sets the
    /// [progress][google.container.v1.Operation.progress] field and may be
    /// [canceled][google.container.v1.ClusterManager.CancelOperation].
    ///
    /// The upgrade strategy depends on [node pool
    /// configuration](https://cloud.google.com/kubernetes-engine/docs/concepts/node-pool-upgrade-strategies).
    /// The nodes are generally still usable during this operation.
    ///
    /// [google.container.v1.ClusterManager.CancelOperation]: <doc:ClusterManager/cancelOperation(request:)>
    /// [google.container.v1.Operation.progress]: <doc:Operation/progress>
    case upgradeNodes
    /// A problem has been detected with the control plane and is being repaired.
    /// This operation type is initiated by GKE. For more details, see
    /// [documentation on
    /// repairs](https://cloud.google.com/kubernetes-engine/docs/concepts/maintenance-windows-and-exclusions#repairs).
    case repairCluster
    /// The cluster is being updated. This is a broad category of operations and
    /// includes operations that only change metadata as well as those that must
    /// recreate the entire cluster. If the control plane must be recreated, this
    /// will cause temporary downtime for zonal clusters.
    ///
    /// Some features require recreating the nodes as well. Those will be
    /// recreated as separate operations and the update may not be completely
    /// functional until the node pools recreations finish. Node recreations will
    /// generally follow [maintenance
    /// policies](https://cloud.google.com/kubernetes-engine/docs/concepts/maintenance-windows-and-exclusions).
    ///
    /// Some GKE-initiated operations use this type. This includes certain types
    /// of auto-upgrades and incident mitigations.
    case updateCluster
    /// A node pool is being created. The node pool should be assumed to be
    /// unusable until this operation finishes. In the event of an error, the
    /// node pool may be partially created.
    ///
    /// If enabled, [node
    /// autoprovisioning](https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning)
    /// may have automatically initiated such operations.
    case createNodePool
    /// The node pool is being deleted. The node pool should be assumed to be
    /// unusable as soon as this operation starts.
    case deleteNodePool
    /// The node pool's [manamagent][google.container.v1.NodePool.management]
    /// field is being updated. These operations only update metadata and may be
    /// concurrent with most other operations.
    ///
    /// [google.container.v1.NodePool.management]: <doc:NodePool/management>
    case setNodePoolManagement
    /// A problem has been detected with nodes and [they are being
    /// repaired](https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-repair).
    /// This operation type is initiated by GKE, typically automatically. This
    /// operation may be concurrent with other operations and there may be
    /// multiple repairs occurring on the same node pool.
    case autoRepairNodes
    /// Unused. Automatic node upgrade uses
    /// [UPGRADE_NODES][google.container.v1.Operation.Type.UPGRADE_NODES].
    ///
    /// [google.container.v1.Operation.Type.UPGRADE_NODES]: <doc:Operation/Type_/upgradeNodes>
    @available(*, deprecated)
    case autoUpgradeNodes
    /// Unused. Updating labels uses
    /// [UPDATE_CLUSTER][google.container.v1.Operation.Type.UPDATE_CLUSTER].
    ///
    /// [google.container.v1.Operation.Type.UPDATE_CLUSTER]: <doc:Operation/Type_/updateCluster>
    @available(*, deprecated)
    case setLabels
    /// Unused. Updating master auth uses
    /// [UPDATE_CLUSTER][google.container.v1.Operation.Type.UPDATE_CLUSTER].
    ///
    /// [google.container.v1.Operation.Type.UPDATE_CLUSTER]: <doc:Operation/Type_/updateCluster>
    @available(*, deprecated)
    case setMasterAuth
    /// The node pool is being resized. With the exception of resizing to or from
    /// size zero, the node pool is generally usable during this operation.
    case setNodePoolSize
    /// Unused. Updating network policy uses
    /// [UPDATE_CLUSTER][google.container.v1.Operation.Type.UPDATE_CLUSTER].
    ///
    /// [google.container.v1.Operation.Type.UPDATE_CLUSTER]: <doc:Operation/Type_/updateCluster>
    @available(*, deprecated)
    case setNetworkPolicy
    /// Unused. Updating maintenance policy uses
    /// [UPDATE_CLUSTER][google.container.v1.Operation.Type.UPDATE_CLUSTER].
    ///
    /// [google.container.v1.Operation.Type.UPDATE_CLUSTER]: <doc:Operation/Type_/updateCluster>
    @available(*, deprecated)
    case setMaintenancePolicy
    /// The control plane is being resized. This operation type is initiated by
    /// GKE. These operations are often performed preemptively to ensure that the
    /// control plane has sufficient resources and is not typically an indication
    /// of issues. For more details, see
    /// [documentation on
    /// resizes](https://cloud.google.com/kubernetes-engine/docs/concepts/maintenance-windows-and-exclusions#repairs).
    case resizeCluster
    /// Fleet features of GKE Enterprise are being upgraded. The cluster should
    /// be assumed to be blocked for other upgrades until the operation finishes.
    case fleetFeatureUpgrade
    /// 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 .createCluster: return 1
      case .deleteCluster: return 2
      case .upgradeMaster: return 3
      case .upgradeNodes: return 4
      case .repairCluster: return 5
      case .updateCluster: return 6
      case .createNodePool: return 7
      case .deleteNodePool: return 8
      case .setNodePoolManagement: return 9
      case .autoRepairNodes: return 10
      case .autoUpgradeNodes: return 11
      case .setLabels: return 12
      case .setMasterAuth: return 13
      case .setNodePoolSize: return 14
      case .setNetworkPolicy: return 15
      case .setMaintenancePolicy: return 16
      case .resizeCluster: return 18
      case .fleetFeatureUpgrade: return 19
      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 "TYPE_UNSPECIFIED"
      case .createCluster: return "CREATE_CLUSTER"
      case .deleteCluster: return "DELETE_CLUSTER"
      case .upgradeMaster: return "UPGRADE_MASTER"
      case .upgradeNodes: return "UPGRADE_NODES"
      case .repairCluster: return "REPAIR_CLUSTER"
      case .updateCluster: return "UPDATE_CLUSTER"
      case .createNodePool: return "CREATE_NODE_POOL"
      case .deleteNodePool: return "DELETE_NODE_POOL"
      case .setNodePoolManagement: return "SET_NODE_POOL_MANAGEMENT"
      case .autoRepairNodes: return "AUTO_REPAIR_NODES"
      case .autoUpgradeNodes: return "AUTO_UPGRADE_NODES"
      case .setLabels: return "SET_LABELS"
      case .setMasterAuth: return "SET_MASTER_AUTH"
      case .setNodePoolSize: return "SET_NODE_POOL_SIZE"
      case .setNetworkPolicy: return "SET_NETWORK_POLICY"
      case .setMaintenancePolicy: return "SET_MAINTENANCE_POLICY"
      case .resizeCluster: return "RESIZE_CLUSTER"
      case .fleetFeatureUpgrade: return "FLEET_FEATURE_UPGRADE"
      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:Type_/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "TYPE_UNSPECIFIED": self = .unspecified
      case "CREATE_CLUSTER": self = .createCluster
      case "DELETE_CLUSTER": self = .deleteCluster
      case "UPGRADE_MASTER": self = .upgradeMaster
      case "UPGRADE_NODES": self = .upgradeNodes
      case "REPAIR_CLUSTER": self = .repairCluster
      case "UPDATE_CLUSTER": self = .updateCluster
      case "CREATE_NODE_POOL": self = .createNodePool
      case "DELETE_NODE_POOL": self = .deleteNodePool
      case "SET_NODE_POOL_MANAGEMENT": self = .setNodePoolManagement
      case "AUTO_REPAIR_NODES": self = .autoRepairNodes
      case "AUTO_UPGRADE_NODES": self = .autoUpgradeNodes
      case "SET_LABELS": self = .setLabels
      case "SET_MASTER_AUTH": self = .setMasterAuth
      case "SET_NODE_POOL_SIZE": self = .setNodePoolSize
      case "SET_NETWORK_POLICY": self = .setNetworkPolicy
      case "SET_MAINTENANCE_POLICY": self = .setMaintenancePolicy
      case "RESIZE_CLUSTER": self = .resizeCluster
      case "FLEET_FEATURE_UPGRADE": self = .fleetFeatureUpgrade
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Type_/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .createCluster
      case 2: self = .deleteCluster
      case 3: self = .upgradeMaster
      case 4: self = .upgradeNodes
      case 5: self = .repairCluster
      case 6: self = .updateCluster
      case 7: self = .createNodePool
      case 8: self = .deleteNodePool
      case 9: self = .setNodePoolManagement
      case 10: self = .autoRepairNodes
      case 11: self = .autoUpgradeNodes
      case 12: self = .setLabels
      case 13: self = .setMasterAuth
      case 14: self = .setNodePoolSize
      case 15: self = .setNetworkPolicy
      case 16: self = .setMaintenancePolicy
      case 18: self = .resizeCluster
      case 19: self = .fleetFeatureUpgrade
      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 .createCluster: return try container.encode(1)
      case .deleteCluster: return try container.encode(2)
      case .upgradeMaster: return try container.encode(3)
      case .upgradeNodes: return try container.encode(4)
      case .repairCluster: return try container.encode(5)
      case .updateCluster: return try container.encode(6)
      case .createNodePool: return try container.encode(7)
      case .deleteNodePool: return try container.encode(8)
      case .setNodePoolManagement: return try container.encode(9)
      case .autoRepairNodes: return try container.encode(10)
      case .autoUpgradeNodes: return try container.encode(11)
      case .setLabels: return try container.encode(12)
      case .setMasterAuth: return try container.encode(13)
      case .setNodePoolSize: return try container.encode(14)
      case .setNetworkPolicy: return try container.encode(15)
      case .setMaintenancePolicy: return try container.encode(16)
      case .resizeCluster: return try container.encode(18)
      case .fleetFeatureUpgrade: return try container.encode(19)
      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.container.v1.Operation"
  }
  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)
  }
}
