// 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 instance-attached disk resource.
  public struct AttachedDisk: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. [Output Only] The architecture of the attached disk. Valid values are ARM64
    /// or X86_64.
    public var architecture: AttachedDisk.Architecture? = nil

    /// Specifies whether the disk will be auto-deleted when the instance is
    /// deleted (but not when the disk is detached from the instance).
    public var autoDelete: Swift.Bool? = nil

    /// Indicates that this is a boot disk. The virtual machine will use the first
    /// partition of the disk for its root filesystem.
    public var boot: Swift.Bool? = nil

    /// Specifies a unique device name of your choice that is reflected into the/dev/disk/by-id/google-* tree of a Linux operating system
    /// running within the instance. This name can be used to reference the device
    /// for mounting, resizing, and so on, from within the instance.
    ///
    /// If not specified, the server chooses a default device name to apply to this
    /// disk, in the form persistent-disk-x, where x is a number
    /// assigned by Google Compute Engine. This field is only applicable for
    /// persistent disks.
    public var deviceName: Swift.String? = nil

    /// Encrypts or decrypts a disk using acustomer-supplied
    /// encryption key.
    ///
    /// If you are creating a new disk, this field encrypts the new disk using
    /// an encryption key that you provide. If you are attaching an existing
    /// disk that is already encrypted, this field decrypts the disk using
    /// the customer-supplied encryption key.
    ///
    /// If you encrypt a disk using a customer-supplied key, you must provide the
    /// same key again when you attempt to use this resource at a later time. For
    /// example, you must provide the key when you create a snapshot or an image
    /// from the disk or when you attach the disk to a virtual machine instance.
    ///
    /// If you do not provide an encryption key, then the disk will be encrypted
    /// using an automatically generated key and you do not need to provide a key
    /// to use the disk later.
    ///
    /// Note:
    ///
    /// Instance templates do not storecustomer-supplied
    /// encryption keys, so you cannot use your own keys to encrypt disks in amanaged instance group.
    ///
    /// You cannot create VMs that have disks with customer-supplied keys using
    /// the bulk
    /// insert method.
    public var diskEncryptionKey: CustomerEncryptionKey? = nil

    /// The size of the disk in GB.
    public var diskSizeGb: Swift.Int64? = nil

    /// [Input Only] Whether to force attach the regional disk even if it's
    /// currently attached to another instance. If you try to force attach a zonal
    /// disk to an instance, you will receive an error.
    public var forceAttach: Swift.Bool? = nil

    /// A list of features to enable on the guest operating system. Applicable
    /// only for bootable images. Read
    /// Enabling guest operating system features to see a list of available
    /// options.
    public var guestOsFeatures: [GuestOsFeature] = []

    /// Output only. [Output Only] A zero-based index to this disk, where 0 is reserved for the
    /// boot disk. If you have many disks attached to an instance, each
    /// disk would have a unique index number.
    public var index: Swift.Int32? = nil

    /// [Input Only] Specifies the parameters for a new disk that will be created
    /// alongside the new instance. Use initialization parameters to create boot
    /// disks or local SSDs attached to the new instance.
    ///
    /// This property is mutually exclusive with the source property;
    /// you can only define one or the other, but not both.
    public var initializeParams: AttachedDiskInitializeParams? = nil

    /// Specifies the disk interface to use for attaching this disk, which is
    /// either SCSI or NVME. For most machine types, the
    /// default is SCSI. Local SSDs can use either NVME or SCSI.
    /// In certain configurations, persistent disks can use NVMe. For more
    /// information, seeAbout
    /// persistent disks.
    public var interface: AttachedDisk.Interface? = nil

    /// Output only. [Output Only] Type of the resource. Alwayscompute#attachedDisk for attached disks.
    public var kind: Swift.String? = nil

    /// Output only. [Output Only] Any valid publicly visible licenses.
    public var licenses: [Swift.String] = []

    /// The mode in which to attach this disk, either READ_WRITE orREAD_ONLY. If not specified, the default is to attach the disk
    /// in READ_WRITE mode.
    public var mode: AttachedDisk.Mode? = nil

    /// Output only. For LocalSSD disks on VM Instances in STOPPED or SUSPENDED state, this
    /// field is set to PRESERVED if the LocalSSD data has been saved
    /// to a persistent location by customer request.  (see the
    /// discard_local_ssd option on Stop/Suspend).
    /// Read-only in the api.
    public var savedState: AttachedDisk.SavedState? = nil

    /// Output only. [Output Only] shielded vm initial state stored on disk
    public var shieldedInstanceInitialState: InitialStateConfig? = nil

    /// Specifies a valid partial or full URL to an existing Persistent Disk
    /// resource. When creating a new instance boot disk, one ofinitializeParams.sourceImage orinitializeParams.sourceSnapshot or disks.source
    /// is required.
    ///
    /// If desired, you can also attach existing non-root persistent disks using
    /// this property. This field is only applicable for persistent disks.
    ///
    /// Note that for InstanceTemplate, specify the disk name for zonal disk,
    /// and the URL for regional disk.
    public var source: Swift.String? = nil

    /// Specifies the type of the disk, either SCRATCH orPERSISTENT. If not specified, the default isPERSISTENT.
    public var type: AttachedDisk.Type_? = nil

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

    /// The enumerated type for the [architecture][google.cloud.compute.v1.AttachedDisk.architecture] field.
    ///
    /// [google.cloud.compute.v1.AttachedDisk.architecture]: <doc:AttachedDisk/Architecture>
    public enum Architecture: Codable, Equatable, Sendable {
      /// Default value indicating Architecture is not set.
      case unspecified
      /// Machines with architecture ARM64
      case arm64
      /// Machines with architecture X86_64
      case x8664
      /// 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 .arm64: return 1
        case .x8664: return 2
        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 "ARCHITECTURE_UNSPECIFIED"
        case .arm64: return "ARM64"
        case .x8664: return "X86_64"
        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:Architecture/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "ARCHITECTURE_UNSPECIFIED": self = .unspecified
        case "ARM64": self = .arm64
        case "X86_64": self = .x8664
        default: self = .unknownStringValue(stringValue)
        }
      }

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

    /// The enumerated type for the [interface][google.cloud.compute.v1.AttachedDisk.interface] field.
    ///
    /// [google.cloud.compute.v1.AttachedDisk.interface]: <doc:AttachedDisk/Interface>
    public enum Interface: Codable, Equatable, Sendable {
      case nvme
      case scsi
      /// 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 = .nvme
      }

      /// 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 .nvme: return 0
        case .scsi: 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 .nvme: return "NVME"
        case .scsi: return "SCSI"
        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:Interface/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "NVME": self = .nvme
        case "SCSI": self = .scsi
        default: self = .unknownStringValue(stringValue)
        }
      }

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

    /// The enumerated type for the [mode][google.cloud.compute.v1.AttachedDisk.mode] field.
    ///
    /// [google.cloud.compute.v1.AttachedDisk.mode]: <doc:AttachedDisk/Mode>
    public enum Mode: Codable, Equatable, Sendable {
      /// Attaches this disk in read-only mode. Multiple virtual machines can use
      /// a disk in read-only mode at a time.
      case readOnly
      /// *[Default]* Attaches this disk in read-write mode. Only one
      /// virtual machine at a time can be attached to a disk in read-write mode.
      case readWrite
      /// 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 = .readOnly
      }

      /// 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 .readOnly: return 0
        case .readWrite: 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 .readOnly: return "READ_ONLY"
        case .readWrite: return "READ_WRITE"
        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:Mode/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "READ_ONLY": self = .readOnly
        case "READ_WRITE": self = .readWrite
        default: self = .unknownStringValue(stringValue)
        }
      }

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

    /// The enumerated type for the [savedState][google.cloud.compute.v1.AttachedDisk.savedState] field.
    ///
    /// [google.cloud.compute.v1.AttachedDisk.savedState]: <doc:AttachedDisk/SavedState>
    public enum SavedState: Codable, Equatable, Sendable {
      /// *[Default]* Disk state has not been preserved.
      case diskSavedStateUnspecified
      /// Disk state has been preserved.
      case preserved
      /// 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 = .diskSavedStateUnspecified
      }

      /// 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 .diskSavedStateUnspecified: return 0
        case .preserved: 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 .diskSavedStateUnspecified: return "DISK_SAVED_STATE_UNSPECIFIED"
        case .preserved: return "PRESERVED"
        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:SavedState/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "DISK_SAVED_STATE_UNSPECIFIED": self = .diskSavedStateUnspecified
        case "PRESERVED": self = .preserved
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:SavedState/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .diskSavedStateUnspecified
        case 1: self = .preserved
        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 .diskSavedStateUnspecified: return try container.encode(0)
        case .preserved: return try container.encode(1)
        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.AttachedDisk.type] field.
    ///
    /// [google.cloud.compute.v1.AttachedDisk.type]: <doc:AttachedDisk/Type_>
    public enum Type_: Codable, Equatable, Sendable {
      case persistent
      case scratch
      /// 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 = .persistent
      }

      /// 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 .persistent: return 0
        case .scratch: 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 .persistent: return "PERSISTENT"
        case .scratch: return "SCRATCH"
        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 "PERSISTENT": self = .persistent
        case "SCRATCH": self = .scratch
        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 = .persistent
        case 1: self = .scratch
        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 .persistent: return try container.encode(0)
        case .scratch: 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.AttachedDisk"
    }
    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
