# Copyright 2019 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
#
#     http://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.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudKMS.V1.Model.CryptoKeyVersion do
  @moduledoc """
  A CryptoKeyVersion represents an individual cryptographic key, and the associated key material. An ENABLED version can be used for cryptographic operations. For security reasons, the raw cryptographic key material represented by a CryptoKeyVersion can never be viewed or exported. It can only be used to encrypt, decrypt, or sign data when an authorized user or application invokes Cloud KMS.

  ## Attributes

  *   `algorithm` (*type:* `String.t`, *default:* `nil`) - Output only. The CryptoKeyVersionAlgorithm that this CryptoKeyVersion supports.
  *   `attestation` (*type:* `GoogleApi.CloudKMS.V1.Model.KeyOperationAttestation.t`, *default:* `nil`) - Output only. Statement that was generated and signed by the HSM at key creation time. Use this statement to verify attributes of the key as stored on the HSM, independently of Google. Only provided for key versions with protection_level HSM.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time at which this CryptoKeyVersion was created.
  *   `destroyEventTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time this CryptoKeyVersion's key material was destroyed. Only present if state is DESTROYED.
  *   `destroyTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time this CryptoKeyVersion's key material is scheduled for destruction. Only present if state is DESTROY_SCHEDULED.
  *   `externalDestructionFailureReason` (*type:* `String.t`, *default:* `nil`) - Output only. The root cause of the most recent external destruction failure. Only present if state is EXTERNAL_DESTRUCTION_FAILED.
  *   `externalProtectionLevelOptions` (*type:* `GoogleApi.CloudKMS.V1.Model.ExternalProtectionLevelOptions.t`, *default:* `nil`) - ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
  *   `generateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time this CryptoKeyVersion's key material was generated.
  *   `generationFailureReason` (*type:* `String.t`, *default:* `nil`) - Output only. The root cause of the most recent generation failure. Only present if state is GENERATION_FAILED.
  *   `importFailureReason` (*type:* `String.t`, *default:* `nil`) - Output only. The root cause of the most recent import failure. Only present if state is IMPORT_FAILED.
  *   `importJob` (*type:* `String.t`, *default:* `nil`) - Output only. The name of the ImportJob used in the most recent import of this CryptoKeyVersion. Only present if the underlying key material was imported.
  *   `importTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time at which this CryptoKeyVersion's key material was most recently imported.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. The resource name for this CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.
  *   `protectionLevel` (*type:* `String.t`, *default:* `nil`) - Output only. The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion.
  *   `reimportEligible` (*type:* `boolean()`, *default:* `nil`) - Output only. Whether or not this key version is eligible for reimport, by being specified as a target in ImportCryptoKeyVersionRequest.crypto_key_version.
  *   `state` (*type:* `String.t`, *default:* `nil`) - The current state of the CryptoKeyVersion.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :algorithm => String.t() | nil,
          :attestation => GoogleApi.CloudKMS.V1.Model.KeyOperationAttestation.t() | nil,
          :createTime => DateTime.t() | nil,
          :destroyEventTime => DateTime.t() | nil,
          :destroyTime => DateTime.t() | nil,
          :externalDestructionFailureReason => String.t() | nil,
          :externalProtectionLevelOptions =>
            GoogleApi.CloudKMS.V1.Model.ExternalProtectionLevelOptions.t() | nil,
          :generateTime => DateTime.t() | nil,
          :generationFailureReason => String.t() | nil,
          :importFailureReason => String.t() | nil,
          :importJob => String.t() | nil,
          :importTime => DateTime.t() | nil,
          :name => String.t() | nil,
          :protectionLevel => String.t() | nil,
          :reimportEligible => boolean() | nil,
          :state => String.t() | nil
        }

  field(:algorithm)
  field(:attestation, as: GoogleApi.CloudKMS.V1.Model.KeyOperationAttestation)
  field(:createTime, as: DateTime)
  field(:destroyEventTime, as: DateTime)
  field(:destroyTime, as: DateTime)
  field(:externalDestructionFailureReason)

  field(:externalProtectionLevelOptions,
    as: GoogleApi.CloudKMS.V1.Model.ExternalProtectionLevelOptions
  )

  field(:generateTime, as: DateTime)
  field(:generationFailureReason)
  field(:importFailureReason)
  field(:importJob)
  field(:importTime, as: DateTime)
  field(:name)
  field(:protectionLevel)
  field(:reimportEligible)
  field(:state)
end

defimpl Poison.Decoder, for: GoogleApi.CloudKMS.V1.Model.CryptoKeyVersion do
  def decode(value, options) do
    GoogleApi.CloudKMS.V1.Model.CryptoKeyVersion.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.CloudKMS.V1.Model.CryptoKeyVersion do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
