// 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 InstanceTemplates || Instances || MachineImages || RegionInstanceTemplates || RegionInstances
  import Foundation
  import GoogleCloudWkt

  /// An access configuration attached to an instance's network interface.
  /// Only one access config per instance is supported.
  public struct AccessConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Applies to ipv6AccessConfigs only.
    /// The first IPv6 address of the external IPv6 range associated
    /// with this instance, prefix length is stored inexternalIpv6PrefixLength in ipv6AccessConfig. To
    /// use a static external IP address, it must be unused and in the same region
    /// as the instance's zone. If not specified, Google Cloud will automatically
    /// assign an external IPv6 address from the instance's subnetwork.
    public var externalIpv6: Swift.String? = nil

    /// Applies to ipv6AccessConfigs only. The prefix length of the
    /// external IPv6 range.
    public var externalIpv6PrefixLength: Swift.Int32? = nil

    /// Output only. [Output Only] Type of the resource. Alwayscompute#accessConfig for access configs.
    public var kind: Swift.String? = nil

    /// The name of this access configuration. In accessConfigs
    /// (IPv4), the default and recommended name is External NAT, but
    /// you can use any arbitrary string, such as My external IP orNetwork Access. In ipv6AccessConfigs, the
    /// recommend name is External IPv6.
    public var name: Swift.String? = nil

    /// Applies to accessConfigs (IPv4) only. Anexternal IP
    /// address associated with this instance. Specify an unused static
    /// external IP address available to the project or leave this field undefined
    /// to use an IP from a shared ephemeral IP address pool. If you specify a
    /// static external IP address, it must live in the same region as the zone of
    /// the instance.
    public var natIp: Swift.String? = nil

    /// This signifies the networking tier used for configuring this access
    /// configuration and can only take the following values: PREMIUM,STANDARD.
    ///
    /// If an AccessConfig is specified without a valid external IP address, an
    /// ephemeral IP will be created with this networkTier.
    ///
    /// If an AccessConfig with a valid external IP address is specified, it must
    /// match that of the networkTier associated with the Address resource owning
    /// that IP.
    public var networkTier: AccessConfig.NetworkTier? = nil

    /// The DNS domain name for the public PTR record.
    ///
    /// You can set this field only if the `setPublicPtr` field is enabled inaccessConfig. If this field is unspecified inipv6AccessConfig, a default PTR record will be created for
    /// first IP in associated external IPv6 range.
    public var publicPtrDomainName: Swift.String? = nil

    /// The resource URL for the security policy associated with this access
    /// config.
    public var securityPolicy: Swift.String? = nil

    /// Specifies whether a public DNS 'PTR' record should be created to map the
    /// external IP address of the instance to a DNS domain name.
    ///
    /// This field is not used in ipv6AccessConfig. A default PTR
    /// record will be created if the VM has external IPv6 range associated.
    public var setPublicPtr: Swift.Bool? = nil

    /// The type of configuration. In accessConfigs (IPv4), the
    /// default and only option is ONE_TO_ONE_NAT. Inipv6AccessConfigs, the default and only option isDIRECT_IPV6.
    public var type: AccessConfig.Type_? = nil

    /// Initialize a new instance of `AccessConfig`.
    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 = AccessConfig().with { $0.externalIpv6 = ... }
    /// ```
    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 externalIpv6 = "externalIpv6"
      case externalIpv6PrefixLength = "externalIpv6PrefixLength"
      case kind = "kind"
      case name = "name"
      case natIp = "natIP"
      case networkTier = "networkTier"
      case publicPtrDomainName = "publicPtrDomainName"
      case securityPolicy = "securityPolicy"
      case setPublicPtr = "setPublicPtr"
      case type = "type"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.externalIpv6 = try container.decodeIfPresent(Swift.String.self, forKey: .externalIpv6)
      self.externalIpv6PrefixLength = try container.decodeIfPresent(
        Swift.Int32.self, forKey: .externalIpv6PrefixLength)
      self.kind = try container.decodeIfPresent(Swift.String.self, forKey: .kind)
      self.name = try container.decodeIfPresent(Swift.String.self, forKey: .name)
      self.natIp = try container.decodeIfPresent(Swift.String.self, forKey: .natIp)
      self.networkTier = try container.decodeIfPresent(
        AccessConfig.NetworkTier.self, forKey: .networkTier)
      self.publicPtrDomainName = try container.decodeIfPresent(
        Swift.String.self, forKey: .publicPtrDomainName)
      self.securityPolicy = try container.decodeIfPresent(
        Swift.String.self, forKey: .securityPolicy)
      self.setPublicPtr = try container.decodeIfPresent(Swift.Bool.self, forKey: .setPublicPtr)
      self.type = try container.decodeIfPresent(AccessConfig.Type_.self, forKey: .type)
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.externalIpv6, forKey: .externalIpv6)
      try container.encode(self.externalIpv6PrefixLength, forKey: .externalIpv6PrefixLength)
      try container.encode(self.kind, forKey: .kind)
      try container.encode(self.name, forKey: .name)
      try container.encode(self.natIp, forKey: .natIp)
      try container.encode(self.networkTier, forKey: .networkTier)
      try container.encode(self.publicPtrDomainName, forKey: .publicPtrDomainName)
      try container.encode(self.securityPolicy, forKey: .securityPolicy)
      try container.encode(self.setPublicPtr, forKey: .setPublicPtr)
      try container.encode(self.type, forKey: .type)
    }

    /// The enumerated type for the [networkTier][google.cloud.compute.v1.AccessConfig.networkTier] field.
    ///
    /// [google.cloud.compute.v1.AccessConfig.networkTier]: <doc:AccessConfig/NetworkTier>
    public enum NetworkTier: Codable, Equatable, Sendable {
      /// Public internet quality with fixed bandwidth.
      case fixedStandard
      /// High quality, Google-grade network tier, support for all networking
      /// products.
      case premium
      /// Public internet quality, only limited support for other networking
      /// products.
      case standard
      /// (Output only) Temporary tier for FIXED_STANDARD when fixed standard tier
      /// is expired or not configured.
      case standardOverridesFixedStandard
      /// 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 = .fixedStandard
      }

      /// 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 .fixedStandard: return 0
        case .premium: return 1
        case .standard: return 2
        case .standardOverridesFixedStandard: 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 .fixedStandard: return "FIXED_STANDARD"
        case .premium: return "PREMIUM"
        case .standard: return "STANDARD"
        case .standardOverridesFixedStandard: return "STANDARD_OVERRIDES_FIXED_STANDARD"
        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:NetworkTier/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "FIXED_STANDARD": self = .fixedStandard
        case "PREMIUM": self = .premium
        case "STANDARD": self = .standard
        case "STANDARD_OVERRIDES_FIXED_STANDARD": self = .standardOverridesFixedStandard
        default: self = .unknownStringValue(stringValue)
        }
      }

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

    /// The enumerated type for the [type][google.cloud.compute.v1.AccessConfig.type] field.
    ///
    /// [google.cloud.compute.v1.AccessConfig.type]: <doc:AccessConfig/Type_>
    public enum Type_: Codable, Equatable, Sendable {
      case directIpv6
      case oneToOneNat
      /// 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 = .directIpv6
      }

      /// 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 .directIpv6: return 0
        case .oneToOneNat: return 1
        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 .directIpv6: return "DIRECT_IPV6"
        case .oneToOneNat: return "ONE_TO_ONE_NAT"
        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 "DIRECT_IPV6": self = .directIpv6
        case "ONE_TO_ONE_NAT": self = .oneToOneNat
        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 = .directIpv6
        case 1: self = .oneToOneNat
        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 .directIpv6: return try container.encode(0)
        case .oneToOneNat: return try container.encode(1)
        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.compute.v1.AccessConfig"
    }
    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
