gitlab-fog-azure-rm 1.7.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +12 -0
  3. data/.rubocop_todo.yml +1 -1
  4. data/CHANGELOG.md +4 -0
  5. data/gitlab-fog-azure-rm.gemspec +3 -3
  6. data/lib/fog/azurerm/constants.rb +0 -6
  7. data/lib/fog/azurerm/custom_fog_errors.rb +0 -41
  8. data/lib/fog/azurerm/docs/storage.md +1 -1
  9. data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
  10. data/lib/fog/azurerm/models/storage/directories.rb +6 -6
  11. data/lib/fog/azurerm/models/storage/directory.rb +4 -4
  12. data/lib/fog/azurerm/models/storage/file.rb +6 -3
  13. data/lib/fog/azurerm/models/storage/files.rb +8 -8
  14. data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
  15. data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
  16. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
  17. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
  18. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
  19. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
  20. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
  21. data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
  22. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
  23. data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
  24. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
  25. data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
  26. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
  27. data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
  28. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
  29. data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
  30. data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
  31. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
  32. data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
  33. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
  34. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
  35. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
  36. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
  37. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
  38. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
  39. data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
  40. data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
  41. data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
  42. data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
  43. data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
  44. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
  45. data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
  46. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
  47. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
  48. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
  49. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
  50. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
  51. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
  52. data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
  53. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
  54. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
  55. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
  56. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
  57. data/lib/fog/azurerm/storage.rb +62 -27
  58. data/lib/fog/azurerm/utilities/general.rb +2 -58
  59. data/lib/fog/azurerm/version.rb +1 -1
  60. data/lib/fog/azurerm.rb +4 -11
  61. data/rakefile +4 -5
  62. data/test/api_stub/models/storage/directory.rb +1 -1
  63. data/test/api_stub/models/storage/file.rb +1 -1
  64. data/test/api_stub/requests/storage/directory.rb +1 -1
  65. data/test/api_stub/requests/storage/file.rb +4 -4
  66. data/test/integration/README.md +5 -7
  67. data/test/integration/blob.rb +28 -36
  68. data/test/integration/container.rb +8 -39
  69. data/test/integration/credentials/azure.yml +4 -5
  70. data/test/models/storage/test_directories.rb +5 -5
  71. data/test/models/storage/test_directory.rb +2 -2
  72. data/test/models/storage/test_file.rb +16 -4
  73. data/test/models/storage/test_files.rb +8 -8
  74. data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
  75. data/test/requests/storage/test_acquire_container_lease.rb +2 -2
  76. data/test/requests/storage/test_check_container_exists.rb +1 -1
  77. data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
  78. data/test/requests/storage/test_compare_container_blobs.rb +2 -2
  79. data/test/requests/storage/test_copy_blob.rb +2 -2
  80. data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
  81. data/test/requests/storage/test_create_block_blob.rb +2 -2
  82. data/test/requests/storage/test_create_container.rb +2 -2
  83. data/test/requests/storage/test_create_page_blob.rb +2 -2
  84. data/test/requests/storage/test_delete_blob.rb +2 -2
  85. data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
  86. data/test/requests/storage/test_delete_container.rb +2 -2
  87. data/test/requests/storage/test_delete_object.rb +2 -2
  88. data/test/requests/storage/test_get_blob.rb +2 -2
  89. data/test/requests/storage/test_get_blob_encoding.rb +45 -0
  90. data/test/requests/storage/test_get_blob_http_url.rb +13 -9
  91. data/test/requests/storage/test_get_blob_https_url.rb +95 -13
  92. data/test/requests/storage/test_get_blob_properties.rb +2 -2
  93. data/test/requests/storage/test_get_blob_url.rb +15 -24
  94. data/test/requests/storage/test_get_container_acl.rb +2 -2
  95. data/test/requests/storage/test_get_container_properties.rb +2 -2
  96. data/test/requests/storage/test_get_container_url.rb +5 -8
  97. data/test/requests/storage/test_get_object.rb +2 -2
  98. data/test/requests/storage/test_list_blobs.rb +2 -2
  99. data/test/requests/storage/test_list_containers.rb +2 -2
  100. data/test/requests/storage/test_put_blob_block.rb +2 -2
  101. data/test/requests/storage/test_put_blob_http_url.rb +33 -0
  102. data/test/requests/storage/test_put_blob_https_url.rb +8 -11
  103. data/test/requests/storage/test_put_blob_metadata.rb +2 -2
  104. data/test/requests/storage/test_put_blob_pages.rb +2 -2
  105. data/test/requests/storage/test_put_blob_properties.rb +2 -2
  106. data/test/requests/storage/test_put_container_acl.rb +2 -2
  107. data/test/requests/storage/test_put_container_metadata.rb +2 -2
  108. data/test/requests/storage/test_release_blob_lease.rb +2 -2
  109. data/test/requests/storage/test_release_container_lease.rb +2 -2
  110. data/test/requests/storage/test_save_page_blob.rb +2 -2
  111. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
  112. data/test/test_helper.rb +38 -698
  113. metadata +27 -36
  114. data/lib/fog/azurerm/credentials.rb +0 -44
  115. data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
  116. data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
  117. data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
  118. data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
  119. data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
  120. data/lib/fog/azurerm/models/resources/provider.rb +0 -27
  121. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
  122. data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
  123. data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
  124. data/test/integration/storage_account.rb +0 -135
  125. data/test/smoke_tests/compute/test_resource_group_smoke.rb +0 -37
  126. data/test/test_credentials.rb +0 -63
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-fog-azure-rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaffan Chaudhry
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2023-02-27 00:00:00.000000000 Z
21
+ date: 2024-03-16 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: codeclimate-test-reporter
@@ -90,6 +90,20 @@ dependencies:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
+ - !ruby/object:Gem::Dependency
94
+ name: webrick
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.8'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '1.8'
93
107
  - !ruby/object:Gem::Dependency
