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

  /// Represents a VPC Network resource.
  ///
  /// Networks connect resources to each other and to the internet. For more
  /// information, readVirtual Private Cloud (VPC) Network.
  public struct Network: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Deprecated in favor of subnet mode networks.
    /// The range of internal addresses that are legal on this network. This
    /// range is aCIDR specification, for example:192.168.0.0/16. Provided by the client when the network is
    /// created.
    @available(*, deprecated)
    public var ipv4Range: Swift.String? = nil

    /// Must be set to create a VPC network. If not set, a legacy network is
    /// created.
    ///
    /// When set to true, the VPC network is created in auto mode.
    /// When set to false, the VPC network is created in custom mode.
    ///
    /// An auto mode VPC network starts with one subnet per region. Each subnet
    /// has a predetermined range as described inAuto mode VPC network IP ranges.
    ///
    /// For custom mode VPC networks, you can add subnets using the subnetworksinsert
    /// method.
    public var autoCreateSubnetworks: Swift.Bool? = nil

    /// Output only. [Output Only] Creation timestamp inRFC3339
    /// text format.
    public var creationTimestamp: Swift.String? = nil

    /// An optional description of this resource. Provide this field when you
    /// create the resource.
    public var description: Swift.String? = nil

    /// Enable ULA internal ipv6 on this network. Enabling this feature will assign
    /// a /48 from google defined ULA prefix fd20::/20.
    /// .
    public var enableUlaInternalIpv6: Swift.Bool? = nil

    /// Output only. [Output Only] URL of the firewall policy the network is associated with.
    public var firewallPolicy: Swift.String? = nil

    /// [Output Only] The gateway address for default routing out of the network,
    /// selected by Google Cloud.
    public var gatewayIpv4: Swift.String? = nil

    /// Output only. [Output Only] The unique identifier for the resource. This identifier is
    /// defined by the server.
    public var id: Swift.UInt64? = nil

    /// When enabling ula internal ipv6, caller optionally can specify the /48
    /// range they want from the google defined ULA prefix fd20::/20. The input
    /// must be a valid /48 ULA IPv6 address and must be within the fd20::/20.
    /// Operation will fail if the speficied /48 is already in used by another
    /// resource. If the field is not speficied, then a /48 range will be randomly
    /// allocated from fd20::/20 and returned via this field.
    /// .
    public var internalIpv6Range: Swift.String? = nil

    /// Output only. [Output Only] Type of the resource. Always compute#network for
    /// networks.
    public var kind: Swift.String? = nil

    /// Maximum Transmission Unit in bytes.
    /// The minimum value for this field is 1300 and the maximum value is 8896.
    /// The suggested value is 1500, which is the default MTU used on the
    /// Internet, or 8896 if you want to use Jumbo frames. If unspecified, the
    /// value defaults to 1460.
    public var mtu: Swift.Int32? = nil

    /// Name of the resource. Provided by the client when the resource is created.
    /// The name must be 1-63 characters long, and comply withRFC1035.
    /// Specifically, the name must be 1-63 characters long and match the regular
    /// expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a
    /// lowercase letter, and all following characters (except for the last
    /// character) must be a dash, lowercase letter, or digit. The last character
    /// must be a lowercase letter or digit.
    public var name: Swift.String? = nil

    /// The network firewall policy enforcement order. Can be either
    /// AFTER_CLASSIC_FIREWALL or BEFORE_CLASSIC_FIREWALL. Defaults to
    /// AFTER_CLASSIC_FIREWALL if the field is not specified.
    public var networkFirewallPolicyEnforcementOrder:
      Network.NetworkFirewallPolicyEnforcementOrder? = nil

    /// A full or partial URL of the network profile to apply to this network.
    /// This field can be set only at resource creation time. For example, the
    /// following are valid URLs:
    ///
    ///    - https://www.googleapis.com/compute/{api_version}/projects/{project_id}/global/networkProfiles/{network_profile_name}
    ///    - projects/{project_id}/global/networkProfiles/{network_profile_name}
    public var networkProfile: Swift.String? = nil

    /// Input only. [Input Only] Additional params passed with the request, but not persisted
    /// as part of resource payload.
    public var params: NetworkParams? = nil

    /// Output only. [Output Only] A list of network peerings for the resource.
    public var peerings: [NetworkPeering] = []

    /// The network-level routing configuration for this network.  Used by Cloud
    /// Router to determine what type of network-wide routing behavior to enforce.
    public var routingConfig: NetworkRoutingConfig? = nil

    /// [Output Only] Server-defined URL for the resource.
    public var selfLink: Swift.String? = nil

    /// Output only. [Output Only] Server-defined URL for this resource with the resource id.
    public var selfLinkWithId: Swift.String? = nil

    /// [Output Only] Server-defined fully-qualified URLs for all subnetworks
    /// in this VPC network.
    public var subnetworks: [Swift.String] = []

    /// Initialize a new instance of `Network`.
    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 = Network().with { $0.ipv4Range = ... }
    /// ```
    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 ipv4Range = "IPv4Range"
      case autoCreateSubnetworks = "autoCreateSubnetworks"
      case creationTimestamp = "creationTimestamp"
      case description = "description"
      case enableUlaInternalIpv6 = "enableUlaInternalIpv6"
      case firewallPolicy = "firewallPolicy"
      case gatewayIpv4 = "gatewayIPv4"
      case id = "id"
      case internalIpv6Range = "internalIpv6Range"
      case kind = "kind"
      case mtu = "mtu"
      case name = "name"
      case networkFirewallPolicyEnforcementOrder = "networkFirewallPolicyEnforcementOrder"
      case networkProfile = "networkProfile"
      case params = "params"
      case peerings = "peerings"
      case routingConfig = "routingConfig"
      case selfLink = "selfLink"
      case selfLinkWithId = "selfLinkWithId"
      case subnetworks = "subnetworks"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.ipv4Range = try container.decodeIfPresent(Swift.String.self, forKey: .ipv4Range)
      self.autoCreateSubnetworks = try container.decodeIfPresent(
        Swift.Bool.self, forKey: .autoCreateSubnetworks)
      self.creationTimestamp = try container.decodeIfPresent(
        Swift.String.self, forKey: .creationTimestamp)
      self.description = try container.decodeIfPresent(Swift.String.self, forKey: .description)
      self.enableUlaInternalIpv6 = try container.decodeIfPresent(
        Swift.Bool.self, forKey: .enableUlaInternalIpv6)
      self.firewallPolicy = try container.decodeIfPresent(
        Swift.String.self, forKey: .firewallPolicy)
      self.gatewayIpv4 = try container.decodeIfPresent(Swift.String.self, forKey: .gatewayIpv4)
      self.id = try container.decodeIfPresent(Swift.UInt64.self, forKey: .id)
      self.internalIpv6Range = try container.decodeIfPresent(
        Swift.String.self, forKey: .internalIpv6Range)
      self.kind = try container.decodeIfPresent(Swift.String.self, forKey: .kind)
      self.mtu = try container.decodeIfPresent(Swift.Int32.self, forKey: .mtu)
      self.name = try container.decodeIfPresent(Swift.String.self, forKey: .name)
      self.networkFirewallPolicyEnforcementOrder = try container.decodeIfPresent(
        Network.NetworkFirewallPolicyEnforcementOrder.self,
        forKey: .networkFirewallPolicyEnforcementOrder)
      self.networkProfile = try container.decodeIfPresent(
        Swift.String.self, forKey: .networkProfile)
      self.params = try container.decodeIfPresent(NetworkParams.self, forKey: .params)
      self.peerings = try container.decode([NetworkPeering].self, forKey: .peerings)
      self.routingConfig = try container.decodeIfPresent(
        NetworkRoutingConfig.self, forKey: .routingConfig)
      self.selfLink = try container.decodeIfPresent(Swift.String.self, forKey: .selfLink)
      self.selfLinkWithId = try container.decodeIfPresent(
        Swift.String.self, forKey: .selfLinkWithId)
      self.subnetworks = try container.decode([Swift.String].self, forKey: .subnetworks)
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.ipv4Range, forKey: .ipv4Range)
      try container.encode(self.autoCreateSubnetworks, forKey: .autoCreateSubnetworks)
      try container.encode(self.creationTimestamp, forKey: .creationTimestamp)
      try container.encode(self.description, forKey: .description)
      try container.encode(self.enableUlaInternalIpv6, forKey: .enableUlaInternalIpv6)
      try container.encode(self.firewallPolicy, forKey: .firewallPolicy)
      try container.encode(self.gatewayIpv4, forKey: .gatewayIpv4)
      try container.encode(self.id, forKey: .id)
      try container.encode(self.internalIpv6Range, forKey: .internalIpv6Range)
      try container.encode(self.kind, forKey: .kind)
      try container.encode(self.mtu, forKey: .mtu)
      try container.encode(self.name, forKey: .name)
      try container.encode(
        self.networkFirewallPolicyEnforcementOrder, forKey: .networkFirewallPolicyEnforcementOrder)
      try container.encode(self.networkProfile, forKey: .networkProfile)
      try container.encode(self.params, forKey: .params)
      try container.encode(self.peerings, forKey: .peerings)
      try container.encode(self.routingConfig, forKey: .routingConfig)
      try container.encode(self.selfLink, forKey: .selfLink)
      try container.encode(self.selfLinkWithId, forKey: .selfLinkWithId)
      try container.encode(self.subnetworks, forKey: .subnetworks)
    }

    /// The enumerated type for the [networkFirewallPolicyEnforcementOrder][google.cloud.compute.v1.Network.networkFirewallPolicyEnforcementOrder] field.
    ///
    /// [google.cloud.compute.v1.Network.networkFirewallPolicyEnforcementOrder]: <doc:Network/NetworkFirewallPolicyEnforcementOrder>
    public enum NetworkFirewallPolicyEnforcementOrder: Codable, Equatable, Sendable {
      case afterClassicFirewall
      case beforeClassicFirewall
      /// 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 = .afterClassicFirewall
      }

      /// 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 .afterClassicFirewall: return 0
        case .beforeClassicFirewall: 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 .afterClassicFirewall: return "AFTER_CLASSIC_FIREWALL"
        case .beforeClassicFirewall: return "BEFORE_CLASSIC_FIREWALL"
        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:NetworkFirewallPolicyEnforcementOrder/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "AFTER_CLASSIC_FIREWALL": self = .afterClassicFirewall
        case "BEFORE_CLASSIC_FIREWALL": self = .beforeClassicFirewall
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:NetworkFirewallPolicyEnforcementOrder/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .afterClassicFirewall
        case 1: self = .beforeClassicFirewall
        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 .afterClassicFirewall: return try container.encode(0)
        case .beforeClassicFirewall: 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.Network"
    }
    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
