Class: Azure::Armrest::TemplateDeploymentService

Inherits:
ResourceGroupBasedService show all
Defined in:
lib/azure/armrest/template_deployment_service.rb

Overview

Base class for managing templates and deployments

Constant Summary

Constants inherited from ResourceGroupBasedService

ResourceGroupBasedService::SERVICE_NAME_MAP

Instance Attribute Summary

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #provider, #service_name

Instance Method Summary collapse

Methods inherited from ResourceGroupBasedService

#create, #delete, #get, #get_associated_resource, #list

Methods inherited from ArmrestService

configure, #get_provider, #get_subscription, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #poll, #tags, #tenants, #wait

Constructor Details

#initialize(configuration, options = {}) ⇒ TemplateDeploymentService

Returns a new instance of TemplateDeploymentService.



6
7
8
# File 'lib/azure/armrest/template_deployment_service.rb', line 6

def initialize(configuration, options = {})
  super(configuration, 'deployments', 'Microsoft.Resources', options)
end

Instance Method Details

#get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group) ⇒ Object

Get the operation of a deployment in a resource group

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
# File 'lib/azure/armrest/template_deployment_service.rb', line 31

def get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group)
  validate_resource_group(resource_group)
  validate_resource(deploy_name)
  raise ArgumentError, "must specify operation id" unless op_id

  url = build_url(resource_group, deploy_name, 'operations', op_id)
  response = rest_get(url)
  TemplateDeploymentOperation.new(response)
end

#get_template(deploy_name, resource_group = configuration.resource_group) ⇒ Object

Returns the json template as an object for the given deployment.

If you want the plain JSON text then call .to_json on the returned object.



45
46
47
48
49
50
51
# File 'lib/azure/armrest/template_deployment_service.rb', line 45

def get_template(deploy_name, resource_group = configuration.resource_group)
  validate_resource_group(resource_group)
  validate_resource(deploy_name)
  url = build_url(resource_group, deploy_name, 'exportTemplate')
  response = JSON.parse(rest_post(url))['template']
  DeploymentTemplate.new(response)
end

#list_allObject

Get all deployments for the current subscription



16
17
18
# File 'lib/azure/armrest/template_deployment_service.rb', line 16

def list_all
  list_in_all_groups
end

#list_deployment_operations(deploy_name, resource_group = configuration.resource_group) ⇒ Object

Get all operations of a deployment in a resource group



21
22
23
24
25
26
27
28
# File 'lib/azure/armrest/template_deployment_service.rb', line 21

def list_deployment_operations(deploy_name, resource_group = configuration.resource_group)
  validate_resource_group(resource_group)
  validate_resource(deploy_name)

  url = build_url(resource_group, deploy_name, 'operations')
  response = rest_get(url)
  JSON.parse(response)['value'].map { |hash| TemplateDeploymentOperation.new(hash) }
end

#list_names(resource_group = configuration.resource_group) ⇒ Object

Get names of all deployments in a resource group



11
12
13
# File 'lib/azure/armrest/template_deployment_service.rb', line 11

def list_names(resource_group = configuration.resource_group)
  list(resource_group).map(&:name)
end