94
108
  name: azure-storage-blob
95
109
  requirement: !ruby/object:Gem::Requirement
@@ -122,30 +136,30 @@ dependencies:
122
136
  name: fog-core
123
137
  requirement: !ruby/object:Gem::Requirement
124
138
  requirements:
125
- - - '='
139
+ - - "~>"
126
140
  - !ruby/object:Gem::Version
127
- version: 2.1.0
141
+ version: '2.1'
128
142
  type: :runtime
129
143
  prerelease: false
130
144
  version_requirements: !ruby/object:Gem::Requirement
131
145
  requirements:
132
- - - '='
146
+ - - "~>"
133
147
  - !ruby/object:Gem::Version
134
- version: 2.1.0
148
+ version: '2.1'
135
149
  - !ruby/object:Gem::Dependency
136
150
  name: fog-json
137
151
  requirement: !ruby/object:Gem::Requirement
138
152
  requirements:
139
153
  - - "~>"
140
154
  - !ruby/object:Gem::Version
141
- version: 1.2.0
155
+ version: '1.2'
142
156
  type: :runtime
143
157
  prerelease: false
144
158
  version_requirements: !ruby/object:Gem::Requirement
145
159
  requirements:
146
160
  - - "~>"
147
161
  - !ruby/object:Gem::Version
148
- version: 1.2.0
162
+ version: '1.2'
149
163
  - !ruby/object:Gem::Dependency
150
164
  name: mime-types
151
165
  requirement: !ruby/object:Gem::Requirement
@@ -160,20 +174,6 @@ dependencies:
160
174
  - - ">="
161
175
  - !ruby/object:Gem::Version
162
176
  version: '0'
163
- - !ruby/object:Gem::Dependency
164
- name: ms_rest_azure
165
- requirement: !ruby/object:Gem::Requirement
166
- requirements:
167
- - - "~>"
168
- - !ruby/object:Gem::Version
169
- version: 0.12.0
170
- type: :runtime
171
- prerelease: false
172
- version_requirements: !ruby/object:Gem::Requirement
173
- requirements:
174
- - - "~>"
175
- - !ruby/object:Gem::Version
176
- version: 0.12.0
177
177
  description: This is a stripped-down fork of fog-azure-rm that enables Azure Blob
178
178
  Storage to be used with CarrierWave and Fog.
179
179
  email:
