azure_mgmt_storage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +15 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +111 -0
  8. data/Rakefile +5 -0
  9. data/azure_mgmt_storage.gemspec +39 -0
  10. data/lib/azure_mgmt_storage.rb +54 -0
  11. data/lib/azure_mgmt_storage/models/account_status.rb +16 -0
  12. data/lib/azure_mgmt_storage/models/account_type.rb +19 -0
  13. data/lib/azure_mgmt_storage/models/check_name_availability_result.rb +85 -0
  14. data/lib/azure_mgmt_storage/models/custom_domain.rb +70 -0
  15. data/lib/azure_mgmt_storage/models/endpoints.rb +77 -0
  16. data/lib/azure_mgmt_storage/models/key_name.rb +16 -0
  17. data/lib/azure_mgmt_storage/models/provisioning_state.rb +17 -0
  18. data/lib/azure_mgmt_storage/models/reason.rb +16 -0
  19. data/lib/azure_mgmt_storage/models/storage_account.rb +94 -0
  20. data/lib/azure_mgmt_storage/models/storage_account_check_name_availability_parameters.rb +68 -0
  21. data/lib/azure_mgmt_storage/models/storage_account_create_parameters.rb +94 -0
  22. data/lib/azure_mgmt_storage/models/storage_account_keys.rb +67 -0
  23. data/lib/azure_mgmt_storage/models/storage_account_list_result.rb +89 -0
  24. data/lib/azure_mgmt_storage/models/storage_account_properties.rb +212 -0
  25. data/lib/azure_mgmt_storage/models/storage_account_properties_create_parameters.rb +63 -0
  26. data/lib/azure_mgmt_storage/models/storage_account_properties_update_parameters.rb +85 -0
  27. data/lib/azure_mgmt_storage/models/storage_account_regenerate_key_parameters.rb +62 -0
  28. data/lib/azure_mgmt_storage/models/storage_account_update_parameters.rb +94 -0
  29. data/lib/azure_mgmt_storage/models/usage.rb +101 -0
  30. data/lib/azure_mgmt_storage/models/usage_list_result.rb +78 -0
  31. data/lib/azure_mgmt_storage/models/usage_name.rb +67 -0
  32. data/lib/azure_mgmt_storage/models/usage_unit.rb +20 -0
  33. data/lib/azure_mgmt_storage/module_definition.rb +6 -0
  34. data/lib/azure_mgmt_storage/storage_accounts.rb +1105 -0
  35. data/lib/azure_mgmt_storage/storage_management_client.rb +65 -0
  36. data/lib/azure_mgmt_storage/usage_operations.rb +111 -0
  37. data/lib/azure_mgmt_storage/version.rb +6 -0
  38. metadata +226 -0
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # Model object.
10
+ #
11
+ class StorageAccountRegenerateKeyParameters
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [KeyName] Possible values for this property include: 'key1',
16
+ # 'key2'.
17
+ attr_accessor :key_name
18
+
19
+ #
20
+ # Validate the object. Throws ValidationError if validation fails.
21
+ #
22
+ def validate
23
+ end
24
+
25
+ #
26
+ # Serializes given Model object into Ruby Hash.
27
+ # @param object Model object to serialize.
28
+ # @return [Hash] Serialized object in form of Ruby Hash.
29
+ #
30
+ def self.serialize_object(object)
31
+ object.validate
32
+ output_object = {}
33
+
34
+ serialized_property = object.key_name
35
+ output_object['keyName'] = serialized_property unless serialized_property.nil?
36
+
37
+ output_object
38
+ end
39
+
40
+ #
41
+ # Deserializes given Ruby Hash into Model object.
42
+ # @param object [Hash] Ruby Hash object to deserialize.
43
+ # @return [StorageAccountRegenerateKeyParameters] Deserialized object.
44
+ #
45
+ def self.deserialize_object(object)
46
+ return if object.nil?
47
+ output_object = StorageAccountRegenerateKeyParameters.new
48
+
49
+ deserialized_property = object['keyName']
50
+ if (!deserialized_property.nil? && !deserialized_property.empty?)
51
+ enum_is_valid = KeyName.constants.any? { |e| KeyName.const_get(e).to_s.downcase == deserialized_property.downcase }
52
+ fail MsRest::DeserializationError.new('Error occured while deserializing the enum', nil, nil, nil) unless enum_is_valid
53
+ end
54
+ output_object.key_name = deserialized_property
55
+
56
+ output_object.validate
57
+
58
+ output_object
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,94 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # The parameters to update on the account.
10
+ #
11
+ class StorageAccountUpdateParameters < MsRestAzure::Resource
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [StorageAccountPropertiesUpdateParameters]
16
+ attr_accessor :properties
17
+
18
+ #
19
+ # Validate the object. Throws ValidationError if validation fails.
20
+ #
21
+ def validate
22
+ @properties.validate unless @properties.nil?
23
+ end
24
+
25
+ #
26
+ # Serializes given Model object into Ruby Hash.
27
+ # @param object Model object to serialize.
28
+ # @return [Hash] Serialized object in form of Ruby Hash.
29
+ #
30
+ def self.serialize_object(object)
31
+ object.validate
32
+ output_object = {}
33
+
34
+ serialized_property = object.location
35
+ output_object['location'] = serialized_property unless serialized_property.nil?
36
+
37
+ serialized_property = object.id
38
+ output_object['id'] = serialized_property unless serialized_property.nil?
39
+
40
+ serialized_property = object.name
41
+ output_object['name'] = serialized_property unless serialized_property.nil?
42
+
43
+ serialized_property = object.type
44
+ output_object['type'] = serialized_property unless serialized_property.nil?
45
+
46
+ serialized_property = object.tags
47
+ output_object['tags'] = serialized_property unless serialized_property.nil?
48
+
49
+ serialized_property = object.properties
50
+ unless serialized_property.nil?
51
+ serialized_property = StorageAccountPropertiesUpdateParameters.serialize_object(serialized_property)
52
+ end
53
+ output_object['properties'] = serialized_property unless serialized_property.nil?
54
+
55
+ output_object
56
+ end
57
+
58
+ #
59
+ # Deserializes given Ruby Hash into Model object.
60
+ # @param object [Hash] Ruby Hash object to deserialize.
61
+ # @return [StorageAccountUpdateParameters] Deserialized object.
62
+ #
63
+ def self.deserialize_object(object)
64
+ return if object.nil?
65
+ output_object = StorageAccountUpdateParameters.new
66
+
67
+ deserialized_property = object['location']
68
+ output_object.location = deserialized_property
69
+
70
+ deserialized_property = object['id']
71
+ output_object.id = deserialized_property
72
+
73
+ deserialized_property = object['name']
74
+ output_object.name = deserialized_property
75
+
76
+ deserialized_property = object['type']
77
+ output_object.type = deserialized_property
78
+
79
+ deserialized_property = object['tags']
80
+ output_object.tags = deserialized_property
81
+
82
+ deserialized_property = object['properties']
83
+ unless deserialized_property.nil?
84
+ deserialized_property = StorageAccountPropertiesUpdateParameters.deserialize_object(deserialized_property)
85
+ end
86
+ output_object.properties = deserialized_property
87
+
88
+ output_object.validate
89
+
90
+ output_object
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # Describes Storage Resource Usage.
10
+ #
11
+ class Usage
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [UsageUnit] Gets the unit of measurement. Possible values for
16
+ # this property include: 'Count', 'Bytes', 'Seconds', 'Percent',
17
+ # 'CountsPerSecond', 'BytesPerSecond'.
18
+ attr_accessor :unit
19
+
20
+ # @return [Integer] Gets the current count of the allocated resources in
21
+ # the subscription.
22
+ attr_accessor :current_value
23
+
24
+ # @return [Integer] Gets the maximum count of the resources that can be
25
+ # allocated in the subscription.
26
+ attr_accessor :limit
27
+
28
+ # @return [UsageName] Gets the name of the type of usage.
29
+ attr_accessor :name
30
+
31
+ #
32
+ # Validate the object. Throws ValidationError if validation fails.
33
+ #
34
+ def validate
35
+ @name.validate unless @name.nil?
36
+ end
37
+
38
+ #
39
+ # Serializes given Model object into Ruby Hash.
40
+ # @param object Model object to serialize.
41
+ # @return [Hash] Serialized object in form of Ruby Hash.
42
+ #
43
+ def self.serialize_object(object)
44
+ object.validate
45
+ output_object = {}
46
+
47
+ serialized_property = object.unit
48
+ output_object['unit'] = serialized_property unless serialized_property.nil?
49
+
50
+ serialized_property = object.current_value
51
+ output_object['currentValue'] = serialized_property unless serialized_property.nil?
52
+
53
+ serialized_property = object.limit
54
+ output_object['limit'] = serialized_property unless serialized_property.nil?
55
+
56
+ serialized_property = object.name
57
+ unless serialized_property.nil?
58
+ serialized_property = UsageName.serialize_object(serialized_property)
59
+ end
60
+ output_object['name'] = serialized_property unless serialized_property.nil?
61
+
62
+ output_object
63
+ end
64
+
65
+ #
66
+ # Deserializes given Ruby Hash into Model object.
67
+ # @param object [Hash] Ruby Hash object to deserialize.
68
+ # @return [Usage] Deserialized object.
69
+ #
70
+ def self.deserialize_object(object)
71
+ return if object.nil?
72
+ output_object = Usage.new
73
+
74
+ deserialized_property = object['unit']
75
+ if (!deserialized_property.nil? && !deserialized_property.empty?)
76
+ enum_is_valid = UsageUnit.constants.any? { |e| UsageUnit.const_get(e).to_s.downcase == deserialized_property.downcase }
77
+ fail MsRest::DeserializationError.new('Error occured while deserializing the enum', nil, nil, nil) unless enum_is_valid
78
+ end
79
+ output_object.unit = deserialized_property
80
+
81
+ deserialized_property = object['currentValue']
82
+ deserialized_property = Integer(deserialized_property) unless deserialized_property.to_s.empty?
83
+ output_object.current_value = deserialized_property
84
+
85
+ deserialized_property = object['limit']
86
+ deserialized_property = Integer(deserialized_property) unless deserialized_property.to_s.empty?
87
+ output_object.limit = deserialized_property
88
+
89
+ deserialized_property = object['name']
90
+ unless deserialized_property.nil?
91
+ deserialized_property = UsageName.deserialize_object(deserialized_property)
92
+ end
93
+ output_object.name = deserialized_property
94
+
95
+ output_object.validate
96
+
97
+ output_object
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,78 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # The List Usages operation response.
10
+ #
11
+ class UsageListResult
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [Array<Usage>] Gets or sets the list Storage Resource Usages.
16
+ attr_accessor :value
17
+
18
+ #
19
+ # Validate the object. Throws ValidationError if validation fails.
20
+ #
21
+ def validate
22
+ @value.each{ |e| e.validate if e.respond_to?(:validate) } unless @value.nil?
23
+ end
24
+
25
+ #
26
+ # Serializes given Model object into Ruby Hash.
27
+ # @param object Model object to serialize.
28
+ # @return [Hash] Serialized object in form of Ruby Hash.
29
+ #
30
+ def self.serialize_object(object)
31
+ object.validate
32
+ output_object = {}
33
+
34
+ serialized_property = object.value
35
+ unless serialized_property.nil?
36
+ serializedArray = []
37
+ serialized_property.each do |element|
38
+ unless element.nil?
39
+ element = Usage.serialize_object(element)
40
+ end
41
+ serializedArray.push(element)
42
+ end
43
+ serialized_property = serializedArray
44
+ end
45
+ output_object['value'] = serialized_property unless serialized_property.nil?
46
+
47
+ output_object
48
+ end
49
+
50
+ #
51
+ # Deserializes given Ruby Hash into Model object.
52
+ # @param object [Hash] Ruby Hash object to deserialize.
53
+ # @return [UsageListResult] Deserialized object.
54
+ #
55
+ def self.deserialize_object(object)
56
+ return if object.nil?
57
+ output_object = UsageListResult.new
58
+
59
+ deserialized_property = object['value']
60
+ unless deserialized_property.nil?
61
+ deserializedArray = [];
62
+ deserialized_property.each do |element1|
63
+ unless element1.nil?
64
+ element1 = Usage.deserialize_object(element1)
65
+ end
66
+ deserializedArray.push(element1);
67
+ end
68
+ deserialized_property = deserializedArray;
69
+ end
70
+ output_object.value = deserialized_property
71
+
72
+ output_object.validate
73
+
74
+ output_object
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # The Usage Names.
10
+ #
11
+ class UsageName
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] Gets a string describing the resource name.
16
+ attr_accessor :value
17
+
18
+ # @return [String] Gets a localized string describing the resource name.
19
+ attr_accessor :localized_value
20
+
21
+ #
22
+ # Validate the object. Throws ValidationError if validation fails.
23
+ #
24
+ def validate
25
+ # Nothing to validate
26
+ end
27
+
28
+ #
29
+ # Serializes given Model object into Ruby Hash.
30
+ # @param object Model object to serialize.
31
+ # @return [Hash] Serialized object in form of Ruby Hash.
32
+ #
33
+ def self.serialize_object(object)
34
+ object.validate
35
+ output_object = {}
36
+
37
+ serialized_property = object.value
38
+ output_object['value'] = serialized_property unless serialized_property.nil?
39
+
40
+ serialized_property = object.localized_value
41
+ output_object['localizedValue'] = serialized_property unless serialized_property.nil?
42
+
43
+ output_object
44
+ end
45
+
46
+ #
47
+ # Deserializes given Ruby Hash into Model object.
48
+ # @param object [Hash] Ruby Hash object to deserialize.
49
+ # @return [UsageName] Deserialized object.
50
+ #
51
+ def self.deserialize_object(object)
52
+ return if object.nil?
53
+ output_object = UsageName.new
54
+
55
+ deserialized_property = object['value']
56
+ output_object.value = deserialized_property
57
+
58
+ deserialized_property = object['localizedValue']
59
+ output_object.localized_value = deserialized_property
60
+
61
+ output_object.validate
62
+
63
+ output_object
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ module Models
8
+ #
9
+ # Defines values for UsageUnit
10
+ #
11
+ module UsageUnit
12
+ Count = "Count"
13
+ Bytes = "Bytes"
14
+ Seconds = "Seconds"
15
+ Percent = "Percent"
16
+ CountsPerSecond = "CountsPerSecond"
17
+ BytesPerSecond = "BytesPerSecond"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+ # Licensed under the MIT License. See License.txt in the project root for license information.
3
+
4
+ module Azure end
5
+ module Azure::ARM end
6
+ module Azure::ARM::Storage end
@@ -0,0 +1,1105 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Storage
7
+ #
8
+ # StorageAccounts
9
+ #
10
+ class StorageAccounts
11
+ include Azure::ARM::Storage::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the StorageAccounts class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return reference to the StorageManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Checks that account name is valid and is not in use.
27
+ # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name
28
+ # of the storage account within the specified resource group. Storage account
29
+ # names must be between 3 and 24 characters in length and use numbers and
30
+ # lower-case letters only.
31
+ # @param [Hash{String => String}] The hash of custom headers need to be
32
+ # applied to HTTP request.
33
+ #
34
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
35
+ # response.
36
+ #
37
+ def check_name_availability(account_name, custom_headers = nil)
38
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
39
+ account_name.validate unless account_name.nil?
40
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
41
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
42
+ # Construct URL
43
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"
44
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
45
+ url = URI.join(@client.base_url, path)
46
+ properties = {}
47
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
48
+ unless url.query.nil?
49
+ url.query.split('&').each do |url_item|
50
+ url_items_parts = url_item.split('=')
51
+ properties[url_items_parts[0]] = url_items_parts[1]
52
+ end
53
+ end
54
+ properties.reject!{ |key, value| value.nil? }
55
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
56
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
57
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
58
+ url = URI.parse(corrected_url)
59
+
60
+ connection = Faraday.new(:url => url) do |faraday|
61
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
62
+ faraday.use :cookie_jar
63
+ faraday.adapter Faraday.default_adapter
64
+ end
65
+ request_headers = Hash.new
66
+
67
+ # Set Headers
68
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
69
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
70
+
71
+ unless custom_headers.nil?
72
+ custom_headers.each do |key, value|
73
+ request_headers[key] = value
74
+ end
75
+ end
76
+
77
+ # Serialize Request
78
+ request_headers['Content-Type'] = 'application/json'
79
+ unless account_name.nil?
80
+ account_name = StorageAccountCheckNameAvailabilityParameters.serialize_object(account_name)
81
+ end
82
+ request_content = JSON.generate(account_name, quirks_mode: true)
83
+
84
+ # Send Request
85
+ promise = Concurrent::Promise.new do
86
+ connection.post do |request|
87
+ request.headers = request_headers
88
+ request.body = request_content
89
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
90
+ end
91
+ end
92
+
93
+ promise = promise.then do |http_response|
94
+ status_code = http_response.status
95
+ response_content = http_response.body
96
+ unless (status_code == 200)
97
+ error_model = JSON.load(response_content)
98
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
99
+ end
100
+
101
+ # Create Result
102
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
103
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
104
+ # Deserialize Response
105
+ if status_code == 200
106
+ begin
107
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
108
+ unless parsed_response.nil?
109
+ parsed_response = CheckNameAvailabilityResult.deserialize_object(parsed_response)
110
+ end
111
+ result.body = parsed_response
112
+ rescue Exception => e
113
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
114
+ end
115
+ end
116
+
117
+ result
118
+ end
119
+
120
+ promise.execute
121
+ end
122
+
123
+ #
124
+ # Asynchronously creates a new storage account with the specified parameters.
125
+ # Existing accounts cannot be updated with this API and should instead use
126
+ # the Update Storage Account API. If an account is already created and
127
+ # subsequent PUT request is issued with exact same set of properties, then
128
+ # HTTP 200 would be returned.
129
+ # @param resource_group_name [String] The name of the resource group within
130
+ # the user’s subscription.
131
+ # @param account_name [String] The name of the storage account within the
132
+ # specified resource group. Storage account names must be between 3 and 24
133
+ # characters in length and use numbers and lower-case letters only.
134
+ # @param parameters [StorageAccountCreateParameters] The parameters to provide
135
+ # for the created account.
136
+ # @param @client.api_version [String] Client Api Version.
137
+ # @param @client.subscription_id [String] Gets subscription credentials which
138
+ # uniquely identify Microsoft Azure subscription. The subscription ID forms
139
+ # part of the URI for every service call.
140
+ # @param @client.accept_language [String] Gets or sets the preferred language
141
+ # for the response.
142
+ #
143
+ # @return [Concurrent::Promise] promise which provides async access to http
144
+ # response.
145
+ #
146
+ def create(resource_group_name, account_name, parameters, custom_headers = nil)
147
+ # Send request
148
+ promise = begin_create(resource_group_name, account_name, parameters, custom_headers)
149
+
150
+ promise = promise.then do |response|
151
+ # Defining deserialization method.
152
+ deserialize_method = lambda do |parsed_response|
153
+ unless parsed_response.nil?
154
+ parsed_response = StorageAccount.deserialize_object(parsed_response)
155
+ end
156
+ end
157
+
158
+ # Waiting for response.
159
+ @client.get_put_operation_result(response, custom_headers, deserialize_method)
160
+ end
161
+
162
+ promise
163
+ end
164
+
165
+ #
166
+ # Asynchronously creates a new storage account with the specified parameters.
167
+ # Existing accounts cannot be updated with this API and should instead use
168
+ # the Update Storage Account API. If an account is already created and
169
+ # subsequent PUT request is issued with exact same set of properties, then
170
+ # HTTP 200 would be returned.
171
+ # @param resource_group_name [String] The name of the resource group within
172
+ # the user’s subscription.
173
+ # @param account_name [String] The name of the storage account within the
174
+ # specified resource group. Storage account names must be between 3 and 24
175
+ # characters in length and use numbers and lower-case letters only.
176
+ # @param parameters [StorageAccountCreateParameters] The parameters to provide
177
+ # for the created account.
178
+ # @param [Hash{String => String}] The hash of custom headers need to be
179
+ # applied to HTTP request.
180
+ #
181
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
182
+ # response.
183
+ #
184
+ def begin_create(resource_group_name, account_name, parameters, custom_headers = nil)
185
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
186
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
187
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
188
+ parameters.validate unless parameters.nil?
189
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
190
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
191
+ # Construct URL
192
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
193
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
194
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
195
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
196
+ url = URI.join(@client.base_url, path)
197
+ properties = {}
198
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
199
+ unless url.query.nil?
200
+ url.query.split('&').each do |url_item|
201
+ url_items_parts = url_item.split('=')
202
+ properties[url_items_parts[0]] = url_items_parts[1]
203
+ end
204
+ end
205
+ properties.reject!{ |key, value| value.nil? }
206
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
207
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
208
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
209
+ url = URI.parse(corrected_url)
210
+
211
+ connection = Faraday.new(:url => url) do |faraday|
212
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
213
+ faraday.use :cookie_jar
214
+ faraday.adapter Faraday.default_adapter
215
+ end
216
+ request_headers = Hash.new
217
+
218
+ # Set Headers
219
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
220
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
221
+
222
+ unless custom_headers.nil?
223
+ custom_headers.each do |key, value|
224
+ request_headers[key] = value
225
+ end
226
+ end
227
+
228
+ # Serialize Request
229
+ request_headers['Content-Type'] = 'application/json'
230
+ unless parameters.nil?
231
+ parameters = StorageAccountCreateParameters.serialize_object(parameters)
232
+ end
233
+ request_content = JSON.generate(parameters, quirks_mode: true)
234
+
235
+ # Send Request
236
+ promise = Concurrent::Promise.new do
237
+ connection.put do |request|
238
+ request.headers = request_headers
239
+ request.body = request_content
240
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
241
+ end
242
+ end
243
+
244
+ promise = promise.then do |http_response|
245
+ status_code = http_response.status
246
+ response_content = http_response.body
247
+ unless (status_code == 200 || status_code == 202)
248
+ error_model = JSON.load(response_content)
249
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
250
+ end
251
+
252
+ # Create Result
253
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
254
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
255
+ # Deserialize Response
256
+ if status_code == 200
257
+ begin
258
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
259
+ unless parsed_response.nil?
260
+ parsed_response = StorageAccount.deserialize_object(parsed_response)
261
+ end
262
+ result.body = parsed_response
263
+ rescue Exception => e
264
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
265
+ end
266
+ end
267
+
268
+ result
269
+ end
270
+
271
+ promise.execute
272
+ end
273
+
274
+ #
275
+ # Deletes a storage account in Microsoft Azure.
276
+ # @param resource_group_name [String] The name of the resource group within
277
+ # the user’s subscription.
278
+ # @param account_name [String] The name of the storage account within the
279
+ # specified resource group. Storage account names must be between 3 and 24
280
+ # characters in length and use numbers and lower-case letters only.
281
+ # @param [Hash{String => String}] The hash of custom headers need to be
282
+ # applied to HTTP request.
283
+ #
284
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
285
+ # response.
286
+ #
287
+ def delete(resource_group_name, account_name, custom_headers = nil)
288
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
289
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
290
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
291
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
292
+ # Construct URL
293
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
294
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
295
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
296
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
297
+ url = URI.join(@client.base_url, path)
298
+ properties = {}
299
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
300
+ unless url.query.nil?
301
+ url.query.split('&').each do |url_item|
302
+ url_items_parts = url_item.split('=')
303
+ properties[url_items_parts[0]] = url_items_parts[1]
304
+ end
305
+ end
306
+ properties.reject!{ |key, value| value.nil? }
307
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
308
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
309
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
310
+ url = URI.parse(corrected_url)
311
+
312
+ connection = Faraday.new(:url => url) do |faraday|
313
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
314
+ faraday.use :cookie_jar
315
+ faraday.adapter Faraday.default_adapter
316
+ end
317
+ request_headers = Hash.new
318
+
319
+ # Set Headers
320
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
321
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
322
+
323
+ unless custom_headers.nil?
324
+ custom_headers.each do |key, value|
325
+ request_headers[key] = value
326
+ end
327
+ end
328
+
329
+ # Send Request
330
+ promise = Concurrent::Promise.new do
331
+ connection.delete do |request|
332
+ request.headers = request_headers
333
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
334
+ end
335
+ end
336
+
337
+ promise = promise.then do |http_response|
338
+ status_code = http_response.status
339
+ response_content = http_response.body
340
+ unless (status_code == 200 || status_code == 204)
341
+ fail MsRestAzure::AzureOperationError.new(connection, http_response)
342
+ end
343
+
344
+ # Create Result
345
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
346
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
347
+
348
+ result
349
+ end
350
+
351
+ promise.execute
352
+ end
353
+
354
+ #
355
+ # Returns the properties for the specified storage account including but not
356
+ # limited to name, account type, location, and account status. The ListKeys
357
+ # operation should be used to retrieve storage keys.
358
+ # @param resource_group_name [String] The name of the resource group within
359
+ # the user’s subscription.
360
+ # @param account_name [String] The name of the storage account within the
361
+ # specified resource group. Storage account names must be between 3 and 24
362
+ # characters in length and use numbers and lower-case letters only.
363
+ # @param [Hash{String => String}] The hash of custom headers need to be
364
+ # applied to HTTP request.
365
+ #
366
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
367
+ # response.
368
+ #
369
+ def get_properties(resource_group_name, account_name, custom_headers = nil)
370
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
371
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
372
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
373
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
374
+ # Construct URL
375
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
376
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
377
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
378
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
379
+ url = URI.join(@client.base_url, path)
380
+ properties = {}
381
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
382
+ unless url.query.nil?
383
+ url.query.split('&').each do |url_item|
384
+ url_items_parts = url_item.split('=')
385
+ properties[url_items_parts[0]] = url_items_parts[1]
386
+ end
387
+ end
388
+ properties.reject!{ |key, value| value.nil? }
389
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
390
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
391
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
392
+ url = URI.parse(corrected_url)
393
+
394
+ connection = Faraday.new(:url => url) do |faraday|
395
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
396
+ faraday.use :cookie_jar
397
+ faraday.adapter Faraday.default_adapter
398
+ end
399
+ request_headers = Hash.new
400
+
401
+ # Set Headers
402
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
403
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
404
+
405
+ unless custom_headers.nil?
406
+ custom_headers.each do |key, value|
407
+ request_headers[key] = value
408
+ end
409
+ end
410
+
411
+ # Send Request
412
+ promise = Concurrent::Promise.new do
413
+ connection.get do |request|
414
+ request.headers = request_headers
415
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
416
+ end
417
+ end
418
+
419
+ promise = promise.then do |http_response|
420
+ status_code = http_response.status
421
+ response_content = http_response.body
422
+ unless (status_code == 200)
423
+ error_model = JSON.load(response_content)
424
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
425
+ end
426
+
427
+ # Create Result
428
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
429
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
430
+ # Deserialize Response
431
+ if status_code == 200
432
+ begin
433
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
434
+ unless parsed_response.nil?
435
+ parsed_response = StorageAccount.deserialize_object(parsed_response)
436
+ end
437
+ result.body = parsed_response
438
+ rescue Exception => e
439
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
440
+ end
441
+ end
442
+
443
+ result
444
+ end
445
+
446
+ promise.execute
447
+ end
448
+
449
+ #
450
+ # Updates the account type or tags for a storage account. It can also be used
451
+ # to add a custom domain (note that custom domains cannot be added via the
452
+ # Create operation). Only one custom domain is supported per storage account.
453
+ # This API can only be used to update one of tags, accountType, or
454
+ # customDomain per call. To update multiple of these properties, call the API
455
+ # multiple times with one change per call. This call does not change the
456
+ # storage keys for the account. If you want to change storage account keys,
457
+ # use the RegenerateKey operation. The location and name of the storage
458
+ # account cannot be changed after creation.
459
+ # @param resource_group_name [String] The name of the resource group within
460
+ # the user’s subscription.
461
+ # @param account_name [String] The name of the storage account within the
462
+ # specified resource group. Storage account names must be between 3 and 24
463
+ # characters in length and use numbers and lower-case letters only.
464
+ # @param parameters [StorageAccountUpdateParameters] The parameters to update
465
+ # on the account. Note that only one property can be changed at a time using
466
+ # this API.
467
+ # @param [Hash{String => String}] The hash of custom headers need to be
468
+ # applied to HTTP request.
469
+ #
470
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
471
+ # response.
472
+ #
473
+ def update(resource_group_name, account_name, parameters, custom_headers = nil)
474
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
475
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
476
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
477
+ parameters.validate unless parameters.nil?
478
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
479
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
480
+ # Construct URL
481
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
482
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
483
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
484
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
485
+ url = URI.join(@client.base_url, path)
486
+ properties = {}
487
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
488
+ unless url.query.nil?
489
+ url.query.split('&').each do |url_item|
490
+ url_items_parts = url_item.split('=')
491
+ properties[url_items_parts[0]] = url_items_parts[1]
492
+ end
493
+ end
494
+ properties.reject!{ |key, value| value.nil? }
495
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
496
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
497
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
498
+ url = URI.parse(corrected_url)
499
+
500
+ connection = Faraday.new(:url => url) do |faraday|
501
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
502
+ faraday.use :cookie_jar
503
+ faraday.adapter Faraday.default_adapter
504
+ end
505
+ request_headers = Hash.new
506
+
507
+ # Set Headers
508
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
509
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
510
+
511
+ unless custom_headers.nil?
512
+ custom_headers.each do |key, value|
513
+ request_headers[key] = value
514
+ end
515
+ end
516
+
517
+ # Serialize Request
518
+ request_headers['Content-Type'] = 'application/json'
519
+ unless parameters.nil?
520
+ parameters = StorageAccountUpdateParameters.serialize_object(parameters)
521
+ end
522
+ request_content = JSON.generate(parameters, quirks_mode: true)
523
+
524
+ # Send Request
525
+ promise = Concurrent::Promise.new do
526
+ connection.patch do |request|
527
+ request.headers = request_headers
528
+ request.body = request_content
529
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
530
+ end
531
+ end
532
+
533
+ promise = promise.then do |http_response|
534
+ status_code = http_response.status
535
+ response_content = http_response.body
536
+ unless (status_code == 200)
537
+ error_model = JSON.load(response_content)
538
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
539
+ end
540
+
541
+ # Create Result
542
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
543
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
544
+ # Deserialize Response
545
+ if status_code == 200
546
+ begin
547
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
548
+ unless parsed_response.nil?
549
+ parsed_response = StorageAccount.deserialize_object(parsed_response)
550
+ end
551
+ result.body = parsed_response
552
+ rescue Exception => e
553
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
554
+ end
555
+ end
556
+
557
+ result
558
+ end
559
+
560
+ promise.execute
561
+ end
562
+
563
+ #
564
+ # Lists the access keys for the specified storage account.
565
+ # @param resource_group_name [String] The name of the resource group.
566
+ # @param account_name [String] The name of the storage account.
567
+ # @param [Hash{String => String}] The hash of custom headers need to be
568
+ # applied to HTTP request.
569
+ #
570
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
571
+ # response.
572
+ #
573
+ def list_keys(resource_group_name, account_name, custom_headers = nil)
574
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
575
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
576
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
577
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
578
+ # Construct URL
579
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"
580
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
581
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
582
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
583
+ url = URI.join(@client.base_url, path)
584
+ properties = {}
585
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
586
+ unless url.query.nil?
587
+ url.query.split('&').each do |url_item|
588
+ url_items_parts = url_item.split('=')
589
+ properties[url_items_parts[0]] = url_items_parts[1]
590
+ end
591
+ end
592
+ properties.reject!{ |key, value| value.nil? }
593
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
594
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
595
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
596
+ url = URI.parse(corrected_url)
597
+
598
+ connection = Faraday.new(:url => url) do |faraday|
599
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
600
+ faraday.use :cookie_jar
601
+ faraday.adapter Faraday.default_adapter
602
+ end
603
+ request_headers = Hash.new
604
+
605
+ # Set Headers
606
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
607
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
608
+
609
+ unless custom_headers.nil?
610
+ custom_headers.each do |key, value|
611
+ request_headers[key] = value
612
+ end
613
+ end
614
+
615
+ # Send Request
616
+ promise = Concurrent::Promise.new do
617
+ connection.post do |request|
618
+ request.headers = request_headers
619
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
620
+ end
621
+ end
622
+
623
+ promise = promise.then do |http_response|
624
+ status_code = http_response.status
625
+ response_content = http_response.body
626
+ unless (status_code == 200)
627
+ error_model = JSON.load(response_content)
628
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
629
+ end
630
+
631
+ # Create Result
632
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
633
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
634
+ # Deserialize Response
635
+ if status_code == 200
636
+ begin
637
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
638
+ unless parsed_response.nil?
639
+ parsed_response = StorageAccountKeys.deserialize_object(parsed_response)
640
+ end
641
+ result.body = parsed_response
642
+ rescue Exception => e
643
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
644
+ end
645
+ end
646
+
647
+ result
648
+ end
649
+
650
+ promise.execute
651
+ end
652
+
653
+ #
654
+ # Lists all the storage accounts available under the subscription. Note that
655
+ # storage keys are not returned; use the ListKeys operation for this.
656
+ # @param [Hash{String => String}] The hash of custom headers need to be
657
+ # applied to HTTP request.
658
+ #
659
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
660
+ # response.
661
+ #
662
+ def list(custom_headers = nil)
663
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
664
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
665
+ # Construct URL
666
+ path = "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"
667
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
668
+ url = URI.join(@client.base_url, path)
669
+ properties = {}
670
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
671
+ unless url.query.nil?
672
+ url.query.split('&').each do |url_item|
673
+ url_items_parts = url_item.split('=')
674
+ properties[url_items_parts[0]] = url_items_parts[1]
675
+ end
676
+ end
677
+ properties.reject!{ |key, value| value.nil? }
678
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
679
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
680
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
681
+ url = URI.parse(corrected_url)
682
+
683
+ connection = Faraday.new(:url => url) do |faraday|
684
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
685
+ faraday.use :cookie_jar
686
+ faraday.adapter Faraday.default_adapter
687
+ end
688
+ request_headers = Hash.new
689
+
690
+ # Set Headers
691
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
692
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
693
+
694
+ unless custom_headers.nil?
695
+ custom_headers.each do |key, value|
696
+ request_headers[key] = value
697
+ end
698
+ end
699
+
700
+ # Send Request
701
+ promise = Concurrent::Promise.new do
702
+ connection.get do |request|
703
+ request.headers = request_headers
704
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
705
+ end
706
+ end
707
+
708
+ promise = promise.then do |http_response|
709
+ status_code = http_response.status
710
+ response_content = http_response.body
711
+ unless (status_code == 200)
712
+ error_model = JSON.load(response_content)
713
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
714
+ end
715
+
716
+ # Create Result
717
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
718
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
719
+ # Deserialize Response
720
+ if status_code == 200
721
+ begin
722
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
723
+ unless parsed_response.nil?
724
+ parsed_response = StorageAccountListResult.deserialize_object(parsed_response)
725
+ end
726
+ result.body = parsed_response
727
+ rescue Exception => e
728
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
729
+ end
730
+ end
731
+
732
+ result
733
+ end
734
+
735
+ promise.execute
736
+ end
737
+
738
+ #
739
+ # Lists all the storage accounts available under the given resource group.
740
+ # Note that storage keys are not returned; use the ListKeys operation for
741
+ # this.
742
+ # @param resource_group_name [String] The name of the resource group within
743
+ # the user’s subscription.
744
+ # @param [Hash{String => String}] The hash of custom headers need to be
745
+ # applied to HTTP request.
746
+ #
747
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
748
+ # response.
749
+ #
750
+ def list_by_resource_group(resource_group_name, custom_headers = nil)
751
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
752
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
753
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
754
+ # Construct URL
755
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"
756
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
757
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
758
+ url = URI.join(@client.base_url, path)
759
+ properties = {}
760
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
761
+ unless url.query.nil?
762
+ url.query.split('&').each do |url_item|
763
+ url_items_parts = url_item.split('=')
764
+ properties[url_items_parts[0]] = url_items_parts[1]
765
+ end
766
+ end
767
+ properties.reject!{ |key, value| value.nil? }
768
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
769
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
770
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
771
+ url = URI.parse(corrected_url)
772
+
773
+ connection = Faraday.new(:url => url) do |faraday|
774
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
775
+ faraday.use :cookie_jar
776
+ faraday.adapter Faraday.default_adapter
777
+ end
778
+ request_headers = Hash.new
779
+
780
+ # Set Headers
781
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
782
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
783
+
784
+ unless custom_headers.nil?
785
+ custom_headers.each do |key, value|
786
+ request_headers[key] = value
787
+ end
788
+ end
789
+
790
+ # Send Request
791
+ promise = Concurrent::Promise.new do
792
+ connection.get do |request|
793
+ request.headers = request_headers
794
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
795
+ end
796
+ end
797
+
798
+ promise = promise.then do |http_response|
799
+ status_code = http_response.status
800
+ response_content = http_response.body
801
+ unless (status_code == 200)
802
+ error_model = JSON.load(response_content)
803
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
804
+ end
805
+
806
+ # Create Result
807
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
808
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
809
+ # Deserialize Response
810
+ if status_code == 200
811
+ begin
812
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
813
+ unless parsed_response.nil?
814
+ parsed_response = StorageAccountListResult.deserialize_object(parsed_response)
815
+ end
816
+ result.body = parsed_response
817
+ rescue Exception => e
818
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
819
+ end
820
+ end
821
+
822
+ result
823
+ end
824
+
825
+ promise.execute
826
+ end
827
+
828
+ #
829
+ # Regenerates the access keys for the specified storage account.
830
+ # @param resource_group_name [String] The name of the resource group within
831
+ # the user’s subscription.
832
+ # @param account_name [String] The name of the storage account within the
833
+ # specified resource group. Storage account names must be between 3 and 24
834
+ # characters in length and use numbers and lower-case letters only.
835
+ # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name
836
+ # of the key which should be regenerated.
837
+ # @param [Hash{String => String}] The hash of custom headers need to be
838
+ # applied to HTTP request.
839
+ #
840
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
841
+ # response.
842
+ #
843
+ def regenerate_key(resource_group_name, account_name, regenerate_key, custom_headers = nil)
844
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
845
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
846
+ fail ArgumentError, 'regenerate_key is nil' if regenerate_key.nil?
847
+ regenerate_key.validate unless regenerate_key.nil?
848
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
849
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
850
+ # Construct URL
851
+ path = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"
852
+ path['{resourceGroupName}'] = ERB::Util.url_encode(resource_group_name) if path.include?('{resourceGroupName}')
853
+ path['{accountName}'] = ERB::Util.url_encode(account_name) if path.include?('{accountName}')
854
+ path['{subscriptionId}'] = ERB::Util.url_encode(@client.subscription_id) if path.include?('{subscriptionId}')
855
+ url = URI.join(@client.base_url, path)
856
+ properties = {}
857
+ properties['api-version'] = ERB::Util.url_encode(@client.api_version.to_s) unless @client.api_version.nil?
858
+ unless url.query.nil?
859
+ url.query.split('&').each do |url_item|
860
+ url_items_parts = url_item.split('=')
861
+ properties[url_items_parts[0]] = url_items_parts[1]
862
+ end
863
+ end
864
+ properties.reject!{ |key, value| value.nil? }
865
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
866
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
867
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
868
+ url = URI.parse(corrected_url)
869
+
870
+ connection = Faraday.new(:url => url) do |faraday|
871
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
872
+ faraday.use :cookie_jar
873
+ faraday.adapter Faraday.default_adapter
874
+ end
875
+ request_headers = Hash.new
876
+
877
+ # Set Headers
878
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
879
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
880
+
881
+ unless custom_headers.nil?
882
+ custom_headers.each do |key, value|
883
+ request_headers[key] = value
884
+ end
885
+ end
886
+
887
+ # Serialize Request
888
+ request_headers['Content-Type'] = 'application/json'
889
+ unless regenerate_key.nil?
890
+ regenerate_key = StorageAccountRegenerateKeyParameters.serialize_object(regenerate_key)
891
+ end
892
+ request_content = JSON.generate(regenerate_key, quirks_mode: true)
893
+
894
+ # Send Request
895
+ promise = Concurrent::Promise.new do
896
+ connection.post do |request|
897
+ request.headers = request_headers
898
+ request.body = request_content
899
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
900
+ end
901
+ end
902
+
903
+ promise = promise.then do |http_response|
904
+ status_code = http_response.status
905
+ response_content = http_response.body
906
+ unless (status_code == 200)
907
+ error_model = JSON.load(response_content)
908
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
909
+ end
910
+
911
+ # Create Result
912
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
913
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
914
+ # Deserialize Response
915
+ if status_code == 200
916
+ begin
917
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
918
+ unless parsed_response.nil?
919
+ parsed_response = StorageAccountKeys.deserialize_object(parsed_response)
920
+ end
921
+ result.body = parsed_response
922
+ rescue Exception => e
923
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
924
+ end
925
+ end
926
+
927
+ result
928
+ end
929
+
930
+ promise.execute
931
+ end
932
+
933
+ #
934
+ # Lists all the storage accounts available under the subscription. Note that
935
+ # storage keys are not returned; use the ListKeys operation for this.
936
+ # @param next_page_link [String] The NextLink from the previous successful
937
+ # call to List operation.
938
+ # @param [Hash{String => String}] The hash of custom headers need to be
939
+ # applied to HTTP request.
940
+ #
941
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
942
+ # response.
943
+ #
944
+ def list_next(next_page_link, custom_headers = nil)
945
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
946
+ # Construct URL
947
+ path = "{nextLink}"
948
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
949
+ url = URI.parse(path)
950
+ properties = {}
951
+ unless url.query.nil?
952
+ url.query.split('&').each do |url_item|
953
+ url_items_parts = url_item.split('=')
954
+ properties[url_items_parts[0]] = url_items_parts[1]
955
+ end
956
+ end
957
+ properties.reject!{ |key, value| value.nil? }
958
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
959
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
960
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
961
+ url = URI.parse(corrected_url)
962
+
963
+ connection = Faraday.new(:url => url) do |faraday|
964
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
965
+ faraday.use :cookie_jar
966
+ faraday.adapter Faraday.default_adapter
967
+ end
968
+ request_headers = Hash.new
969
+
970
+ # Set Headers
971
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
972
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
973
+
974
+ unless custom_headers.nil?
975
+ custom_headers.each do |key, value|
976
+ request_headers[key] = value
977
+ end
978
+ end
979
+
980
+ # Send Request
981
+ promise = Concurrent::Promise.new do
982
+ connection.get do |request|
983
+ request.headers = request_headers
984
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
985
+ end
986
+ end
987
+
988
+ promise = promise.then do |http_response|
989
+ status_code = http_response.status
990
+ response_content = http_response.body
991
+ unless (status_code == 200)
992
+ error_model = JSON.load(response_content)
993
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
994
+ end
995
+
996
+ # Create Result
997
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
998
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
999
+ # Deserialize Response
1000
+ if status_code == 200
1001
+ begin
1002
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
1003
+ unless parsed_response.nil?
1004
+ parsed_response = StorageAccountListResult.deserialize_object(parsed_response)
1005
+ end
1006
+ result.body = parsed_response
1007
+ rescue Exception => e
1008
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
1009
+ end
1010
+ end
1011
+
1012
+ result
1013
+ end
1014
+
1015
+ promise.execute
1016
+ end
1017
+
1018
+ #
1019
+ # Lists all the storage accounts available under the given resource group.
1020
+ # Note that storage keys are not returned; use the ListKeys operation for
1021
+ # this.
1022
+ # @param next_page_link [String] The NextLink from the previous successful
1023
+ # call to List operation.
1024
+ # @param [Hash{String => String}] The hash of custom headers need to be
1025
+ # applied to HTTP request.
1026
+ #
1027
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
1028
+ # response.
1029
+ #
1030
+ def list_by_resource_group_next(next_page_link, custom_headers = nil)
1031
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1032
+ # Construct URL
1033
+ path = "{nextLink}"
1034
+ path['{nextLink}'] = next_page_link if path.include?('{nextLink}')
1035
+ url = URI.parse(path)
1036
+ properties = {}
1037
+ unless url.query.nil?
1038
+ url.query.split('&').each do |url_item|
1039
+ url_items_parts = url_item.split('=')
1040
+ properties[url_items_parts[0]] = url_items_parts[1]
1041
+ end
1042
+ end
1043
+ properties.reject!{ |key, value| value.nil? }
1044
+ url.query = properties.map{ |key, value| "#{key}=#{value}" }.compact.join('&')
1045
+ fail URI::Error unless url.to_s =~ /\A#{URI::regexp}\z/
1046
+ corrected_url = url.to_s.gsub(/([^:])\/\//, '\1/')
1047
+ url = URI.parse(corrected_url)
1048
+
1049
+ connection = Faraday.new(:url => url) do |faraday|
1050
+ faraday.use MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02
1051
+ faraday.use :cookie_jar
1052
+ faraday.adapter Faraday.default_adapter
1053
+ end
1054
+ request_headers = Hash.new
1055
+
1056
+ # Set Headers
1057
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1058
+ request_headers["accept-language"] = @client.accept_language unless @client.accept_language.nil?
1059
+
1060
+ unless custom_headers.nil?
1061
+ custom_headers.each do |key, value|
1062
+ request_headers[key] = value
1063
+ end
1064
+ end
1065
+
1066
+ # Send Request
1067
+ promise = Concurrent::Promise.new do
1068
+ connection.get do |request|
1069
+ request.headers = request_headers
1070
+ @client.credentials.sign_request(request) unless @client.credentials.nil?
1071
+ end
1072
+ end
1073
+
1074
+ promise = promise.then do |http_response|
1075
+ status_code = http_response.status
1076
+ response_content = http_response.body
1077
+ unless (status_code == 200)
1078
+ error_model = JSON.load(response_content)
1079
+ fail MsRestAzure::AzureOperationError.new(connection, http_response, error_model)
1080
+ end
1081
+
1082
+ # Create Result
1083
+ result = MsRestAzure::AzureOperationResponse.new(connection, http_response)
1084
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1085
+ # Deserialize Response
1086
+ if status_code == 200
1087
+ begin
1088
+ parsed_response = JSON.load(response_content) unless response_content.to_s.empty?
1089
+ unless parsed_response.nil?
1090
+ parsed_response = StorageAccountListResult.deserialize_object(parsed_response)
1091
+ end
1092
+ result.body = parsed_response
1093
+ rescue Exception => e
1094
+ fail MsRest::DeserializationError.new("Error occured in deserializing the response", e.message, e.backtrace, response_content)
1095
+ end
1096
+ end
1097
+
1098
+ result
1099
+ end
1100
+
1101
+ promise.execute
1102
+ end
1103
+
1104
+ end
1105
+ end