Class: Azure::ARM::DevTestLabs::ArtifactOperations

Inherits:
Object
  • Object
show all
Includes:
Models, MsRestAzure
Defined in:
lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb

Overview

Azure DevTest Labs REST API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ArtifactOperations

Creates and initializes a new instance of the ArtifactOperations class.

Parameters:

  • client

    service class for accessing basic functionality.



18
19
20
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientDevTestLabsClient (readonly)

Returns reference to the DevTestLabsClient.

Returns:



23
24
25
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 23

def client
  @client
end

Instance Method Details

#generate_arm_template(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil) ⇒ ArmTemplateInfo

Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact.

will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

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

    A hash of custom headers that

Returns:



248
249
250
251
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 248

def generate_arm_template(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil)
  response = generate_arm_template_async(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers).value!
  response.body unless response.nil?
end

#generate_arm_template_async(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil) ⇒ Concurrent::Promise

Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact.

to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

  • generate_arm_template_request (GenerateArmTemplateRequest)
  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
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
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 285

def generate_arm_template_async(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'lab_name is nil' if lab_name.nil?
  fail ArgumentError, 'artifact_source_name is nil' if artifact_source_name.nil?
  fail ArgumentError, 'name is nil' if name.nil?
  fail ArgumentError, 'generate_arm_template_request is nil' if generate_arm_template_request.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 = GenerateArmTemplateRequest.mapper()
  request_content = @client.serialize(request_mapper,  generate_arm_template_request, 'generate_arm_template_request')
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}/generateArmTemplate'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'artifactSourceName' => artifact_source_name,'name' => name},
      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(:post, 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 MsRestAzure::AzureOperationError.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 = ArmTemplateInfo.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
      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

#generate_arm_template_with_http_info(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Generates an ARM template for the given artifact, uploads the required files to a storage account, and validates the generated artifact.

will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



267
268
269
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 267

def generate_arm_template_with_http_info(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers = nil)
  generate_arm_template_async(resource_group_name, lab_name, artifact_source_name, name, generate_arm_template_request, custom_headers).value!
end

#get_resource(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil) ⇒ Artifact

Get artifact.

will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

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

    A hash of custom headers that

Returns:



147
148
149
150
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 147

def get_resource(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil)
  response = get_resource_async(resource_group_name, lab_name, artifact_source_name, name, custom_headers).value!
  response.body unless response.nil?
end

#get_resource_async(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil) ⇒ Concurrent::Promise

Get artifact.

to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
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
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 180

def get_resource_async(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'lab_name is nil' if lab_name.nil?
  fail ArgumentError, 'artifact_source_name is nil' if artifact_source_name.nil?
  fail ArgumentError, 'name is nil' if name.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.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts/{name}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'artifactSourceName' => artifact_source_name,'name' => name},
      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 MsRestAzure::AzureOperationError.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 = Artifact.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
      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_resource_with_http_info(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Get artifact.

will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • name (String)

    The name of the artifact.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



164
165
166
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 164

def get_resource_with_http_info(resource_group_name, lab_name, artifact_source_name, name, custom_headers = nil)
  get_resource_async(resource_group_name, lab_name, artifact_source_name, name, custom_headers).value!
end

#list(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil) ⇒ Array<Artifact>

List artifacts in a given artifact source.

operation. notation. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation.

  • top (Integer) (defaults to: nil)

    The maximum number of resources to return from the

  • order_by (String) (defaults to: nil)

    The ordering expression for the results, using OData

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

    A hash of custom headers that

Returns:

  • (Array<Artifact>)

    operation results.



41
42
43
44
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 41

def list(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
  first_page = list_as_lazy(resource_group_name, lab_name, artifact_source_name, filter, top, order_by, custom_headers)
  first_page.get_all_items
end

#list_as_lazy(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil) ⇒ ResponseWithContinuationArtifact

List artifacts in a given artifact source.

operation. notation. will be added to the HTTP request.

of the response.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation.

  • top (Integer) (defaults to: nil)

    The maximum number of resources to return from the

  • order_by (String) (defaults to: nil)

    The ordering expression for the results, using OData

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

    A hash of custom headers that

Returns:



453
454
455
456
457
458
459
460
461
462
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 453

def list_as_lazy(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
  response = list_async(resource_group_name, lab_name, artifact_source_name, filter, top, order_by, custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_next_async(next_page_link, custom_headers)
    end
    page
  end
end

#list_async(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil) ⇒ Concurrent::Promise

List artifacts in a given artifact source.

operation. notation. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation.

  • top (Integer) (defaults to: nil)

    The maximum number of resources to return from the

  • order_by (String) (defaults to: nil)

    The ordering expression for the results, using OData

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
127
128
129
130
131
132
133
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 82

def list_async(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'lab_name is nil' if lab_name.nil?
  fail ArgumentError, 'artifact_source_name is nil' if artifact_source_name.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.DevTestLab/labs/{labName}/artifactsources/{artifactSourceName}/artifacts'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'labName' => lab_name,'artifactSourceName' => artifact_source_name},
      query_params: {'$filter' => filter,'$top' => top,'$orderBy' => order_by,'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 MsRestAzure::AzureOperationError.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 = ResponseWithContinuationArtifact.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
      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_next(next_page_link, custom_headers = nil) ⇒ ResponseWithContinuationArtifact

List artifacts in a given artifact source.

to List operation. will be added to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:



359
360
361
362
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 359

def list_next(next_page_link, custom_headers = nil)
  response = list_next_async(next_page_link, custom_headers).value!
  response.body unless response.nil?
end

#list_next_async(next_page_link, custom_headers = nil) ⇒ Concurrent::Promise

List artifacts in a given artifact source.

to List operation. to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
429
430
431
432
433
434
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 388

def list_next_async(next_page_link, custom_headers = nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.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 = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      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 MsRestAzure::AzureOperationError.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 = ResponseWithContinuationArtifact.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
      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_next_with_http_info(next_page_link, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

List artifacts in a given artifact source.

to List operation. will be added to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



374
375
376
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 374

def list_next_with_http_info(next_page_link, custom_headers = nil)
  list_next_async(next_page_link, custom_headers).value!
end

#list_with_http_info(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

List artifacts in a given artifact source.

operation. notation. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group.

  • lab_name (String)

    The name of the lab.

  • artifact_source_name (String)

    The name of the artifact source.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation.

  • top (Integer) (defaults to: nil)

    The maximum number of resources to return from the

  • order_by (String) (defaults to: nil)

    The ordering expression for the results, using OData

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



62
63
64
# File 'lib/generated/azure_mgmt_devtestlabs/artifact_operations.rb', line 62

def list_with_http_info(resource_group_name, lab_name, artifact_source_name, filter = nil, top = nil, order_by = nil, custom_headers = nil)
  list_async(resource_group_name, lab_name, artifact_source_name, filter, top, order_by, custom_headers).value!
end