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

  /// Represents long-lasting resources that are dedicated to users to runs custom
  /// workloads.
  /// A PersistentResource can have multiple node pools and each node
  /// pool can have its own machine spec.
  public struct PersistentResource: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Immutable. Resource name of a PersistentResource.
    public var name: Swift.String = Swift.String()

    /// Optional. The display name of the PersistentResource.
    /// The name can be up to 128 characters long and can consist of any UTF-8
    /// characters.
    public var displayName: Swift.String = Swift.String()

    /// Required. The spec of the pools of different resources.
    public var resourcePools: [ResourcePool] = []

    /// Output only. The detailed state of a Study.
    public var state: PersistentResource.State = PersistentResource.State()

    /// Output only. Only populated when persistent resource's state is `STOPPING`
    /// or `ERROR`.
    public var error: GoogleRpc.Status? = nil

    /// Output only. Time when the PersistentResource was created.
    public var createTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. Time when the PersistentResource for the first time entered
    /// the `RUNNING` state.
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. Time when the PersistentResource was most recently updated.
    public var updateTime: GoogleCloudWkt.Timestamp? = nil

    /// Optional. The labels with user-defined metadata to organize
    /// PersistentResource.
    ///
    /// Label keys and values can be no longer than 64 characters
    /// (Unicode codepoints), can only contain lowercase letters, numeric
    /// characters, underscores and dashes. International characters are allowed.
    ///
    /// See https://goo.gl/xmQnxf for more information and examples of labels.
    public var labels: [Swift.String: Swift.String] = [:]

    /// Optional. The full name of the Compute Engine
    /// [network](/compute/docs/networks-and-firewalls#networks) to peered with
    /// Vertex AI to host the persistent resources.
    /// For example, `projects/12345/global/networks/myVPC`.
    /// [Format](/compute/docs/reference/rest/v1/networks/insert)
    /// is of the form `projects/{project}/global/networks/{network}`.
    /// Where {project} is a project number, as in `12345`, and {network} is a
    /// network name.
    ///
    /// To specify this field, you must have already [configured VPC Network
    /// Peering for Vertex
    /// AI](https://cloud.google.com/vertex-ai/docs/general/vpc-peering).
    ///
    /// If this field is left unspecified, the resources aren't peered with any
    /// network.
    public var network: Swift.String = Swift.String()

    /// Optional. Configuration for PSC-I for PersistentResource.
    public var pscInterfaceConfig: PscInterfaceConfig? = nil

    /// Optional. Customer-managed encryption key spec for a PersistentResource.
    /// If set, this PersistentResource and all sub-resources of this
    /// PersistentResource will be secured by this key.
    public var encryptionSpec: EncryptionSpec? = nil

    /// Optional. Persistent Resource runtime spec.
    /// For example, used for Ray cluster configuration.
    public var resourceRuntimeSpec: ResourceRuntimeSpec? = nil

    /// Output only. Runtime information of the Persistent Resource.
    public var resourceRuntime: ResourceRuntime? = nil

    /// Optional. A list of names for the reserved IP ranges under the VPC network
    /// that can be used for this persistent resource.
    ///
    /// If set, we will deploy the persistent resource within the provided IP
    /// ranges. Otherwise, the persistent resource is deployed to any IP
    /// ranges under the provided VPC network.
    ///
    /// Example: ['vertex-ai-ip-range'].
    public var reservedIpRanges: [Swift.String] = []

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

    /// Describes the PersistentResource state.
    public enum State: Codable, Equatable, Sendable {
      /// Not set.
      case unspecified
      /// The PROVISIONING state indicates the persistent resources is being
      /// created.
      case provisioning
      /// The RUNNING state indicates the persistent resource is healthy and fully
      /// usable.
      case running
      /// The STOPPING state indicates the persistent resource is being deleted.
      case stopping
      /// The ERROR state indicates the persistent resource may be unusable.
      /// Details can be found in the `error` field.
      case error
      /// The REBOOTING state indicates the persistent resource is being rebooted
      /// (PR is not available right now but is expected to be ready again later).
      case rebooting
      /// The UPDATING state indicates the persistent resource is being updated.
      case updating
      /// 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 .provisioning: return 1
        case .running: return 3
        case .stopping: return 4
        case .error: return 5
        case .rebooting: return 6
        case .updating: return 7
        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 "STATE_UNSPECIFIED"
        case .provisioning: return "PROVISIONING"
        case .running: return "RUNNING"
        case .stopping: return "STOPPING"
        case .error: return "ERROR"
        case .rebooting: return "REBOOTING"
        case .updating: return "UPDATING"
        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:State/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "STATE_UNSPECIFIED": self = .unspecified
        case "PROVISIONING": self = .provisioning
        case "RUNNING": self = .running
        case "STOPPING": self = .stopping
        case "ERROR": self = .error
        case "REBOOTING": self = .rebooting
        case "UPDATING": self = .updating
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:State/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .provisioning
        case 3: self = .running
        case 4: self = .stopping
        case 5: self = .error
        case 6: self = .rebooting
        case 7: self = .updating
        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 .provisioning: return try container.encode(1)
        case .running: return try container.encode(3)
        case .stopping: return try container.encode(4)
        case .error: return try container.encode(5)
        case .rebooting: return try container.encode(6)
        case .updating: return try container.encode(7)
        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.aiplatform.v1.PersistentResource"
    }
    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
