Class: Azure::ARM::CDN::Origins

Inherits:
Object
  • Object
show all
Includes:
Models, MsRestAzure
Defined in:
lib/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 <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) ⇒ Origins

Creates and initializes a new instance of the Origins class.

Parameters:

  • client

    service class for accessing basic functionality.



22
23
24
# File 'lib/azure_mgmt_cdn/origins.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/origins.rb', line 27

def client
  @client
end

Instance Method Details

#begin_create(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 applied to 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

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



222
223
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
# File 'lib/azure_mgmt_cdn/origins.rb', line 222

def begin_create(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?
  origin_properties.validate unless 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?

  # Serialize Request
  request_headers['Content-Type'] = 'application/json; charset=utf-8'
  unless origin_properties.nil?
    origin_properties = OriginParameters.serialize_object(origin_properties)
  end
  request_content = JSON.generate(origin_properties, quirks_mode: true)
  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
  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 || {})
  }
  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 = Origin.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 = Origin.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(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Deletes an existing CDN Origin within an Endpoint

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

response.

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

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



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
# File 'lib/azure_mgmt_cdn/origins.rb', line 478

def begin_delete_if_exists(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}'
  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 || {})
  }
  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 == 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 = Origin.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_update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Updates an existing CDN Origin within an Endpoint

needs to be unique under endpoint group Azure subscription applied to 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

  • The (Hash{String => String})

    hash of custom headers need to be

Returns:

  • (Concurrent::Promise)

    Promise object which allows to get HTTP



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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/azure_mgmt_cdn/origins.rb', line 354

def begin_update(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?
  origin_properties.validate unless 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?

  # Serialize Request
  request_headers['Content-Type'] = 'application/json; charset=utf-8'
  unless origin_properties.nil?
    origin_properties = OriginParameters.serialize_object(origin_properties)
  end
  request_content = JSON.generate(origin_properties, quirks_mode: true)
  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}'
  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 || {})
  }
  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 == 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 == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        unless parsed_response.nil?
          parsed_response = Origin.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 = Origin.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(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 client request, current version is 2015-06-01 for the response.

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

  • @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



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

def create(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_create(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|
      unless parsed_response.nil?
        parsed_response = Origin.deserialize_object(parsed_response)
      end
    end

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

  promise
end

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

Deletes an existing CDN Origin within an Endpoint

needs to be unique under endpoint group Azure subscription response.

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

Returns:

  • (Concurrent::Promise)

    promise which provides async access to http



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/azure_mgmt_cdn/origins.rb', line 443

def delete_if_exists(origin_name, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_delete_if_exists(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|
      unless parsed_response.nil?
        parsed_response = Origin.deserialize_object(parsed_response)
      end
    end

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

  promise
end

#get(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 applied to HTTP request.

response.

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

  • 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/origins.rb', line 112

def get(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}'
  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 || {})
  }
  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 = Origin.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 Origins 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/origins.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}/origins'
  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 = OriginListResult.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(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Updates an existing CDN Origin within an Endpoint

needs to be unique under endpoint group Azure subscription client request, current version is 2015-06-01 for the response.

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

  • @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



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/azure_mgmt_cdn/origins.rb', line 318

def update(origin_name, origin_properties, endpoint_name, profile_name, resource_group_name, custom_headers = nil)
  # Send request
  promise = begin_update(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|
      unless parsed_response.nil?
        parsed_response = Origin.deserialize_object(parsed_response)
      end
    end

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

  promise
end