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

  public struct AutoscalerStatusDetails: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The status message.
    public var message: Swift.String? = nil

    /// The type of error, warning, or notice returned. Current set of possible
    /// values:
    ///
    ///    - ALL_INSTANCES_UNHEALTHY (WARNING):
    ///      All instances in the instance group are unhealthy (not in RUNNING
    ///      state).
    ///    - BACKEND_SERVICE_DOES_NOT_EXIST (ERROR):
    ///      There is no backend service attached to the instance group.
    ///    - CAPPED_AT_MAX_NUM_REPLICAS (WARNING):
    ///      Autoscaler recommends a size greater than maxNumReplicas.
    ///    - CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE (WARNING):
    ///      The custom metric samples are not exported often enough to be
    ///      a credible base for autoscaling.
    ///    - CUSTOM_METRIC_INVALID (ERROR):
    ///      The custom metric that was specified does not exist or does not have
    ///      the necessary labels.
    ///    - MIN_EQUALS_MAX (WARNING):
    ///      The minNumReplicas is equal to maxNumReplicas. This means the
    ///      autoscaler cannot add or remove instances from the instance group.
    ///    - MISSING_CUSTOM_METRIC_DATA_POINTS (WARNING):
    ///      The autoscaler did not receive any data from the custom metric
    ///      configured for autoscaling.
    ///    - MISSING_LOAD_BALANCING_DATA_POINTS (WARNING):
    ///      The autoscaler is configured to scale based on a load balancing signal
    ///      but the instance group has not received any requests from the load
    ///      balancer.
    ///    - MODE_OFF (WARNING):
    ///      Autoscaling is turned off. The number of instances in the group won't
    ///      change automatically. The autoscaling configuration is preserved.
    ///    - MODE_ONLY_UP (WARNING):
    ///      Autoscaling is in the "Autoscale only out" mode. The autoscaler can add
    ///      instances but not remove any.
    ///    - MORE_THAN_ONE_BACKEND_SERVICE (ERROR):
    ///      The instance group cannot be autoscaled because it has more than one
    ///      backend service attached to it.
    ///    - NOT_ENOUGH_QUOTA_AVAILABLE (ERROR):
    ///      There is insufficient quota for the necessary resources, such as CPU or
    ///      number of instances.
    ///    - REGION_RESOURCE_STOCKOUT (ERROR):
    ///      Shown only for regional autoscalers: there is a resource stockout in
    ///      the chosen region.
    ///    - SCALING_TARGET_DOES_NOT_EXIST (ERROR):
    ///      The target to be scaled does not exist.
    ///    - UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION
    ///      (ERROR): Autoscaling does not work with an HTTP/S load balancer that
    ///      has been configured for maxRate.
    ///    - ZONE_RESOURCE_STOCKOUT (ERROR):
    ///      For zonal autoscalers: there is a resource stockout in the chosen zone.
    ///      For regional autoscalers: in at least one of the zones you're using
    ///      there is a resource stockout.
    ///
    ///
    /// New values might be added in the future. Some of the values might not be
    /// available in all API versions.
    public var type: AutoscalerStatusDetails.Type_? = nil

    /// Initialize a new instance of `AutoscalerStatusDetails`.
    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 = AutoscalerStatusDetails().with { $0.message = ... }
    /// ```
    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.AutoscalerStatusDetails.type] field.
    ///
    /// [google.cloud.compute.v1.AutoscalerStatusDetails.type]: <doc:AutoscalerStatusDetails/Type_>
    public enum Type_: Codable, Equatable, Sendable {
      /// All instances in the instance group are unhealthy (not in RUNNING state).
      case allInstancesUnhealthy
      /// There is no backend service attached to the instance group.
      case backendServiceDoesNotExist
      /// Autoscaler recommends a size greater than maxNumReplicas.
      case cappedAtMaxNumReplicas
      /// The custom metric samples are not exported often enough to be a credible
      /// base for autoscaling.
      case customMetricDataPointsTooSparse
      /// The custom metric that was specified does not exist or does not have the
      /// necessary labels.
      case customMetricInvalid
      /// The minNumReplicas is equal to maxNumReplicas. This means the autoscaler
      /// cannot add or remove instances from the instance group.
      case minEqualsMax
      /// The autoscaler did not receive any data from the custom metric configured
      /// for autoscaling.
      case missingCustomMetricDataPoints
      /// The autoscaler is configured to scale based on a load balancing signal
      /// but the instance group has not received any requests from the load
      /// balancer.
      case missingLoadBalancingDataPoints
      /// Autoscaling is turned off. The number of instances in the group won't
      /// change automatically. The autoscaling configuration is preserved.
      case modeOff
      /// Autoscaling is in the "Autoscale only scale out" mode.
      /// Instances in the group will be only added.
      case modeOnlyScaleOut
      /// Autoscaling is in the "Autoscale only out" mode. Instances in the group
      /// will be only added.
      case modeOnlyUp
      /// The instance group cannot be autoscaled because it has more than one
      /// backend service attached to it.
      case moreThanOneBackendService
      /// There is insufficient quota for the necessary resources, such as CPU or
      /// number of instances.
      case notEnoughQuotaAvailable
      /// Showed only for regional autoscalers: there is a resource stockout in
      /// the chosen region.
      case regionResourceStockout
      /// The target to be scaled does not exist.
      case scalingTargetDoesNotExist
      /// For some scaling schedules minRequiredReplicas is greater than
      /// maxNumReplicas. Autoscaler always recommends at most maxNumReplicas
      /// instances.
      case scheduledInstancesGreaterThanAutoscalerMax
      /// For some scaling schedules minRequiredReplicas is less than
      /// minNumReplicas. Autoscaler always recommends at least minNumReplicas
      /// instances.
      case scheduledInstancesLessThanAutoscalerMin
      case unknown
      /// Autoscaling does not work with an HTTP/S load balancer that has been
      /// configured for maxRate.
      case unsupportedMaxRateLoadBalancingConfiguration
      /// For zonal autoscalers: there is a resource stockout in the chosen zone.
      /// For regional autoscalers: in at least one of the zones you're using there
      /// is a resource stockout.
      case zoneResourceStockout
      /// 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 = .allInstancesUnhealthy
      }

      /// 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 .allInstancesUnhealthy: return 0
        case .backendServiceDoesNotExist: return 1
        case .cappedAtMaxNumReplicas: return 2
        case .customMetricDataPointsTooSparse: return 3
        case .customMetricInvalid: return 4
        case .minEqualsMax: return 5
        case .missingCustomMetricDataPoints: return 6
        case .missingLoadBalancingDataPoints: return 7
        case .modeOff: return 8
        case .modeOnlyScaleOut: return 9
        case .modeOnlyUp: return 10
        case .moreThanOneBackendService: return 11
        case .notEnoughQuotaAvailable: return 12
        case .regionResourceStockout: return 13
        case .scalingTargetDoesNotExist: return 14
        case .scheduledInstancesGreaterThanAutoscalerMax: return 15
        case .scheduledInstancesLessThanAutoscalerMin: return 16
        case .unknown: return 17
        case .unsupportedMaxRateLoadBalancingConfiguration: return 18
        case .zoneResourceStockout: return 19
        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 .allInstancesUnhealthy: return "ALL_INSTANCES_UNHEALTHY"
        case .backendServiceDoesNotExist: return "BACKEND_SERVICE_DOES_NOT_EXIST"
        case .cappedAtMaxNumReplicas: return "CAPPED_AT_MAX_NUM_REPLICAS"
        case .customMetricDataPointsTooSparse: return "CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE"
        case .customMetricInvalid: return "CUSTOM_METRIC_INVALID"
        case .minEqualsMax: return "MIN_EQUALS_MAX"
        case .missingCustomMetricDataPoints: return "MISSING_CUSTOM_METRIC_DATA_POINTS"
        case .missingLoadBalancingDataPoints: return "MISSING_LOAD_BALANCING_DATA_POINTS"
        case .modeOff: return "MODE_OFF"
        case .modeOnlyScaleOut: return "MODE_ONLY_SCALE_OUT"
        case .modeOnlyUp: return "MODE_ONLY_UP"
        case .moreThanOneBackendService: return "MORE_THAN_ONE_BACKEND_SERVICE"
        case .notEnoughQuotaAvailable: return "NOT_ENOUGH_QUOTA_AVAILABLE"
        case .regionResourceStockout: return "REGION_RESOURCE_STOCKOUT"
        case .scalingTargetDoesNotExist: return "SCALING_TARGET_DOES_NOT_EXIST"
        case .scheduledInstancesGreaterThanAutoscalerMax:
          return "SCHEDULED_INSTANCES_GREATER_THAN_AUTOSCALER_MAX"
        case .scheduledInstancesLessThanAutoscalerMin:
          return "SCHEDULED_INSTANCES_LESS_THAN_AUTOSCALER_MIN"
        case .unknown: return "UNKNOWN"
        case .unsupportedMaxRateLoadBalancingConfiguration:
          return "UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION"
        case .zoneResourceStockout: return "ZONE_RESOURCE_STOCKOUT"
        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 "ALL_INSTANCES_UNHEALTHY": self = .allInstancesUnhealthy
        case "BACKEND_SERVICE_DOES_NOT_EXIST": self = .backendServiceDoesNotExist
        case "CAPPED_AT_MAX_NUM_REPLICAS": self = .cappedAtMaxNumReplicas
        case "CUSTOM_METRIC_DATA_POINTS_TOO_SPARSE": self = .customMetricDataPointsTooSparse
        case "CUSTOM_METRIC_INVALID": self = .customMetricInvalid
        case "MIN_EQUALS_MAX": self = .minEqualsMax
        case "MISSING_CUSTOM_METRIC_DATA_POINTS": self = .missingCustomMetricDataPoints
        case "MISSING_LOAD_BALANCING_DATA_POINTS": self = .missingLoadBalancingDataPoints
        case "MODE_OFF": self = .modeOff
        case "MODE_ONLY_SCALE_OUT": self = .modeOnlyScaleOut
        case "MODE_ONLY_UP": self = .modeOnlyUp
        case "MORE_THAN_ONE_BACKEND_SERVICE": self = .moreThanOneBackendService
        case "NOT_ENOUGH_QUOTA_AVAILABLE": self = .notEnoughQuotaAvailable
        case "REGION_RESOURCE_STOCKOUT": self = .regionResourceStockout
        case "SCALING_TARGET_DOES_NOT_EXIST": self = .scalingTargetDoesNotExist
        case "SCHEDULED_INSTANCES_GREATER_THAN_AUTOSCALER_MAX":
          self = .scheduledInstancesGreaterThanAutoscalerMax
        case "SCHEDULED_INSTANCES_LESS_THAN_AUTOSCALER_MIN":
          self = .scheduledInstancesLessThanAutoscalerMin
        case "UNKNOWN": self = .unknown
        case "UNSUPPORTED_MAX_RATE_LOAD_BALANCING_CONFIGURATION":
          self = .unsupportedMaxRateLoadBalancingConfiguration
        case "ZONE_RESOURCE_STOCKOUT": self = .zoneResourceStockout
        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 = .allInstancesUnhealthy
        case 1: self = .backendServiceDoesNotExist
        case 2: self = .cappedAtMaxNumReplicas
        case 3: self = .customMetricDataPointsTooSparse
        case 4: self = .customMetricInvalid
        case 5: self = .minEqualsMax
        case 6: self = .missingCustomMetricDataPoints
        case 7: self = .missingLoadBalancingDataPoints
        case 8: self = .modeOff
        case 9: self = .modeOnlyScaleOut
        case 10: self = .modeOnlyUp
        case 11: self = .moreThanOneBackendService
        case 12: self = .notEnoughQuotaAvailable
        case 13: self = .regionResourceStockout
        case 14: self = .scalingTargetDoesNotExist
        case 15: self = .scheduledInstancesGreaterThanAutoscalerMax
        case 16: self = .scheduledInstancesLessThanAutoscalerMin
        case 17: self = .unknown
        case 18: self = .unsupportedMaxRateLoadBalancingConfiguration
        case 19: self = .zoneResourceStockout
        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 .allInstancesUnhealthy: return try container.encode(0)
        case .backendServiceDoesNotExist: return try container.encode(1)
        case .cappedAtMaxNumReplicas: return try container.encode(2)
        case .customMetricDataPointsTooSparse: return try container.encode(3)
        case .customMetricInvalid: return try container.encode(4)
        case .minEqualsMax: return try container.encode(5)
        case .missingCustomMetricDataPoints: return try container.encode(6)
        case .missingLoadBalancingDataPoints: return try container.encode(7)
        case .modeOff: return try container.encode(8)
        case .modeOnlyScaleOut: return try container.encode(9)
        case .modeOnlyUp: return try container.encode(10)
        case .moreThanOneBackendService: return try container.encode(11)
        case .notEnoughQuotaAvailable: return try container.encode(12)
        case .regionResourceStockout: return try container.encode(13)
        case .scalingTargetDoesNotExist: return try container.encode(14)
        case .scheduledInstancesGreaterThanAutoscalerMax: return try container.encode(15)
        case .scheduledInstancesLessThanAutoscalerMin: return try container.encode(16)
        case .unknown: return try container.encode(17)
        case .unsupportedMaxRateLoadBalancingConfiguration: return try container.encode(18)
        case .zoneResourceStockout: return try container.encode(19)
        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.AutoscalerStatusDetails"
    }
    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
