// 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.

import Foundation
import GoogleCloudWkt

/// Defines TLS certificate.
public struct Certificate: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// A user-defined name of the certificate. Certificate names must be unique
  /// globally and match pattern `projects/*/locations/*/certificates/*`.
  public var name: Swift.String = Swift.String()

  /// One or more paragraphs of text description of a certificate.
  public var description: Swift.String = Swift.String()

  /// Output only. The creation timestamp of a Certificate.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The last update timestamp of a Certificate.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Set of labels associated with a Certificate.
  public var labels: [Swift.String: Swift.String] = [:]

  /// Output only. The list of Subject Alternative Names of dnsName type defined
  /// in the certificate (see RFC 5280 4.2.1.6). Managed certificates that
  /// haven't been provisioned yet have this field populated with a value of the
  /// managed.domains field.
  public var sanDnsnames: [Swift.String] = []

  /// Output only. The PEM-encoded certificate chain.
  public var pemCertificate: Swift.String = Swift.String()

  /// Output only. The expiry timestamp of a Certificate.
  public var expireTime: GoogleCloudWkt.Timestamp? = nil

  /// Immutable. The scope of the certificate.
  public var scope: Certificate.Scope = Certificate.Scope()

  public var type: OneOf_Type_? = nil

  /// Initialize a new instance of `Certificate`.
  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 = Certificate().with { $0.name = ... }
  /// ```
  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 name = "name"
    case description = "description"
    case createTime = "createTime"
    case updateTime = "updateTime"
    case labels = "labels"
    case selfManaged = "selfManaged"
    case managed = "managed"
    case sanDnsnames = "sanDnsnames"
    case pemCertificate = "pemCertificate"
    case expireTime = "expireTime"
    case scope = "scope"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.name = try container.decode(Swift.String.self, forKey: .name)
    self.description = try container.decode(Swift.String.self, forKey: .description)
    self.createTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .createTime)
    self.updateTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .updateTime)
    self.labels = try container.decode([Swift.String: Swift.String].self, forKey: .labels)
    self.sanDnsnames = try container.decode([Swift.String].self, forKey: .sanDnsnames)
    self.pemCertificate = try container.decode(Swift.String.self, forKey: .pemCertificate)
    self.expireTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .expireTime)
    self.scope = try container.decode(Certificate.Scope.self, forKey: .scope)

    var type: OneOf_Type_? = nil
    let typeCheckAndSet = {
      if type != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath, debugDescription: "Multiple values set for oneof 'type'"
          ))
      }
      type = $0
    }
    if let selfManaged = try container.decodeIfPresent(
      Certificate.SelfManagedCertificate?.self, forKey: .selfManaged)
    {
      try typeCheckAndSet(.selfManaged(selfManaged))
    }
    if let managed = try container.decodeIfPresent(
      Certificate.ManagedCertificate?.self, forKey: .managed)
    {
      try typeCheckAndSet(.managed(managed))
    }
    self.type = type
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.name, forKey: .name)
    try container.encode(self.description, forKey: .description)
    try container.encode(self.createTime, forKey: .createTime)
    try container.encode(self.updateTime, forKey: .updateTime)
    try container.encode(self.labels, forKey: .labels)
    try container.encode(self.sanDnsnames, forKey: .sanDnsnames)
    try container.encode(self.pemCertificate, forKey: .pemCertificate)
    try container.encode(self.expireTime, forKey: .expireTime)
    try container.encode(self.scope, forKey: .scope)

    if let choice = self.type {
      switch choice {
      case .selfManaged(let value):
        try container.encode(value, forKey: .selfManaged)
      case .managed(let value):
        try container.encode(value, forKey: .managed)
      }
    }
  }

  /// Certificate data for a SelfManaged Certificate.
  /// SelfManaged Certificates are uploaded by the user. Updating such
  /// certificates before they expire remains the user's responsibility.
  public struct SelfManagedCertificate: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Input only. The PEM-encoded certificate chain.
    /// Leaf certificate comes first, followed by intermediate ones if any.
    public var pemCertificate: Swift.String = Swift.String()

    /// Input only. The PEM-encoded private key of the leaf certificate.
    public var pemPrivateKey: Swift.String = Swift.String()

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

    public static var _anyTypeUrl: Swift.String {
      return
        "type.googleapis.com/google.cloud.certificatemanager.v1.Certificate.SelfManagedCertificate"
    }
    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)
    }
  }

  /// Configuration and state of a Managed Certificate.
  /// Certificate Manager provisions and renews Managed Certificates
  /// automatically, for as long as it's authorized to do so.
  public struct ManagedCertificate: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Immutable. The domains for which a managed SSL certificate will be
    /// generated. Wildcard domains are only supported with DNS challenge
    /// resolution.
    public var domains: [Swift.String] = []

    /// Immutable. Authorizations that will be used for performing domain
    /// authorization.
    public var dnsAuthorizations: [Swift.String] = []

    /// Immutable. The resource name for a
    /// [CertificateIssuanceConfig][google.cloud.certificatemanager.v1.CertificateIssuanceConfig]
    /// used to configure private PKI certificates in the format
    /// `projects/*/locations/*/certificateIssuanceConfigs/*`.
    /// If this field is not set, the certificates will instead be publicly
    /// signed as documented at
    /// https://cloud.google.com/load-balancing/docs/ssl-certificates/google-managed-certs#caa.
    ///
    /// [google.cloud.certificatemanager.v1.CertificateIssuanceConfig]: <doc:CertificateIssuanceConfig>
    public var issuanceConfig: Swift.String = Swift.String()

    /// Output only. State of the managed certificate resource.
    public var state: Certificate.ManagedCertificate.State = Certificate.ManagedCertificate.State()

    /// Output only. Information about issues with provisioning a Managed
    /// Certificate.
    public var provisioningIssue: Certificate.ManagedCertificate.ProvisioningIssue? = nil

    /// Output only. Detailed state of the latest authorization attempt for each
    /// domain specified for managed certificate resource.
    public var authorizationAttemptInfo: [Certificate.ManagedCertificate.AuthorizationAttemptInfo] =
      []

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

    /// Information about issues with provisioning a Managed Certificate.
    public struct ProvisioningIssue: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. Reason for provisioning failures.
      public var reason: Certificate.ManagedCertificate.ProvisioningIssue.Reason = Certificate
        .ManagedCertificate.ProvisioningIssue.Reason()

      /// Output only. Human readable explanation about the issue. Provided to
      /// help address the configuration issues. Not guaranteed to be stable. For
      /// programmatic access use Reason enum.
      public var details: Swift.String = Swift.String()

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

      /// Reason for provisioning failures.
      public enum Reason: Codable, Equatable, Sendable {
        /// Reason is unspecified.
        case unspecified
        /// Certificate provisioning failed due to an issue with one or more of
        /// the domains on the certificate.
        /// For details of which domains failed, consult the
        /// `authorization_attempt_info` field.
        case authorizationIssue
        /// Exceeded Certificate Authority quotas or internal rate limits of the
        /// system. Provisioning may take longer to complete.
        case rateLimited
        /// 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 .authorizationIssue: return 1
          case .rateLimited: 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 "REASON_UNSPECIFIED"
          case .authorizationIssue: return "AUTHORIZATION_ISSUE"
          case .rateLimited: return "RATE_LIMITED"
          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:Reason/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "REASON_UNSPECIFIED": self = .unspecified
          case "AUTHORIZATION_ISSUE": self = .authorizationIssue
          case "RATE_LIMITED": self = .rateLimited
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Reason/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .authorizationIssue
          case 2: self = .rateLimited
          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 .authorizationIssue: return try container.encode(1)
          case .rateLimited: return try container.encode(2)
          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.certificatemanager.v1.Certificate.ManagedCertificate.ProvisioningIssue"
      }
      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)
      }
    }

    /// State of the latest attempt to authorize a domain for certificate
    /// issuance.
    public struct AuthorizationAttemptInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Domain name of the authorization attempt.
      public var domain: Swift.String = Swift.String()

      /// Output only. State of the domain for managed certificate issuance.
      public var state: Certificate.ManagedCertificate.AuthorizationAttemptInfo.State = Certificate
        .ManagedCertificate.AuthorizationAttemptInfo.State()

      /// Output only. Reason for failure of the authorization attempt for the
      /// domain.
      public var failureReason:
        Certificate.ManagedCertificate.AuthorizationAttemptInfo.FailureReason = Certificate
          .ManagedCertificate.AuthorizationAttemptInfo.FailureReason()

      /// Output only. Human readable explanation for reaching the state.
      /// Provided to help address the configuration issues. Not guaranteed to be
      /// stable. For programmatic access use FailureReason enum.
      public var details: Swift.String = Swift.String()

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

      /// State of the domain for managed certificate issuance.
      public enum State: Codable, Equatable, Sendable {
        /// State is unspecified.
        case unspecified
        /// Certificate provisioning for this domain is under way. Google Cloud
        /// will attempt to authorize the domain.
        case authorizing
        /// A managed certificate can be provisioned, no issues for this domain.
        case authorized
        /// Attempt to authorize the domain failed. This prevents the Managed
        /// Certificate from being issued.
        /// See `failure_reason` and `details` fields for more information.
        case failed
        /// 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 .authorizing: return 1
          case .authorized: return 6
          case .failed: 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 .authorizing: return "AUTHORIZING"
          case .authorized: return "AUTHORIZED"
          case .failed: return "FAILED"
          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 "AUTHORIZING": self = .authorizing
          case "AUTHORIZED": self = .authorized
          case "FAILED": self = .failed
          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 = .authorizing
          case 6: self = .authorized
          case 7: self = .failed
          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 .authorizing: return try container.encode(1)
          case .authorized: return try container.encode(6)
          case .failed: return try container.encode(7)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      /// Reason for failure of the authorization attempt for the domain.
      public enum FailureReason: Codable, Equatable, Sendable {
        /// FailureReason is unspecified.
        case unspecified
        /// There was a problem with the user's DNS or load balancer
        /// configuration for this domain.
        case config
        /// Certificate issuance forbidden by an explicit CAA record for the
        /// domain or a failure to check CAA records for the domain.
        case caa
        /// Reached a CA or internal rate-limit for the domain,
        /// e.g. for certificates per top-level private domain.
        case rateLimited
        /// 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 .config: return 1
          case .caa: return 2
          case .rateLimited: return 3
          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 "FAILURE_REASON_UNSPECIFIED"
          case .config: return "CONFIG"
          case .caa: return "CAA"
          case .rateLimited: return "RATE_LIMITED"
          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:FailureReason/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "FAILURE_REASON_UNSPECIFIED": self = .unspecified
          case "CONFIG": self = .config
          case "CAA": self = .caa
          case "RATE_LIMITED": self = .rateLimited
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:FailureReason/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .config
          case 2: self = .caa
          case 3: self = .rateLimited
          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 .config: return try container.encode(1)
          case .caa: return try container.encode(2)
          case .rateLimited: return try container.encode(3)
          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.certificatemanager.v1.Certificate.ManagedCertificate.AuthorizationAttemptInfo"
      }
      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)
      }
    }

    /// State of the managed certificate resource.
    public enum State: Codable, Equatable, Sendable {
      /// State is unspecified.
      case unspecified
      /// Certificate Manager attempts to provision or renew the certificate.
      /// If the process takes longer than expected, consult the
      /// `provisioning_issue` field.
      case provisioning
      /// Multiple certificate provisioning attempts failed and Certificate
      /// Manager gave up. To try again, delete and create a new managed
      /// Certificate resource.
      /// For details see the `provisioning_issue` field.
      case failed
      /// The certificate management is working, and a certificate has been
      /// provisioned.
      case active
      /// 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 .failed: return 2
        case .active: return 3
        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 .failed: return "FAILED"
        case .active: return "ACTIVE"
        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 "FAILED": self = .failed
        case "ACTIVE": self = .active
        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 2: self = .failed
        case 3: self = .active
        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 .failed: return try container.encode(2)
        case .active: return try container.encode(3)
        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.certificatemanager.v1.Certificate.ManagedCertificate"
    }
    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)
    }
  }

  /// Certificate scope.
  public enum Scope: Codable, Equatable, Sendable {
    /// Certificates with default scope are served from core Google data centers.
    /// If unsure, choose this option.
    case `default`
    /// Certificates with scope EDGE_CACHE are special-purposed certificates,
    /// served from Edge Points of Presence.
    /// See https://cloud.google.com/vpc/docs/edge-locations.
    case edgeCache
    /// Certificates with ALL_REGIONS scope are served from all Google Cloud
    /// regions. See https://cloud.google.com/compute/docs/regions-zones.
    case allRegions
    /// 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 = .`default`
    }

    /// 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 .`default`: return 0
      case .edgeCache: return 1
      case .allRegions: 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 .`default`: return "DEFAULT"
      case .edgeCache: return "EDGE_CACHE"
      case .allRegions: return "ALL_REGIONS"
      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:Scope/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "DEFAULT": self = .`default`
      case "EDGE_CACHE": self = .edgeCache
      case "ALL_REGIONS": self = .allRegions
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  public enum OneOf_Type_: Codable, Equatable, Sendable {
    /// If set, defines data of a self-managed certificate.
    indirect case selfManaged(Certificate.SelfManagedCertificate?)
    /// If set, contains configuration and state of a managed certificate.
    indirect case managed(Certificate.ManagedCertificate?)
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.certificatemanager.v1.Certificate"
  }
  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)
  }
}
