azure_mgmt_subscriptions 0.18.1 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2016-06-01/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  3. data/lib/2017-11-01-preview/generated/azure_mgmt_subscriptions/subscription_definitions_client.rb +1 -1
  4. data/lib/2018-03-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  5. data/lib/2018-11-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  6. data/lib/2019-03-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  7. data/lib/2019-06-01/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  8. data/lib/2019-11-01/generated/azure_mgmt_subscriptions.rb +48 -0
  9. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/location.rb +109 -0
  10. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/location_list_result.rb +55 -0
  11. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/location_metadata.rb +129 -0
  12. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/managed_by_tenant.rb +47 -0
  13. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/operation.rb +58 -0
  14. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/operation_display.rb +80 -0
  15. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/operation_list_result.rb +100 -0
  16. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/paired_region.rb +72 -0
  17. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/region_category.rb +16 -0
  18. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/region_type.rb +16 -0
  19. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/spending_limit.rb +17 -0
  20. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/subscription.rb +164 -0
  21. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/subscription_list_result.rb +98 -0
  22. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/subscription_policies.rb +76 -0
  23. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/subscription_state.rb +19 -0
  24. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/tenant_category.rb +17 -0
  25. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/tenant_id_description.rb +131 -0
  26. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/models/tenant_list_result.rb +98 -0
  27. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/module_definition.rb +9 -0
  28. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/operations.rb +222 -0
  29. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/subscription_client.rb +136 -0
  30. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/subscriptions.rb +409 -0
  31. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/tenants.rb +222 -0
  32. data/lib/azure_mgmt_subscriptions.rb +1 -0
  33. data/lib/profiles/latest/modules/subscriptions_profile_module.rb +62 -34
  34. data/lib/version.rb +1 -1
  35. metadata +26 -2
