azure_mgmt_billing 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2017-02-27-preview/generated/azure_mgmt_billing/billing_client.rb +7 -6
  3. data/lib/2017-04-24-preview/generated/azure_mgmt_billing/billing_management_client.rb +7 -6
  4. data/lib/2018-03-01-preview/generated/azure_mgmt_billing.rb +44 -0
  5. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/billing_management_client.rb +144 -0
  6. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/billing_periods.rb +371 -0
  7. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/enrollment_accounts.rb +303 -0
  8. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/invoices.rb +503 -0
  9. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/billing_period.rb +107 -0
  10. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/billing_periods_list_result.rb +101 -0
  11. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/download_url.rb +61 -0
  12. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/enrollment_account.rb +74 -0
  13. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/enrollment_account_list_result.rb +100 -0
  14. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/error_details.rb +71 -0
  15. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/error_response.rb +48 -0
  16. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/invoice.rb +120 -0
  17. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/invoices_list_result.rb +101 -0
  18. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/operation.rb +59 -0
  19. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/operation_display.rb +72 -0
  20. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/operation_list_result.rb +103 -0
  21. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/models/resource.rb +71 -0
  22. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/module_definition.rb +9 -0
  23. data/lib/2018-03-01-preview/generated/azure_mgmt_billing/operations.rb +216 -0
  24. data/lib/azure_mgmt_billing.rb +1 -0
  25. data/lib/profiles/latest/modules/billing_profile_module.rb +43 -33
  26. data/lib/version.rb +1 -1
  27. metadata +24 -4