@@ -201,19 +201,10 @@ files:
201
201
  - lib/fog/azurerm/async_response.rb
202
202
  - lib/fog/azurerm/config.rb
203
203
  - lib/fog/azurerm/constants.rb
204
- - lib/fog/azurerm/credentials.rb
205
204
  - lib/fog/azurerm/custom_fog_errors.rb
206
205
  - lib/fog/azurerm/docs/storage.md
207
206
  - lib/fog/azurerm/docs/structure.md
208
- - lib/fog/azurerm/models/resources/azure_resource.rb
209
- - lib/fog/azurerm/models/resources/azure_resources.rb
210
- - lib/fog/azurerm/models/resources/dependency.rb
211
- - lib/fog/azurerm/models/resources/deployment.rb
212
- - lib/fog/azurerm/models/resources/deployments.rb
213
- - lib/fog/azurerm/models/resources/provider.rb
214
- - lib/fog/azurerm/models/resources/provider_resource_type.rb
215
- - lib/fog/azurerm/models/resources/resource_group.rb
216
- - lib/fog/azurerm/models/resources/resource_groups.rb
207
+ - lib/fog/azurerm/identity_encoding_filter.rb
217
208
  - lib/fog/azurerm/models/storage/directories.rb
218
209
  - lib/fog/azurerm/models/storage/directory.rb
219
210
  - lib/fog/azurerm/models/storage/file.rb
@@ -252,6 +243,7 @@ files:
252
243
  - lib/fog/azurerm/requests/storage/list_blobs.rb
253
244
  - lib/fog/azurerm/requests/storage/list_containers.rb
254
245
  - lib/fog/azurerm/requests/storage/put_blob_block.rb
246
+ - lib/fog/azurerm/requests/storage/put_blob_http_url.rb
255
247
  - lib/fog/azurerm/requests/storage/put_blob_https_url.rb
256
248
  - lib/fog/azurerm/requests/storage/put_blob_metadata.rb
257
249
  - lib/fog/azurerm/requests/storage/put_blob_pages.rb
@@ -278,7 +270,6 @@ files:
278
270
  - test/integration/blob.rb
279
271
  - test/integration/container.rb
280
272
  - test/integration/credentials/azure.yml
281
- - test/integration/storage_account.rb
282
273
  - test/models/storage/test_directories.rb
283
274
  - test/models/storage/test_directory.rb
284
275
  - test/models/storage/test_file.rb
@@ -298,6 +289,7 @@ files:
298
289
  - test/requests/storage/test_delete_container.rb
299
290
  - test/requests/storage/test_delete_object.rb
300
291
  - test/requests/storage/test_get_blob.rb
292
+ - test/requests/storage/test_get_blob_encoding.rb
301
293
  - test/requests/storage/test_get_blob_http_url.rb
302
294
  - test/requests/storage/test_get_blob_https_url.rb
303
295
  - test/requests/storage/test_get_blob_properties.rb
@@ -309,6 +301,7 @@ files:
309
301
  - test/requests/storage/test_list_blobs.rb
310
302
  - test/requests/storage/test_list_containers.rb
311
303
  - test/requests/storage/test_put_blob_block.rb
304
+ - test/requests/storage/test_put_blob_http_url.rb
312
305
  - test/requests/storage/test_put_blob_https_url.rb
313
306
  - test/requests/storage/test_put_blob_metadata.rb
314
307
  - test/requests/storage/test_put_blob_pages.rb
@@ -319,8 +312,6 @@ files:
319
312
  - test/requests/storage/test_release_container_lease.rb
320
313
  - test/requests/storage/test_save_page_blob.rb
321
314
  - test/requests/storage/test_wait_blob_copy_operation_to_finish.rb
322
- - test/smoke_tests/compute/test_resource_group_smoke.rb
323
- - test/test_credentials.rb
324
315
  - test/test_helper.rb
325
316
  homepage: https://gitlab.com/gitlab-org/gitlab-fog-azure-rm
326
317
  licenses:
@@ -342,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
333
  - !ruby/object:Gem::Version
343
334
  version: '0'
344
335
  requirements: []
