Class: Azure::CostManagement::Mgmt::V2019_03_01_preview::ExternalSubscription

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb

Overview

ExternalSubscription

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ExternalSubscription

Creates and initializes a new instance of the ExternalSubscription class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientCostManagementClient (readonly)

Returns reference to the CostManagementClient.

Returns:



22
23
24
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 22

def client
  @client
end

Instance Method Details

#get(external_subscription_name, expand: nil, custom_headers: nil) ⇒ ExternalSubscriptionDefinition

Get an ExternalSubscription definition

'aws-UsageAccountId') default, collectionInfo is not included. will be added to the HTTP request.

Parameters:

  • external_subscription_name (String)

    External Subscription Name. (eg

  • expand (String) (defaults to: nil)

    May be used to expand the collectionInfo property. By

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (ExternalSubscriptionDefinition)

    operation results.



212
213
214
215
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 212

def get(external_subscription_name, expand:nil, custom_headers:nil)
  response = get_async(external_subscription_name, expand:expand, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#get_async(external_subscription_name, expand: nil, custom_headers: nil) ⇒ Concurrent::Promise

Get an ExternalSubscription definition

'aws-UsageAccountId') default, collectionInfo is not included. to the HTTP request.

Parameters:

  • external_subscription_name (String)

    External Subscription Name. (eg

  • expand (String) (defaults to: nil)

    May be used to expand the collectionInfo property. By

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 245

def get_async(external_subscription_name, expand:nil, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'external_subscription_name is nil' if external_subscription_name.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'externalSubscriptionName' => external_subscription_name},
      query_params: {'api-version' => @client.api_version,'$expand' => expand},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ExternalSubscriptionDefinition.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#get_with_http_info(external_subscription_name, expand: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Get an ExternalSubscription definition

'aws-UsageAccountId') default, collectionInfo is not included. will be added to the HTTP request.

Parameters:

  • external_subscription_name (String)

    External Subscription Name. (eg

  • expand (String) (defaults to: nil)

    May be used to expand the collectionInfo property. By

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



229
230
231
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 229

def get_with_http_info(external_subscription_name, expand:nil, custom_headers:nil)
  get_async(external_subscription_name, expand:expand, custom_headers:custom_headers).value!
end

#list(custom_headers: nil) ⇒ ExternalSubscriptionDefinitionListResult

List all ExternalSubscription definitions

will be added to the HTTP request.

Parameters:

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (ExternalSubscriptionDefinitionListResult)

    operation results.



124
125
126
127
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 124

def list(custom_headers:nil)
  response = list_async(custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_async(custom_headers: nil) ⇒ Concurrent::Promise

List all ExternalSubscription definitions

to the HTTP request.

Parameters:

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 149

def list_async(custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.CostManagement/externalSubscriptions'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ExternalSubscriptionDefinitionListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_by_external_billing_account(external_billing_account_name, custom_headers: nil) ⇒ ExternalSubscriptionDefinitionListResult

List all ExternalSubscriptions by ExternalBillingAccount definitions

(eg 'aws-PayerAccountId') will be added to the HTTP request.

Parameters:

  • external_billing_account_name (String)

    External Billing Account Name.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (ExternalSubscriptionDefinitionListResult)

    operation results.



34
35
36
37
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 34

def (, custom_headers:nil)
  response = (, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_by_external_billing_account_async(external_billing_account_name, custom_headers: nil) ⇒ Concurrent::Promise

List all ExternalSubscriptions by ExternalBillingAccount definitions

(eg 'aws-PayerAccountId') to the HTTP request.

Parameters:

  • external_billing_account_name (String)

    External Billing Account Name.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 63

def (, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'external_billing_account_name is nil' if .nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}/externalSubscriptions'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'externalBillingAccountName' => },
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ExternalSubscriptionDefinitionListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_by_external_billing_account_with_http_info(external_billing_account_name, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

List all ExternalSubscriptions by ExternalBillingAccount definitions

(eg 'aws-PayerAccountId') will be added to the HTTP request.

Parameters:

  • external_billing_account_name (String)

    External Billing Account Name.

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



49
50
51
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 49

def (, custom_headers:nil)
  (, custom_headers:custom_headers).value!
end

#list_by_management_group(management_group_id, recurse: nil, custom_headers: nil) ⇒ ExternalSubscriptionDefinitionListResult

List all ExternalSubscription definitions for Management Group

returning externalSubscriptions associated with the specified managementGroup, or any of its descendants. will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • recurse (Boolean) (defaults to: nil)

    The $recurse=true query string parameter allows

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (ExternalSubscriptionDefinitionListResult)

    operation results.



310
311
312
313
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 310

def list_by_management_group(management_group_id, recurse:nil, custom_headers:nil)
  response = list_by_management_group_async(management_group_id, recurse:recurse, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_by_management_group_async(management_group_id, recurse: nil, custom_headers: nil) ⇒ Concurrent::Promise

List all ExternalSubscription definitions for Management Group

returning externalSubscriptions associated with the specified managementGroup, or any of its descendants. to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • recurse (Boolean) (defaults to: nil)

    The $recurse=true query string parameter allows

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 343

def list_by_management_group_async(management_group_id, recurse:nil, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.CostManagement/externalSubscriptions'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'managementGroupId' => management_group_id},
      query_params: {'api-version' => @client.api_version,'$recurse' => recurse},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ExternalSubscriptionDefinitionListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_by_management_group_with_http_info(management_group_id, recurse: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

List all ExternalSubscription definitions for Management Group

returning externalSubscriptions associated with the specified managementGroup, or any of its descendants. will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • recurse (Boolean) (defaults to: nil)

    The $recurse=true query string parameter allows

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



327
328
329
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 327

def list_by_management_group_with_http_info(management_group_id, recurse:nil, custom_headers:nil)
  list_by_management_group_async(management_group_id, recurse:recurse, custom_headers:custom_headers).value!
end

#list_with_http_info(custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

List all ExternalSubscription definitions

will be added to the HTTP request.

Parameters:

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



137
138
139
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 137

def list_with_http_info(custom_headers:nil)
  list_async(custom_headers:custom_headers).value!
end

#update_management_group(management_group_id, external_subscription_name, custom_headers: nil) ⇒ Object

Updates the management group of an ExternalSubscription

'aws-UsageAccountId') will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • external_subscription_name (String)

    External Subscription Name. (eg

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that



406
407
408
409
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 406

def update_management_group(management_group_id, external_subscription_name, custom_headers:nil)
  response = update_management_group_async(management_group_id, external_subscription_name, custom_headers:custom_headers).value!
  nil
end

#update_management_group_async(management_group_id, external_subscription_name, custom_headers: nil) ⇒ Concurrent::Promise

Updates the management group of an ExternalSubscription

'aws-UsageAccountId') to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • external_subscription_name (String)

    External Subscription Name. (eg

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 437

def update_management_group_async(management_group_id, external_subscription_name, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
  fail ArgumentError, 'external_subscription_name is nil' if external_subscription_name.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'managementGroupId' => management_group_id,'externalSubscriptionName' => external_subscription_name},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:put, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 204
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end

#update_management_group_with_http_info(management_group_id, external_subscription_name, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Updates the management group of an ExternalSubscription

'aws-UsageAccountId') will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    ManagementGroup ID

  • external_subscription_name (String)

    External Subscription Name. (eg

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



422
423
424
# File 'lib/2019-03-01-preview/generated/azure_mgmt_cost_management/external_subscription.rb', line 422

def update_management_group_with_http_info(management_group_id, external_subscription_name, custom_headers:nil)
  update_management_group_async(management_group_id, external_subscription_name, custom_headers:custom_headers).value!
end