Class: Azure::CDN::Mgmt::V2015_06_01::Origins

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2015-06-01/generated/azure_mgmt_cdn/origins.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 msdn.microsoft.com/en-us/library/azure/dn790557.aspx.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Origins

Creates and initializes a new instance of the Origins class.

Parameters:

  • client

    service class for accessing basic functionality.



20
21
22
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 20

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientCdnManagementClient (readonly)

Returns reference to the CdnManagementClient.

Returns:



25
26
27
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 25

def client
  @client
end

Instance Method Details

#begin_create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Creates a new CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



412
413
414
415
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 412

def begin_create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = begin_create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#begin_create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Creates a new CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • origin_properties (OriginParameters)

    Origin properties

  • 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

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 453

def begin_create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'origin_name is nil' if origin_name.nil?
  fail ArgumentError, 'origin_properties is nil' if origin_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?

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

  # Serialize Request
  request_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::OriginParameters.mapper()
  request_content = @client.serialize(request_mapper,  origin_properties)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'originName' => origin_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 || {}),
      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 == 200 || status_code == 201 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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
    # Deserialize Response
    if status_code == 202
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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

#begin_create_with_http_info(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Creates a new CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



433
434
435
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 433

def begin_create_with_http_info(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  begin_create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
end

#begin_delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Deletes an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



683
684
685
686
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 683

def begin_delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = begin_delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#begin_delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Deletes an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • 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

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 722

def begin_delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'origin_name is nil' if origin_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}/origins/{originName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'originName' => origin_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 || {}),
      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 == 202 || 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?
    # Deserialize Response
    if status_code == 202
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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

#begin_delete_if_exists_with_http_info(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • 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

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



703
704
705
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 703

def begin_delete_if_exists_with_http_info(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  begin_delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers).value!
end

#begin_update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Updates an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



553
554
555
556
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 553

def begin_update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = begin_update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#begin_update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Updates an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • origin_properties (OriginParameters)

    Origin properties

  • 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

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 594

def begin_update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'origin_name is nil' if origin_name.nil?
  fail ArgumentError, 'origin_properties is nil' if origin_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?

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

  # Serialize Request
  request_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::OriginParameters.mapper()
  request_content = @client.serialize(request_mapper,  origin_properties)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'originName' => origin_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 || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:patch, 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 || status_code == 202
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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
    # Deserialize Response
    if status_code == 202
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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

#begin_update_with_http_info(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Updates an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



574
575
576
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 574

def begin_update_with_http_info(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  begin_update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
end

#create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Creates a new CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



252
253
254
255
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 252

def create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

response.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 272

def create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_create_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

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

  promise
end

#delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Deletes an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



359
360
361
362
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 359

def delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

endpoint. group. Azure subscription. will be added to the HTTP request.

response.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • 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

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

    A hash of custom headers that

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 378

def delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_delete_if_exists_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

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

  promise
end

#get(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Gets an existing CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



143
144
145
146
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 143

def get(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = get_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#get_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Gets an existing CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • 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

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 182

def get_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  fail ArgumentError, 'origin_name is nil' if origin_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}/origins/{originName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'originName' => origin_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 || {}),
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.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(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Gets an existing CDN origin within an endpoint.

needs to be unique under endpoint group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin, an arbitrary value but it

  • 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

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



163
164
165
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 163

def get_with_http_info(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  get_async(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers).value!
end

#list_by_endpoint(endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ OriginListResult

Lists the existing CDN origins within an endpoint.

group. Azure subscription. will be added to the HTTP request.

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

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

    A hash of custom headers that

Returns:

  • (OriginListResult)

    operation results.



40
41
42
43
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 40

def list_by_endpoint(endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = list_by_endpoint_async(endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

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

Lists the existing CDN origins within an endpoint.

group. Azure subscription. to the HTTP request.

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

  • 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
117
118
119
120
121
122
123
124
125
126
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 75

def list_by_endpoint_async(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}/origins'

  request_url = @base_url || @client.base_url

  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 || {}),
      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?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::OriginListResult.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_endpoint_with_http_info(endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Lists the existing CDN origins within an endpoint.

group. Azure subscription. will be added to the HTTP request.

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

  • 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/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 58

def list_by_endpoint_with_http_info(endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  list_by_endpoint_async(endpoint_name, profile_name, resource_group_name, custom_headers).value!
end

#update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Origin

Updates an existing CDN origin within an endpoint.

endpoint. group. Azure subscription. will be added to the HTTP request.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Origin)

    operation results.



306
307
308
309
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 306

def update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  response = update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

endpoint. group. Azure subscription. will be added to the HTTP request.

response.

Parameters:

  • origin_name (String)

    Name of the origin. Must be unique within

  • origin_properties (OriginParameters)

    Origin properties

  • 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

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

    A hash of custom headers that

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/2015-06-01/generated/azure_mgmt_cdn/origins.rb', line 326

def update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_update_async(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::CDN::Mgmt::V2015_06_01::Models::Origin.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

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

  promise
end