Class: Azure::Armrest::TemplateDeploymentService
- Inherits:
-
ResourceGroupBasedService
- Object
- ArmrestService
- ResourceGroupBasedService
- Azure::Armrest::TemplateDeploymentService
- 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
-
#delete_associated_resources(deploy_name, resource_group = configuration.resource_group) ⇒ Object
Delete a deployment and all associated resources that were generated by the deployment.
-
#exists?(deploy_name, resource_group = configuration.resource_group) ⇒ Boolean
Returns whether or not the given deployment exists.
-
#get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group) ⇒ Object
Get the operation of a deployment in a resource group.
-
#get_template(deploy_name, resource_group = configuration.resource_group) ⇒ Object
Returns the raw json template for the given deployment as a string.
-
#initialize(configuration, options = {}) ⇒ TemplateDeploymentService
constructor
A new instance of TemplateDeploymentService.
-
#list_all(filter = {}) ⇒ Object
Get all deployments for the current subscription.
-
#list_deployment_operations(deploy_name, resource_group = configuration.resource_group) ⇒ Object
Get all operations of a deployment in a resource group.
-
#list_names(resource_group = configuration.resource_group) ⇒ Object
Get names of all deployments in a resource group.
Methods inherited from ResourceGroupBasedService
#create, #delete, #delete_by_id, #get, #get_by_id, #list
Methods inherited from ArmrestService
configure, #get_provider, #get_subscription, #list_locations, #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, = {}) super(configuration, 'deployments', 'Microsoft.Resources', ) end |
Instance Method Details
#delete_associated_resources(deploy_name, resource_group = configuration.resource_group) ⇒ Object
Delete a deployment and all associated resources that were generated by the deployment.
This is a synchronous call. It waits until all deletions complete
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/azure/armrest/template_deployment_service.rb', line 54 def delete_associated_resources(deploy_name, resource_group = configuration.resource_group) operations = list_deployment_operations(deploy_name, resource_group) resource_ids = operations.collect do |op| if op.properties.provisioning_operation =~ /^create$/i op.properties.target_resource.id end end.compact resource_ids << build_id_string(resource_group, deploy_name) delete_resources(resource_ids, resource_ids.size) end |
#exists?(deploy_name, resource_group = configuration.resource_group) ⇒ Boolean
Returns whether or not the given deployment exists.
68 69 70 71 72 73 |
# File 'lib/azure/armrest/template_deployment_service.rb', line 68 def exists?(deploy_name, resource_group = configuration.resource_group) url = build_url(resource_group, deploy_name) rest_head(url) and true rescue Azure::Armrest::NotFoundException false end |
#get_deployment_operation(op_id, deploy_name, resource_group = configuration.resource_group) ⇒ Object
Get the operation of a deployment in a resource group
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 raw json template for the given deployment as a string.
43 44 45 46 47 48 |
# File 'lib/azure/armrest/template_deployment_service.rb', line 43 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') JSON.parse(rest_post(url))['template'].to_json end |
#list_all(filter = {}) ⇒ Object
Get all deployments for the current subscription
16 17 18 |
# File 'lib/azure/armrest/template_deployment_service.rb', line 16 def list_all(filter = {}) list_in_all_groups(filter) 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 |