345
- rubygems_version: 3.4.7
336
+ rubygems_version: 3.3.26
346
337
  signing_key:
347
338
  specification_version: 4
348
339
  summary: Module for the 'fog' gem to support Azure Blob Storage with CarrierWave and
@@ -1,44 +0,0 @@
1
- module Fog
2
- module Credentials
3
- # This class is managing credentials token
4
- class AzureRM
5
- class << self
6
- include Fog::AzureRM::Utilities::General
7
- end
8
-
9
- def self.get_credentials(tenant_id, client_id, client_secret, environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
10
- if @credentials.nil? || new_management_credential?(tenant_id, client_id, client_secret, environment)
11
- get_new_credentials(tenant_id, client_id, client_secret, environment)
12
- else
13
- @credentials
14
- end
15
- end
16
-
17
- def self.get_token(tenant_id, client_id, client_secret, environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
18
- get_credentials(tenant_id, client_id, client_secret, environment) if @credentials.nil?
19
- @token_provider.get_authentication_header
20
- end
21
-
22
- def self.get_new_credentials(tenant_id, client_id, client_secret, environment)
23
- @tenant_id = tenant_id
24
- @client_id = client_id
25
- @client_secret = client_secret
26
- @environment = environment
27
- return if @tenant_id.nil? || @client_id.nil? || @client_secret.nil?
28
- @token_provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret, active_directory_service_settings(environment))
29
- @credentials = MsRest::TokenCredentials.new(@token_provider)
30
- @credentials
31
- end
32
-
33
- def self.new_management_credential?(tenant_id, client_id, client_secret, environment)
34
- @tenant_id != tenant_id ||
35
- @client_id != client_id ||
36
- @client_secret != client_secret ||
37
- @environment != environment
38
- end
39
-
40
- private_class_method :get_new_credentials
41
- private_class_method :new_management_credential?
42
- end
43
- end
44
- end
@@ -1,25 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # This class is giving implementation of create/save and
5
- # delete/destroy for resources.
6
- class AzureResource < Fog::Model
7
- attribute :id
8
- attribute :name
9
- attribute :type
10
- attribute :location
11
- attribute :tags
12
-
13
- def self.parse(resource)
14
- hash = {}
15
- hash['id'] = resource.id
16
- hash['name'] = resource.name
17
- hash['type'] = resource.type
18
- hash['location'] = resource.location
19
- hash['tags'] = resource.tags
20
- hash
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,40 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # This class is giving implementation of all/list and get.
5
- class AzureResources < Fog::Collection
6
- attribute :tag_name
7
- attribute :tag_value
8
- model Fog::Resources::AzureRM::AzureResource
9
-
10
- def all
11
- unless tag_name.nil? && tag_value.nil?
12
- resources = []
13
- service.list_tagged_resources(tag_name, tag_value).each do |resource|
14
- resources << Fog::Resources::AzureRM::AzureResource.parse(resource)
15
- end
16
- resources.inspect
17
- return load(resources)
18
- end
19
- nil
20
- end
21
-
22
- def get(resource_id)
23
- all.find { |f| f.id == resource_id }
24
- end
25
-
26
- def check_azure_resource_exists(resource_id, api_version)
27
- service.check_azure_resource_exists(resource_id, api_version)
28
- end
29
-
30
- def list_resources_in_resource_group(resource_group_name)
31
- resources = []
32
- service.list_resources_in_resource_group(resource_group_name).each do |resource|
33
- resources.push(Fog::Resources::AzureRM::AzureResource.parse(resource))
34
- end
35
- load(resources)
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,27 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # Dependency model class
5
- class Dependency < Fog::Model
6
- attribute :id
7
- attribute :resource_name
8
- attribute :resource_type
9
- attribute :depends_on
10
-
11
- def self.parse(dependency)
12
- hash = {}
13
- hash['id'] = dependency.id
14
- hash['resource_name'] = dependency.resource_name
15
- hash['resource_type'] = dependency.resource_type
16
-
17
- hash['depends_on'] = []
18
- dependency.depends_on.each do |sub_dependency|
19
- dependency_obj = Fog::Resources::AzureRM::Dependency.new
20
- hash['depends_on'] << dependency_obj.merge_attributes(Fog::Resources::AzureRM::Dependency.parse(sub_dependency))
21
- end if dependency.respond_to?('depends_on')
22
- hash
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,65 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # This class is giving implementation of create/save and
5
- # delete/destroy for Deployment model.
6
- class Deployment < Fog::Model
7
- identity :name
8
- attribute :id
9
- attribute :resource_group
10
- attribute :correlation_id
11
- attribute :timestamp
12
- attribute :outputs
13
- attribute :providers
14
- attribute :dependencies
15
- attribute :template_link
16
- attribute :parameters_link
17
- attribute :mode
18
- attribute :debug_setting
19
- attribute :content_version
20
- attribute :provisioning_state
21
-
22
- def self.parse(deployment)
23
- hash = {}
24
- hash['name'] = deployment.name
25
- hash['id'] = deployment.id
26
- hash['resource_group'] = get_resource_from_resource_id(deployment.id, RESOURCE_GROUP_NAME)
27
- hash['correlation_id'] = deployment.properties.correlation_id
28
- hash['timestamp'] = deployment.properties.timestamp
29
- hash['outputs'] = deployment.properties.outputs
30
-
31
- hash['providers'] = []
32
- deployment.properties.providers.each do |provider|
33
- provider_obj = Fog::Resources::AzureRM::Provider.new
34
- hash['providers'] << provider_obj.merge_attributes(Fog::Resources::AzureRM::Provider.parse(provider))
35
- end
36
-
37
- hash['dependencies'] = []
38
- deployment.properties.dependencies.each do |dependency|
39
- dependency_obj = Fog::Resources::AzureRM::Dependency.new
40
- hash['dependencies'] << dependency_obj.merge_attributes(Fog::Resources::AzureRM::Dependency.parse(dependency))
41
- end
42
-
43
- hash['template_link'] = deployment.properties.template_link.uri
44
- hash['parameters_link'] = deployment.properties.parameters_link.uri
45
- hash['content_version'] = deployment.properties.template_link.content_version
46
- hash['mode'] = deployment.properties.mode
47
- hash['debug_setting'] = deployment.properties.debug_setting.detail_level unless deployment.properties.debug_setting.nil?
48
- hash['provisioning_state'] = deployment.properties.provisioning_state
49
- hash
50
- end
51
-
52
- def save
53
- requires :name, :resource_group, :template_link, :parameters_link
54
-
55
- deployment = service.create_deployment(resource_group, name, template_link, parameters_link)
56
- merge_attributes(Fog::Resources::AzureRM::Deployment.parse(deployment))
57
- end
58
-
59
- def destroy
60
- service.delete_deployment(resource_group, name)
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,30 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # Deployments collection class
5
- class Deployments < Fog::Collection
6
- attribute :resource_group
7
- model Fog::Resources::AzureRM::Deployment
8
-
9
- def all
10
- requires :resource_group
11
- deployments = []
12
- service.list_deployments(resource_group).each do |deployment|
13
- deployments << Fog::Resources::AzureRM::Deployment.parse(deployment)
14
- end
15
- load(deployments)
16
- end
17
-
18
- def get(resource_group_name, deployment_name)
19
- deployment = service.get_deployment(resource_group_name, deployment_name)
20
- deployment_fog = Fog::Resources::AzureRM::Deployment.new(service: service)
21
- deployment_fog.merge_attributes(Fog::Resources::AzureRM::Deployment.parse(deployment))
22
- end
23
-
24
- def check_deployment_exists(resource_group_name, deployment_name)
25
- service.check_deployment_exists(resource_group_name, deployment_name)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,27 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # Provider model class
5
- class Provider < Fog::Model
6
- attribute :id
7
- attribute :namespace
8
- attribute :registration_state
9
- attribute :resource_types
10
-
11
- def self.parse(provider)
12
- hash = {}
13
- hash['id'] = provider.id
14
- hash['namespace'] = provider.namespace
15
- hash['registration_state'] = provider.registration_state if provider.respond_to?('registration_state')
16
-
17
- hash['resource_types'] = []
18
- provider.resource_types.each do |provider_resource_type|
19
- provider_resource_type_obj = Fog::Resources::AzureRM::ProviderResourceType.new
20
- hash['resource_types'] << provider_resource_type_obj.merge_attributes(Fog::Resources::AzureRM::ProviderResourceType.parse(provider_resource_type))
21
- end
22
- hash
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,22 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # ProviderResourceType model class
5
- class ProviderResourceType < Fog::Model
6
- attribute :resource_type
7
- attribute :locations
8
- attribute :api_versions
9
- attribute :properties
10
-
11
- def self.parse(provider_resource_type)
12
- hash = {}
13
- hash['resource_type'] = provider_resource_type.resource_type
14
- hash['locations'] = provider_resource_type.locations
15
- hash['api_versions'] = provider_resource_type.api_versions if provider_resource_type.respond_to?('api_versions')
16
- hash['properties'] = provider_resource_type.properties if provider_resource_type.respond_to?('properties')
17
- hash
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,34 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # This class is giving implementation of create/save and
5
- # delete/destroy for resource group.
6
- class ResourceGroup < Fog::Model
7
- identity :name
8
- attribute :id
9
- attribute :location
10
- attribute :tags
11
-
12
- def self.parse(resource_group)
13
- hash = {}
14
- hash['id'] = resource_group.id
15
- hash['name'] = resource_group.name
16
- hash['location'] = resource_group.location
17
- hash['tags'] = resource_group.tags
18
- hash
19
- end
20
-
21
- def save
22
- requires :name
23
- requires :location
24
- resource_group = service.create_resource_group(name, location, tags)
25
- merge_attributes(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
26
- end
27
-
28
- def destroy
29
- service.delete_resource_group(name)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,29 +0,0 @@
1
- module Fog
2
- module Resources
3
- class AzureRM
4
- # This class is giving implementation of all/list, get and
5
- # check name availability for resource groups.
6
- class ResourceGroups < Fog::Collection
7
- model Fog::Resources::AzureRM::ResourceGroup
8
-
9
- def all
10
- resource_groups = []
11
- service.list_resource_groups.each do |resource_group|
12
- resource_groups.push(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
13
- end
14
- load(resource_groups)
15
- end
16
-
17
- def get(resource_group_name)
18
- resource_group = service.get_resource_group(resource_group_name)
19
- resource_group_fog = Fog::Resources::AzureRM::ResourceGroup.new(service: service)
20
- resource_group_fog.merge_attributes(Fog::Resources::AzureRM::ResourceGroup.parse(resource_group))
21
- end
22
-
23
- def check_resource_group_exists(resource_group_name)
24
- service.check_resource_group_exists(resource_group_name)
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,135 +0,0 @@
1
- require 'fog/azurerm'
2
- require 'yaml'
3
-
4
- ########################################################################################################################
5
- ###################### Services object required by all actions ######################
6
- ###################### Keep it Uncommented! ######################
7
- ########################################################################################################################
8
-
9
- azure_credentials = YAML.load_file(File.expand_path('credentials/azure.yml', __dir__))
10
-
11
- rs = Fog::Resources::AzureRM.new(
12
- tenant_id: azure_credentials['tenant_id'],
13
- client_id: azure_credentials['client_id'],
14
- client_secret: azure_credentials['client_secret'],
15
- subscription_id: azure_credentials['subscription_id']
16
- )
17
-
18
- storage = Fog::Storage::AzureRM.new(
19
- tenant_id: azure_credentials['tenant_id'],
20
- client_id: azure_credentials['client_id'],
21
- client_secret: azure_credentials['client_secret'],
22
- subscription_id: azure_credentials['subscription_id'],
23
- environment: azure_credentials['environment']
24
- )
25
-
26
- ########################################################################################################################
27
- ###################### Resource names #####################
28
- ########################################################################################################################
29
-
30
- time = current_time
31
- resource_group_name = "TestRG-SA-#{time}"
32
- storage_account_name = "teststorage#{time}"
33
- lrs_storage_account = "lrs#{time}"
34
- grs_storage_account = "grs#{time}"
35
- premium_storage_acc = "premsa#{time}"
36
-
37
- ########################################################################################################################
38
- ###################### Prerequisites ######################
39
- ########################################################################################################################
40
-
41
- begin
42
- resource_group = rs.resource_groups.create(
43
- name: resource_group_name,
44
- location: LOCATION
45
- )
46
-
47
- ########################################################################################################################
48
- ###################### Check Storage Account name Availability ######################
49
- ########################################################################################################################
50
-
51
- storage_account_avail = storage.storage_accounts.check_name_availability(storage_account_name)
52
- puts storage_account_avail ? 'Storage Account name available' : 'Storage Account name unavailable'
53
-
54
- ########################################################################################################################
55
- ###################### Check Subnet Exists? ######################
56
- ########################################################################################################################
57
-
58
- flag = storage.storage_accounts.check_storage_account_exists(resource_group_name, lrs_storage_account)
59
- puts "Storage Account doesn't exist." unless flag
60
-
61
- ########################################################################################################################
62
- ############### Create A Standard Storage Account of Replication: LRS (Locally-redundant storage) ###############
63
- ########################################################################################################################
64
-
65
- tags = { key1: 'value1', key2: 'value2' }
66
-
67
- storage_account = storage.storage_accounts.create(
68
- name: lrs_storage_account,
69
- location: LOCATION,
70
- resource_group: resource_group_name,
71
- tags: tags
72
- )
73
- puts "Created storage account for standard lrs replication: #{storage_account.name}"
74
-
75
- ########################################################################################################################
76
- ############### Create A Standard Storage Account of Replication: GRS (Geo-redundant storage) #################
77
- ########################################################################################################################
78
-
79
- storage_account = storage.storage_accounts.create(
80
- name: grs_storage_account,
81
- location: LOCATION,
82
- resource_group: resource_group_name,
83
- sku_name: Fog::ARM::Storage::Models::SkuTier::Standard,
84
- replication: 'GRS',
85
- encryption: true,
86
- tags: tags
87
- )
88
- puts "Created storage account for standard grs replication: #{storage_account.name}"
89
-
90
- ########################################################################################################################
91
- ########### Create A Premium(SSD) Storage Account of its only Replication: LRS (Locally-redundant storage) ##########
92
- ########################################################################################################################
93
-
94
- storage_account = storage.storage_accounts.create(
95
- name: premium_storage_acc,
96
- location: LOCATION,
97
- resource_group: resource_group_name,
98
- sku_name: Fog::ARM::Storage::Models::SkuTier::Premium,
99
- replication: 'LRS',
100
- tags: tags
101
- )
102
- puts "Created storage account for premium lrs replication: #{storage_account.name}"
103
-
104
- ########################################################################################################################
105
- ###################### Get and Update Storage Account ######################
106
- ########################################################################################################################
107
-
108
- premium_storage_account = storage.storage_accounts.get(resource_group_name, premium_storage_acc)
109
- puts "Get storage account: #{premium_storage_account.name}"
110
- premium_storage_account.update(encryption: true)
111
- puts 'Updated encryption of storage account'
112
-
113
- ########################################################################################################################
114
- ###################### Get and Delete Storage Account ######################
115
- ########################################################################################################################
116
-
117
- standard_storage_account = storage.storage_accounts.get(resource_group_name, lrs_storage_account)
118
- puts "Deleted storage account for standard lrs replication: #{standard_storage_account.destroy}"
119
- standard_storage_account = storage.storage_accounts.get(resource_group_name, grs_storage_account)
120
- puts "Deleted storage account for standard grs replication: #{standard_storage_account.destroy}"
121
- premium_storage_account = storage.storage_accounts.get(resource_group_name, premium_storage_acc)
122
- puts "Deleted storage account for premium lrs replication: #{premium_storage_account.destroy}"
123
-
124
- ########################################################################################################################
125
- ###################### CleanUp ######################
126
- ########################################################################################################################
127
-
128
- resource_group = rs.resource_groups.get(resource_group_name)
129
- resource_group.destroy
130
-
131
- puts 'Integration test for storage account ran successfully!'
132
- rescue
133
- puts 'Integration Test for storage account is failing'
134
- resource_group.destroy unless resource_group.nil?
135
- end