Class: Azure::ARM::CDN::CustomDomains

Inherits:
Object
  • Object
show all
Includes:
Models, MsRestAzure
Defined in:
lib/azure_mgmt_cdn/custom_domains.rb

Overview

Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure. For more information, see <a href=“msdn.microsoft.com/en-us/library/azure/dn790557.aspx”>Authenticating Azure Resource Manager requests.</a>

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CustomDomains

Creates and initializes a new instance of the CustomDomains class.

Parameters:

  • client

    service class for accessing basic functionality.



22
23
24
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 22

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns reference to the CdnManagementClient.

Returns:

  • reference to the CdnManagementClient



27
28
29
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 27

def client
  @client
end

Instance Method Details

#begin_create(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Creates a new CDN Custom Domain within an Endpoint

endpoint properties required for creation group Azure subscription applied to HTTP request.

response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • custom_domain_properties (CustomDomainParameters)

    Custom domain

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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
297
298
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 224

def begin_create(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'custom_domain_name is nil' if custom_domain_name.nil?
  fail ArgumentError, 'custom_domain_properties is nil' if custom_domain_properties.nil?
  custom_domain_properties.validate unless custom_domain_properties.nil?
  fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
  fail ArgumentError, 'profile_name is nil' if profile_name.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  request_headers = {}

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

  # Serialize Request
  request_headers['Content-Type'] = 'application/json; charset=utf-8'
  unless custom_domain_properties.nil?
    custom_domain_properties = CustomDomainParameters.serialize_object(custom_domain_properties)
  end
  request_content = JSON.generate(custom_domain_properties, quirks_mode: true)
  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'customDomainName' => custom_domain_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {})
  }
  request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
  promise = request.run_promise do |req|
    @client.credentials.sign_request(req) unless @client.credentials.nil?
  end

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

    # Create Result
    result = MsRestAzure::AzureOperationResponse.new(request, http_response)
    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = CustomDomain.deserialize_object(parsed_response)
        end
        result.body = parsed_response
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end
    # Deserialize Response
    if status_code == 202
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = CustomDomain.deserialize_object(parsed_response)
        end
        result.body = 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

#begin_delete_if_exists(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Deletes an existing CDN Custom Domain within an Endpoint

endpoint group Azure subscription applied to HTTP request.

response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



427
428
429
430
431
432
433
434
435
436
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/azure_mgmt_cdn/custom_domains.rb', line 427

def begin_delete_if_exists(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'custom_domain_name is nil' if custom_domain_name.nil?
  fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
  fail ArgumentError, 'profile_name is nil' if profile_name.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  request_headers = {}

  # 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 = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'customDomainName' => custom_domain_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }
  request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
  promise = request.run_promise do |req|
    @client.credentials.sign_request(req) unless @client.credentials.nil?
  end

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

    # Create Result
    result = MsRestAzure::AzureOperationResponse.new(request, http_response)
    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 202
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = CustomDomain.deserialize_object(parsed_response)
        end
        result.body = 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

#create(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Creates a new CDN Custom Domain within an Endpoint

endpoint properties required for creation group Azure subscription client request, current version is 2015-06-01 for the response.

response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • custom_domain_properties (CustomDomainParameters)

    Custom domain

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • @client.subscription_id (String)

    Azure Subscription ID

  • @client.api_version (String)

    Version of the API to be used with the

  • @client.accept_language (String)

    Gets or sets the preferred language

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 187

def create(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_create(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      unless parsed_response.nil?
        parsed_response = CustomDomain.deserialize_object(parsed_response)
      end
    end

    # Waiting for response.
    @client.get_put_operation_result(response, deserialize_method)
  end

  promise
end

#delete_if_exists(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Deletes an existing CDN Custom Domain within an Endpoint

endpoint group Azure subscription response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 392

def delete_if_exists(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_delete_if_exists(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      unless parsed_response.nil?
        parsed_response = CustomDomain.deserialize_object(parsed_response)
      end
    end

   # Waiting for response.
   @client.get_post_or_delete_operation_result(response, deserialize_method)
  end

  promise
end

#get(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Gets an existing CDN Custom Domain within an Endpoint

endpoint group Azure subscription applied to HTTP request.

response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 112

def get(custom_domain_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'custom_domain_name is nil' if custom_domain_name.nil?
  fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
  fail ArgumentError, 'profile_name is nil' if profile_name.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  request_headers = {}

  # 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 = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'customDomainName' => custom_domain_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }
  request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
  promise = request.run_promise do |req|
    @client.credentials.sign_request(req) unless @client.credentials.nil?
  end

  promise = promise.then do |http_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(request, http_response, error_model)
    end

    # Create Result
    result = MsRestAzure::AzureOperationResponse.new(request, http_response)
    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = CustomDomain.deserialize_object(parsed_response)
        end
        result.body = 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_endpoint(endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Lists the existing CDN Custom Domains within an Endpoint

group Azure subscription applied to HTTP request.

response.

Parameters:

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 43

def list_by_endpoint(endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
  fail ArgumentError, 'profile_name is nil' if profile_name.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  request_headers = {}

  # 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 = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }
  request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
  promise = request.run_promise do |req|
    @client.credentials.sign_request(req) unless @client.credentials.nil?
  end

  promise = promise.then do |http_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(request, http_response, error_model)
    end

    # Create Result
    result = MsRestAzure::AzureOperationResponse.new(request, http_response)
    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = CustomDomainListResult.deserialize_object(parsed_response)
        end
        result.body = 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

#update(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Updates an existing CDN Custom Domain within an Endpoint

endpoint properties to update group Azure subscription applied to HTTP request.

response.

Parameters:

  • custom_domain_name (String)

    Name of the custom domain within an

  • custom_domain_properties (CustomDomainParameters)

    Custom domain

  • endpoint_name (String)

    Name of the endpoint within the CDN profile

  • profile_name (String)

    Name of the CDN profile within the resource

  • resource_group_name (String)

    Name of the resource group within the

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
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
# File 'lib/azure_mgmt_cdn/custom_domains.rb', line 318

def update(custom_domain_name, custom_domain_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'custom_domain_name is nil' if custom_domain_name.nil?
  fail ArgumentError, 'custom_domain_properties is nil' if custom_domain_properties.nil?
  custom_domain_properties.validate unless custom_domain_properties.nil?
  fail ArgumentError, 'endpoint_name is nil' if endpoint_name.nil?
  fail ArgumentError, 'profile_name is nil' if profile_name.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  request_headers = {}

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

  # Serialize Request
  request_headers['Content-Type'] = 'application/json; charset=utf-8'
  unless custom_domain_properties.nil?
    custom_domain_properties = CustomDomainParameters.serialize_object(custom_domain_properties)
  end
  request_content = JSON.generate(custom_domain_properties, quirks_mode: true)
  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'customDomainName' => custom_domain_name,'endpointName' => endpoint_name,'profileName' => profile_name,'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {})
  }
  request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :patch, options)
  promise = request.run_promise do |req|
    @client.credentials.sign_request(req) unless @client.credentials.nil?
  end

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

    # Create Result
    result = MsRestAzure::AzureOperationResponse.new(request, http_response)
    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    begin
      parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
      unless parsed_response.nil?
        parsed_response = ErrorResponse.deserialize_object(parsed_response)
      end
      result.body = parsed_response
    rescue Exception => e
      fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
    end

    result
  end

  promise.execute
end