@@ -0,0 +1,222 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Subscriptions::Mgmt::V2019_11_01
7
+ #
8
+ # All resource groups and resources exist within subscriptions. These
9
+ # operation enable you get information about your subscriptions and tenants.
10
+ # A tenant is a dedicated instance of Azure Active Directory (Azure AD) for
11
+ # your organization.
12
+ #
13
+ class Operations
14
+ include MsRestAzure
15
+
16
+ #
17
+ # Creates and initializes a new instance of the Operations class.
18
+ # @param client service class for accessing basic functionality.
19
+ #
20
+ def initialize(client)
21
+ @client = client
22
+ end
23
+
24
+ # @return [SubscriptionClient] reference to the SubscriptionClient
25
+ attr_reader :client
26
+
27
+ #
28
+ # Lists all of the available Microsoft.Resources REST API operations.
29
+ #
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
32
+ #
33
+ # @return [Array<Operation>] operation results.
34
+ #
35
+ def list(custom_headers:nil)
36
+ first_page = list_as_lazy(custom_headers:custom_headers)
37
+ first_page.get_all_items
38
+ end
39
+
40
+ #
41
+ # Lists all of the available Microsoft.Resources REST API operations.
42
+ #
43
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
44
+ # will be added to the HTTP request.
45
+ #
46
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
47
+ #
48
+ def list_with_http_info(custom_headers:nil)
49
+ list_async(custom_headers:custom_headers).value!
50
+ end
51
+
52
+ #
53
+ # Lists all of the available Microsoft.Resources REST API operations.
54
+ #
55
+ # @param [Hash{String => String}] A hash of custom headers that will be added
56
+ # to the HTTP request.
57
+ #
58
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
59
+ #
60
+ def list_async(custom_headers:nil)
61
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
62
+
63
+
64
+ request_headers = {}
65
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
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
+ path_template = 'providers/Microsoft.Resources/operations'
71
+
72
+ request_url = @base_url || @client.base_url
73
+
74
+ options = {
75
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
76
+ query_params: {'api-version' => @client.api_version},
77
+ headers: request_headers.merge(custom_headers || {}),
78
+ base_url: request_url
79
+ }
80
+ promise = @client.make_request_async(:get, path_template, options)
81
+
82
+ promise = promise.then do |result|
83
+ http_response = result.response
84
+ status_code = http_response.status
85
+ response_content = http_response.body
86
+ unless status_code == 200
87
+ error_model = JSON.load(response_content)
88
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
89
+ end
90
+
91
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
92
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
93
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
94
+ # Deserialize Response
95
+ if status_code == 200
96
+ begin
97
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
98
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::OperationListResult.mapper()
99
+ result.body = @client.deserialize(result_mapper, parsed_response)
100
+ rescue Exception => e
101
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
102
+ end
103
+ end
104
+
105
+ result
106
+ end
107
+
108
+ promise.execute
109
+ end
110
+
111
+ #
112
+ # Lists all of the available Microsoft.Resources REST API operations.
113
+ #
114
+ # @param next_page_link [String] The NextLink from the previous successful call
115
+ # to List operation.
116
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
117
+ # will be added to the HTTP request.
118
+ #
119
+ # @return [OperationListResult] operation results.
120
+ #
121
+ def list_next(next_page_link, custom_headers:nil)
122
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
123
+ response.body unless response.nil?
124
+ end
125
+
126
+ #
127
+ # Lists all of the available Microsoft.Resources REST API operations.
128
+ #
129
+ # @param next_page_link [String] The NextLink from the previous successful call
130
+ # to List operation.
131
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
132
+ # will be added to the HTTP request.
133
+ #
134
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
135
+ #
136
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
137
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
138
+ end
139
+
140
+ #
141
+ # Lists all of the available Microsoft.Resources REST API operations.
142
+ #
143
+ # @param next_page_link [String] The NextLink from the previous successful call
144
+ # to List operation.
145
+ # @param [Hash{String => String}] A hash of custom headers that will be added
146
+ # to the HTTP request.
147
+ #
148
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
149
+ #
150
+ def list_next_async(next_page_link, custom_headers:nil)
151
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
152
+
153
+
154
+ request_headers = {}
155
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
156
+
157
+ # Set Headers
158
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
159
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
160
+ path_template = '{nextLink}'
161
+
162
+ request_url = @base_url || @client.base_url
163
+
164
+ options = {
165
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
166
+ skip_encoding_path_params: {'nextLink' => next_page_link},
167
+ headers: request_headers.merge(custom_headers || {}),
168
+ base_url: request_url
169
+ }
170
+ promise = @client.make_request_async(:get, path_template, options)
171
+
172
+ promise = promise.then do |result|
173
+ http_response = result.response
174
+ status_code = http_response.status
175
+ response_content = http_response.body
176
+ unless status_code == 200
177
+ error_model = JSON.load(response_content)
178
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
179
+ end
180
+
181
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
182
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
183
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
184
+ # Deserialize Response
185
+ if status_code == 200
186
+ begin
187
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
188
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::OperationListResult.mapper()
189
+ result.body = @client.deserialize(result_mapper, parsed_response)
190
+ rescue Exception => e
191
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
192
+ end
193
+ end
194
+
195
+ result
196
+ end
197
+
198
+ promise.execute
199
+ end
200
+
201
+ #
202
+ # Lists all of the available Microsoft.Resources REST API operations.
203
+ #
204
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
205
+ # will be added to the HTTP request.
206
+ #
207
+ # @return [OperationListResult] which provide lazy access to pages of the
208
+ # response.
209
+ #
210
+ def list_as_lazy(custom_headers:nil)
211
+ response = list_async(custom_headers:custom_headers).value!
212
+ unless response.nil?
213
+ page = response.body
214
+ page.next_method = Proc.new do |next_page_link|
215
+ list_next_async(next_page_link, custom_headers:custom_headers)
216
+ end
217
+ page
218
+ end
219
+ end
220
+
221
+ end
222
+ end
@@ -0,0 +1,136 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Subscriptions::Mgmt::V2019_11_01
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class SubscriptionClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_accessor :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials
19
+
20
+ # @return [String] The API version to use for the operation.
21
+ attr_reader :api_version
22
+
23
+ # @return [String] The preferred language for the response.
24
+ attr_accessor :accept_language
25
+
26
+ # @return [Integer] The retry timeout in seconds for Long Running
27
+ # Operations. Default value is 30.
28
+ attr_accessor :long_running_operation_retry_timeout
29
+
30
+ # @return [Boolean] Whether a unique x-ms-client-request-id should be
31
+ # generated. When set to true a unique x-ms-client-request-id value is
32
+ # generated and included in each request. Default is true.
33
+ attr_accessor :generate_client_request_id
34
+
35
+ # @return [Operations] operations
36
+ attr_reader :operations
37
+
38
+ # @return [Subscriptions] subscriptions
39
+ attr_reader :subscriptions
40
+
41
+ # @return [Tenants] tenants
42
+ attr_reader :tenants
43
+
44
+ #
45
+ # Creates initializes a new instance of the SubscriptionClient class.
46
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
47
+ # @param base_url [String] the base URI of the service.
48
+ # @param options [Array] filters to be applied to the HTTP requests.
49
+ #
50
+ def initialize(credentials = nil, base_url = nil, options = nil)
51
+ super(credentials, options)
52
+ @base_url = base_url || 'https://management.azure.com'
53
+
54
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
55
+ @credentials = credentials
56
+
57
+ @operations = Operations.new(self)
58
+ @subscriptions = Subscriptions.new(self)
59
+ @tenants = Tenants.new(self)
60
+ @api_version = '2019-11-01'
61
+ @accept_language = 'en-US'
62
+ @long_running_operation_retry_timeout = 30
63
+ @generate_client_request_id = true
64
+ add_telemetry
65
+ end
66
+
67
+ #
68
+ # Makes a request and returns the body of the response.
69
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
70
+ # @param path [String] the path, relative to {base_url}.
71
+ # @param options [Hash{String=>String}] specifying any request options like :body.
72
+ # @return [Hash{String=>String}] containing the body of the response.
73
+ # Example:
74
+ #
75
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
76
+ # path = "/path"
77
+ # options = {
78
+ # body: request_content,
79
+ # query_params: {'api-version' => '2016-02-01'}
80
+ # }
81
+ # result = @client.make_request(:put, path, options)
82
+ #
83
+ def make_request(method, path, options = {})
84
+ result = make_request_with_http_info(method, path, options)
85
+ result.body unless result.nil?
86
+ end
87
+
88
+ #
89
+ # Makes a request and returns the operation response.
90
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
91
+ # @param path [String] the path, relative to {base_url}.
92
+ # @param options [Hash{String=>String}] specifying any request options like :body.
93
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
94
+ #
95
+ def make_request_with_http_info(method, path, options = {})
96
+ result = make_request_async(method, path, options).value!
97
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
98
+ result
99
+ end
100
+
101
+ #
102
+ # Makes a request asynchronously.
103
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
104
+ # @param path [String] the path, relative to {base_url}.
105
+ # @param options [Hash{String=>String}] specifying any request options like :body.
106
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
107
+ #
108
+ def make_request_async(method, path, options = {})
109
+ fail ArgumentError, 'method is nil' if method.nil?
110
+ fail ArgumentError, 'path is nil' if path.nil?
111
+
112
+ request_url = options[:base_url] || @base_url
113
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
114
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
115
+ end
116
+
117
+ request_headers = @request_headers
118
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
119
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
120
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
121
+
122
+ super(request_url, method, path, options)
123
+ end
124
+
125
+
126
+ private
127
+ #
128
+ # Adds telemetry information.
129
+ #
130
+ def add_telemetry
131
+ sdk_information = 'azure_mgmt_subscriptions'
132
+ sdk_information = "#{sdk_information}/0.18.2"
133
+ add_user_agent_information(sdk_information)
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,409 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Subscriptions::Mgmt::V2019_11_01
7
+ #
8
+ # All resource groups and resources exist within subscriptions. These
9
+ # operation enable you get information about your subscriptions and tenants.
10
+ # A tenant is a dedicated instance of Azure Active Directory (Azure AD) for
11
+ # your organization.
12
+ #
13
+ class Subscriptions
14
+ include MsRestAzure
15
+
16
+ #
17
+ # Creates and initializes a new instance of the Subscriptions class.
18
+ # @param client service class for accessing basic functionality.
19
+ #
20
+ def initialize(client)
21
+ @client = client
22
+ end
23
+
24
+ # @return [SubscriptionClient] reference to the SubscriptionClient
25
+ attr_reader :client
26
+
27
+ #
28
+ # Gets all available geo-locations.
29
+ #
30
+ # This operation provides all the locations that are available for resource
31
+ # providers; however, each resource provider may support a subset of this list.
32
+ #
33
+ # @param subscription_id [String] The ID of the target subscription.
34
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
35
+ # will be added to the HTTP request.
36
+ #
37
+ # @return [LocationListResult] operation results.
38
+ #
39
+ def list_locations(subscription_id, custom_headers:nil)
40
+ response = list_locations_async(subscription_id, custom_headers:custom_headers).value!
41
+ response.body unless response.nil?
42
+ end
43
+
44
+ #
45
+ # Gets all available geo-locations.
46
+ #
47
+ # This operation provides all the locations that are available for resource
48
+ # providers; however, each resource provider may support a subset of this list.
49
+ #
50
+ # @param subscription_id [String] The ID of the target subscription.
51
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
52
+ # will be added to the HTTP request.
53
+ #
54
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
55
+ #
56
+ def list_locations_with_http_info(subscription_id, custom_headers:nil)
57
+ list_locations_async(subscription_id, custom_headers:custom_headers).value!
58
+ end
59
+
60
+ #
61
+ # Gets all available geo-locations.
62
+ #
63
+ # This operation provides all the locations that are available for resource
64
+ # providers; however, each resource provider may support a subset of this list.
65
+ #
66
+ # @param subscription_id [String] The ID of the target subscription.
67
+ # @param [Hash{String => String}] A hash of custom headers that will be added
68
+ # to the HTTP request.
69
+ #
70
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
71
+ #
72
+ def list_locations_async(subscription_id, custom_headers:nil)
73
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
74
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
75
+
76
+
77
+ request_headers = {}
78
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
79
+
80
+ # Set Headers
81
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
82
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
83
+ path_template = 'subscriptions/{subscriptionId}/locations'
84
+
85
+ request_url = @base_url || @client.base_url
86
+
87
+ options = {
88
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
89
+ path_params: {'subscriptionId' => subscription_id},
90
+ query_params: {'api-version' => @client.api_version},
91
+ headers: request_headers.merge(custom_headers || {}),
92
+ base_url: request_url
93
+ }
94
+ promise = @client.make_request_async(:get, path_template, options)
95
+
96
+ promise = promise.then do |result|
97
+ http_response = result.response
98
+ status_code = http_response.status
99
+ response_content = http_response.body
100
+ unless status_code == 200
101
+ error_model = JSON.load(response_content)
102
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
103
+ end
104
+
105
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
106
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
107
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
108
+ # Deserialize Response
109
+ if status_code == 200
110
+ begin
111
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
112
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::LocationListResult.mapper()
113
+ result.body = @client.deserialize(result_mapper, parsed_response)
114
+ rescue Exception => e
115
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
116
+ end
117
+ end
118
+
119
+ result
120
+ end
121
+
122
+ promise.execute
123
+ end
124
+
125
+ #
126
+ # Gets details about a specified subscription.
127
+ #
128
+ # @param subscription_id [String] The ID of the target subscription.
129
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
130
+ # will be added to the HTTP request.
131
+ #
132
+ # @return [Subscription] operation results.
133
+ #
134
+ def get(subscription_id, custom_headers:nil)
135
+ response = get_async(subscription_id, custom_headers:custom_headers).value!
136
+ response.body unless response.nil?
137
+ end
138
+
139
+ #
140
+ # Gets details about a specified subscription.
141
+ #
142
+ # @param subscription_id [String] The ID of the target subscription.
143
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
144
+ # will be added to the HTTP request.
145
+ #
146
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
147
+ #
148
+ def get_with_http_info(subscription_id, custom_headers:nil)
149
+ get_async(subscription_id, custom_headers:custom_headers).value!
150
+ end
151
+
152
+ #
153
+ # Gets details about a specified subscription.
154
+ #
155
+ # @param subscription_id [String] The ID of the target subscription.
156
+ # @param [Hash{String => String}] A hash of custom headers that will be added
157
+ # to the HTTP request.
158
+ #
159
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
160
+ #
161
+ def get_async(subscription_id, custom_headers:nil)
162
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
163
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
164
+
165
+
166
+ request_headers = {}
167
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
168
+
169
+ # Set Headers
170
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
171
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
172
+ path_template = 'subscriptions/{subscriptionId}'
173
+
174
+ request_url = @base_url || @client.base_url
175
+
176
+ options = {
177
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
178
+ path_params: {'subscriptionId' => subscription_id},
179
+ query_params: {'api-version' => @client.api_version},
180
+ headers: request_headers.merge(custom_headers || {}),
181
+ base_url: request_url
182
+ }
183
+ promise = @client.make_request_async(:get, path_template, options)
184
+
185
+ promise = promise.then do |result|
186
+ http_response = result.response
187
+ status_code = http_response.status
188
+ response_content = http_response.body
189
+ unless status_code == 200
190
+ error_model = JSON.load(response_content)
191
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
192
+ end
193
+
194
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
195
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
196
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
197
+ # Deserialize Response
198
+ if status_code == 200
199
+ begin
200
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
201
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::Subscription.mapper()
202
+ result.body = @client.deserialize(result_mapper, parsed_response)
203
+ rescue Exception => e
204
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
205
+ end
206
+ end
207
+
208
+ result
209
+ end
210
+
211
+ promise.execute
212
+ end
213
+
214
+ #
215
+ # Gets all subscriptions for a tenant.
216
+ #
217
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
218
+ # will be added to the HTTP request.
219
+ #
220
+ # @return [Array<Subscription>] operation results.
221
+ #
222
+ def list(custom_headers:nil)
223
+ first_page = list_as_lazy(custom_headers:custom_headers)
224
+ first_page.get_all_items
225
+ end
226
+
227
+ #
228
+ # Gets all subscriptions for a tenant.
229
+ #
230
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
231
+ # will be added to the HTTP request.
232
+ #
233
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
234
+ #
235
+ def list_with_http_info(custom_headers:nil)
236
+ list_async(custom_headers:custom_headers).value!
237
+ end
238
+
239
+ #
240
+ # Gets all subscriptions for a tenant.
241
+ #
242
+ # @param [Hash{String => String}] A hash of custom headers that will be added
243
+ # to the HTTP request.
244
+ #
245
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
246
+ #
247
+ def list_async(custom_headers:nil)
248
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
249
+
250
+
251
+ request_headers = {}
252
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
253
+
254
+ # Set Headers
255
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
256
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
257
+ path_template = 'subscriptions'
258
+
259
+ request_url = @base_url || @client.base_url
260
+
261
+ options = {
262
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
263
+ query_params: {'api-version' => @client.api_version},
264
+ headers: request_headers.merge(custom_headers || {}),
265
+ base_url: request_url
266
+ }
267
+ promise = @client.make_request_async(:get, path_template, options)
268
+
269
+ promise = promise.then do |result|
270
+ http_response = result.response
271
+ status_code = http_response.status
272
+ response_content = http_response.body
273
+ unless status_code == 200
274
+ error_model = JSON.load(response_content)
275
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
276
+ end
277
+
278
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
279
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
280
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
281
+ # Deserialize Response
282
+ if status_code == 200
283
+ begin
284
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
285
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::SubscriptionListResult.mapper()
286
+ result.body = @client.deserialize(result_mapper, parsed_response)
287
+ rescue Exception => e
288
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
289
+ end
290
+ end
291
+
292
+ result
293
+ end
294
+
295
+ promise.execute
296
+ end
297
+
298
+ #
299
+ # Gets all subscriptions for a tenant.
300
+ #
301
+ # @param next_page_link [String] The NextLink from the previous successful call
302
+ # to List operation.
303
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
304
+ # will be added to the HTTP request.
305
+ #
306
+ # @return [SubscriptionListResult] operation results.
307
+ #
308
+ def list_next(next_page_link, custom_headers:nil)
309
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
310
+ response.body unless response.nil?
311
+ end
312
+
313
+ #
314
+ # Gets all subscriptions for a tenant.
315
+ #
316
+ # @param next_page_link [String] The NextLink from the previous successful call
317
+ # to List operation.
318
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
319
+ # will be added to the HTTP request.
320
+ #
321
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
322
+ #
323
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
324
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
325
+ end
326
+
327
+ #
328
+ # Gets all subscriptions for a tenant.
329
+ #
330
+ # @param next_page_link [String] The NextLink from the previous successful call
331
+ # to List operation.
332
+ # @param [Hash{String => String}] A hash of custom headers that will be added
333
+ # to the HTTP request.
334
+ #
335
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
336
+ #
337
+ def list_next_async(next_page_link, custom_headers:nil)
338
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
339
+
340
+
341
+ request_headers = {}
342
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
343
+
344
+ # Set Headers
345
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
346
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
347
+ path_template = '{nextLink}'
348
+
349
+ request_url = @base_url || @client.base_url
350
+
351
+ options = {
352
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
353
+ skip_encoding_path_params: {'nextLink' => next_page_link},
354
+ headers: request_headers.merge(custom_headers || {}),
355
+ base_url: request_url
356
+ }
357
+ promise = @client.make_request_async(:get, path_template, options)
358
+
359
+ promise = promise.then do |result|
360
+ http_response = result.response
361
+ status_code = http_response.status
362
+ response_content = http_response.body
363
+ unless status_code == 200
364
+ error_model = JSON.load(response_content)
365
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
366
+ end
367
+
368
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
369
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
370
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
371
+ # Deserialize Response
372
+ if status_code == 200
373
+ begin
374
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
375
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_11_01::Models::SubscriptionListResult.mapper()
376
+ result.body = @client.deserialize(result_mapper, parsed_response)
377
+ rescue Exception => e
378
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
379
+ end
380
+ end
381
+
382
+ result
383
+ end
384
+
385
+ promise.execute
386
+ end
387
+
388
+ #
389
+ # Gets all subscriptions for a tenant.
390
+ #
391
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
392
+ # will be added to the HTTP request.
393
+ #
394
+ # @return [SubscriptionListResult] which provide lazy access to pages of the
395
+ # response.
396
+ #
397
+ def list_as_lazy(custom_headers:nil)
398
+ response = list_async(custom_headers:custom_headers).value!
399
+ unless response.nil?
400
+ page = response.body
401
+ page.next_method = Proc.new do |next_page_link|
402
+ list_next_async(next_page_link, custom_headers:custom_headers)
403
+ end
404
+ page
405
+ end
406
+ end
407
+
408
+ end
409
+ end