Class: OCI::KeyManagement::Models::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/key_management/models/key.rb

Overview

The logical entities that represent one or more key versions, each of which contains cryptographic material.

Constant Summary collapse

PROTECTION_MODE_ENUM =
[
  PROTECTION_MODE_HSM = 'HSM'.freeze,
  PROTECTION_MODE_SOFTWARE = 'SOFTWARE'.freeze,
  PROTECTION_MODE_EXTERNAL = 'EXTERNAL'.freeze,
  PROTECTION_MODE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
LIFECYCLE_STATE_ENUM =
[
  LIFECYCLE_STATE_CREATING = 'CREATING'.freeze,
  LIFECYCLE_STATE_ENABLING = 'ENABLING'.freeze,
  LIFECYCLE_STATE_ENABLED = 'ENABLED'.freeze,
  LIFECYCLE_STATE_DISABLING = 'DISABLING'.freeze,
  LIFECYCLE_STATE_DISABLED = 'DISABLED'.freeze,
  LIFECYCLE_STATE_DELETING = 'DELETING'.freeze,
  LIFECYCLE_STATE_DELETED = 'DELETED'.freeze,
  LIFECYCLE_STATE_PENDING_DELETION = 'PENDING_DELETION'.freeze,
  LIFECYCLE_STATE_SCHEDULING_DELETION = 'SCHEDULING_DELETION'.freeze,
  LIFECYCLE_STATE_CANCELLING_DELETION = 'CANCELLING_DELETION'.freeze,
  LIFECYCLE_STATE_UPDATING = 'UPDATING'.freeze,
  LIFECYCLE_STATE_BACKUP_IN_PROGRESS = 'BACKUP_IN_PROGRESS'.freeze,
  LIFECYCLE_STATE_RESTORING = 'RESTORING'.freeze,
  LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Key

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/oci/key_management/models/key.rb', line 195

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.current_key_version = attributes[:'currentKeyVersion'] if attributes[:'currentKeyVersion']

  raise 'You cannot provide both :currentKeyVersion and :current_key_version' if attributes.key?(:'currentKeyVersion') && attributes.key?(:'current_key_version')

  self.current_key_version = attributes[:'current_key_version'] if attributes[:'current_key_version']

  self.defined_tags = attributes[:'definedTags'] if attributes[:'definedTags']

  raise 'You cannot provide both :definedTags and :defined_tags' if attributes.key?(:'definedTags') && attributes.key?(:'defined_tags')

  self.defined_tags = attributes[:'defined_tags'] if attributes[:'defined_tags']

  self.display_name = attributes[:'displayName'] if attributes[:'displayName']

  raise 'You cannot provide both :displayName and :display_name' if attributes.key?(:'displayName') && attributes.key?(:'display_name')

  self.display_name = attributes[:'display_name'] if attributes[:'display_name']

  self.freeform_tags = attributes[:'freeformTags'] if attributes[:'freeformTags']

  raise 'You cannot provide both :freeformTags and :freeform_tags' if attributes.key?(:'freeformTags') && attributes.key?(:'freeform_tags')

  self.freeform_tags = attributes[:'freeform_tags'] if attributes[:'freeform_tags']

  self.id = attributes[:'id'] if attributes[:'id']

  self.key_shape = attributes[:'keyShape'] if attributes[:'keyShape']

  raise 'You cannot provide both :keyShape and :key_shape' if attributes.key?(:'keyShape') && attributes.key?(:'key_shape')

  self.key_shape = attributes[:'key_shape'] if attributes[:'key_shape']

  self.protection_mode = attributes[:'protectionMode'] if attributes[:'protectionMode']

  raise 'You cannot provide both :protectionMode and :protection_mode' if attributes.key?(:'protectionMode') && attributes.key?(:'protection_mode')

  self.protection_mode = attributes[:'protection_mode'] if attributes[:'protection_mode']

  self.lifecycle_state = attributes[:'lifecycleState'] if attributes[:'lifecycleState']

  raise 'You cannot provide both :lifecycleState and :lifecycle_state' if attributes.key?(:'lifecycleState') && attributes.key?(:'lifecycle_state')

  self.lifecycle_state = attributes[:'lifecycle_state'] if attributes[:'lifecycle_state']

  self.time_created = attributes[:'timeCreated'] if attributes[:'timeCreated']

  raise 'You cannot provide both :timeCreated and :time_created' if attributes.key?(:'timeCreated') && attributes.key?(:'time_created')

  self.time_created = attributes[:'time_created'] if attributes[:'time_created']

  self.time_of_deletion = attributes[:'timeOfDeletion'] if attributes[:'timeOfDeletion']

  raise 'You cannot provide both :timeOfDeletion and :time_of_deletion' if attributes.key?(:'timeOfDeletion') && attributes.key?(:'time_of_deletion')

  self.time_of_deletion = attributes[:'time_of_deletion'] if attributes[:'time_of_deletion']

  self.vault_id = attributes[:'vaultId'] if attributes[:'vaultId']

  raise 'You cannot provide both :vaultId and :vault_id' if attributes.key?(:'vaultId') && attributes.key?(:'vault_id')

  self.vault_id = attributes[:'vault_id'] if attributes[:'vault_id']

  self.restored_from_key_id = attributes[:'restoredFromKeyId'] if attributes[:'restoredFromKeyId']

  raise 'You cannot provide both :restoredFromKeyId and :restored_from_key_id' if attributes.key?(:'restoredFromKeyId') && attributes.key?(:'restored_from_key_id')

  self.restored_from_key_id = attributes[:'restored_from_key_id'] if attributes[:'restored_from_key_id']

  self.replica_details = attributes[:'replicaDetails'] if attributes[:'replicaDetails']

  raise 'You cannot provide both :replicaDetails and :replica_details' if attributes.key?(:'replicaDetails') && attributes.key?(:'replica_details')

  self.replica_details = attributes[:'replica_details'] if attributes[:'replica_details']

  self.is_primary = attributes[:'isPrimary'] unless attributes[:'isPrimary'].nil?

  raise 'You cannot provide both :isPrimary and :is_primary' if attributes.key?(:'isPrimary') && attributes.key?(:'is_primary')

  self.is_primary = attributes[:'is_primary'] unless attributes[:'is_primary'].nil?

  self.external_key_reference_details = attributes[:'externalKeyReferenceDetails'] if attributes[:'externalKeyReferenceDetails']

  raise 'You cannot provide both :externalKeyReferenceDetails and :external_key_reference_details' if attributes.key?(:'externalKeyReferenceDetails') && attributes.key?(:'external_key_reference_details')

  self.external_key_reference_details = attributes[:'external_key_reference_details'] if attributes[:'external_key_reference_details']
end

Instance Attribute Details

#compartment_idString

[Required] The OCID of the compartment that contains this master encryption key.

Returns:

  • (String)


38
39
40
# File 'lib/oci/key_management/models/key.rb', line 38

def compartment_id
  @compartment_id
end

#current_key_versionString

[Required] The OCID of the key version used in cryptographic operations. During key rotation, the service might be in a transitional state where this or a newer key version are used intermittently. The currentKeyVersion property is updated when the service is guaranteed to use the new key version for all subsequent encryption operations.

Returns:

  • (String)


45
46
47
# File 'lib/oci/key_management/models/key.rb', line 45

def current_key_version
  @current_key_version
end

#defined_tagsHash<String, Hash<String, Object>>

Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {\"Operations\": {\"CostCenter\": \"42\"}}

Returns:

  • (Hash<String, Hash<String, Object>>)


52
53
54
# File 'lib/oci/key_management/models/key.rb', line 52

def defined_tags
  @defined_tags
end

#display_nameString

[Required] A user-friendly name for the key. It does not have to be unique, and it is changeable. Avoid entering confidential information.

Returns:

  • (String)


58
59
60
# File 'lib/oci/key_management/models/key.rb', line 58

def display_name
  @display_name
end

#external_key_reference_detailsOCI::KeyManagement::Models::ExternalKeyReferenceDetails



123
124
125
# File 'lib/oci/key_management/models/key.rb', line 123

def external_key_reference_details
  @external_key_reference_details
end

#freeform_tagsHash<String, String>

Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {\"Department\": \"Finance\"}

Returns:

  • (Hash<String, String>)


65
66
67
# File 'lib/oci/key_management/models/key.rb', line 65

def freeform_tags
  @freeform_tags
end

#idString

[Required] The OCID of the key.

Returns:

  • (String)


69
70
71
# File 'lib/oci/key_management/models/key.rb', line 69

def id
  @id
end

#is_primaryBOOLEAN

A Boolean value that indicates whether the Key belongs to primary Vault or replica vault.

Returns:

  • (BOOLEAN)


120
121
122
# File 'lib/oci/key_management/models/key.rb', line 120

def is_primary
  @is_primary
end

#key_shapeOCI::KeyManagement::Models::KeyShape

This attribute is required.



73
74
75
# File 'lib/oci/key_management/models/key.rb', line 73

def key_shape
  @key_shape
end

#lifecycle_stateString

[Required] The key's current lifecycle state.

Example: ENABLED

Returns:

  • (String)


92
93
94
# File 'lib/oci/key_management/models/key.rb', line 92

def lifecycle_state
  @lifecycle_state
end

#protection_modeString

The key's protection mode indicates how the key persists and where cryptographic operations that use the key are performed. A protection mode of HSM means that the key persists on a hardware security module (HSM) and all cryptographic operations are performed inside the HSM. A protection mode of SOFTWARE means that the key persists on the server, protected by the vault's RSA wrapping key which persists on the HSM. All cryptographic operations that use a key with a protection mode of SOFTWARE are performed on the server. By default, a key's protection mode is set to HSM. You can't change a key's protection mode after the key is created or imported. A protection mode of EXTERNAL mean that the key persists on the customer's external key manager which is hosted externally outside of oracle. Oracle only hold a reference to that key. All cryptographic operations that use a key with a protection mode of EXTERNAL are performed by external key manager.

Returns:

  • (String)


85
86
87
# File 'lib/oci/key_management/models/key.rb', line 85

def protection_mode
  @protection_mode
end

#replica_detailsOCI::KeyManagement::Models::KeyReplicaDetails



116
117
118
# File 'lib/oci/key_management/models/key.rb', line 116

def replica_details
  @replica_details
end

#restored_from_key_idString

The OCID of the key from which this key was restored.

Returns:

  • (String)


113
114
115
# File 'lib/oci/key_management/models/key.rb', line 113

def restored_from_key_id
  @restored_from_key_id
end

#time_createdDateTime

[Required] The date and time the key was created, expressed in RFC 3339 timestamp format.

Example: 2018-04-03T21:10:29.600Z

Returns:

  • (DateTime)


99
100
101
# File 'lib/oci/key_management/models/key.rb', line 99

def time_created
  @time_created
end

#time_of_deletionDateTime

An optional property indicating when to delete the key, expressed in RFC 3339 timestamp format. Example: 2019-04-03T21:10:29.600Z

Returns:

  • (DateTime)


105
106
107
# File 'lib/oci/key_management/models/key.rb', line 105

def time_of_deletion
  @time_of_deletion
end

#vault_idString

[Required] The OCID of the vault that contains this key.

Returns:

  • (String)


109
110
111
# File 'lib/oci/key_management/models/key.rb', line 109

def vault_id
  @vault_id
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/oci/key_management/models/key.rb', line 126

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'compartment_id': :'compartmentId',
    'current_key_version': :'currentKeyVersion',
    'defined_tags': :'definedTags',
    'display_name': :'displayName',
    'freeform_tags': :'freeformTags',
    'id': :'id',
    'key_shape': :'keyShape',
    'protection_mode': :'protectionMode',
    'lifecycle_state': :'lifecycleState',
    'time_created': :'timeCreated',
    'time_of_deletion': :'timeOfDeletion',
    'vault_id': :'vaultId',
    'restored_from_key_id': :'restoredFromKeyId',
    'replica_details': :'replicaDetails',
    'is_primary': :'isPrimary',
    'external_key_reference_details': :'externalKeyReferenceDetails'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/oci/key_management/models/key.rb', line 150

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'compartment_id': :'String',
    'current_key_version': :'String',
    'defined_tags': :'Hash<String, Hash<String, Object>>',
    'display_name': :'String',
    'freeform_tags': :'Hash<String, String>',
    'id': :'String',
    'key_shape': :'OCI::KeyManagement::Models::KeyShape',
    'protection_mode': :'String',
    'lifecycle_state': :'String',
    'time_created': :'DateTime',
    'time_of_deletion': :'DateTime',
    'vault_id': :'String',
    'restored_from_key_id': :'String',
    'replica_details': :'OCI::KeyManagement::Models::KeyReplicaDetails',
    'is_primary': :'BOOLEAN',
    'external_key_reference_details': :'OCI::KeyManagement::Models::ExternalKeyReferenceDetails'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/oci/key_management/models/key.rb', line 327

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    compartment_id == other.compartment_id &&
    current_key_version == other.current_key_version &&
    defined_tags == other.defined_tags &&
    display_name == other.display_name &&
    freeform_tags == other.freeform_tags &&
    id == other.id &&
    key_shape == other.key_shape &&
    protection_mode == other.protection_mode &&
    lifecycle_state == other.lifecycle_state &&
    time_created == other.time_created &&
    time_of_deletion == other.time_of_deletion &&
    vault_id == other.vault_id &&
    restored_from_key_id == other.restored_from_key_id &&
    replica_details == other.replica_details &&
    is_primary == other.is_primary &&
    external_key_reference_details == other.external_key_reference_details
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/oci/key_management/models/key.rb', line 372

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


352
353
354
# File 'lib/oci/key_management/models/key.rb', line 352

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



361
362
363
# File 'lib/oci/key_management/models/key.rb', line 361

def hash
  [compartment_id, current_key_version, defined_tags, display_name, freeform_tags, id, key_shape, protection_mode, lifecycle_state, time_created, time_of_deletion, vault_id, restored_from_key_id, replica_details, is_primary, external_key_reference_details].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



405
406
407
408
409
410
411
412
413
414
# File 'lib/oci/key_management/models/key.rb', line 405

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



399
400
401
# File 'lib/oci/key_management/models/key.rb', line 399

def to_s
  to_hash.to_s
end