Class: Fog::Compute::AzureRM::ManagedDisk

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

Overview

This class is giving implementation of create/save and delete/destroy for Managed Disk.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(managed_disk) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/azurerm/models/compute/managed_disk.rb', line 22

def self.parse(managed_disk)
  disk = get_hash_from_object(managed_disk)

  unless managed_disk.creation_data.nil?
    creation_data = Fog::Compute::AzureRM::CreationData.new
    disk['creation_data'] = creation_data.merge_attributes(Fog::Compute::AzureRM::CreationData.parse(managed_disk.creation_data))
  end

  unless managed_disk.encryption_settings.nil?
    encryption_settings = Fog::Compute::AzureRM::EncryptionSettings.new
    disk['encryption_settings'] = encryption_settings.merge_attributes(Fog::Compute::AzureRM::EncryptionSettings.parse(managed_disk.encryption_settings))
  end

  disk['resource_group_name'] = get_resource_group_from_id(managed_disk.id)

  disk
end

Instance Method Details

#destroy(async = false) ⇒ Object



49
50
51
52
53
# File 'lib/fog/azurerm/models/compute/managed_disk.rb', line 49

def destroy(async = false)
  response = service.delete_managed_disk(resource_group_name, name,
                                         async)
  async ? create_fog_async_response(response) : response
end

#saveObject



40
41
42
43
44
45
46
47
# File 'lib/fog/azurerm/models/compute/managed_disk.rb', line 40

def save
  requires :name, :location, :resource_group_name, :creation_data
  requires :disk_size_gb, :account_type
  validate_creation_data_params(creation_data)

  disk = service.create_or_update_managed_disk(managed_disk_params)
  merge_attributes(Fog::Compute::AzureRM::ManagedDisk.parse(disk))
end