Class: Azure::ARM::CognitiveServices::CognitiveServicesAccounts

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

Overview

Cognitive Services Management Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ CognitiveServicesAccounts

Creates and initializes a new instance of the CognitiveServicesAccounts class.

Parameters:

  • client

    service class for accessing basic functionality.



18
19
20
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientCognitiveServicesManagementClient (readonly)

Returns reference to the CognitiveServicesManagementClient.

Returns:



23
24
25
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 23

def client
  @client
end

Instance Method Details

#create(resource_group_name, account_name, parameters, custom_headers = nil) ⇒ CognitiveServicesAccount

Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It’s also the resource type for billing.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to provide for the created account. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • parameters (CognitiveServicesAccountCreateParameters)

    The parameters

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

    A hash of custom headers that

Returns:



43
44
45
46
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 43

def create(resource_group_name, , parameters, custom_headers = nil)
  response = create_async(resource_group_name, , parameters, custom_headers).value!
  response.body unless response.nil?
end

#create_async(resource_group_name, account_name, parameters, custom_headers = nil) ⇒ Concurrent::Promise

Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It’s also the resource type for billing.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to provide for the created account. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • parameters (CognitiveServicesAccountCreateParameters)

    The parameters

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
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
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 88

def create_async(resource_group_name, , parameters, custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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 = CognitiveServicesAccountCreateParameters.mapper()
  request_content = @client.serialize(request_mapper,  parameters, 'parameters')
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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 == 200 || status_code == 201
      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)
        result_mapper = CognitiveServicesAccount.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
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = CognitiveServicesAccount.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

#create_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It’s also the resource type for billing.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to provide for the created account. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • parameters (CognitiveServicesAccountCreateParameters)

    The parameters

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



66
67
68
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 66

def create_with_http_info(resource_group_name, , parameters, custom_headers = nil)
  create_async(resource_group_name, , parameters, custom_headers).value!
end

#delete(resource_group_name, account_name, custom_headers = nil) ⇒ Object

Deletes a Cognitive Services account from the resource group.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that



314
315
316
317
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 314

def delete(resource_group_name, , custom_headers = nil)
  response = delete_async(resource_group_name, , custom_headers).value!
  nil
end

#delete_async(resource_group_name, account_name, custom_headers = nil) ⇒ Concurrent::Promise

Deletes a Cognitive Services account from the resource group.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 351

