Class: Fog::Resources::AzureRM::Mock
- Inherits:
-
Object
- Object
- Fog::Resources::AzureRM::Mock
- Defined in:
- lib/fog/azurerm/resources.rb,
lib/fog/azurerm/requests/resources/tag_resource.rb,
lib/fog/azurerm/requests/resources/get_deployment.rb,
lib/fog/azurerm/requests/resources/list_deployments.rb,
lib/fog/azurerm/requests/resources/create_deployment.rb,
lib/fog/azurerm/requests/resources/delete_deployment.rb,
lib/fog/azurerm/requests/resources/get_resource_group.rb,
lib/fog/azurerm/requests/resources/delete_resource_tag.rb,
lib/fog/azurerm/requests/resources/list_resource_groups.rb,
lib/fog/azurerm/requests/resources/create_resource_group.rb,
lib/fog/azurerm/requests/resources/delete_resource_group.rb,
lib/fog/azurerm/requests/resources/list_tagged_resources.rb,
lib/fog/azurerm/requests/resources/check_deployment_exists.rb,
lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb,
lib/fog/azurerm/requests/resources/check_resource_group_exists.rb,
lib/fog/azurerm/requests/resources/list_resources_in_resource_group.rb
Overview
This class provides the mock implementation for unit tests.
Instance Method Summary collapse
- #check_azure_resource_exists ⇒ Object
- #check_deployment_exists ⇒ Object
- #check_resource_group_exists ⇒ Object
- #create_deployment(resource_group, deployment_name, template_link, parameters_link) ⇒ Object
- #create_resource_group(name, location) ⇒ Object
- #delete_deployment(_resource_group, deployment_name) ⇒ Object
- #delete_resource_group(name) ⇒ Object
- #delete_resource_tag(_resource_id, tag_name, _tag_value, _api_version) ⇒ Object
- #get_deployment ⇒ Object
- #get_resource_group ⇒ Object
-
#initialize(_options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_deployments(resource_group) ⇒ Object
- #list_resource_groups ⇒ Object
- #list_resources_in_resource_group ⇒ Object
- #list_tagged_resources(tag_name, tag_value) ⇒ Object
- #tag_resource(_resource_id, tag_name, _tag_value, _api_version) ⇒ Object
Constructor Details
#initialize(_options = {}) ⇒ Mock
Returns a new instance of Mock.
41 42 43 44 45 46 47 48 |
# File 'lib/fog/azurerm/resources.rb', line 41 def initialize( = {}) begin require 'azure_mgmt_resources' rescue LoadError => e retry if require('rubygems') raise e. end end |
Instance Method Details
#check_azure_resource_exists ⇒ Object
34 35 36 |
# File 'lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb', line 34 def check_azure_resource_exists(*) true end |
#check_deployment_exists ⇒ Object
24 25 26 |
# File 'lib/fog/azurerm/requests/resources/check_deployment_exists.rb', line 24 def check_deployment_exists(*) true end |
#check_resource_group_exists ⇒ Object
24 25 26 |
# File 'lib/fog/azurerm/requests/resources/check_resource_group_exists.rb', line 24 def check_resource_group_exists(*) true end |
#create_deployment(resource_group, deployment_name, template_link, parameters_link) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fog/azurerm/requests/resources/create_deployment.rb', line 43 def create_deployment(resource_group, deployment_name, template_link, parameters_link) deployment = { id: "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/microsoft.resources/deployments/#{deployment_name}", name: deployment_name, properties: { templateLink: { uri: template_link, contentVersion: '1.0.0.0' }, parametersLink: { uri: parameters_link, contentVersion: '1.0.0.0' }, parameters: { parameter1: { type: 'string', value: 'parameter1' } }, mode: 'Incremental', provisioningState: 'Accepted', timestamp: '2015-01-01T18:26:20.6229141Z', correlationId: 'd5062e45-6e9f-4fd3-a0a0-6b2c56b15757', outputs: { key1: { type: 'string', value: 'output1' } }, providers: [{ namespace: 'namespace1', resourceTypes: [{ resourceType: 'resourceType1', locations: ['westus'] }] }], dependencies: [{ dependsOn: [{ id: 'resourceid1', resourceType: 'namespace1/resourcetype1', resourceName: 'resourcename1' }], id: 'resourceid2', resourceType: 'namespace1/resourcetype2', resourceName: 'resourcename2' }] } } result_mapper = Azure::ARM::Resources::Models::DeploymentExtended.mapper @rmc.deserialize(result_mapper, deployment, 'result.body') end |
#create_resource_group(name, location) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/azurerm/requests/resources/create_resource_group.rb', line 24 def create_resource_group(name, location) resource_group = { 'location' => location, 'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{name}", 'name' => name, 'properties' => { 'provisioningState' => 'Succeeded' } } result_mapper = Azure::ARM::Resources::Models::ResourceGroup.mapper @rmc.deserialize(result_mapper, resource_group, 'result.body') end |
#delete_deployment(_resource_group, deployment_name) ⇒ Object
21 22 23 24 |
# File 'lib/fog/azurerm/requests/resources/delete_deployment.rb', line 21 def delete_deployment(_resource_group, deployment_name) Fog::Logger.debug "Deployment: #{deployment_name} deleted successfully." true end |
#delete_resource_group(name) ⇒ Object
21 22 23 24 |
# File 'lib/fog/azurerm/requests/resources/delete_resource_group.rb', line 21 def delete_resource_group(name) Fog::Logger.debug "Resource Group #{name} deleted successfully." true end |
#delete_resource_tag(_resource_id, tag_name, _tag_value, _api_version) ⇒ Object
37 38 39 40 |
# File 'lib/fog/azurerm/requests/resources/delete_resource_tag.rb', line 37 def delete_resource_tag(_resource_id, tag_name, _tag_value, _api_version) Fog::Logger.debug "Tag #{tag_name} deleted successfully from Resource your-resource-name" true end |
#get_deployment ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fog/azurerm/requests/resources/get_deployment.rb', line 21 def get_deployment(*) deployments = { id: "/subscriptions/########-####-####-####-############/resourceGroups/fog-test-rg/providers/microsoft.resources/deployments/testdeployment", name: 'testdeployment', properties: { templateLink: { uri: 'https://test.com/template.json', contentVersion: '1.0.0.0' }, parametersLink: { uri: 'https://test.com/parameters.json', contentVersion: '1.0.0.0' }, parameters: { parameter1: { type: 'string', value: 'parameter1' } }, mode: 'Incremental', provisioningState: 'Accepted', timestamp: '2015-01-01T18:26:20.6229141Z', correlationId: 'd5062e45-6e9f-4fd3-a0a0-6b2c56b15757', outputs: { key1: { type: 'string', value: 'output1' } }, providers: [{ namespace: 'namespace1', resourceTypes: [ { resourceType: 'resourceType1', locations: ['westus'] } ] }], dependencies: [ { dependsOn: [ { id: 'resourceid1', resourceType: 'namespace1/resourcetype1', resourceName: 'resourcename1' } ], id: 'resourceid2', resourceType: 'namespace1/resourcetype2', resourceName: 'resourcename2' } ] } } result_mapper = Azure::ARM::Resources::Models::Deployment.mapper @rmc.deserialize(result_mapper, deployments, 'result.body') end |
#get_resource_group ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/azurerm/requests/resources/get_resource_group.rb', line 21 def get_resource_group(*) resource_group = { 'location' => 'westus', 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg', 'name' => 'Fog_test_rg', 'properties' => { 'provisioningState' => 'Succeeded' } }, { 'location' => 'westus', 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg1', 'name' => 'Fog_test_rg1', 'properties' => { 'provisioningState' => 'Succeeded' } } result_mapper = Azure::ARM::Resources::Models::ResourceGroup.mapper @rmc.deserialize(result_mapper, resource_group, 'result.body') end |
#list_deployments(resource_group) ⇒ Object
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fog/azurerm/requests/resources/list_deployments.rb', line 21 def list_deployments(resource_group) deployments = { value: [{ id: "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/microsoft.resources/deployments/testdeployment", name: 'testdeployment', properties: { templateLink: { uri: 'https://test.com/template.json', contentVersion: '1.0.0.0' }, parametersLink: { uri: 'https://test.com/parameters.json', contentVersion: '1.0.0.0' }, parameters: { parameter1: { type: 'string', value: 'parameter1' } }, mode: 'Incremental', provisioningState: 'Accepted', timestamp: '2015-01-01T18:26:20.6229141Z', correlationId: 'd5062e45-6e9f-4fd3-a0a0-6b2c56b15757', outputs: { key1: { type: 'string', value: 'output1' } }, providers: [{ namespace: 'namespace1', resourceTypes: [{ resourceType: 'resourceType1', locations: ['westus'] }] }], dependencies: [{ dependsOn: [{ id: 'resourceid1', resourceType: 'namespace1/resourcetype1', resourceName: 'resourcename1' }], id: 'resourceid2', resourceType: 'namespace1/resourcetype2', resourceName: 'resourcename2' }] } }] } result_mapper = Azure::ARM::Resources::Models::DeploymentListResult.mapper @rmc.deserialize(result_mapper, deployments, 'result.body').value end |
#list_resource_groups ⇒ 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 |
# File 'lib/fog/azurerm/requests/resources/list_resource_groups.rb', line 22 def list_resource_groups resource_groups = { 'value' => [ { 'location' => 'westus', 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg', 'name' => 'Fog_test_rg', 'properties' => { 'provisioningState' => 'Succeeded' } }, { 'location' => 'westus', 'id' => '/subscriptions/########-####-####-####-############/resourceGroups/Fog_test_rg1', 'name' => 'Fog_test_rg1', 'properties' => { 'provisioningState' => 'Succeeded' } } ] } result_mapper = Azure::ARM::Resources::Models::ResourceGroupListResult.mapper @rmc.deserialize(result_mapper, resource_groups, 'result.body').value end |
#list_resources_in_resource_group ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/azurerm/requests/resources/list_resources_in_resource_group.rb', line 21 def list_resources_in_resource_group(*) resources = { 'id' => '/subscriptions/########-####-####-####-############/fog-rg', 'name' => 'your-resource-name', 'type' => 'providernamespace/resourcetype', 'location' => 'westus', 'tags' => { tag_name => tag_value }, 'plan' => { 'name' => 'free' } } result_mapper = Azure::ARM::Resources::Models::GenericResource.mapper @rmc.deserialize(result_mapper, resources, 'result.body').value end |
#list_tagged_resources(tag_name, tag_value) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fog/azurerm/requests/resources/list_tagged_resources.rb', line 25 def list_tagged_resources(tag_name, tag_value) resources = { 'value' => [ { 'id' => '/subscriptions/########-####-####-####-############/fog-rg', 'name' => 'your-resource-name', 'type' => 'providernamespace/resourcetype', 'location' => 'westus', 'tags' => { tag_name => tag_value }, 'plan' => { 'name' => 'free' } } ] } result_mapper = Azure::ARM::Resources::Models::ResourceListResult.mapper @rmc.deserialize(result_mapper, resources, 'result.body').value end |
#tag_resource(_resource_id, tag_name, _tag_value, _api_version) ⇒ Object
36 37 38 39 |
# File 'lib/fog/azurerm/requests/resources/tag_resource.rb', line 36 def tag_resource(_resource_id, tag_name, _tag_value, _api_version) Fog::Logger.debug "Tag #{tag_name} created successfully for Resource 'resource_name'" true end |