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

  /// Ephemeral certificate creation request.
  public struct GenerateEphemeralCertRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Cloud SQL instance ID. This does not include the project ID.
    public var instance: Swift.String = Swift.String()

    /// Project ID of the project that contains the instance.
    public var project: Swift.String = Swift.String()

    /// PEM encoded public key to include in the signed certificate.
    public var publicKey: Swift.String = Swift.String()

    /// Optional. Access token to include in the signed certificate.
    public var accessToken: Swift.String = Swift.String()

    /// Optional. Optional snapshot read timestamp to trade freshness for
    /// performance.
    public var readTime: GoogleCloudWkt.Timestamp? = nil

    /// Optional. If set, it will contain the cert valid duration.
    public var validDuration: GoogleCloudWkt.Duration? = nil

    /// Initialize a new instance of `GenerateEphemeralCertRequest`.
    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 = GenerateEphemeralCertRequest().with { $0.instance = ... }
    /// ```
    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 instance = "instance"
      case project = "project"
      case publicKey = "public_key"
      case accessToken = "access_token"
      case readTime = "readTime"
      case validDuration = "validDuration"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.instance = try container.decode(Swift.String.self, forKey: .instance)
      self.project = try container.decode(Swift.String.self, forKey: .project)
      self.publicKey = try container.decode(Swift.String.self, forKey: .publicKey)
      self.accessToken = try container.decode(Swift.String.self, forKey: .accessToken)
      self.readTime = try container.decodeIfPresent(
        GoogleCloudWkt.Timestamp.self, forKey: .readTime)
      self.validDuration = try container.decodeIfPresent(
        GoogleCloudWkt.Duration.self, forKey: .validDuration)
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.instance, forKey: .instance)
      try container.encode(self.project, forKey: .project)
      try container.encode(self.publicKey, forKey: .publicKey)
      try container.encode(self.accessToken, forKey: .accessToken)
      try container.encode(self.readTime, forKey: .readTime)
      try container.encode(self.validDuration, forKey: .validDuration)
    }

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