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

/// Response message for
/// [KeyManagementService.AsymmetricDecrypt][google.cloud.kms.v1.KeyManagementService.AsymmetricDecrypt].
///
/// [google.cloud.kms.v1.KeyManagementService.AsymmetricDecrypt]: <doc:KeyManagementService/asymmetricDecrypt(request:)>
public struct AsymmetricDecryptResponse: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The decrypted data originally encrypted with the matching public key.
  public var plaintext: Foundation.Data = Foundation.Data()

  /// Integrity verification field. A CRC32C checksum of the returned
  /// [AsymmetricDecryptResponse.plaintext][google.cloud.kms.v1.AsymmetricDecryptResponse.plaintext].
  /// An integrity check of
  /// [AsymmetricDecryptResponse.plaintext][google.cloud.kms.v1.AsymmetricDecryptResponse.plaintext]
  /// can be performed by computing the CRC32C checksum of
  /// [AsymmetricDecryptResponse.plaintext][google.cloud.kms.v1.AsymmetricDecryptResponse.plaintext]
  /// and comparing your results to this field. Discard the response in case of
  /// non-matching checksum values, and perform a limited number of retries. A
  /// persistent mismatch may indicate an issue in your computation of the CRC32C
  /// checksum. Note: This field is defined as int64 for reasons of compatibility
  /// across different languages. However, it is a non-negative integer, which
  /// will never exceed 2^32-1, and can be safely downconverted to uint32 in
  /// languages that support this type.
  ///
  /// [google.cloud.kms.v1.AsymmetricDecryptResponse.plaintext]: <doc:AsymmetricDecryptResponse/plaintext>
  public var plaintextCrc32C: GoogleCloudWkt.Int64Value? = nil

  /// Integrity verification field. A flag indicating whether
  /// [AsymmetricDecryptRequest.ciphertext_crc32c][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c]
  /// was received by
  /// [KeyManagementService][google.cloud.kms.v1.KeyManagementService] and used
  /// for the integrity verification of the
  /// [ciphertext][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext]. A
  /// false value of this field indicates either that
  /// [AsymmetricDecryptRequest.ciphertext_crc32c][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c]
  /// was left unset or that it was not delivered to
  /// [KeyManagementService][google.cloud.kms.v1.KeyManagementService]. If you've
  /// set
  /// [AsymmetricDecryptRequest.ciphertext_crc32c][google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c]
  /// but this field is still false, discard the response and perform a limited
  /// number of retries.
  ///
  /// [google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext]: <doc:AsymmetricDecryptRequest/ciphertext>
  /// [google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c]: <doc:AsymmetricDecryptRequest/ciphertextCrc32C>
  /// [google.cloud.kms.v1.KeyManagementService]: <doc:KeyManagementService>
  public var verifiedCiphertextCrc32C: Swift.Bool = Swift.Bool()

  /// The [ProtectionLevel][google.cloud.kms.v1.ProtectionLevel] of the
  /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] used in
  /// decryption.
  ///
  /// [google.cloud.kms.v1.CryptoKeyVersion]: <doc:CryptoKeyVersion>
  /// [google.cloud.kms.v1.ProtectionLevel]: <doc:ProtectionLevel>
  public var protectionLevel: ProtectionLevel = ProtectionLevel()

  /// Initialize a new instance of `AsymmetricDecryptResponse`.
  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 = AsymmetricDecryptResponse().with { $0.plaintext = ... }
  /// ```
  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 plaintext = "plaintext"
    case plaintextCrc32C = "plaintextCrc32c"
    case verifiedCiphertextCrc32C = "verifiedCiphertextCrc32c"
    case protectionLevel = "protectionLevel"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.plaintext = try container.decode(Foundation.Data.self, forKey: .plaintext)
    self.plaintextCrc32C = try container.decodeIfPresent(
      GoogleCloudWkt.Int64Value.self, forKey: .plaintextCrc32C)
    self.verifiedCiphertextCrc32C = try container.decode(
      Swift.Bool.self, forKey: .verifiedCiphertextCrc32C)
    self.protectionLevel = try container.decode(ProtectionLevel.self, forKey: .protectionLevel)
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.plaintext, forKey: .plaintext)
    try container.encode(self.plaintextCrc32C, forKey: .plaintextCrc32C)
    try container.encode(self.verifiedCiphertextCrc32C, forKey: .verifiedCiphertextCrc32C)
    try container.encode(self.protectionLevel, forKey: .protectionLevel)
  }

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