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,186 @@
1
+ require File.expand_path('../../custom_fog_errors.rb', __FILE__)
2
+
3
+ # Pick Resource Group name from Azure Resource Id(String)
4
+ def get_resource_group_from_id(id)
5
+ id.split('/')[4]
6
+ end
7
+
8
+ # Pick Virtual Network name from Subnet Resource Id(String)
9
+ def get_virtual_network_from_id(subnet_id)
10
+ subnet_id.split('/')[8]
11
+ end
12
+
13
+ # Pick Virtual Machine name from Virtual Machine Extension Id(String)
14
+ def get_virtual_machine_from_id(vme_id)
15
+ vme_id.split('/')[VM_NAME_POSITION]
16
+ end
17
+
18
+ # Extract Endpoint type from (String)
19
+ def get_end_point_type(endpoint_type)
20
+ endpoint_type.split('/')[2]
21
+ end
22
+
23
+ def get_record_set_from_id(id)
24
+ id.split('/')[8]
25
+ end
26
+
27
+ def get_type_from_recordset_type(type)
28
+ type.split('/')[2]
29
+ end
30
+
31
+ def get_hash_from_object(object)
32
+ hash = {}
33
+ object.instance_variables.each { |attr| hash[attr.to_s.delete('@')] = object.instance_variable_get(attr) }
34
+ hash
35
+ end
36
+
37
+ # Extract Traffic Manager Profile Name from Endpoint id(String)
38
+ def get_traffic_manager_profile_name_from_endpoint_id(endpoint_id)
39
+ endpoint_id.split('/')[8]
40
+ end
41
+
42
+ # Pick Express Route Circuit name from Id(String)
43
+ def get_circuit_name_from_id(circuit_id)
44
+ circuit_id.split('/')[8]
45
+ end
46
+
47
+ def get_record_type(type)
48
+ type.split('/').last
49
+ end
50
+
51
+ def raise_azure_exception(exception, msg)
52
+ raise Fog::AzureRM::CustomAzureCoreHttpError.new(exception) if exception.is_a?(Azure::Core::Http::HTTPError)
53
+ raise exception unless exception.is_a?(MsRestAzure::AzureOperationError)
54
+
55
+ azure_operation_error = Fog::AzureRM::CustomAzureOperationError.new(msg, exception)
56
+ azure_operation_error.print_subscription_limits_information if !azure_operation_error.request.nil? && !azure_operation_error.response.nil?
57
+ raise azure_operation_error
58
+ end
59
+
60
+ # Make sure if input_params(Hash) contains all keys present in required_params(Array)
61
+ def validate_params(required_params, input_params)
62
+ missing_params = required_params.select { |param| param unless input_params.key?(param) }
63
+ raise(ArgumentError, "Missing Parameters: #{missing_params.join(', ')} required for this operation") if missing_params.any?
64
+ end
65
+
66
+ def get_resource_from_resource_id(resource_id, position)
67
+ data = resource_id.split('/') unless resource_id.nil?
68
+
69
+ raise 'Invalid Resource ID' if data.count < 9 && data.count != 5
70
+
71
+ data[position]
72
+ end
73
+
74
+ def random_string(length)
75
+ (0...length).map { ('a'..'z').to_a[rand(26)] }.join
76
+ end
77
+
78
+ def active_directory_service_settings(environment = ENVIRONMENT_AZURE_CLOUD)
79
+ case environment
80
+ when ENVIRONMENT_AZURE_CHINA_CLOUD
81
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
82
+ when ENVIRONMENT_AZURE_US_GOVERNMENT
83
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
84
+ when ENVIRONMENT_AZURE_GERMAN_CLOUD
85
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
86
+ else
87
+ MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
88
+ end
89
+ end
90
+
91
+ def resource_manager_endpoint_url(environment = ENVIRONMENT_AZURE_CLOUD)
92
+ case environment
93
+ when ENVIRONMENT_AZURE_CHINA_CLOUD
94
+ MsRestAzure::AzureEnvironments::ChinaCloud.resource_manager_endpoint_url
95
+ when ENVIRONMENT_AZURE_US_GOVERNMENT
96
+ MsRestAzure::AzureEnvironments::USGovernment.resource_manager_endpoint_url
97
+ when ENVIRONMENT_AZURE_GERMAN_CLOUD
98
+ MsRestAzure::AzureEnvironments::GermanCloud.resource_manager_endpoint_url
99
+ else
100
+ MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
101
+ end
102
+ end
103
+
104
+ # storage_endpoint_suffix is nil in ms_rest_azure 0.6.2
105
+ # Reference the issue: https://github.com/Azure/azure-sdk-for-ruby/issues/603
106
+ def storage_endpoint_suffix(environment = ENVIRONMENT_AZURE_CLOUD)
107
+ case environment
108
+ when ENVIRONMENT_AZURE_CHINA_CLOUD
109
+ # MsRestAzure::AzureEnvironments::AzureChina.storage_endpoint_suffix
110
+ '.core.chinacloudapi.cn'
111
+ when ENVIRONMENT_AZURE_US_GOVERNMENT
112
+ # MsRestAzure::AzureEnvironments::AzureUSGovernment.storage_endpoint_suffix
113
+ '.core.usgovcloudapi.net'
114
+ when ENVIRONMENT_AZURE_GERMAN_CLOUD
115
+ # MsRestAzure::AzureEnvironments::AzureGermanCloud.storage_endpoint_suffix
116
+ '.core.cloudapi.de'
117
+ else
118
+ # MsRestAzure::AzureEnvironments::Azure.storage_endpoint_suffix
119
+ '.core.windows.net'
120
+ end
121
+ end
122
+
123
+ def get_blob_endpoint(storage_account_name, enable_https = false, environment = ENVIRONMENT_AZURE_CLOUD)
124
+ protocol = enable_https ? 'https' : 'http'
125
+ "#{protocol}://#{storage_account_name}.blob#{storage_endpoint_suffix(environment)}"
126
+ end
127
+
128
+ def current_time
129
+ time = Time.now.to_f.to_s
130
+ time.split(/\W+/).join
131
+ end
132
+
133
+ # Parse storage blob/container to a hash
134
+ def parse_storage_object(object)
135
+ data = {}
136
+ if object.is_a? Hash
137
+ object.each do |k, v|
138
+ if k == 'properties'
139
+ v.each do |j, l|
140
+ data[j] = l
141
+ end
142
+ else
143
+ data[k] = v
144
+ end
145
+ end
146
+ else
147
+ object.instance_variables.each do |p|
148
+ kname = p.to_s.delete('@')
149
+ if kname == 'properties'
150
+ properties = object.instance_variable_get(p)
151
+ properties.each do |k, v|
152
+ data[k.to_s] = v
153
+ end
154
+ else
155
+ data[kname] = object.instance_variable_get(p)
156
+ end
157
+ end
158
+ end
159
+
160
+ data['last_modified'] = Time.parse(data['last_modified'])
161
+ data['etag'].delete!('"')
162
+ data
163
+ end
164
+
165
+ def resource_not_found?(azure_operation_error)
166
+ is_found = false
167
+ if azure_operation_error.response.status == HTTP_NOT_FOUND
168
+ if azure_operation_error.body['code']
169
+ is_found = azure_operation_error.body['code'] == ERROR_CODE_NOT_FOUND
170
+ elsif azure_operation_error.body['error']
171
+ is_found = azure_operation_error.body['error']['code'] == ERROR_CODE_NOT_FOUND ||
172
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_GROUP_NOT_FOUND ||
173
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND ||
174
+ azure_operation_error.body['error']['code'] == ERROR_CODE_PARENT_RESOURCE_NOT_FOUND
175
+ end
176
+ end
177
+ is_found
178
+ end
179
+
180
+ def get_image_name(id)
181
+ id.split('/').last
182
+ end
183
+
184
+ def get_subscription_id(id)
185
+ id.split('/')[2]
186
+ end
@@ -0,0 +1,19 @@
1
+ network:
2
+ express_route_circuit_authentication:
3
+ message:
4
+ create: Creating/updating Express Route Circuit Authorization 'NAME' in Resource Group 'RESOURCE_GROUP'.
5
+ delete: Deleting Express Route Circuit Authorization 'NAME' from Resource Group 'RESOURCE_GROUP'.
6
+ get: Getting Express Route Circuit Authorization 'NAME' from Resource Group 'RESOURCE_GROUP'.
7
+ list: Getting list of Express Route Circuit Authorizations from Resource Group 'RESOURCE_GROUP'.
8
+ local_network_gateway:
9
+ message:
10
+ create: Creating/Updating Local Network Gateway 'NAME' in Resource Group 'RESOURCE_GROUP'.
11
+ delete: Deleting Local Network Gateway 'NAME' in Resource Group 'RESOURCE_GROUP'.
12
+ get: Getting Local Network Gateway 'NAME' in Resource Group 'RESOURCE_GROUP'.
13
+ list: Getting list of Local Network Gateways in Resource Group 'RESOURCE_GROUP'.
14
+ virtual_network_gateway_connection:
15
+ message:
16
+ create: Creating/Updating Virtual Network Gateway Connection 'NAME' in Resource Group 'RESOURCE_GROUP'.
17
+ delete: Deleting Virtual Network Gateway Connection 'NAME' in Resource Group 'RESOURCE_GROUP'.
18
+ get: Getting Virtual Network Gateway Connection 'NAME' in Resource Group 'RESOURCE_GROUP'.
19
+ list: Getting list of Virtual Network Gateway Connections in Resource Group 'RESOURCE_GROUP'.
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module AzureRM
3
+ VERSION = '0.6.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ rake cc_coverage
3
+ R=$?
4
+ export CODECLIMATE_REPO_TOKEN="b1401494baa004d90402414cb33a7fc6420fd3693e60c677a120ddefd7d84cfd"
5
+ codeclimate-test-reporter
6
+ if [ $R == 1 ]; then
7
+ exit 1
8
+ else
9
+ exit 0
10
+ fi
@@ -0,0 +1,29 @@
1
+ require 'rake/testtask'
2
+ task default: :cc_coverage
3
+ task :test do
4
+ ENV['COVERAGE'] = nil
5
+ ENV['CODECLIMATE_REPO_TOKEN'] = nil
6
+ Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
7
+ Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
8
+ end
9
+
10
+ desc 'Generates a coverage report for minitest-cases using simple-cov'
11
+ task :coverage do
12
+ ENV['CODECLIMATE_REPO_TOKEN'] = nil
13
+ ENV['COVERAGE'] = 'true'
14
+ Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
15
+ Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
16
+ end
17
+
18
+ desc 'Generates a coverage report for minitest-cases using code-climate'
19
+ task :cc_coverage do
20
+ ENV['COVERAGE'] = nil
21
+ ENV['CODECLIMATE_REPO_TOKEN'] = 'b1401494baa004d90402414cb33a7fc6420fd3693e60c677a120ddefd7d84cfd'
22
+ Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
23
+ Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
24
+ end
25
+
26
+ desc 'Generates a coverage report for integration tests'
27
+ task :integration_tests do
28
+ Dir.glob('test/smoke_tests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
29
+ end
@@ -0,0 +1,147 @@
1
+ # Module for API Stub
2
+ module ApiStub
3
+ module Models
4
+ # Load test Compute models
5
+ module Compute
6
+ autoload :Server, File.expand_path('api_stub/models/compute/server', __dir__)
7
+ autoload :AvailabilitySet, File.expand_path('api_stub/models/compute/availability_set', __dir__)
8
+ autoload :VirtualMachineExtension, File.expand_path('api_stub/models/compute/virtual_machine_extension', __dir__)
9
+ autoload :ManagedDisk, File.expand_path('api_stub/models/compute/managed_disk', __dir__)
10
+ autoload :Snapshot, File.expand_path('api_stub/models/compute/snapshot', __dir__)
11
+ end
12
+
13
+ # Load test Resources models
14
+ module Resources
15
+ autoload :ResourceGroup, File.expand_path('api_stub/models/resources/resource_group', __dir__)
16
+ autoload :Deployment, File.expand_path('api_stub/models/resources/deployment', __dir__)
17
+ autoload :Resource, File.expand_path('api_stub/models/resources/resource', __dir__)
18
+ end
19
+
20
+ # Load test Storage models
21
+ module Storage
22
+ autoload :StorageAccount, File.expand_path('api_stub/models/storage/storageaccount', __dir__)
23
+ autoload :File, ::File.expand_path('api_stub/models/storage/file', __dir__)
24
+ autoload :Directory, ::File.expand_path('api_stub/models/storage/directory', __dir__)
25
+ end
26
+
27
+ # Load test Network models
28
+ module Network
29
+ autoload :PublicIp, File.expand_path('api_stub/models/network/public_ip', __dir__)
30
+ autoload :Subnet, File.expand_path('api_stub/models/network/subnet', __dir__)
31
+ autoload :VirtualNetwork, File.expand_path('api_stub/models/network/virtual_network', __dir__)
32
+ autoload :NetworkInterface, File.expand_path('api_stub/models/network/network_interface', __dir__)
33
+ autoload :LoadBalancer, File.expand_path('api_stub/models/network/load_balancer', __dir__)
34
+ autoload :NetworkSecurityGroup, File.expand_path('api_stub/models/network/network_security_group', __dir__)
35
+ autoload :NetworkSecurityRule, File.expand_path('api_stub/models/network/network_security_rule', __dir__)
36
+ autoload :VirtualNetworkGateway, File.expand_path('api_stub/models/network/virtual_network_gateway', __dir__)
37
+ autoload :VirtualNetworkGatewayConnection, File.expand_path('api_stub/models/network/virtual_network_gateway_connection', __dir__)
38
+ autoload :ExpressRouteCircuit, File.expand_path('api_stub/models/network/express_route_circuit', __dir__)
39
+ autoload :ExpressRouteCircuitPeering, File.expand_path('api_stub/models/network/express_route_circuit_peering', __dir__)
40
+ autoload :ExpressRouteCircuitAuthorization, File.expand_path('api_stub/models/network/express_route_circuit_authorization', __dir__)
41
+ autoload :ExpressRouteServiceProvider, File.expand_path('api_stub/models/network/express_route_service_provider', __dir__)
42
+ autoload :LocalNetworkGateway, File.expand_path('api_stub/models/network/local_network_gateway', __dir__)
43
+ end
44
+
45
+ # Load test ApplicationGateway models
46
+ module ApplicationGateway
47
+ autoload :Gateway, File.expand_path('api_stub/models/application_gateway/gateway', __dir__)
48
+ end
49
+
50
+ # Load test TrafficManager models
51
+ module TrafficManager
52
+ autoload :TrafficManagerEndPoint, File.expand_path('api_stub/models/traffic_manager/traffic_manager_end_point', __dir__)
53
+ autoload :TrafficManagerProfile, File.expand_path('api_stub/models/traffic_manager/traffic_manager_profile', __dir__)
54
+ end
55
+
56
+ # Load test DNS models
57
+ module DNS
58
+ autoload :Zone, File.expand_path('api_stub/models/dns/zone', __dir__)
59
+ autoload :RecordSet, File.expand_path('api_stub/models/dns/record_set', __dir__)
60
+ end
61
+
62
+ # Load test Sql models
63
+ module Sql
64
+ autoload :SqlServer, File.expand_path('api_stub/models/sql/sql_server', __dir__)
65
+ autoload :SqlDatabase, File.expand_path('api_stub/models/sql/sql_database', __dir__)
66
+ autoload :SqlFirewallRule, File.expand_path('api_stub/models/sql/sql_firewall_rule', __dir__)
67
+ end
68
+
69
+ # Load test KeyVault models
70
+ module KeyVault
71
+ autoload :Vault, File.expand_path('api_stub/models/key_vault/vault', __dir__)
72
+ end
73
+ end
74
+
75
+ module Requests
76
+ # Load test Compute requests
77
+ module Compute
78
+ autoload :AvailabilitySet, File.expand_path('api_stub/requests/compute/availability_set', __dir__)
79
+ autoload :VirtualMachine, File.expand_path('api_stub/requests/compute/virtual_machine', __dir__)
80
+ autoload :VirtualMachineExtension, File.expand_path('api_stub/requests/compute/virtual_machine_extension', __dir__)
81
+ autoload :ManagedDisk, File.expand_path('api_stub/requests/compute/managed_disk', __dir__)
82
+ autoload :Image, File.expand_path('api_stub/requests/compute/image', __dir__)
83
+ autoload :Snapshot, File.expand_path('api_stub/requests/compute/snapshot', __dir__)
84
+ end
85
+
86
+ # Load test Resources requests
87
+ module Resources
88
+ autoload :ResourceGroup, File.expand_path('api_stub/requests/resources/resource_group', __dir__)
89
+ autoload :Deployment, File.expand_path('api_stub/requests/resources/deployment', __dir__)
90
+ autoload :AzureResource, File.expand_path('api_stub/requests/resources/resource', __dir__)
91
+ end
92
+
93
+ # Load test Storage requests
94
+ module Storage
95
+ autoload :StorageAccount, File.expand_path('api_stub/requests/storage/storageaccount', __dir__)
96
+ autoload :File, ::File.expand_path('api_stub/requests/storage/file', __dir__)
97
+ autoload :Directory, ::File.expand_path('api_stub/requests/storage/directory', __dir__)
98
+ end
99
+
100
+ # Load test Network requests
101
+ module Network
102
+ autoload :PublicIp, File.expand_path('api_stub/requests/network/public_ip', __dir__)
103
+ autoload :Subnet, File.expand_path('api_stub/requests/network/subnet', __dir__)
104
+ autoload :VirtualNetwork, File.expand_path('api_stub/requests/network/virtual_network', __dir__)
105
+ autoload :NetworkInterface, File.expand_path('api_stub/requests/network/network_interface', __dir__)
106
+ autoload :LoadBalancer, File.expand_path('api_stub/requests/network/load_balancer', __dir__)
107
+ autoload :NetworkSecurityGroup, File.expand_path('api_stub/requests/network/network_security_group', __dir__)
108
+ autoload :NetworkSecurityRule, File.expand_path('api_stub/requests/network/network_security_rule', __dir__)
109
+ autoload :VirtualNetworkGateway, File.expand_path('api_stub/requests/network/virtual_network_gateway', __dir__)
110
+ autoload :VirtualNetworkGatewayConnection, File.expand_path('api_stub/requests/network/virtual_network_gateway_connection', __dir__)
111
+ autoload :ExpressRouteCircuit, File.expand_path('api_stub/requests/network/express_route_circuit', __dir__)
112
+ autoload :ExpressRouteCircuitPeering, File.expand_path('api_stub/requests/network/express_route_circuit_peering', __dir__)
113
+ autoload :ExpressRouteCircuitAuthorization, File.expand_path('api_stub/requests/network/express_route_circuit_authorization', __dir__)
114
+ autoload :ExpressRouteServiceProvider, File.expand_path('api_stub/requests/network/express_route_service_provider', __dir__)
115
+ autoload :LocalNetworkGateway, File.expand_path('api_stub/requests/network/local_network_gateway', __dir__)
116
+ end
117
+
118
+ # Load test ApplicationGateway requests
119
+ module ApplicationGateway
120
+ autoload :Gateway, File.expand_path('api_stub/requests/application_gateway/gateway', __dir__)
121
+ end
122
+
123
+ # Load test TrafficManager requests
124
+ module TrafficManager
125
+ autoload :TrafficManagerEndPoint, File.expand_path('api_stub/requests/traffic_manager/traffic_manager_endpoint', __dir__)
126
+ autoload :TrafficManagerProfile, File.expand_path('api_stub/requests/traffic_manager/traffic_manager_profile', __dir__)
127
+ end
128
+
129
+ # Load test DNS requests
130
+ module DNS
131
+ autoload :Zone, File.expand_path('api_stub/requests/dns/zone', __dir__)
132
+ autoload :RecordSet, File.expand_path('api_stub/requests/dns/record_set', __dir__)
133
+ end
134
+
135
+ # Load test Sql requests
136
+ module Sql
137
+ autoload :SqlServer, File.expand_path('api_stub/requests/sql/sql_server', __dir__)
138
+ autoload :SqlDatabase, File.expand_path('api_stub/requests/sql/database', __dir__)
139
+ autoload :FirewallRule, File.expand_path('api_stub/requests/sql/firewall_rule', __dir__)
140
+ end
141
+
142
+ # Load test KeyVault requests
143
+ module KeyVault
144
+ autoload :Vault, File.expand_path('api_stub/requests/key_vault/vault', __dir__)
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,178 @@
1
+ module ApiStub
2
+ module Models
3
+ module Storage
4
+ # Mock class for Data Disk Model
5
+ class Directory
6
+ def self.container
7
+ {
8
+ 'name' => 'test_container',
9
+ 'public_access_level' => nil,
10
+ 'metadata' => {},
11
+ 'properties' => {
12
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
13
+ 'etag' => '"0x8D3A3B5F017F52D"',
14
+ 'lease_status' => 'unlocked',
15
+ 'lease_state' => 'available'
16
+ }
17
+ }
18
+ end
19
+
20
+ def self.container_acl
21
+ ['container', {}]
22
+ end
23
+
24
+ def self.container_https_url
25
+ 'https://sa.blob.core.windows.net/test_container?comp=list&restype=container'
26
+ end
27
+
28
+ def self.container_list
29
+ [
30
+ {
31
+ 'name' => 'test_container1',
32
+ 'metadata' => {},
33
+ 'properties' => {
34
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
35
+ 'etag' => '"0x8D3A3B5F017F52D"',
36
+ 'lease_status' => 'unlocked',
37
+ 'lease_state' => 'available'
38
+ }
39
+ },
40
+ {
41
+ 'name' => 'test_container2',
42
+ 'metadata' => {},
43
+ 'properties' => {
44
+ 'last_modified' => 'Tue, 04 Aug 2015 06:01:08 GMT',
45
+ 'etag' => '"0x8D29C92176C8352"',
46
+ 'lease_status' => 'unlocked',
47
+ 'lease_state' => 'available'
48
+ }
49
+ },
50
+ {
51
+ 'name' => 'test_container3',
52
+ 'metadata' => {},
53
+ 'properties' => {
54
+ 'last_modified' => 'Tue, 01 Sep 2015 05:15:36 GMT',
55
+ 'etag' => '"0x8D2B28C5EB36458"',
56
+ 'lease_status' => 'unlocked',
57
+ 'lease_state' => 'available'
58
+ }
59
+ }
60
+ ]
61
+ end
62
+
63
+ def self.blob_list
64
+ {
65
+ next_marker: 'marker',
66
+ blobs:
67
+ [
68
+ {
69
+ 'name' => 'test_blob1',
70
+ 'metadata' => {},
71
+ 'properties' => {
72
+ 'last_modified' => 'Mon, 04 Jul 2016 02:50:20 GMT',
73
+ 'etag' => '"0x8D3A3B5F017F52D"',
74
+ 'lease_status' => 'unlocked',
75
+ 'lease_state' => 'available',
76
+ 'content_length' => 4_194_304,
77
+ 'content_type' => 'application/octet-stream',
78
+ 'content_encoding' => nil,
79
+ 'content_language' => nil,
80
+ 'content_disposition' => nil,
81
+ 'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
82
+ 'cache_control' => nil,
83
+ 'sequence_number' => 0,
84
+ 'blob_type' => 'PageBlob',
85
+ 'copy_id' => '095adc3b-e277-4c3d-97e0-0abca881f60c',
86
+ 'copy_status' => 'success',
87
+ 'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3256874Z',
88
+ 'copy_progress' => '4194304/4194304',
89
+ 'copy_completion_time' => 'Thu, 04 Feb 2016 08:35:52 GMT',
90
+ 'copy_status_description' => nil,
91
+ 'accept_ranges' => 0
92
+ }
93
+ },
94
+ {
95
+ 'name' => 'test_blob2',
96
+ 'metadata' => {},
97
+ 'properties' => {
98
+ 'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
99
+ 'etag' => '"0x8D29C92173526C8"',
100
+ 'lease_status' => 'unlocked',
101
+ 'lease_state' => 'available',
102
+ 'content_length' => 4_194_304,
103
+ 'content_type' => 'application/octet-stream',
104
+ 'content_encoding' => nil,
105
+ 'content_language' => nil,
106
+ 'content_disposition' => nil,
107
+ 'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
108
+ 'cache_control' => nil,
109
+ 'sequence_number' => 0,
110
+ 'blob_type' => 'PageBlob',
111
+ 'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
112
+ 'copy_status' => 'success',
113
+ 'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
114
+ 'copy_progress' => '4194304/4194304',
115
+ 'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
116
+ 'copy_status_description' => nil,
117
+ 'accept_ranges' => 0
118
+ }
119
+ },
120
+ {
121
+ 'name' => 'test_blob3',
122
+ 'metadata' => {},
123
+ 'properties' => {
124
+ 'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
125
+ 'etag' => '"0x8D29C92173526C8"',
126
+ 'lease_status' => 'unlocked',
127
+ 'lease_state' => 'available',
128
+ 'content_length' => 4_194_304,
129
+ 'content_type' => 'application/octet-stream',
130
+ 'content_encoding' => nil,
131
+ 'content_language' => nil,
132
+ 'content_disposition' => nil,
133
+ 'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
134
+ 'cache_control' => nil,
135
+ 'sequence_number' => 0,
136
+ 'blob_type' => 'PageBlob',
137
+ 'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
138
+ 'copy_status' => 'success',
139
+ 'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
140
+ 'copy_progress' => '4194304/4194304',
141
+ 'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
142
+ 'copy_status_description' => nil,
143
+ 'accept_ranges' => 0
144
+ }
145
+ },
146
+ {
147
+ 'name' => 'test_blob4',
148
+ 'metadata' => {},
149
+ 'properties' => {
150
+ 'last_modified' => 'Tue, 04 Aug 2015 06:02:08 GMT',
151
+ 'etag' => '"0x8D29C92173526C8"',
152
+ 'lease_status' => 'unlocked',
153
+ 'lease_state' => 'available',
154
+ 'content_length' => 4_194_304,
155
+ 'content_type' => 'application/octet-stream',
156
+ 'content_encoding' => nil,
157
+ 'content_language' => nil,
158
+ 'content_disposition' => nil,
159
+ 'content_md5' => 'tXAohIyxuu/t94Lp/ujeRw==',
160
+ 'cache_control' => nil,
161
+ 'sequence_number' => 0,
162
+ 'blob_type' => 'PageBlob',
163
+ 'copy_id' => '0abcdc3b-4c3d-e277-97e0-0abca881f60c',
164
+ 'copy_status' => 'success',
165
+ 'copy_source' => 'https://testaccount.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A55.3157696Z',
166
+ 'copy_progress' => '4194304/4194304',
167
+ 'copy_completion_time' => 'Thu, 04 Feb 2016 08:40:52 GMT',
168
+ 'copy_status_description' => nil,
169
+ 'accept_ranges' => 0
170
+ }
171
+ }
172
+ ]
173
+ }
174
+ end
175
+ end
176
+ end
177
+ end
178
+ end