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

/// The properties of GoldengateKafkaSchemaRegistryConnection.
public struct GoldengateKafkaSchemaRegistryConnectionProperties: Codable, Equatable, GoogleCloudWkt
    ._AnyPackable,
  Sendable
{
  /// Optional. The technology type of KafkaSchemaRegistryConnection.
  public var technologyType: Swift.String = Swift.String()

  /// Optional. Kafka Schema Registry URL.
  /// e.g.: 'https://server1.us.oracle.com:8081'
  public var url: Swift.String = Swift.String()

  /// Optional. Used authentication mechanism to access Schema Registry.
  public var authenticationType:
    GoldengateKafkaSchemaRegistryConnectionProperties.AuthenticationType =
      GoldengateKafkaSchemaRegistryConnectionProperties.AuthenticationType()

  /// Optional. The username to access Schema Registry using basic
  /// authentication. This value is injected into
  /// 'schema.registry.basic.auth.user.info=user:password' configuration
  /// property.
  public var username: Swift.String = Swift.String()

  /// Optional. The base64 encoded content of the TrustStore file.
  public var trustStoreFile: Swift.String = Swift.String()

  /// Optional. The base64 encoded content of the KeyStore file.
  public var keyStoreFile: Swift.String = Swift.String()

  /// The password to access Schema Registry using basic authentication.
  public var connectionPasswordOptions: OneOf_ConnectionPasswordOptions? = nil

  /// The TrustStore password.
  public var trustStorePasswordOptions: OneOf_TrustStorePasswordOptions? = nil

  /// The KeyStore password.
  public var keyStorePasswordOptions: OneOf_KeyStorePasswordOptions? = nil

  /// The password for the cert inside the KeyStore.
  public var sslKeyPasswordOptions: OneOf_SslKeyPasswordOptions? = nil

  /// Initialize a new instance of `GoldengateKafkaSchemaRegistryConnectionProperties`.
  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 = GoldengateKafkaSchemaRegistryConnectionProperties().with { $0.password = ... }
  /// ```
  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 password = "password"
    case passwordSecretVersion = "passwordSecretVersion"
    case trustStorePassword = "trustStorePassword"
    case trustStorePasswordSecretVersion = "trustStorePasswordSecretVersion"
    case keyStorePassword = "keyStorePassword"
    case keyStorePasswordSecretVersion = "keyStorePasswordSecretVersion"
    case sslKeyPassword = "sslKeyPassword"
    case sslKeyPasswordSecretVersion = "sslKeyPasswordSecretVersion"
    case technologyType = "technologyType"
    case url = "url"
    case authenticationType = "authenticationType"
    case username = "username"
    case trustStoreFile = "trustStoreFile"
    case keyStoreFile = "keyStoreFile"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.technologyType = try container.decode(Swift.String.self, forKey: .technologyType)
    self.url = try container.decode(Swift.String.self, forKey: .url)
    self.authenticationType = try container.decode(
      GoldengateKafkaSchemaRegistryConnectionProperties.AuthenticationType.self,
      forKey: .authenticationType)
    self.username = try container.decode(Swift.String.self, forKey: .username)
    self.trustStoreFile = try container.decode(Swift.String.self, forKey: .trustStoreFile)
    self.keyStoreFile = try container.decode(Swift.String.self, forKey: .keyStoreFile)

    var connectionPasswordOptions: OneOf_ConnectionPasswordOptions? = nil
    let connectionPasswordOptionsCheckAndSet = {
      if connectionPasswordOptions != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'connectionPasswordOptions'"))
      }
      connectionPasswordOptions = $0
    }
    if let password = try container.decodeIfPresent(Swift.String.self, forKey: .password) {
      try connectionPasswordOptionsCheckAndSet(.password(password))
    }
    if let passwordSecretVersion = try container.decodeIfPresent(
      Swift.String.self, forKey: .passwordSecretVersion)
    {
      try connectionPasswordOptionsCheckAndSet(.passwordSecretVersion(passwordSecretVersion))
    }
    self.connectionPasswordOptions = connectionPasswordOptions

    var trustStorePasswordOptions: OneOf_TrustStorePasswordOptions? = nil
    let trustStorePasswordOptionsCheckAndSet = {
      if trustStorePasswordOptions != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'trustStorePasswordOptions'"))
      }
      trustStorePasswordOptions = $0
    }
    if let trustStorePassword = try container.decodeIfPresent(
      Swift.String.self, forKey: .trustStorePassword)
    {
      try trustStorePasswordOptionsCheckAndSet(.trustStorePassword(trustStorePassword))
    }
    if let trustStorePasswordSecretVersion = try container.decodeIfPresent(
      Swift.String.self, forKey: .trustStorePasswordSecretVersion)
    {
      try trustStorePasswordOptionsCheckAndSet(
        .trustStorePasswordSecretVersion(trustStorePasswordSecretVersion))
    }
    self.trustStorePasswordOptions = trustStorePasswordOptions

    var keyStorePasswordOptions: OneOf_KeyStorePasswordOptions? = nil
    let keyStorePasswordOptionsCheckAndSet = {
      if keyStorePasswordOptions != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'keyStorePasswordOptions'"))
      }
      keyStorePasswordOptions = $0
    }
    if let keyStorePassword = try container.decodeIfPresent(
      Swift.String.self, forKey: .keyStorePassword)
    {
      try keyStorePasswordOptionsCheckAndSet(.keyStorePassword(keyStorePassword))
    }
    if let keyStorePasswordSecretVersion = try container.decodeIfPresent(
      Swift.String.self, forKey: .keyStorePasswordSecretVersion)
    {
      try keyStorePasswordOptionsCheckAndSet(
        .keyStorePasswordSecretVersion(keyStorePasswordSecretVersion))
    }
    self.keyStorePasswordOptions = keyStorePasswordOptions

    var sslKeyPasswordOptions: OneOf_SslKeyPasswordOptions? = nil
    let sslKeyPasswordOptionsCheckAndSet = {
      if sslKeyPasswordOptions != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'sslKeyPasswordOptions'"))
      }
      sslKeyPasswordOptions = $0
    }
    if let sslKeyPassword = try container.decodeIfPresent(
      Swift.String.self, forKey: .sslKeyPassword)
    {
      try sslKeyPasswordOptionsCheckAndSet(.sslKeyPassword(sslKeyPassword))
    }
    if let sslKeyPasswordSecretVersion = try container.decodeIfPresent(
      Swift.String.self, forKey: .sslKeyPasswordSecretVersion)
    {
      try sslKeyPasswordOptionsCheckAndSet(
        .sslKeyPasswordSecretVersion(sslKeyPasswordSecretVersion))
    }
    self.sslKeyPasswordOptions = sslKeyPasswordOptions
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.technologyType, forKey: .technologyType)
    try container.encode(self.url, forKey: .url)
    try container.encode(self.authenticationType, forKey: .authenticationType)
    try container.encode(self.username, forKey: .username)
    try container.encode(self.trustStoreFile, forKey: .trustStoreFile)
    try container.encode(self.keyStoreFile, forKey: .keyStoreFile)

    if let choice = self.connectionPasswordOptions {
      switch choice {
      case .password(let value):
        try container.encode(value, forKey: .password)
      case .passwordSecretVersion(let value):
        try container.encode(value, forKey: .passwordSecretVersion)
      }
    }

    if let choice = self.trustStorePasswordOptions {
      switch choice {
      case .trustStorePassword(let value):
        try container.encode(value, forKey: .trustStorePassword)
      case .trustStorePasswordSecretVersion(let value):
        try container.encode(value, forKey: .trustStorePasswordSecretVersion)
      }
    }

    if let choice = self.keyStorePasswordOptions {
      switch choice {
      case .keyStorePassword(let value):
        try container.encode(value, forKey: .keyStorePassword)
      case .keyStorePasswordSecretVersion(let value):
        try container.encode(value, forKey: .keyStorePasswordSecretVersion)
      }
    }

    if let choice = self.sslKeyPasswordOptions {
      switch choice {
      case .sslKeyPassword(let value):
        try container.encode(value, forKey: .sslKeyPassword)
      case .sslKeyPasswordSecretVersion(let value):
        try container.encode(value, forKey: .sslKeyPasswordSecretVersion)
      }
    }
  }

  /// Enum for authentication mechanism to access Schema Registry.
  public enum AuthenticationType: Codable, Equatable, Sendable {
    /// Authentication type not specified.
    case unspecified
    /// No authentication.
    case `none`
    /// Basic authentication.
    case basic
    /// Mutual authentication.
    case mutual
    /// 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 .`none`: return 1
      case .basic: return 2
      case .mutual: 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 "AUTHENTICATION_TYPE_UNSPECIFIED"
      case .`none`: return "NONE"
      case .basic: return "BASIC"
      case .mutual: return "MUTUAL"
      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:AuthenticationType/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "AUTHENTICATION_TYPE_UNSPECIFIED": self = .unspecified
      case "NONE": self = .`none`
      case "BASIC": self = .basic
      case "MUTUAL": self = .mutual
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The password to access Schema Registry using basic authentication.
  public enum OneOf_ConnectionPasswordOptions: Codable, Equatable, Sendable {
    /// Optional. Input only. The password to access Schema Registry in plain
    /// text.
    case password(Swift.String)
    /// Optional. Input only. The resource name of a secret version in Secret
    /// Manager which contains the password to access Schema Registry using basic
    /// authentication. Format:
    /// projects/{project}/secrets/{secret}/versions/{version}.
    case passwordSecretVersion(Swift.String)
  }

  /// The TrustStore password.
  public enum OneOf_TrustStorePasswordOptions: Codable, Equatable, Sendable {
    /// Optional. Input only. The TrustStore password in plain text.
    case trustStorePassword(Swift.String)
    /// Optional. Input only. The resource name of a secret version in Secret
    /// Manager which contains the TrustStore password. Format:
    /// projects/{project}/secrets/{secret}/versions/{version}.
    case trustStorePasswordSecretVersion(Swift.String)
  }

  /// The KeyStore password.
  public enum OneOf_KeyStorePasswordOptions: Codable, Equatable, Sendable {
    /// Optional. Input only. The KeyStore password in plain text.
    case keyStorePassword(Swift.String)
    /// Optional. Input only. The resource name of a secret version in Secret
    /// Manager which contains the KeyStore password. Format:
    /// projects/{project}/secrets/{secret}/versions/{version}.
    case keyStorePasswordSecretVersion(Swift.String)
  }

  /// The password for the cert inside the KeyStore.
  public enum OneOf_SslKeyPasswordOptions: Codable, Equatable, Sendable {
    /// Optional. Input only. The password for the cert inside the KeyStore in
    /// plain text.
    case sslKeyPassword(Swift.String)
    /// Optional. Input only. The resource name of a secret version in Secret
    /// Manager which contains the password for the cert inside the KeyStore.
    /// Format: projects/{project}/secrets/{secret}/versions/{version}.
    case sslKeyPasswordSecretVersion(Swift.String)
  }

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