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

/// Salesforce profile
public struct SalesforceProfile: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. Domain endpoint for the Salesforce connection.
  public var domain: Swift.String = Swift.String()

  /// Credentials for Salesforce connection.
  public var credentials: OneOf_Credentials? = nil

  /// Initialize a new instance of `SalesforceProfile`.
  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 = SalesforceProfile().with { $0.domain = ... }
  /// ```
  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 domain = "domain"
    case userCredentials = "userCredentials"
    case oauth2ClientCredentials = "oauth2ClientCredentials"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.domain = try container.decode(Swift.String.self, forKey: .domain)

    var credentials: OneOf_Credentials? = nil
    let credentialsCheckAndSet = {
      if credentials != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'credentials'"))
      }
      credentials = $0
    }
    if let userCredentials = try container.decodeIfPresent(
      SalesforceProfile.UserCredentials?.self, forKey: .userCredentials)
    {
      try credentialsCheckAndSet(.userCredentials(userCredentials))
    }
    if let oauth2ClientCredentials = try container.decodeIfPresent(
      SalesforceProfile.Oauth2ClientCredentials?.self, forKey: .oauth2ClientCredentials)
    {
      try credentialsCheckAndSet(.oauth2ClientCredentials(oauth2ClientCredentials))
    }
    self.credentials = credentials
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.domain, forKey: .domain)

    if let choice = self.credentials {
      switch choice {
      case .userCredentials(let value):
        try container.encode(value, forKey: .userCredentials)
      case .oauth2ClientCredentials(let value):
        try container.encode(value, forKey: .oauth2ClientCredentials)
      }
    }
  }

  /// Username-password credentials.
  public struct UserCredentials: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Username for the Salesforce connection.
    public var username: Swift.String = Swift.String()

    /// Optional. Password for the Salesforce connection.
    /// Mutually exclusive with the `secret_manager_stored_password` field.
    public var password: Swift.String = Swift.String()

    /// Optional. Security token for the Salesforce connection.
    /// Mutually exclusive with the `secret_manager_stored_security_token` field.
    public var securityToken: Swift.String = Swift.String()

    /// Optional. A reference to a Secret Manager resource name storing the
    /// Salesforce connection's password. Mutually exclusive with the `password`
    /// field.
    public var secretManagerStoredPassword: Swift.String = Swift.String()

    /// Optional. A reference to a Secret Manager resource name storing the
    /// Salesforce connection's security token. Mutually exclusive with the
    /// `security_token` field.
    public var secretManagerStoredSecurityToken: Swift.String = Swift.String()

    /// Initialize a new instance of `UserCredentials`.
    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 = UserCredentials().with { $0.username = ... }
    /// ```
    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.datastream.v1.SalesforceProfile.UserCredentials"
    }
    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)
    }
  }

  /// OAuth2 Client Credentials.
  public struct Oauth2ClientCredentials: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Client ID for Salesforce OAuth2 Client Credentials.
    public var clientId: Swift.String = Swift.String()

    /// Optional. Client secret for Salesforce OAuth2 Client Credentials.
    /// Mutually exclusive with the `secret_manager_stored_client_secret` field.
    public var clientSecret: Swift.String = Swift.String()

    /// Optional. A reference to a Secret Manager resource name storing the
    /// Salesforce OAuth2 client_secret. Mutually exclusive with the
    /// `client_secret` field.
    public var secretManagerStoredClientSecret: Swift.String = Swift.String()

    /// Initialize a new instance of `Oauth2ClientCredentials`.
    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 = Oauth2ClientCredentials().with { $0.clientId = ... }
    /// ```
    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.datastream.v1.SalesforceProfile.Oauth2ClientCredentials"
    }
    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)
    }
  }

  /// Credentials for Salesforce connection.
  public enum OneOf_Credentials: Codable, Equatable, Sendable {
    /// User-password authentication.
    indirect case userCredentials(SalesforceProfile.UserCredentials?)
    /// Connected app authentication.
    indirect case oauth2ClientCredentials(SalesforceProfile.Oauth2ClientCredentials?)
  }

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