def delete_async(resource_group_name, , custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.CognitiveServices/accounts/{accountName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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 == 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?

    result
  end

  promise.execute
end

#delete_with_http_info(resource_group_name, account_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes a Cognitive Services account from the resource group.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



333
334
335
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 333

def delete_with_http_info(resource_group_name, , custom_headers = nil)
  delete_async(resource_group_name, , custom_headers).value!
end

#get_properties(resource_group_name, account_name, custom_headers = nil) ⇒ CognitiveServicesAccount

Returns a Cognitive Services account specified by the parameters.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:



410
411
412
413
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 410

def get_properties(resource_group_name, , custom_headers = nil)
  response = get_properties_async(resource_group_name, , custom_headers).value!
  response.body unless response.nil?
end

#get_properties_async(resource_group_name, account_name, custom_headers = nil) ⇒ Concurrent::Promise

Returns a Cognitive Services account specified by the parameters.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 447

def get_properties_async(resource_group_name, , custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.CognitiveServices/accounts/{accountName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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)
        result_mapper = CognitiveServicesAccount.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_properties_with_http_info(resource_group_name, account_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Returns a Cognitive Services account specified by the parameters.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



429
430
431
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 429

def get_properties_with_http_info(resource_group_name, , custom_headers = nil)
  get_properties_async(resource_group_name, , custom_headers).value!
end

#list(custom_headers = nil) ⇒ CognitiveServicesAccountListResult

Returns all the resources of a particular type belonging to a subscription.

will be added to the HTTP request.

Parameters:

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

    A hash of custom headers that

Returns:



603
604
605
606
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 603

def list(custom_headers = nil)
  response = list_async(custom_headers).value!
  response.body unless response.nil?
end

#list_async(custom_headers = nil) ⇒ Concurrent::Promise

Returns all the resources of a particular type belonging to a subscription.

to the HTTP request.

Parameters:

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
667
668
669
670
671
672
673
674
675
676
677
678
679
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 628

def list_async(custom_headers = nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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}/providers/Microsoft.CognitiveServices/accounts'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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)
        result_mapper = CognitiveServicesAccountListResult.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_by_resource_group(resource_group_name, custom_headers = nil) ⇒ CognitiveServicesAccountListResult

Returns all the resources of a particular type belonging to a resource group

the user’s subscription. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

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

    A hash of custom headers that

Returns:



512
513
514
515
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 512

def list_by_resource_group(resource_group_name, custom_headers = nil)
  response = list_by_resource_group_async(resource_group_name, custom_headers).value!
  response.body unless response.nil?
end

#list_by_resource_group_async(resource_group_name, custom_headers = nil) ⇒ Concurrent::Promise

Returns all the resources of a particular type belonging to a resource group

the user’s subscription. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 541

def list_by_resource_group_async(resource_group_name, custom_headers = 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.CognitiveServices/accounts'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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)
        result_mapper = CognitiveServicesAccountListResult.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_by_resource_group_with_http_info(resource_group_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Returns all the resources of a particular type belonging to a resource group

the user’s subscription. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



527
528
529
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 527

def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil)
  list_by_resource_group_async(resource_group_name, custom_headers).value!
end

#list_keys(resource_group_name, account_name, custom_headers = nil) ⇒ CognitiveServicesAccountKeys

Lists the account keys for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Congitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:



695
696
697
698
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 695

def list_keys(resource_group_name, , custom_headers = nil)
  response = list_keys_async(resource_group_name, , custom_headers).value!
  response.body unless response.nil?
end

#list_keys_async(resource_group_name, account_name, custom_headers = nil) ⇒ Concurrent::Promise

Lists the account keys for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Congitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
775
776
777
778
779
780
781
782
783
784
785
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 732

def list_keys_async(resource_group_name, , custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.CognitiveServices/accounts/{accountName}/listKeys'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, 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)
        result_mapper = CognitiveServicesAccountKeys.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_keys_with_http_info(resource_group_name, account_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Lists the account keys for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Congitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



714
715
716
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 714

def list_keys_with_http_info(resource_group_name, , custom_headers = nil)
  list_keys_async(resource_group_name, , custom_headers).value!
end

#list_skus(resource_group_name, account_name, custom_headers = nil) ⇒ CognitiveServicesAccountEnumerateSkusResult

List available SKUs for the requested Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:



929
930
931
932
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 929

def list_skus(resource_group_name, , custom_headers = nil)
  response = list_skus_async(resource_group_name, , custom_headers).value!
  response.body unless response.nil?
end

#list_skus_async(resource_group_name, account_name, custom_headers = nil) ⇒ Concurrent::Promise

List available SKUs for the requested Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 966

def list_skus_async(resource_group_name, , custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.CognitiveServices/accounts/{accountName}/skus'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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)
        result_mapper = CognitiveServicesAccountEnumerateSkusResult.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_skus_with_http_info(resource_group_name, account_name, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

List available SKUs for the requested Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



948
949
950
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 948

def list_skus_with_http_info(resource_group_name, , custom_headers = nil)
  list_skus_async(resource_group_name, , custom_headers).value!
end

#list_with_http_info(custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Returns all the resources of a particular type belonging to a subscription.

will be added to the HTTP request.

Parameters:

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



616
617
618
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 616

def list_with_http_info(custom_headers = nil)
  list_async(custom_headers).value!
end

#regenerate_key(resource_group_name, account_name, key_name = nil, custom_headers = nil) ⇒ CognitiveServicesAccountKeys

Regenerates the specified account key for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. include: ‘Key1’, ‘Key2’ will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • key_name (KeyName) (defaults to: nil)

    key name to generate (Key1|Key2). Possible values

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

    A hash of custom headers that

Returns:



804
805
806
807
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 804

def regenerate_key(resource_group_name, , key_name = nil, custom_headers = nil)
  response = regenerate_key_async(resource_group_name, , key_name, custom_headers).value!
  response.body unless response.nil?
end

#regenerate_key_async(resource_group_name, account_name, key_name = nil, custom_headers = nil) ⇒ Concurrent::Promise

Regenerates the specified account key for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. include: ‘Key1’, ‘Key2’ to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • key_name (KeyName) (defaults to: nil)

    key name to generate (Key1|Key2). Possible values

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 847

def regenerate_key_async(resource_group_name, , key_name = nil, custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?

  body = RegenerateKeyParameters.new
  unless key_name.nil?
    body.key_name = key_name
  end

  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 = RegenerateKeyParameters.mapper()
  request_content = @client.serialize(request_mapper,  body, 'body')
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, 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)
        result_mapper = CognitiveServicesAccountKeys.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

#regenerate_key_with_http_info(resource_group_name, account_name, key_name = nil, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Regenerates the specified account key for the specified Cognitive Services account.

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. include: ‘Key1’, ‘Key2’ will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • key_name (KeyName) (defaults to: nil)

    key name to generate (Key1|Key2). Possible values

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



826
827
828
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 826

def regenerate_key_with_http_info(resource_group_name, , key_name = nil, custom_headers = nil)
  regenerate_key_async(resource_group_name, , key_name, custom_headers).value!
end

#update(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil) ⇒ CognitiveServicesAccount

Updates a Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • sku (Sku) (defaults to: nil)
  • tags (Hash{String => String}) (defaults to: nil)

    Gets or sets a list of key value pairs

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

    A hash of custom headers that

Returns:



183
184
185
186
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 183

def update(resource_group_name, , sku = nil, tags = nil, custom_headers = nil)
  response = update_async(resource_group_name, , sku, tags, custom_headers).value!
  response.body unless response.nil?
end

#update_async(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil) ⇒ Concurrent::Promise

Updates a Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • sku (Sku) (defaults to: nil)
  • tags (Hash{String => String}) (defaults to: nil)

    Gets or sets a list of key value pairs

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
299
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 232

def update_async(resource_group_name, , sku = nil, tags = nil, custom_headers = nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'account_name is nil' if .nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?

  body = CognitiveServicesAccountUpdateParameters.new
  unless sku.nil? && tags.nil?
    body.sku = sku
    body.tags = tags
  end

  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 = CognitiveServicesAccountUpdateParameters.mapper()
  request_content = @client.serialize(request_mapper,  body, 'body')
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'accountName' => ,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {})
  }

  request_url = @base_url || @client.base_url

  request = MsRest::HttpOperationRequest.new(request_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
      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)
        result_mapper = CognitiveServicesAccount.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

#update_with_http_info(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil) ⇒ MsRestAzure::AzureOperationResponse

Updates a Cognitive Services account

the user’s subscription. within the specified resource group. Cognitive Services account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater than 128 characters and value no greater than 256 characters. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group within

  • account_name (String)

    The name of the cognitive services account

  • sku (Sku) (defaults to: nil)
  • tags (Hash{String => String}) (defaults to: nil)

    Gets or sets a list of key value pairs

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



208
209
210
# File 'lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb', line 208

def update_with_http_info(resource_group_name, , sku = nil, tags = nil, custom_headers = nil)
  update_async(resource_group_name, , sku, tags, custom_headers).value!
end