// 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 Disks || ImageFamilyViews || Images || InstanceTemplates || Instances || MachineImages || RegionDisks || RegionInstanceTemplates || RegionInstances || RegionSnapshots || Snapshots
  import Foundation
  import GoogleCloudWkt

  /// Guest OS features.
  public struct GuestOsFeature: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The ID of a supported feature. To add multiple values, use commas to
    /// separate values. Set to one or more of the following values:
    ///
    ///    - VIRTIO_SCSI_MULTIQUEUE
    ///    - WINDOWS
    ///    - MULTI_IP_SUBNET
    ///    - UEFI_COMPATIBLE
    ///    - GVNIC
    ///    - SEV_CAPABLE
    ///    - SUSPEND_RESUME_COMPATIBLE
    ///    - SEV_LIVE_MIGRATABLE_V2
    ///    - SEV_SNP_CAPABLE
    ///    - TDX_CAPABLE
    ///    - IDPF
    ///    - SNP_SVSM_CAPABLE
    ///    - CCA_CAPABLE
    ///
    ///
    /// For more information, see
    /// Enabling guest operating system features.
    public var type: GuestOsFeature.Type_? = nil

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

    /// The enumerated type for the [type][google.cloud.compute.v1.GuestOsFeature.type] field.
    ///
    /// [google.cloud.compute.v1.GuestOsFeature.type]: <doc:GuestOsFeature/Type_>
    public enum Type_: Codable, Equatable, Sendable {
      case bareMetalLinuxCompatible
      case ccaCapable
      case featureTypeUnspecified
      case gvnic
      case idpf
      case multiIpSubnet
      case secureBoot
      case sevCapable
      case sevLiveMigratable
      case sevLiveMigratableV2
      case sevSnpCapable
      case snpSvsmCapable
      case tdxCapable
      case uefiCompatible
      case virtioScsiMultiqueue
      case windows
      /// 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 = .bareMetalLinuxCompatible
      }

      /// 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 .bareMetalLinuxCompatible: return 0
        case .ccaCapable: return 1
        case .featureTypeUnspecified: return 2
        case .gvnic: return 3
        case .idpf: return 4
        case .multiIpSubnet: return 5
        case .secureBoot: return 6
        case .sevCapable: return 7
        case .sevLiveMigratable: return 8
        case .sevLiveMigratableV2: return 9
        case .sevSnpCapable: return 10
        case .snpSvsmCapable: return 11
        case .tdxCapable: return 12
        case .uefiCompatible: return 13
        case .virtioScsiMultiqueue: return 14
        case .windows: return 15
        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 .bareMetalLinuxCompatible: return "BARE_METAL_LINUX_COMPATIBLE"
        case .ccaCapable: return "CCA_CAPABLE"
        case .featureTypeUnspecified: return "FEATURE_TYPE_UNSPECIFIED"
        case .gvnic: return "GVNIC"
        case .idpf: return "IDPF"
        case .multiIpSubnet: return "MULTI_IP_SUBNET"
        case .secureBoot: return "SECURE_BOOT"
        case .sevCapable: return "SEV_CAPABLE"
        case .sevLiveMigratable: return "SEV_LIVE_MIGRATABLE"
        case .sevLiveMigratableV2: return "SEV_LIVE_MIGRATABLE_V2"
        case .sevSnpCapable: return "SEV_SNP_CAPABLE"
        case .snpSvsmCapable: return "SNP_SVSM_CAPABLE"
        case .tdxCapable: return "TDX_CAPABLE"
        case .uefiCompatible: return "UEFI_COMPATIBLE"
        case .virtioScsiMultiqueue: return "VIRTIO_SCSI_MULTIQUEUE"
        case .windows: return "WINDOWS"
        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 "BARE_METAL_LINUX_COMPATIBLE": self = .bareMetalLinuxCompatible
        case "CCA_CAPABLE": self = .ccaCapable
        case "FEATURE_TYPE_UNSPECIFIED": self = .featureTypeUnspecified
        case "GVNIC": self = .gvnic
        case "IDPF": self = .idpf
        case "MULTI_IP_SUBNET": self = .multiIpSubnet
        case "SECURE_BOOT": self = .secureBoot
        case "SEV_CAPABLE": self = .sevCapable
        case "SEV_LIVE_MIGRATABLE": self = .sevLiveMigratable
        case "SEV_LIVE_MIGRATABLE_V2": self = .sevLiveMigratableV2
        case "SEV_SNP_CAPABLE": self = .sevSnpCapable
        case "SNP_SVSM_CAPABLE": self = .snpSvsmCapable
        case "TDX_CAPABLE": self = .tdxCapable
        case "UEFI_COMPATIBLE": self = .uefiCompatible
        case "VIRTIO_SCSI_MULTIQUEUE": self = .virtioScsiMultiqueue
        case "WINDOWS": self = .windows
        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 = .bareMetalLinuxCompatible
        case 1: self = .ccaCapable
        case 2: self = .featureTypeUnspecified
        case 3: self = .gvnic
        case 4: self = .idpf
        case 5: self = .multiIpSubnet
        case 6: self = .secureBoot
        case 7: self = .sevCapable
        case 8: self = .sevLiveMigratable
        case 9: self = .sevLiveMigratableV2
        case 10: self = .sevSnpCapable
        case 11: self = .snpSvsmCapable
        case 12: self = .tdxCapable
        case 13: self = .uefiCompatible
        case 14: self = .virtioScsiMultiqueue
        case 15: self = .windows
        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 .bareMetalLinuxCompatible: return try container.encode(0)
        case .ccaCapable: return try container.encode(1)
        case .featureTypeUnspecified: return try container.encode(2)
        case .gvnic: return try container.encode(3)
        case .idpf: return try container.encode(4)
        case .multiIpSubnet: return try container.encode(5)
        case .secureBoot: return try container.encode(6)
        case .sevCapable: return try container.encode(7)
        case .sevLiveMigratable: return try container.encode(8)
        case .sevLiveMigratableV2: return try container.encode(9)
        case .sevSnpCapable: return try container.encode(10)
        case .snpSvsmCapable: return try container.encode(11)
        case .tdxCapable: return try container.encode(12)
        case .uefiCompatible: return try container.encode(13)
        case .virtioScsiMultiqueue: return try container.encode(14)
        case .windows: return try container.encode(15)
        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.GuestOsFeature"
    }
    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
