azure_mgmt_billing 0.15.2 → 0.16.0

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