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

/// Common config settings for resources of Compute Engine cluster
/// instances, applicable to all instances in the cluster.
public struct GceClusterConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Optional. The Compute Engine zone where the Dataproc cluster will be
  /// located. If omitted, the service will pick a zone in the cluster's Compute
  /// Engine region. On a get request, zone will always be present.
  ///
  /// A full URL, partial URI, or short name are valid. Examples:
  ///
  /// * `https://www.googleapis.com/compute/v1/projects/[project_id]/zones/[zone]`
  /// * `projects/[project_id]/zones/[zone]`
  /// * `[zone]`
  public var zoneUri: Swift.String = Swift.String()

  /// Optional. The Compute Engine network to be used for machine
  /// communications. Cannot be specified with subnetwork_uri. If neither
  /// `network_uri` nor `subnetwork_uri` is specified, the "default" network of
  /// the project is used, if it exists. Cannot be a "Custom Subnet Network" (see
  /// [Using Subnetworks](https://cloud.google.com/compute/docs/subnetworks) for
  /// more information).
  ///
  /// A full URL, partial URI, or short name are valid. Examples:
  ///
  /// * `https://www.googleapis.com/compute/v1/projects/[project_id]/global/networks/default`
  /// * `projects/[project_id]/global/networks/default`
  /// * `default`
  public var networkUri: Swift.String = Swift.String()

  /// Optional. The Compute Engine subnetwork to be used for machine
  /// communications. Cannot be specified with network_uri.
  ///
  /// A full URL, partial URI, or short name are valid. Examples:
  ///
  /// * `https://www.googleapis.com/compute/v1/projects/[project_id]/regions/[region]/subnetworks/sub0`
  /// * `projects/[project_id]/regions/[region]/subnetworks/sub0`
  /// * `sub0`
  public var subnetworkUri: Swift.String = Swift.String()

  /// Optional. This setting applies to subnetwork-enabled networks. It is set to
  /// `true` by default in clusters created with image versions 2.2.x.
  ///
  /// When set to `true`:
  ///
  /// * All cluster VMs have internal IP addresses.
  /// * [Google Private Access]
  /// (https://cloud.google.com/vpc/docs/private-google-access)
  /// must be enabled to access Dataproc and other Google Cloud APIs.
  /// * Off-cluster dependencies must be configured to be accessible
  /// without external IP addresses.
  ///
  /// When set to `false`:
  ///
  /// * Cluster VMs are not restricted to internal IP addresses.
  /// * Ephemeral external IP addresses are assigned to each cluster VM.
  public var internalIpOnly: Swift.Bool? = nil

  /// Optional. The type of IPv6 access for a cluster.
  public var privateIpv6GoogleAccess: GceClusterConfig.PrivateIpv6GoogleAccess =
    GceClusterConfig.PrivateIpv6GoogleAccess()

  /// Optional. The [Dataproc service
  /// account](https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/service-accounts#service_accounts_in_dataproc)
  /// (also see [VM Data Plane
  /// identity](https://cloud.google.com/dataproc/docs/concepts/iam/dataproc-principals#vm_service_account_data_plane_identity))
  /// used by Dataproc cluster VM instances to access Google Cloud Platform
  /// services.
  ///
  /// If not specified, the
  /// [Compute Engine default service
  /// account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account)
  /// is used.
  public var serviceAccount: Swift.String = Swift.String()

  /// Optional. The URIs of service account scopes to be included in
  /// Compute Engine instances. The following base set of scopes is always
  /// included:
  ///
  /// * https://www.googleapis.com/auth/cloud.useraccounts.readonly
  /// * https://www.googleapis.com/auth/devstorage.read_write
  /// * https://www.googleapis.com/auth/logging.write
  ///
  /// If no scopes are specified, the following defaults are also provided:
  ///
  /// * https://www.googleapis.com/auth/bigquery
  /// * https://www.googleapis.com/auth/bigtable.admin.table
  /// * https://www.googleapis.com/auth/bigtable.data
  /// * https://www.googleapis.com/auth/devstorage.full_control
  public var serviceAccountScopes: [Swift.String] = []

  /// The Compute Engine network tags to add to all instances (see [Tagging
  /// instances](https://cloud.google.com/vpc/docs/add-remove-network-tags)).
  public var tags: [Swift.String] = []

  /// Optional. The Compute Engine metadata entries to add to all instances (see
  /// [Project and instance
  /// metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata#project_and_instance_metadata)).
  public var metadata: [Swift.String: Swift.String] = [:]

  /// Optional. Reservation Affinity for consuming Zonal reservation.
  public var reservationAffinity: ReservationAffinity? = nil

  /// Optional. Node Group Affinity for sole-tenant clusters.
  public var nodeGroupAffinity: NodeGroupAffinity? = nil

  /// Optional. Shielded Instance Config for clusters using [Compute Engine
  /// Shielded
  /// VMs](https://cloud.google.com/security/shielded-cloud/shielded-vm).
  public var shieldedInstanceConfig: ShieldedInstanceConfig? = nil

  /// Optional. Confidential Instance Config for clusters using [Confidential
  /// VMs](https://cloud.google.com/confidential-computing/confidential-vm/docs).
  public var confidentialInstanceConfig: ConfidentialInstanceConfig? = nil

  /// Optional. [Resource manager tags]
  /// (https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing)
  /// to add to all instances (see [Use secure tags]
  /// (https://cloud.google.com/dataproc/docs/guides/use-secure-tags)).
  public var resourceManagerTags: [Swift.String: Swift.String] = [:]

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

  /// `PrivateIpv6GoogleAccess` controls whether and how Dataproc cluster nodes
  /// can communicate with Google Services through gRPC over IPv6.
  /// These values are directly mapped to corresponding values in the
  /// [Compute Engine Instance
  /// fields](https://cloud.google.com/compute/docs/reference/rest/v1/instances).
  public enum PrivateIpv6GoogleAccess: Codable, Equatable, Sendable {
    /// If unspecified, Compute Engine default behavior will apply, which
    /// is the same as
    /// [INHERIT_FROM_SUBNETWORK][google.cloud.dataproc.v1.GceClusterConfig.PrivateIpv6GoogleAccess.INHERIT_FROM_SUBNETWORK].
    ///
    /// [google.cloud.dataproc.v1.GceClusterConfig.PrivateIpv6GoogleAccess.INHERIT_FROM_SUBNETWORK]: <doc:GceClusterConfig/PrivateIpv6GoogleAccess/inheritFromSubnetwork>
    case unspecified
    /// Private access to and from Google Services configuration
    /// inherited from the subnetwork configuration. This is the
    /// default Compute Engine behavior.
    case inheritFromSubnetwork
    /// Enables outbound private IPv6 access to Google Services from the Dataproc
    /// cluster.
    case outbound
    /// Enables bidirectional private IPv6 access between Google Services and the
    /// Dataproc cluster.
    case bidirectional
    /// 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 .inheritFromSubnetwork: return 1
      case .outbound: return 2
      case .bidirectional: return 3
      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 "PRIVATE_IPV6_GOOGLE_ACCESS_UNSPECIFIED"
      case .inheritFromSubnetwork: return "INHERIT_FROM_SUBNETWORK"
      case .outbound: return "OUTBOUND"
      case .bidirectional: return "BIDIRECTIONAL"
      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:PrivateIpv6GoogleAccess/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "PRIVATE_IPV6_GOOGLE_ACCESS_UNSPECIFIED": self = .unspecified
      case "INHERIT_FROM_SUBNETWORK": self = .inheritFromSubnetwork
      case "OUTBOUND": self = .outbound
      case "BIDIRECTIONAL": self = .bidirectional
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:PrivateIpv6GoogleAccess/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .inheritFromSubnetwork
      case 2: self = .outbound
      case 3: self = .bidirectional
      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 .inheritFromSubnetwork: return try container.encode(1)
      case .outbound: return try container.encode(2)
      case .bidirectional: return try container.encode(3)
      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.dataproc.v1.GceClusterConfig"
  }
  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)
  }
}
