gitlab-fog-azure-rm 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/.arclint +8 -0
  3. data/.codeclimate.yml +17 -0
  4. data/.gitignore +6 -0
  5. data/.gitlab-ci.yml +17 -0
  6. data/.hound.yml +2 -0
  7. data/.rubocop.yml +5 -0
  8. data/.rubocop_todo.yml +274 -0
  9. data/.travis.yml +49 -0
  10. data/CHANGELOG.md +414 -0
  11. data/CONTRIBUTING.md +40 -0
  12. data/CONTRIBUTORS.md +12 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE.md +20 -0
  15. data/README.md +100 -0
  16. data/gitlab-fog-azure-rm.gemspec +31 -0
  17. data/lib/fog/azurerm.rb +30 -0
  18. data/lib/fog/azurerm/async_response.rb +44 -0
  19. data/lib/fog/azurerm/config.rb +1 -0
  20. data/lib/fog/azurerm/constants.rb +72 -0
  21. data/lib/fog/azurerm/credentials.rb +40 -0
  22. data/lib/fog/azurerm/custom_fog_errors.rb +52 -0
  23. data/lib/fog/azurerm/docs/storage.md +398 -0
  24. data/lib/fog/azurerm/docs/structure.md +53 -0
  25. data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
  26. data/lib/fog/azurerm/models/resources/azure_resources.rb +40 -0
  27. data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
  28. data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
  29. data/lib/fog/azurerm/models/resources/deployments.rb +30 -0
  30. data/lib/fog/azurerm/models/resources/provider.rb +27 -0
  31. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
  32. data/lib/fog/azurerm/models/resources/resource_group.rb +34 -0
  33. data/lib/fog/azurerm/models/resources/resource_groups.rb +29 -0
  34. data/lib/fog/azurerm/models/storage/directories.rb +75 -0
  35. data/lib/fog/azurerm/models/storage/directory.rb +151 -0
  36. data/lib/fog/azurerm/models/storage/file.rb +265 -0
  37. data/lib/fog/azurerm/models/storage/files.rb +183 -0
  38. data/lib/fog/azurerm/models/storage/kind.rb +12 -0
  39. data/lib/fog/azurerm/models/storage/sku_name.rb +15 -0
  40. data/lib/fog/azurerm/models/storage/sku_tier.rb +12 -0
  41. data/lib/fog/azurerm/models/storage/storage_account.rb +92 -0
  42. data/lib/fog/azurerm/models/storage/storage_accounts.rb +47 -0
  43. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +32 -0
  44. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +32 -0
  45. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +30 -0
  46. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
  47. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
  48. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  49. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  50. data/lib/fog/azurerm/requests/storage/copy_object.rb +20 -0
  51. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
  52. data/lib/fog/azurerm/requests/storage/create_container.rb +40 -0
  53. data/lib/fog/azurerm/requests/storage/create_disk.rb +62 -0
  54. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
  55. data/lib/fog/azurerm/requests/storage/delete_blob.rb +32 -0
  56. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +39 -0
  57. data/lib/fog/azurerm/requests/storage/delete_container.rb +31 -0
  58. data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
  59. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +30 -0
  60. data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
  61. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
  62. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
  63. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +55 -0
  64. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
  65. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
  66. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +41 -0
  67. data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
  68. data/lib/fog/azurerm/requests/storage/get_object_url.rb +21 -0
  69. data/lib/fog/azurerm/requests/storage/list_blobs.rb +168 -0
  70. data/lib/fog/azurerm/requests/storage/list_containers.rb +73 -0
  71. data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
  72. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
  73. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +39 -0
  74. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +31 -0
  75. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
  76. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
  77. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
  78. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +31 -0
  79. data/lib/fog/azurerm/requests/storage/put_object_url.rb +30 -0
  80. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +30 -0
  81. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +30 -0
  82. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
  83. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
  84. data/lib/fog/azurerm/storage.rb +126 -0
  85. data/lib/fog/azurerm/utilities/general.rb +186 -0
  86. data/lib/fog/azurerm/utilities/logger_messages.yml +19 -0
  87. data/lib/fog/azurerm/version.rb +5 -0
  88. data/rake-script.sh +10 -0
  89. data/rakefile +29 -0
  90. data/test/api_stub.rb +147 -0
  91. data/test/api_stub/models/storage/directory.rb +178 -0
  92. data/test/api_stub/models/storage/file.rb +181 -0
  93. data/test/api_stub/requests/storage/directory.rb +89 -0
  94. data/test/api_stub/requests/storage/file.rb +252 -0
  95. data/test/integration/README.md +14 -0
  96. data/test/integration/blob.rb +297 -0
  97. data/test/integration/container.rb +160 -0
  98. data/test/integration/credentials/azure.yml +5 -0
  99. data/test/integration/storage_account.rb +135 -0
  100. data/test/models/storage/test_directories.rb +74 -0
  101. data/test/models/storage/test_directory.rb +178 -0
  102. data/test/models/storage/test_file.rb +294 -0
  103. data/test/models/storage/test_files.rb +234 -0
  104. data/test/requests/storage/test_acquire_blob_lease.rb +36 -0
  105. data/test/requests/storage/test_acquire_container_lease.rb +36 -0
  106. data/test/requests/storage/test_check_container_exists.rb +18 -0
  107. data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
  108. data/test/requests/storage/test_compare_container_blobs.rb +36 -0
  109. data/test/requests/storage/test_copy_blob.rb +39 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +36 -0
  111. data/test/requests/storage/test_create_block_blob.rb +80 -0
  112. data/test/requests/storage/test_create_container.rb +36 -0
  113. data/test/requests/storage/test_create_disk.rb +70 -0
  114. data/test/requests/storage/test_create_page_blob.rb +34 -0
  115. data/test/requests/storage/test_delete_blob.rb +42 -0
  116. data/test/requests/storage/test_delete_blob_https_url.rb +32 -0
  117. data/test/requests/storage/test_delete_container.rb +42 -0
  118. data/test/requests/storage/test_delete_disk.rb +30 -0
  119. data/test/requests/storage/test_get_blob.rb +141 -0
  120. data/test/requests/storage/test_get_blob_http_url.rb +30 -0
  121. data/test/requests/storage/test_get_blob_https_url.rb +32 -0
  122. data/test/requests/storage/test_get_blob_properties.rb +47 -0
  123. data/test/requests/storage/test_get_blob_url.rb +75 -0
  124. data/test/requests/storage/test_get_container_acl.rb +37 -0
  125. data/test/requests/storage/test_get_container_properties.rb +45 -0
  126. data/test/requests/storage/test_get_container_url.rb +33 -0
  127. data/test/requests/storage/test_list_blobs.rb +77 -0
  128. data/test/requests/storage/test_list_containers.rb +54 -0
  129. data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
  130. data/test/requests/storage/test_put_blob_block.rb +34 -0
  131. data/test/requests/storage/test_put_blob_https_url.rb +32 -0
  132. data/test/requests/storage/test_put_blob_metadata.rb +36 -0
  133. data/test/requests/storage/test_put_blob_pages.rb +34 -0
  134. data/test/requests/storage/test_put_blob_properties.rb +39 -0
  135. data/test/requests/storage/test_put_container_acl.rb +34 -0
  136. data/test/requests/storage/test_put_container_metadata.rb +36 -0
  137. data/test/requests/storage/test_release_blob_lease.rb +34 -0
  138. data/test/requests/storage/test_release_container_lease.rb +34 -0
  139. data/test/requests/storage/test_save_page_blob.rb +115 -0
  140. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
  141. data/test/smoke_tests/compute/test_resource_group_smoke.rb +37 -0
  142. data/test/test_credentials.rb +63 -0
  143. data/test/test_helper.rb +846 -0
  144. metadata +352 -0
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def copy_blob(destination_container, destination_blob, source_container, source_blob, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "Copying blob: #{source_blob} from container #{source_container} to container #{destination_container} options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ copy_id, copy_status = @blob_client.copy_blob(destination_container, destination_blob, source_container, source_blob, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ raise_azure_exception(ex, msg)
15
+ end
16
+
17
+ Fog::Logger.debug "Copying blob: x-ms-copy-id: #{copy_id}, x-ms-copy-status: #{copy_status}"
18
+ [copy_id, copy_status]
19
+ end
20
+ end
21
+
22
+ # This class provides the mock implementation for unit tests.
23
+ class Mock
24
+ def copy_blob(*)
25
+ %w(abc123 pending)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "Copying blob: #{source_blob_uri} to container #{destination_container} options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ copy_id, copy_status = @blob_client.copy_blob_from_uri(destination_container, destination_blob, source_blob_uri, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ raise_azure_exception(ex, msg)
15
+ end
16
+
17
+ Fog::Logger.debug "Copying blob: x-ms-copy-id: #{copy_id}, x-ms-copy-status: #{copy_status}"
18
+ [copy_id, copy_status]
19
+ end
20
+ end
21
+
22
+ # This class provides the mock implementation for unit tests.
23
+ class Mock
24
+ def copy_blob_from_uri(*)
25
+ %w(abc123 pending)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ # This is to make this library compatible with CarrierWave.
6
+ class Real
7
+ def copy_object(source_container, source_blob, target_container, target_blob, options = {})
8
+ copy_blob(target_container, target_blob, source_container, source_blob, options)
9
+ end
10
+ end
11
+
12
+ # This class provides the mock implementation for unit tests.
13
+ class Mock
14
+ def copy_object(*args)
15
+ copy_blob(*args)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,108 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def create_block_blob(container_name, blob_name, body, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "create_block_blob #{blob_name} to the container #{container_name}. options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ if body.nil?
13
+ data = nil
14
+ elsif body.respond_to?(:read)
15
+ if body.respond_to?(:rewind)
16
+ begin
17
+ body.rewind
18
+ rescue
19
+ nil
20
+ end
21
+ end
22
+ data = body.read
23
+ else
24
+ data = Fog::Storage.parse_data(body)
25
+ options[:content_length] = data[:headers]['Content-Length']
26
+ options[:content_type] = data[:headers]['Content-Type']
27
+ data = data[:body]
28
+ end
29
+
30
+ raise ArgumentError.new('The maximum size for a block blob created via create_block_blob is 64 MB.') if !data.nil? && Fog::Storage.get_body_size(data) > 64 * 1024 * 1024
31
+ blob = @blob_client.create_block_blob(container_name, blob_name, data, options)
32
+ rescue Azure::Core::Http::HTTPError => ex
33
+ raise_azure_exception(ex, msg)
34
+ end
35
+
36
+ if data.nil?
37
+ Fog::Logger.debug "Create a block blob #{blob_name} successfully."
38
+ else
39
+ Fog::Logger.debug "Upload a block blob #{blob_name} successfully."
40
+ end
41
+ blob
42
+ end
43
+ end
44
+
45
+ # This class provides the mock implementation for unit tests.
46
+ class Mock
47
+ def create_block_blob(_container_name, _blob_name, body, _options = {})
48
+ Fog::Logger.debug 'Blob created successfully.'
49
+ if body.nil?
50
+ {
51
+ 'name' => 'test_blob',
52
+ 'metadata' => {},
53
+ 'properties' => {
54
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
55
+ 'etag' => '0x8D3A3B5F017F52D',
56
+ 'lease_status' => nil,
57
+ 'lease_state' => nil,
58
+ 'content_length' => 0,
59
+ 'content_type' => 'application/octet-stream',
60
+ 'content_encoding' => nil,
61
+ 'content_language' => nil,
62
+ 'content_disposition' => nil,
63
+ 'content_md5' => nil,
64
+ 'cache_control' => nil,
65
+ 'sequence_number' => 0,
66
+ 'blob_type' => 'BlockBlob',
67
+ 'copy_id' => nil,
68
+ 'copy_status' => nil,
69
+ 'copy_source' => nil,
70
+ 'copy_progress' => nil,
71
+ 'copy_completion_time' => nil,
72
+ 'copy_status_description' => nil,
73
+ 'accept_ranges' => 0
74
+ }
75
+ }
76
+ else
77
+ {
78
+ 'name' => 'test_blob',
79
+ 'metadata' => {},
80
+ 'properties' => {
81
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
82
+ 'etag' => '0x8D3A3B5F017F52D',
83
+ 'lease_status' => 'unlocked',
84
+ 'lease_state' => 'available',
85
+ 'content_length' => 4_194_304,
86
+ 'content_type' => 'application/octet-stream',
87
+ 'content_encoding' => nil,
88
+ 'content_language' => nil,
89
+ 'content_disposition' => nil,
90
+ 'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
91
+ 'cache_control' => nil,
92
+ 'sequence_number' => 0,
93
+ 'blob_type' => 'BlockBlob',
94
+ 'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
95
+ 'copy_status' => 'success',
96
+ 'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3256874Z',
97
+ 'copy_progress' => '4194304/4194304',
98
+ 'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
99
+ 'copy_status_description' => nil,
100
+ 'accept_ranges' => 0
101
+ }
102
+ }
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def create_container(name, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "Creating container: #{name}. options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ container = @blob_client.create_container(name, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ raise_azure_exception(ex, msg)
15
+ end
16
+
17
+ Fog::Logger.debug "Container #{name} created successfully."
18
+ container
19
+ end
20
+ end
21
+
22
+ # This class provides the mock implementation for unit tests.
23
+ class Mock
24
+ def create_container(*)
25
+ {
26
+ 'name' => 'test_container',
27
+ 'public_access_level' => nil,
28
+ 'metadata' => {},
29
+ 'properties' => {
30
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
31
+ 'etag' => '0x8D3A3B5F017F52D',
32
+ 'lease_status' => 'unlocked',
33
+ 'lease_state' => 'available'
34
+ }
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ # Create a disk in Azure storage.
7
+ #
8
+ # @param disk_name [String] Name of disk
9
+ # @param disk_size_in_gb [Integer] Disk size in GiB. Value range: [1, 1023]
10
+ # @param options [Hash]
11
+ # @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
12
+ #
13
+ # @return [Boolean]
14
+ #
15
+ def create_disk(disk_name, disk_size_in_gb, options = {})
16
+ msg = "Creating disk(#{disk_name}, #{disk_size_in_gb}). options: #{options}"
17
+ Fog::Logger.debug msg
18
+
19
+ raise ArgumentError, "disk_size_in_gb #{disk_size_in_gb} must be an integer" unless disk_size_in_gb.is_a?(Integer)
20
+ raise ArgumentError, "Azure minimum disk size is 1 GiB: #{disk_size_in_gb}" if disk_size_in_gb < 1
21
+ raise ArgumentError, "Azure maximum disk size is 1023 GiB: #{disk_size_in_gb}" if disk_size_in_gb > 1023
22
+
23
+ container_name = options.delete(:container_name)
24
+ container_name = 'vhds' if container_name.nil?
25
+ blob_name = "#{disk_name}.vhd"
26
+ vhd_size = disk_size_in_gb * 1024 * 1024 * 1024
27
+ blob_size = vhd_size + 512
28
+
29
+ opts = {
30
+ type: :fixed,
31
+ name: '/tmp/footer.vhd', # Only used to initialize vhd, no local file is generated.
32
+ size: disk_size_in_gb
33
+ }
34
+ vhd_footer = Vhd::Library.new(opts).footer.values.join
35
+
36
+ begin
37
+ create_page_blob(container_name, blob_name, blob_size, options)
38
+ put_blob_pages(container_name, blob_name, vhd_size, blob_size - 1, vhd_footer, options)
39
+ rescue
40
+ begin
41
+ delete_blob(container_name, blob_name)
42
+ rescue => ex
43
+ Fog::Logger.debug "Cannot delete the blob: #{container_name}/#{blob_name} after create_disk failed. #{ex.inspect}"
44
+ end
45
+ raise
46
+ end
47
+
48
+ Fog::Logger.debug "Created a disk #{disk_name} successfully."
49
+ true
50
+ end
51
+ end
52
+
53
+ # This class provides the mock implementation for unit tests.
54
+ class Mock
55
+ def create_disk(*)
56
+ Fog::Logger.debug 'Disk created successfully.'
57
+ true
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def create_page_blob(container_name, blob_name, blob_size, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "create_page_blob #{blob_name} to the container #{container_name}. blob_size: #{blob_size}, options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ @blob_client.create_page_blob(container_name, blob_name, blob_size, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ raise_azure_exception(ex, msg)
15
+ end
16
+
17
+ Fog::Logger.debug "Page blob #{blob_name} created successfully."
18
+ true
19
+ end
20
+ end
21
+
22
+ # This class provides the mock implementation for unit tests.
23
+ class Mock
24
+ def create_page_blob(*)
25
+ Fog::Logger.debug 'Page blob created successfully.'
26
+ true
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def delete_blob(container_name, blob_name, options = {})
7
+ options[:request_id] = SecureRandom.uuid
8
+ msg = "Deleting blob: #{blob_name} in container #{container_name}. options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ @blob_client.delete_blob(container_name, blob_name, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ return true if ex.message.include?('(404)')
15
+ raise_azure_exception(ex, msg)
16
+ end
17
+
18
+ Fog::Logger.debug "Blob #{blob_name} deleted successfully."
19
+ true
20
+ end
21
+ end
22
+
23
+ # This class provides the mock implementation for unit tests.
24
+ class Mock
25
+ def delete_blob(*)
26
+ Fog::Logger.debug 'Blob deleted successfully.'
27
+ true
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implemention for service calls.
5
+ class Real
6
+ # Get a pre-signed URL to delete an object in Azure blob storage
7
+ #
8
+ # @param container_name [String] Name of container containing blob
9
+ # @param blob_name [String] Name of blob to get expiring url for
10
+ # @param expires [Time] An expiry time for this url
11
+ #
12
+ # @return [String] - https url for blob
13
+ #
14
+ # @see https://docs.microsoft.com/en-us/rest/api/storageservices/delete-blob
15
+ #
16
+ def delete_blob_https_url(container_name, blob_name, expires)
17
+ relative_path = "#{container_name}/#{blob_name}"
18
+ params = {
19
+ service: 'b',
20
+ resource: 'b',
21
+ permissions: 'd',
22
+ expiry: expires.utc.iso8601,
23
+ protocol: 'https'
24
+ }
25
+ token = @signature_client.generate_service_sas_token(relative_path, params)
26
+ uri = @blob_client.generate_uri(relative_path)
27
+ "#{uri}?#{token}"
28
+ end
29
+ end
30
+
31
+ # This class provides the mock implementation for unit tests.
32
+ class Mock
33
+ def delete_blob_https_url(*)
34
+ 'https://sa.blob.core.windows.net/test_container/test_blob?token'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ def delete_container(name)
7
+ options = { request_id: SecureRandom.uuid }
8
+ msg = "Deleting container: #{name}. options: #{options}"
9
+ Fog::Logger.debug msg
10
+
11
+ begin
12
+ @blob_client.delete_container(name, options)
13
+ rescue Azure::Core::Http::HTTPError => ex
14
+ return true if ex.message.include?('(404)')
15
+ raise_azure_exception(ex, msg)
16
+ end
17
+
18
+ Fog::Logger.debug "Container #{name} deleted successfully."
19
+ true
20
+ end
21
+ end
22
+
23
+ # This class provides the mock implementation for unit tests.
24
+ class Mock
25
+ def delete_container(*)
26
+ true
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Storage
3
+ class AzureRM
4
+ # This class provides the actual implementation for service calls.
5
+ class Real
6
+ # Delete a disk in Azure storage.
7
+ #
8
+ # @param disk_name [String] Name of disk
9
+ # @param options [Hash]
10
+ # @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
11
+ #
12
+ # @return [Boolean]
13
+ #
14
+ def delete_disk(disk_name, options = {})
15
+ msg = "Deleting disk(#{disk_name}). options: #{options}"
16
+ Fog::Logger.debug msg
17
+
18
+ container_name = options.delete(:container_name)
19
+ container_name = 'vhds' if container_name.nil?
20
+ delete_blob(container_name, "#{disk_name}.vhd")
21
+
22
+ Fog::Logger.debug "Successfully deleted Disk: #{disk_name}."
23
+ true
24
+ end
25
+ end
26
+
27
+ # This class provides the mock implementation for unit tests.
28
+ class Mock
29
+ def delete_disk(*)
30
+ Fog::Logger.debug 'Successfully deleted Disk'
31
+ true
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end