Class: Azure::ResourcesManagement::Mgmt::V2017_11_01_preview::ManagementGroupSubscriptions

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb

Overview

The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ManagementGroupSubscriptions

Creates and initializes a new instance of the ManagementGroupSubscriptions class.

Parameters:

  • client

    service class for accessing basic functionality.



21
22
23
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 21

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientManagementGroupsAPI (readonly)

Returns reference to the ManagementGroupsAPI.

Returns:



26
27
28
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 26

def client
  @client
end

Instance Method Details

#create(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ Object

Associates existing subscription with the management group.

any caches. will be added to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

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

    A hash of custom headers that



40
41
42
43
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 40

def create(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  response = create_async(group_id, subscription_id, cache_control:cache_control, custom_headers:custom_headers).value!
  nil
end

#create_async(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ Concurrent::Promise

Associates existing subscription with the management group.

any caches. to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
115
116
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 75

def create_async(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  fail ArgumentError, 'group_id is nil' if group_id.nil?
  fail ArgumentError, 'subscription_id is nil' if subscription_id.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['Cache-Control'] = cache_control unless cache_control.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'groupId' => group_id,'subscriptionId' => subscription_id},
      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
  end

  promise.execute
end

#create_with_http_info(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Associates existing subscription with the management group.

any caches. will be added to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



58
59
60
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 58

def create_with_http_info(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  create_async(group_id, subscription_id, cache_control:cache_control, custom_headers:custom_headers).value!
end

#delete(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ Object

De-associates subscription from the management group.

any caches. will be added to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

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

    A hash of custom headers that



130
131
132
133
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 130

def delete(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  response = delete_async(group_id, subscription_id, cache_control:cache_control, custom_headers:custom_headers).value!
  nil
end

#delete_async(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ Concurrent::Promise

De-associates subscription from the management group.

any caches. to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
199
200
201
202
203
204
205
206
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 165

def delete_async(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  fail ArgumentError, 'group_id is nil' if group_id.nil?
  fail ArgumentError, 'subscription_id is nil' if subscription_id.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['Cache-Control'] = cache_control unless cache_control.nil?
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'groupId' => group_id,'subscriptionId' => subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, 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
  end

  promise.execute
end

#delete_with_http_info(group_id, subscription_id, cache_control: 'no-cache', custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

De-associates subscription from the management group.

any caches. will be added to the HTTP request.

Parameters:

  • group_id (String)

    Management Group ID.

  • subscription_id (String)

    Subscription ID.

  • cache_control (String) (defaults to: 'no-cache')

    Indicates that the request shouldn’t utilize

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



148
149
150
# File 'lib/2017-11-01-preview/generated/azure_mgmt_resources_management/management_group_subscriptions.rb', line 148

def delete_with_http_info(group_id, subscription_id, cache_control:'no-cache', custom_headers:nil)
  delete_async(group_id, subscription_id, cache_control:cache_control, custom_headers:custom_headers).value!
end