Class: Fog::Resources::AzureRM::Deployment

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

Overview

This class is giving implementation of create/save and delete/destroy for Deployment model.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(deployment) ⇒ Object


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
50
# File 'lib/fog/azurerm/models/resources/deployment.rb', line 22

def self.parse(deployment)
  hash = {}
  hash['name'] = deployment.name
  hash['id'] = deployment.id
  hash['resource_group'] = get_resource_from_resource_id(deployment.id, RESOURCE_GROUP_NAME)
  hash['correlation_id'] = deployment.properties.correlation_id
  hash['timestamp'] = deployment.properties.timestamp
  hash['outputs'] = deployment.properties.outputs

  hash['providers'] = []
  deployment.properties.providers.each do |provider|
    provider_obj = Fog::Resources::AzureRM::Provider.new
    hash['providers'] << provider_obj.merge_attributes(Fog::Resources::AzureRM::Provider.parse(provider))
  end

  hash['dependencies'] = []
  deployment.properties.dependencies.each do |dependency|
    dependency_obj = Fog::Resources::AzureRM::Dependency.new
    hash['dependencies'] << dependency_obj.merge_attributes(Fog::Resources::AzureRM::Dependency.parse(dependency))
  end

  hash['template_link'] = deployment.properties.template_link.uri
  hash['parameters_link'] = deployment.properties.parameters_link.uri
  hash['content_version'] = deployment.properties.template_link.content_version
  hash['mode'] = deployment.properties.mode
  hash['debug_setting'] = deployment.properties.debug_setting.detail_level unless deployment.properties.debug_setting.nil?
  hash['provisioning_state'] = deployment.properties.provisioning_state
  hash
end

Instance Method Details

#destroyObject


59
60
61
# File 'lib/fog/azurerm/models/resources/deployment.rb', line 59

def destroy
  service.delete_deployment(resource_group, name)
end

#saveObject


52
53
54
55
56
57
# File 'lib/fog/azurerm/models/resources/deployment.rb', line 52

def save
  requires :name, :resource_group, :template_link, :parameters_link

  deployment = service.create_deployment(resource_group, name, template_link, parameters_link)
  merge_attributes(Fog::Resources::AzureRM::Deployment.parse(deployment))
end