@@ -0,0 +1,303 @@
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::Billing::Mgmt::V2018_03_01_preview
7
+ #
8
+ # Billing client provides access to billing resources for Azure
9
+ # subscriptions.
10
+ #
11
+ class EnrollmentAccounts
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the EnrollmentAccounts class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [BillingManagementClient] reference to the BillingManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Lists the enrollment accounts the caller has access to.
27
+ #
28
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
29
+ # will be added to the HTTP request.
30
+ #
31
+ # @return [Array<EnrollmentAccount>] operation results.
32
+ #
33
+ def list(custom_headers:nil)
34
+ first_page = list_as_lazy(custom_headers:custom_headers)
35
+ first_page.get_all_items
36
+ end
37
+
38
+ #
39
+ # Lists the enrollment accounts the caller has access to.
40
+ #
41
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
42
+ # will be added to the HTTP request.
43
+ #
44
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
45
+ #
46
+ def list_with_http_info(custom_headers:nil)
47
+ list_async(custom_headers:custom_headers).value!
48
+ end
49
+
50
+ #
51
+ # Lists the enrollment accounts the caller has access to.
52
+ #
53
+ # @param [Hash{String => String}] A hash of custom headers that will be added
54
+ # to the HTTP request.
55
+ #
56
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
57
+ #
58
+ def list_async(custom_headers:nil)
59
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
60
+
61
+
62
+ request_headers = {}
63
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
64
+
65
+ # Set Headers
66
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
67
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
68
+ path_template = 'providers/Microsoft.Billing/enrollmentAccounts'
69
+
70
+ request_url = @base_url || @client.base_url
71
+
72
+ options = {
73
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
74
+ query_params: {'api-version' => @client.api_version},
75
+ headers: request_headers.merge(custom_headers || {}),
76
+ base_url: request_url
77
+ }
78
+ promise = @client.make_request_async(:get, path_template, options)
79
+
80
+ promise = promise.then do |result|
81
+ http_response = result.response
82
+ status_code = http_response.status
83
+ response_content = http_response.body
84
+ unless status_code == 200
85
+ error_model = JSON.load(response_content)
86
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
87
+ end
88
+
89
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
90
+ # Deserialize Response
91
+ if status_code == 200
92
+ begin
93
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
94
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::EnrollmentAccountListResult.mapper()
95
+ result.body = @client.deserialize(result_mapper, parsed_response)
96
+ rescue Exception => e
97
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
98
+ end
99
+ end
100
+
101
+ result
102
+ end
103
+
104
+ promise.execute
105
+ end
106
+
107
+ #
108
+ # Gets a enrollment account by name.
109
+ #
110
+ # @param name [String] Enrollment Account name.
111
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
112
+ # will be added to the HTTP request.
113
+ #
114
+ # @return [EnrollmentAccount] operation results.
115
+ #
116
+ def get(name, custom_headers:nil)
117
+ response = get_async(name, custom_headers:custom_headers).value!
118
+ response.body unless response.nil?
119
+ end
120
+
121
+ #
122
+ # Gets a enrollment account by name.
123
+ #
124
+ # @param name [String] Enrollment Account name.
125
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
126
+ # will be added to the HTTP request.
127
+ #
128
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
129
+ #
130
+ def get_with_http_info(name, custom_headers:nil)
131
+ get_async(name, custom_headers:custom_headers).value!
132
+ end
133
+
134
+ #
135
+ # Gets a enrollment account by name.
136
+ #
137
+ # @param name [String] Enrollment Account name.
138
+ # @param [Hash{String => String}] A hash of custom headers that will be added
139
+ # to the HTTP request.
140
+ #
141
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
142
+ #
143
+ def get_async(name, custom_headers:nil)
144
+ fail ArgumentError, 'name is nil' if name.nil?
145
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
146
+
147
+
148
+ request_headers = {}
149
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
150
+
151
+ # Set Headers
152
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
153
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
154
+ path_template = 'providers/Microsoft.Billing/enrollmentAccounts/{name}'
155
+
156
+ request_url = @base_url || @client.base_url
157
+
158
+ options = {
159
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
160
+ path_params: {'name' => name},
161
+ query_params: {'api-version' => @client.api_version},
162
+ headers: request_headers.merge(custom_headers || {}),
163
+ base_url: request_url
164
+ }
165
+ promise = @client.make_request_async(:get, path_template, options)
166
+
167
+ promise = promise.then do |result|
168
+ http_response = result.response
169
+ status_code = http_response.status
170
+ response_content = http_response.body
171
+ unless status_code == 200
172
+ error_model = JSON.load(response_content)
173
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
174
+ end
175
+
176
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
177
+ # Deserialize Response
178
+ if status_code == 200
179
+ begin
180
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
181
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::EnrollmentAccount.mapper()
182
+ result.body = @client.deserialize(result_mapper, parsed_response)
183
+ rescue Exception => e
184
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
185
+ end
186
+ end
187
+
188
+ result
189
+ end
190
+
191
+ promise.execute
192
+ end
193
+
194
+ #
195
+ # Lists the enrollment accounts the caller has access to.
196
+ #
197
+ # @param next_page_link [String] The NextLink from the previous successful call
198
+ # to List operation.
199
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
200
+ # will be added to the HTTP request.
201
+ #
202
+ # @return [EnrollmentAccountListResult] operation results.
203
+ #
204
+ def list_next(next_page_link, custom_headers:nil)
205
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
206
+ response.body unless response.nil?
207
+ end
208
+
209
+ #
210
+ # Lists the enrollment accounts the caller has access to.
211
+ #
212
+ # @param next_page_link [String] The NextLink from the previous successful call
213
+ # to List operation.
214
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
215
+ # will be added to the HTTP request.
216
+ #
217
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
218
+ #
219
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
220
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
221
+ end
222
+
223
+ #
224
+ # Lists the enrollment accounts the caller has access to.
225
+ #
226
+ # @param next_page_link [String] The NextLink from the previous successful call
227
+ # to List operation.
228
+ # @param [Hash{String => String}] A hash of custom headers that will be added
229
+ # to the HTTP request.
230
+ #
231
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
232
+ #
233
+ def list_next_async(next_page_link, custom_headers:nil)
234
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
235
+
236
+
237
+ request_headers = {}
238
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
239
+
240
+ # Set Headers
241
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
242
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
243
+ path_template = '{nextLink}'
244
+
245
+ request_url = @base_url || @client.base_url
246
+
247
+ options = {
248
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
249
+ skip_encoding_path_params: {'nextLink' => next_page_link},
250
+ headers: request_headers.merge(custom_headers || {}),
251
+ base_url: request_url
252
+ }
253
+ promise = @client.make_request_async(:get, path_template, options)
254
+
255
+ promise = promise.then do |result|
256
+ http_response = result.response
257
+ status_code = http_response.status
258
+ response_content = http_response.body
259
+ unless status_code == 200
260
+ error_model = JSON.load(response_content)
261
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
262
+ end
263
+
264
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
265
+ # Deserialize Response
266
+ if status_code == 200
267
+ begin
268
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
269
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::EnrollmentAccountListResult.mapper()
270
+ result.body = @client.deserialize(result_mapper, parsed_response)
271
+ rescue Exception => e
272
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
273
+ end
274
+ end
275
+
276
+ result
277
+ end
278
+
279
+ promise.execute
280
+ end
281
+
282
+ #
283
+ # Lists the enrollment accounts the caller has access to.
284
+ #
285
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
286
+ # will be added to the HTTP request.
287
+ #
288
+ # @return [EnrollmentAccountListResult] which provide lazy access to pages of
289
+ # the response.
290
+ #
291
+ def list_as_lazy(custom_headers:nil)
292
+ response = list_async(custom_headers:custom_headers).value!
293
+ unless response.nil?
294
+ page = response.body
295
+ page.next_method = Proc.new do |next_page_link|
296
+ list_next_async(next_page_link, custom_headers:custom_headers)
297
+ end
298
+ page
299
+ end
300
+ end
301
+
302
+ end
303
+ end
@@ -0,0 +1,503 @@
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::Billing::Mgmt::V2018_03_01_preview
7
+ #
8
+ # Billing client provides access to billing resources for Azure
9
+ # subscriptions.
10
+ #
11
+ class Invoices
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Invoices class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [BillingManagementClient] reference to the BillingManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Lists the available invoices for a subscription in reverse chronological
27
+ # order beginning with the most recent invoice. In preview, invoices are
28
+ # available via this API only for invoice periods which end December 1, 2016 or
29
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
30
+ # subscription types which were not purchased directly through the Azure web
31
+ # portal are not supported through this preview API.
32
+ #
33
+ # @param expand [String] May be used to expand the downloadUrl property within
34
+ # a list of invoices. This enables download links to be generated for multiple
35
+ # invoices at once. By default, downloadURLs are not included when listing
36
+ # invoices.
37
+ # @param filter [String] May be used to filter invoices by
38
+ # invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and
39
+ # 'and'. It does not currently support 'ne', 'or', or 'not'.
40
+ # @param skiptoken [String] Skiptoken is only used if a previous operation
41
+ # returned a partial result. If a previous response contains a nextLink
42
+ # element, the value of the nextLink element will include a skiptoken parameter
43
+ # that specifies a starting point to use for subsequent calls.
44
+ # @param top [Integer] May be used to limit the number of results to the most
45
+ # recent N invoices.
46
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
47
+ # will be added to the HTTP request.
48
+ #
49
+ # @return [Array<Invoice>] operation results.
50
+ #
51
+ def list(expand:nil, filter:nil, skiptoken:nil, top:nil, custom_headers:nil)
52
+ first_page = list_as_lazy(expand:expand, filter:filter, skiptoken:skiptoken, top:top, custom_headers:custom_headers)
53
+ first_page.get_all_items
54
+ end
55
+
56
+ #
57
+ # Lists the available invoices for a subscription in reverse chronological
58
+ # order beginning with the most recent invoice. In preview, invoices are
59
+ # available via this API only for invoice periods which end December 1, 2016 or
60
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
61
+ # subscription types which were not purchased directly through the Azure web
62
+ # portal are not supported through this preview API.
63
+ #
64
+ # @param expand [String] May be used to expand the downloadUrl property within
65
+ # a list of invoices. This enables download links to be generated for multiple
66
+ # invoices at once. By default, downloadURLs are not included when listing
67
+ # invoices.
68
+ # @param filter [String] May be used to filter invoices by
69
+ # invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and
70
+ # 'and'. It does not currently support 'ne', 'or', or 'not'.
71
+ # @param skiptoken [String] Skiptoken is only used if a previous operation
72
+ # returned a partial result. If a previous response contains a nextLink
73
+ # element, the value of the nextLink element will include a skiptoken parameter
74
+ # that specifies a starting point to use for subsequent calls.
75
+ # @param top [Integer] May be used to limit the number of results to the most
76
+ # recent N invoices.
77
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
78
+ # will be added to the HTTP request.
79
+ #
80
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
81
+ #
82
+ def list_with_http_info(expand:nil, filter:nil, skiptoken:nil, top:nil, custom_headers:nil)
83
+ list_async(expand:expand, filter:filter, skiptoken:skiptoken, top:top, custom_headers:custom_headers).value!
84
+ end
85
+
86
+ #
87
+ # Lists the available invoices for a subscription in reverse chronological
88
+ # order beginning with the most recent invoice. In preview, invoices are
89
+ # available via this API only for invoice periods which end December 1, 2016 or
90
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
91
+ # subscription types which were not purchased directly through the Azure web
92
+ # portal are not supported through this preview API.
93
+ #
94
+ # @param expand [String] May be used to expand the downloadUrl property within
95
+ # a list of invoices. This enables download links to be generated for multiple
96
+ # invoices at once. By default, downloadURLs are not included when listing
97
+ # invoices.
98
+ # @param filter [String] May be used to filter invoices by
99
+ # invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and
100
+ # 'and'. It does not currently support 'ne', 'or', or 'not'.
101
+ # @param skiptoken [String] Skiptoken is only used if a previous operation
102
+ # returned a partial result. If a previous response contains a nextLink
103
+ # element, the value of the nextLink element will include a skiptoken parameter
104
+ # that specifies a starting point to use for subsequent calls.
105
+ # @param top [Integer] May be used to limit the number of results to the most
106
+ # recent N invoices.
107
+ # @param [Hash{String => String}] A hash of custom headers that will be added
108
+ # to the HTTP request.
109
+ #
110
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
111
+ #
112
+ def list_async(expand:nil, filter:nil, skiptoken:nil, top:nil, custom_headers:nil)
113
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
114
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
115
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '100'" if !top.nil? && top > 100
116
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1
117
+
118
+
119
+ request_headers = {}
120
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
121
+
122
+ # Set Headers
123
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
124
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
125
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices'
126
+
127
+ request_url = @base_url || @client.base_url
128
+
129
+ options = {
130
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
131
+ path_params: {'subscriptionId' => @client.subscription_id},
132
+ query_params: {'api-version' => @client.api_version,'$expand' => expand,'$filter' => filter,'$skiptoken' => skiptoken,'$top' => top},
133
+ headers: request_headers.merge(custom_headers || {}),
134
+ base_url: request_url
135
+ }
136
+ promise = @client.make_request_async(:get, path_template, options)
137
+
138
+ promise = promise.then do |result|
139
+ http_response = result.response
140
+ status_code = http_response.status
141
+ response_content = http_response.body
142
+ unless status_code == 200
143
+ error_model = JSON.load(response_content)
144
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
145
+ end
146
+
147
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
148
+ # Deserialize Response
149
+ if status_code == 200
150
+ begin
151
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
152
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::InvoicesListResult.mapper()
153
+ result.body = @client.deserialize(result_mapper, parsed_response)
154
+ rescue Exception => e
155
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
156
+ end
157
+ end
158
+
159
+ result
160
+ end
161
+
162
+ promise.execute
163
+ end
164
+
165
+ #
166
+ # Gets a named invoice resource. When getting a single invoice, the downloadUrl
167
+ # property is expanded automatically. This is only supported for Azure
168
+ # Web-Direct subscriptions. Other subscription types which were not purchased
169
+ # directly through the Azure web portal are not supported through this preview
170
+ # API.
171
+ #
172
+ # @param invoice_name [String] The name of an invoice resource.
173
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
174
+ # will be added to the HTTP request.
175
+ #
176
+ # @return [Invoice] operation results.
177
+ #
178
+ def get(invoice_name, custom_headers:nil)
179
+ response = get_async(invoice_name, custom_headers:custom_headers).value!
180
+ response.body unless response.nil?
181
+ end
182
+
183
+ #
184
+ # Gets a named invoice resource. When getting a single invoice, the downloadUrl
185
+ # property is expanded automatically. This is only supported for Azure
186
+ # Web-Direct subscriptions. Other subscription types which were not purchased
187
+ # directly through the Azure web portal are not supported through this preview
188
+ # API.
189
+ #
190
+ # @param invoice_name [String] The name of an invoice resource.
191
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
192
+ # will be added to the HTTP request.
193
+ #
194
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
195
+ #
196
+ def get_with_http_info(invoice_name, custom_headers:nil)
197
+ get_async(invoice_name, custom_headers:custom_headers).value!
198
+ end
199
+
200
+ #
201
+ # Gets a named invoice resource. When getting a single invoice, the downloadUrl
202
+ # property is expanded automatically. This is only supported for Azure
203
+ # Web-Direct subscriptions. Other subscription types which were not purchased
204
+ # directly through the Azure web portal are not supported through this preview
205
+ # API.
206
+ #
207
+ # @param invoice_name [String] The name of an invoice resource.
208
+ # @param [Hash{String => String}] A hash of custom headers that will be added
209
+ # to the HTTP request.
210
+ #
211
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
212
+ #
213
+ def get_async(invoice_name, custom_headers:nil)
214
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
215
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
216
+ fail ArgumentError, 'invoice_name is nil' if invoice_name.nil?
217
+
218
+
219
+ request_headers = {}
220
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
221
+
222
+ # Set Headers
223
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
224
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
225
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}'
226
+
227
+ request_url = @base_url || @client.base_url
228
+
229
+ options = {
230
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
231
+ path_params: {'subscriptionId' => @client.subscription_id,'invoiceName' => invoice_name},
232
+ query_params: {'api-version' => @client.api_version},
233
+ headers: request_headers.merge(custom_headers || {}),
234
+ base_url: request_url
235
+ }
236
+ promise = @client.make_request_async(:get, path_template, options)
237
+
238
+ promise = promise.then do |result|
239
+ http_response = result.response
240
+ status_code = http_response.status
241
+ response_content = http_response.body
242
+ unless status_code == 200
243
+ error_model = JSON.load(response_content)
244
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
245
+ end
246
+
247
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
248
+ # Deserialize Response
249
+ if status_code == 200
250
+ begin
251
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
252
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::Invoice.mapper()
253
+ result.body = @client.deserialize(result_mapper, parsed_response)
254
+ rescue Exception => e
255
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
256
+ end
257
+ end
258
+
259
+ result
260
+ end
261
+
262
+ promise.execute
263
+ end
264
+
265
+ #
266
+ # Gets the most recent invoice. When getting a single invoice, the downloadUrl
267
+ # property is expanded automatically. This is only supported for Azure
268
+ # Web-Direct subscriptions. Other subscription types which were not purchased
269
+ # directly through the Azure web portal are not supported through this preview
270
+ # API.
271
+ #
272
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
273
+ # will be added to the HTTP request.
274
+ #
275
+ # @return [Invoice] operation results.
276
+ #
277
+ def get_latest(custom_headers:nil)
278
+ response = get_latest_async(custom_headers:custom_headers).value!
279
+ response.body unless response.nil?
280
+ end
281
+
282
+ #
283
+ # Gets the most recent invoice. When getting a single invoice, the downloadUrl
284
+ # property is expanded automatically. This is only supported for Azure
285
+ # Web-Direct subscriptions. Other subscription types which were not purchased
286
+ # directly through the Azure web portal are not supported through this preview
287
+ # API.
288
+ #
289
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
290
+ # will be added to the HTTP request.
291
+ #
292
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
293
+ #
294
+ def get_latest_with_http_info(custom_headers:nil)
295
+ get_latest_async(custom_headers:custom_headers).value!
296
+ end
297
+
298
+ #
299
+ # Gets the most recent invoice. When getting a single invoice, the downloadUrl
300
+ # property is expanded automatically. This is only supported for Azure
301
+ # Web-Direct subscriptions. Other subscription types which were not purchased
302
+ # directly through the Azure web portal are not supported through this preview
303
+ # API.
304
+ #
305
+ # @param [Hash{String => String}] A hash of custom headers that will be added
306
+ # to the HTTP request.
307
+ #
308
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
309
+ #
310
+ def get_latest_async(custom_headers:nil)
311
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
312
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
313
+
314
+
315
+ request_headers = {}
316
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
317
+
318
+ # Set Headers
319
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
320
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
321
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/latest'
322
+
323
+ request_url = @base_url || @client.base_url
324
+
325
+ options = {
326
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
327
+ path_params: {'subscriptionId' => @client.subscription_id},
328
+ query_params: {'api-version' => @client.api_version},
329
+ headers: request_headers.merge(custom_headers || {}),
330
+ base_url: request_url
331
+ }
332
+ promise = @client.make_request_async(:get, path_template, options)
333
+
334
+ promise = promise.then do |result|
335
+ http_response = result.response
336
+ status_code = http_response.status
337
+ response_content = http_response.body
338
+ unless status_code == 200
339
+ error_model = JSON.load(response_content)
340
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
341
+ end
342
+
343
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
344
+ # Deserialize Response
345
+ if status_code == 200
346
+ begin
347
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
348
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::Invoice.mapper()
349
+ result.body = @client.deserialize(result_mapper, parsed_response)
350
+ rescue Exception => e
351
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
352
+ end
353
+ end
354
+
355
+ result
356
+ end
357
+
358
+ promise.execute
359
+ end
360
+
361
+ #
362
+ # Lists the available invoices for a subscription in reverse chronological
363
+ # order beginning with the most recent invoice. In preview, invoices are
364
+ # available via this API only for invoice periods which end December 1, 2016 or
365
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
366
+ # subscription types which were not purchased directly through the Azure web
367
+ # portal are not supported through this preview API.
368
+ #
369
+ # @param next_page_link [String] The NextLink from the previous successful call
370
+ # to List operation.
371
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
372
+ # will be added to the HTTP request.
373
+ #
374
+ # @return [InvoicesListResult] operation results.
375
+ #
376
+ def list_next(next_page_link, custom_headers:nil)
377
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
378
+ response.body unless response.nil?
379
+ end
380
+
381
+ #
382
+ # Lists the available invoices for a subscription in reverse chronological
383
+ # order beginning with the most recent invoice. In preview, invoices are
384
+ # available via this API only for invoice periods which end December 1, 2016 or
385
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
386
+ # subscription types which were not purchased directly through the Azure web
387
+ # portal are not supported through this preview API.
388
+ #
389
+ # @param next_page_link [String] The NextLink from the previous successful call
390
+ # to List operation.
391
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
392
+ # will be added to the HTTP request.
393
+ #
394
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
395
+ #
396
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
397
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
398
+ end
399
+
400
+ #
401
+ # Lists the available invoices for a subscription in reverse chronological
402
+ # order beginning with the most recent invoice. In preview, invoices are
403
+ # available via this API only for invoice periods which end December 1, 2016 or
404
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
405
+ # subscription types which were not purchased directly through the Azure web
406
+ # portal are not supported through this preview API.
407
+ #
408
+ # @param next_page_link [String] The NextLink from the previous successful call
409
+ # to List operation.
410
+ # @param [Hash{String => String}] A hash of custom headers that will be added
411
+ # to the HTTP request.
412
+ #
413
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
414
+ #
415
+ def list_next_async(next_page_link, custom_headers:nil)
416
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
417
+
418
+
419
+ request_headers = {}
420
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
421
+
422
+ # Set Headers
423
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
424
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
425
+ path_template = '{nextLink}'
426
+
427
+ request_url = @base_url || @client.base_url
428
+
429
+ options = {
430
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
431
+ skip_encoding_path_params: {'nextLink' => next_page_link},
432
+ headers: request_headers.merge(custom_headers || {}),
433
+ base_url: request_url
434
+ }
435
+ promise = @client.make_request_async(:get, path_template, options)
436
+
437
+ promise = promise.then do |result|
438
+ http_response = result.response
439
+ status_code = http_response.status
440
+ response_content = http_response.body
441
+ unless status_code == 200
442
+ error_model = JSON.load(response_content)
443
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
444
+ end
445
+
446
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
447
+ # Deserialize Response
448
+ if status_code == 200
449
+ begin
450
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
451
+ result_mapper = Azure::Billing::Mgmt::V2018_03_01_preview::Models::InvoicesListResult.mapper()
452
+ result.body = @client.deserialize(result_mapper, parsed_response)
453
+ rescue Exception => e
454
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
455
+ end
456
+ end
457
+
458
+ result
459
+ end
460
+
461
+ promise.execute
462
+ end
463
+
464
+ #
465
+ # Lists the available invoices for a subscription in reverse chronological
466
+ # order beginning with the most recent invoice. In preview, invoices are
467
+ # available via this API only for invoice periods which end December 1, 2016 or
468
+ # later. This is only supported for Azure Web-Direct subscriptions. Other
469
+ # subscription types which were not purchased directly through the Azure web
470
+ # portal are not supported through this preview API.
471
+ #
472
+ # @param expand [String] May be used to expand the downloadUrl property within
473
+ # a list of invoices. This enables download links to be generated for multiple
474
+ # invoices at once. By default, downloadURLs are not included when listing
475
+ # invoices.
476
+ # @param filter [String] May be used to filter invoices by
477
+ # invoicePeriodEndDate. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and
478
+ # 'and'. It does not currently support 'ne', 'or', or 'not'.
479
+ # @param skiptoken [String] Skiptoken is only used if a previous operation
480
+ # returned a partial result. If a previous response contains a nextLink
481
+ # element, the value of the nextLink element will include a skiptoken parameter
482
+ # that specifies a starting point to use for subsequent calls.
483
+ # @param top [Integer] May be used to limit the number of results to the most
484
+ # recent N invoices.
485
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
486
+ # will be added to the HTTP request.
487
+ #
488
+ # @return [InvoicesListResult] which provide lazy access to pages of the
489
+ # response.
490
+ #
491
+ def list_as_lazy(expand:nil, filter:nil, skiptoken:nil, top:nil, custom_headers:nil)
492
+ response = list_async(expand:expand, filter:filter, skiptoken:skiptoken, top:top, custom_headers:custom_headers).value!
493
+ unless response.nil?
494
+ page = response.body
495
+ page.next_method = Proc.new do |next_page_link|
496
+ list_next_async(next_page_link, custom_headers:custom_headers)
497
+ end
498
+ page
499
+ end
500
+ end
501
+
502
+ end
503
+ end