Class: Fog::KeyVault::AzureRM::Vault

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/azurerm/models/key_vault/vault.rb

Overview

Vault model for KeyVault Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(vault) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/azurerm/models/key_vault/vault.rb', line 20

def self.parse(vault)
  vault_hash = get_hash_from_object(vault)
  vault_properties = vault.properties

  unless vault_properties.nil?
    vault_hash['vault_uri'] = vault_properties.vault_uri
    vault_hash['tenant_id'] = vault_properties.tenant_id

    unless vault_properties.sku.nil?
      vault_hash['sku_family'] = vault_properties.sku.family
      vault_hash['sku_name'] = vault_properties.sku.name
    end

    vault_hash['access_policies'] = []
    unless vault_properties.access_policies.nil?
      vault_properties.access_policies.each do |access_policy|
        access_policy_entry = Fog::KeyVault::AzureRM::AccessPolicyEntry.new
        vault_hash['access_policies'] << access_policy_entry.merge_attributes(Fog::KeyVault::AzureRM::AccessPolicyEntry.parse(access_policy))
      end
    end

    vault_hash['enabled_for_deployment'] = vault_properties.enabled_for_deployment
    vault_hash['enabled_for_disk_encryption'] = vault_properties.enabled_for_disk_encryption
    vault_hash['enabled_for_template_deployment'] = vault_properties.enabled_for_template_deployment

    vault_hash['resource_group'] = get_resource_group_from_id(vault.id)
  end

  vault_hash
end

Instance Method Details

#destroyObject



57
58
59
# File 'lib/fog/azurerm/models/key_vault/vault.rb', line 57

def destroy
  service.delete_vault(resource_group, name)
end

#saveObject



51
52
53
54
55
# File 'lib/fog/azurerm/models/key_vault/vault.rb', line 51

def save
  requires :name, :resource_group, :location, :tenant_id, :sku_family, :sku_name, :access_policies
  vault = service.create_or_update_vault(vault_hash)
  merge_attributes(Fog::KeyVault::AzureRM::Vault.parse(vault))
end