azure_mgmt_consumption 0.14.0
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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/azure_mgmt_consumption.rb +6 -0
- data/lib/generated/azure_mgmt_consumption.rb +38 -0
- data/lib/generated/azure_mgmt_consumption/consumption_management_client.rb +134 -0
- data/lib/generated/azure_mgmt_consumption/models/error_details.rb +67 -0
- data/lib/generated/azure_mgmt_consumption/models/error_response.rb +46 -0
- data/lib/generated/azure_mgmt_consumption/models/meter_details.rb +114 -0
- data/lib/generated/azure_mgmt_consumption/models/operation.rb +56 -0
- data/lib/generated/azure_mgmt_consumption/models/operation_display.rb +68 -0
- data/lib/generated/azure_mgmt_consumption/models/operation_list_result.rb +99 -0
- data/lib/generated/azure_mgmt_consumption/models/resource.rb +85 -0
- data/lib/generated/azure_mgmt_consumption/models/usage_detail.rb +258 -0
- data/lib/generated/azure_mgmt_consumption/models/usage_details_list_result.rb +97 -0
- data/lib/generated/azure_mgmt_consumption/module_definition.rb +8 -0
- data/lib/generated/azure_mgmt_consumption/operations.rb +216 -0
- data/lib/generated/azure_mgmt_consumption/usage_details.rb +304 -0
- data/lib/generated/azure_mgmt_consumption/version.rb +8 -0
- metadata +130 -0
@@ -0,0 +1,97 @@
|
|
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::ARM::Consumption
|
7
|
+
module Models
|
8
|
+
#
|
9
|
+
# Result of listing usage details. It contains a list of available usage
|
10
|
+
# details in reverse chronological order by billing period.
|
11
|
+
#
|
12
|
+
class UsageDetailsListResult
|
13
|
+
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
include MsRest::JSONable
|
17
|
+
# @return [Array<UsageDetail>] The list of usage details.
|
18
|
+
attr_accessor :value
|
19
|
+
|
20
|
+
# @return [String] The link (url) to the next page of results.
|
21
|
+
attr_accessor :next_link
|
22
|
+
|
23
|
+
# return [Proc] with next page method call.
|
24
|
+
attr_accessor :next_method
|
25
|
+
|
26
|
+
#
|
27
|
+
# Gets the rest of the items for the request, enabling auto-pagination.
|
28
|
+
#
|
29
|
+
# @return [Array<UsageDetail>] operation results.
|
30
|
+
#
|
31
|
+
def get_all_items
|
32
|
+
items = @value
|
33
|
+
page = self
|
34
|
+
while page.next_link != nil do
|
35
|
+
page = page.get_next_page
|
36
|
+
items.concat(page.value)
|
37
|
+
end
|
38
|
+
items
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Gets the next page of results.
|
43
|
+
#
|
44
|
+
# @return [UsageDetailsListResult] with next page content.
|
45
|
+
#
|
46
|
+
def get_next_page
|
47
|
+
response = @next_method.call(@next_link).value! unless @next_method.nil?
|
48
|
+
unless response.nil?
|
49
|
+
@next_link = response.body.next_link
|
50
|
+
@value = response.body.value
|
51
|
+
self
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Mapper for UsageDetailsListResult class as Ruby Hash.
|
57
|
+
# This will be used for serialization/deserialization.
|
58
|
+
#
|
59
|
+
def self.mapper()
|
60
|
+
{
|
61
|
+
required: false,
|
62
|
+
serialized_name: 'UsageDetailsListResult',
|
63
|
+
type: {
|
64
|
+
name: 'Composite',
|
65
|
+
class_name: 'UsageDetailsListResult',
|
66
|
+
model_properties: {
|
67
|
+
value: {
|
68
|
+
required: false,
|
69
|
+
read_only: true,
|
70
|
+
serialized_name: 'value',
|
71
|
+
type: {
|
72
|
+
name: 'Sequence',
|
73
|
+
element: {
|
74
|
+
required: false,
|
75
|
+
serialized_name: 'UsageDetailElementType',
|
76
|
+
type: {
|
77
|
+
name: 'Composite',
|
78
|
+
class_name: 'UsageDetail'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
},
|
83
|
+
next_link: {
|
84
|
+
required: false,
|
85
|
+
read_only: true,
|
86
|
+
serialized_name: 'nextLink',
|
87
|
+
type: {
|
88
|
+
name: 'String'
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,216 @@
|
|
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::ARM::Consumption
|
7
|
+
#
|
8
|
+
# Consumption management client provides access to consumption resources for
|
9
|
+
# Azure Web-Direct subscriptions. Other subscription types which were not
|
10
|
+
# purchased directly through the Azure web portal are not supported through
|
11
|
+
# this preview API.
|
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 [ConsumptionManagementClient] reference to the ConsumptionManagementClient
|
25
|
+
attr_reader :client
|
26
|
+
|
27
|
+
#
|
28
|
+
# Lists all of the available consumption 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)
|
37
|
+
first_page.get_all_items
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Lists all of the available consumption 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).value!
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Lists all of the available consumption 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
|
+
|
66
|
+
# Set Headers
|
67
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
68
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
69
|
+
path_template = 'providers/Microsoft.Consumption/operations'
|
70
|
+
|
71
|
+
request_url = @base_url || @client.base_url
|
72
|
+
|
73
|
+
options = {
|
74
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
75
|
+
query_params: {'api-version' => @client.api_version},
|
76
|
+
headers: request_headers.merge(custom_headers || {}),
|
77
|
+
base_url: request_url
|
78
|
+
}
|
79
|
+
promise = @client.make_request_async(:get, path_template, options)
|
80
|
+
|
81
|
+
promise = promise.then do |result|
|
82
|
+
http_response = result.response
|
83
|
+
status_code = http_response.status
|
84
|
+
response_content = http_response.body
|
85
|
+
unless status_code == 200
|
86
|
+
error_model = JSON.load(response_content)
|
87
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
88
|
+
end
|
89
|
+
|
90
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
91
|
+
# Deserialize Response
|
92
|
+
if status_code == 200
|
93
|
+
begin
|
94
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
95
|
+
result_mapper = Azure::ARM::Consumption::Models::OperationListResult.mapper()
|
96
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
97
|
+
rescue Exception => e
|
98
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
result
|
103
|
+
end
|
104
|
+
|
105
|
+
promise.execute
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Lists all of the available consumption REST API operations.
|
110
|
+
#
|
111
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
112
|
+
# to List operation.
|
113
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
114
|
+
# will be added to the HTTP request.
|
115
|
+
#
|
116
|
+
# @return [OperationListResult] operation results.
|
117
|
+
#
|
118
|
+
def list_next(next_page_link, custom_headers = nil)
|
119
|
+
response = list_next_async(next_page_link, custom_headers).value!
|
120
|
+
response.body unless response.nil?
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# Lists all of the available consumption REST API operations.
|
125
|
+
#
|
126
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
127
|
+
# to List operation.
|
128
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
129
|
+
# will be added to the HTTP request.
|
130
|
+
#
|
131
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
132
|
+
#
|
133
|
+
def list_next_with_http_info(next_page_link, custom_headers = nil)
|
134
|
+
list_next_async(next_page_link, custom_headers).value!
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# Lists all of the available consumption REST API operations.
|
139
|
+
#
|
140
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
141
|
+
# to List operation.
|
142
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
143
|
+
# to the HTTP request.
|
144
|
+
#
|
145
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
146
|
+
#
|
147
|
+
def list_next_async(next_page_link, custom_headers = nil)
|
148
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
149
|
+
|
150
|
+
|
151
|
+
request_headers = {}
|
152
|
+
|
153
|
+
# Set Headers
|
154
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
155
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
156
|
+
path_template = '{nextLink}'
|
157
|
+
|
158
|
+
request_url = @base_url || @client.base_url
|
159
|
+
|
160
|
+
options = {
|
161
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
162
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
163
|
+
headers: request_headers.merge(custom_headers || {}),
|
164
|
+
base_url: request_url
|
165
|
+
}
|
166
|
+
promise = @client.make_request_async(:get, path_template, options)
|
167
|
+
|
168
|
+
promise = promise.then do |result|
|
169
|
+
http_response = result.response
|
170
|
+
status_code = http_response.status
|
171
|
+
response_content = http_response.body
|
172
|
+
unless status_code == 200
|
173
|
+
error_model = JSON.load(response_content)
|
174
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
175
|
+
end
|
176
|
+
|
177
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
178
|
+
# Deserialize Response
|
179
|
+
if status_code == 200
|
180
|
+
begin
|
181
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
182
|
+
result_mapper = Azure::ARM::Consumption::Models::OperationListResult.mapper()
|
183
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
184
|
+
rescue Exception => e
|
185
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
result
|
190
|
+
end
|
191
|
+
|
192
|
+
promise.execute
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# Lists all of the available consumption REST API operations.
|
197
|
+
#
|
198
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
199
|
+
# will be added to the HTTP request.
|
200
|
+
#
|
201
|
+
# @return [OperationListResult] which provide lazy access to pages of the
|
202
|
+
# response.
|
203
|
+
#
|
204
|
+
def list_as_lazy(custom_headers = nil)
|
205
|
+
response = list_async(custom_headers).value!
|
206
|
+
unless response.nil?
|
207
|
+
page = response.body
|
208
|
+
page.next_method = Proc.new do |next_page_link|
|
209
|
+
list_next_async(next_page_link, custom_headers)
|
210
|
+
end
|
211
|
+
page
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,304 @@
|
|
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::ARM::Consumption
|
7
|
+
#
|
8
|
+
# Consumption management client provides access to consumption resources for
|
9
|
+
# Azure Web-Direct subscriptions. Other subscription types which were not
|
10
|
+
# purchased directly through the Azure web portal are not supported through
|
11
|
+
# this preview API.
|
12
|
+
#
|
13
|
+
class UsageDetails
|
14
|
+
include MsRestAzure
|
15
|
+
|
16
|
+
#
|
17
|
+
# Creates and initializes a new instance of the UsageDetails class.
|
18
|
+
# @param client service class for accessing basic functionality.
|
19
|
+
#
|
20
|
+
def initialize(client)
|
21
|
+
@client = client
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [ConsumptionManagementClient] reference to the ConsumptionManagementClient
|
25
|
+
attr_reader :client
|
26
|
+
|
27
|
+
#
|
28
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
29
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
30
|
+
# later.
|
31
|
+
#
|
32
|
+
# @param scope [String] The scope of the usage details. The scope can be
|
33
|
+
# '/subscriptions/{subscriptionId}' for a subscription, or
|
34
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}'
|
35
|
+
# for an invoice or
|
36
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'
|
37
|
+
# for a billing perdiod.
|
38
|
+
# @param expand [String] May be used to expand the additionalProperties or
|
39
|
+
# meterDetails property within a list of usage details. By default, these
|
40
|
+
# fields are not included when listing usage details.
|
41
|
+
# @param filter [String] May be used to filter usageDetails by usageEnd (Utc
|
42
|
+
# time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does
|
43
|
+
# not currently support 'ne', 'or', or 'not'.
|
44
|
+
# @param skiptoken [String] Skiptoken is only used if a previous operation
|
45
|
+
# returned a partial result. If a previous response contains a nextLink
|
46
|
+
# element, the value of the nextLink element will include a skiptoken parameter
|
47
|
+
# that specifies a starting point to use for subsequent calls.
|
48
|
+
# @param top [Integer] May be used to limit the number of results to the most
|
49
|
+
# recent N usageDetails.
|
50
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
51
|
+
# will be added to the HTTP request.
|
52
|
+
#
|
53
|
+
# @return [Array<UsageDetail>] operation results.
|
54
|
+
#
|
55
|
+
def list(scope, expand = nil, filter = nil, skiptoken = nil, top = nil, custom_headers = nil)
|
56
|
+
first_page = list_as_lazy(scope, expand, filter, skiptoken, top, custom_headers)
|
57
|
+
first_page.get_all_items
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
62
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
63
|
+
# later.
|
64
|
+
#
|
65
|
+
# @param scope [String] The scope of the usage details. The scope can be
|
66
|
+
# '/subscriptions/{subscriptionId}' for a subscription, or
|
67
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}'
|
68
|
+
# for an invoice or
|
69
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'
|
70
|
+
# for a billing perdiod.
|
71
|
+
# @param expand [String] May be used to expand the additionalProperties or
|
72
|
+
# meterDetails property within a list of usage details. By default, these
|
73
|
+
# fields are not included when listing usage details.
|
74
|
+
# @param filter [String] May be used to filter usageDetails by usageEnd (Utc
|
75
|
+
# time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does
|
76
|
+
# not currently support 'ne', 'or', or 'not'.
|
77
|
+
# @param skiptoken [String] Skiptoken is only used if a previous operation
|
78
|
+
# returned a partial result. If a previous response contains a nextLink
|
79
|
+
# element, the value of the nextLink element will include a skiptoken parameter
|
80
|
+
# that specifies a starting point to use for subsequent calls.
|
81
|
+
# @param top [Integer] May be used to limit the number of results to the most
|
82
|
+
# recent N usageDetails.
|
83
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
84
|
+
# will be added to the HTTP request.
|
85
|
+
#
|
86
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
87
|
+
#
|
88
|
+
def list_with_http_info(scope, expand = nil, filter = nil, skiptoken = nil, top = nil, custom_headers = nil)
|
89
|
+
list_async(scope, expand, filter, skiptoken, top, custom_headers).value!
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
94
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
95
|
+
# later.
|
96
|
+
#
|
97
|
+
# @param scope [String] The scope of the usage details. The scope can be
|
98
|
+
# '/subscriptions/{subscriptionId}' for a subscription, or
|
99
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}'
|
100
|
+
# for an invoice or
|
101
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'
|
102
|
+
# for a billing perdiod.
|
103
|
+
# @param expand [String] May be used to expand the additionalProperties or
|
104
|
+
# meterDetails property within a list of usage details. By default, these
|
105
|
+
# fields are not included when listing usage details.
|
106
|
+
# @param filter [String] May be used to filter usageDetails by usageEnd (Utc
|
107
|
+
# time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does
|
108
|
+
# not currently support 'ne', 'or', or 'not'.
|
109
|
+
# @param skiptoken [String] Skiptoken is only used if a previous operation
|
110
|
+
# returned a partial result. If a previous response contains a nextLink
|
111
|
+
# element, the value of the nextLink element will include a skiptoken parameter
|
112
|
+
# that specifies a starting point to use for subsequent calls.
|
113
|
+
# @param top [Integer] May be used to limit the number of results to the most
|
114
|
+
# recent N usageDetails.
|
115
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
116
|
+
# to the HTTP request.
|
117
|
+
#
|
118
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
119
|
+
#
|
120
|
+
def list_async(scope, expand = nil, filter = nil, skiptoken = nil, top = nil, custom_headers = nil)
|
121
|
+
fail ArgumentError, 'scope is nil' if scope.nil?
|
122
|
+
fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
|
123
|
+
|
124
|
+
|
125
|
+
request_headers = {}
|
126
|
+
|
127
|
+
# Set Headers
|
128
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
129
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
130
|
+
path_template = '{scope}/providers/Microsoft.Consumption/usageDetails'
|
131
|
+
|
132
|
+
request_url = @base_url || @client.base_url
|
133
|
+
|
134
|
+
options = {
|
135
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
136
|
+
skip_encoding_path_params: {'scope' => scope},
|
137
|
+
query_params: {'$expand' => expand,'$filter' => filter,'$skiptoken' => skiptoken,'$top' => top,'api-version' => @client.api_version},
|
138
|
+
headers: request_headers.merge(custom_headers || {}),
|
139
|
+
base_url: request_url
|
140
|
+
}
|
141
|
+
promise = @client.make_request_async(:get, path_template, options)
|
142
|
+
|
143
|
+
promise = promise.then do |result|
|
144
|
+
http_response = result.response
|
145
|
+
status_code = http_response.status
|
146
|
+
response_content = http_response.body
|
147
|
+
unless status_code == 200
|
148
|
+
error_model = JSON.load(response_content)
|
149
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
150
|
+
end
|
151
|
+
|
152
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
153
|
+
# Deserialize Response
|
154
|
+
if status_code == 200
|
155
|
+
begin
|
156
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
157
|
+
result_mapper = Azure::ARM::Consumption::Models::UsageDetailsListResult.mapper()
|
158
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
159
|
+
rescue Exception => e
|
160
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
result
|
165
|
+
end
|
166
|
+
|
167
|
+
promise.execute
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
172
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
173
|
+
# later.
|
174
|
+
#
|
175
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
176
|
+
# to List operation.
|
177
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
178
|
+
# will be added to the HTTP request.
|
179
|
+
#
|
180
|
+
# @return [UsageDetailsListResult] operation results.
|
181
|
+
#
|
182
|
+
def list_next(next_page_link, custom_headers = nil)
|
183
|
+
response = list_next_async(next_page_link, custom_headers).value!
|
184
|
+
response.body unless response.nil?
|
185
|
+
end
|
186
|
+
|
187
|
+
#
|
188
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
189
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
190
|
+
# later.
|
191
|
+
#
|
192
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
193
|
+
# to List operation.
|
194
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
195
|
+
# will be added to the HTTP request.
|
196
|
+
#
|
197
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
198
|
+
#
|
199
|
+
def list_next_with_http_info(next_page_link, custom_headers = nil)
|
200
|
+
list_next_async(next_page_link, custom_headers).value!
|
201
|
+
end
|
202
|
+
|
203
|
+
#
|
204
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
205
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
206
|
+
# later.
|
207
|
+
#
|
208
|
+
# @param next_page_link [String] The NextLink from the previous successful call
|
209
|
+
# to List operation.
|
210
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
211
|
+
# to the HTTP request.
|
212
|
+
#
|
213
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
214
|
+
#
|
215
|
+
def list_next_async(next_page_link, custom_headers = nil)
|
216
|
+
fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
|
217
|
+
|
218
|
+
|
219
|
+
request_headers = {}
|
220
|
+
|
221
|
+
# Set Headers
|
222
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
223
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
224
|
+
path_template = '{nextLink}'
|
225
|
+
|
226
|
+
request_url = @base_url || @client.base_url
|
227
|
+
|
228
|
+
options = {
|
229
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
230
|
+
skip_encoding_path_params: {'nextLink' => next_page_link},
|
231
|
+
headers: request_headers.merge(custom_headers || {}),
|
232
|
+
base_url: request_url
|
233
|
+
}
|
234
|
+
promise = @client.make_request_async(:get, path_template, options)
|
235
|
+
|
236
|
+
promise = promise.then do |result|
|
237
|
+
http_response = result.response
|
238
|
+
status_code = http_response.status
|
239
|
+
response_content = http_response.body
|
240
|
+
unless status_code == 200
|
241
|
+
error_model = JSON.load(response_content)
|
242
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
243
|
+
end
|
244
|
+
|
245
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
246
|
+
# Deserialize Response
|
247
|
+
if status_code == 200
|
248
|
+
begin
|
249
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
250
|
+
result_mapper = Azure::ARM::Consumption::Models::UsageDetailsListResult.mapper()
|
251
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
252
|
+
rescue Exception => e
|
253
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
promise.execute
|
261
|
+
end
|
262
|
+
|
263
|
+
#
|
264
|
+
# Lists the usage details for a scope in reverse chronological order by billing
|
265
|
+
# period. Usage details are available via this API only for January 1, 2017 or
|
266
|
+
# later.
|
267
|
+
#
|
268
|
+
# @param scope [String] The scope of the usage details. The scope can be
|
269
|
+
# '/subscriptions/{subscriptionId}' for a subscription, or
|
270
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}'
|
271
|
+
# for an invoice or
|
272
|
+
# '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'
|
273
|
+
# for a billing perdiod.
|
274
|
+
# @param expand [String] May be used to expand the additionalProperties or
|
275
|
+
# meterDetails property within a list of usage details. By default, these
|
276
|
+
# fields are not included when listing usage details.
|
277
|
+
# @param filter [String] May be used to filter usageDetails by usageEnd (Utc
|
278
|
+
# time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does
|
279
|
+
# not currently support 'ne', 'or', or 'not'.
|
280
|
+
# @param skiptoken [String] Skiptoken is only used if a previous operation
|
281
|
+
# returned a partial result. If a previous response contains a nextLink
|
282
|
+
# element, the value of the nextLink element will include a skiptoken parameter
|
283
|
+
# that specifies a starting point to use for subsequent calls.
|
284
|
+
# @param top [Integer] May be used to limit the number of results to the most
|
285
|
+
# recent N usageDetails.
|
286
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
287
|
+
# will be added to the HTTP request.
|
288
|
+
#
|
289
|
+
# @return [UsageDetailsListResult] which provide lazy access to pages of the
|
290
|
+
# response.
|
291
|
+
#
|
292
|
+
def list_as_lazy(scope, expand = nil, filter = nil, skiptoken = nil, top = nil, custom_headers = nil)
|
293
|
+
response = list_async(scope, expand, filter, skiptoken, top, custom_headers).value!
|
294
|
+
unless response.nil?
|
295
|
+
page = response.body
|
296
|
+
page.next_method = Proc.new do |next_page_link|
|
297
|
+
list_next_async(next_page_link, custom_headers)
|
298
|
+
end
|
299
|
+
page
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
end
|
304
|
+
end
|