azure_mgmt_cognitive_services 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/Rakefile +5 -0
  5. data/azure_mgmt_cognitive_services.gemspec +34 -0
  6. data/lib/azure_mgmt_cognitive_services.rb +5 -0
  7. data/lib/generated/azure_mgmt_cognitive_services.rb +44 -0
  8. data/lib/generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb +1022 -0
  9. data/lib/generated/azure_mgmt_cognitive_services/cognitive_services_management_client.rb +67 -0
  10. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account.rb +151 -0
  11. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account_create_parameters.rb +103 -0
  12. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account_enumerate_skus_result.rb +55 -0
  13. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account_keys.rb +54 -0
  14. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account_list_result.rb +54 -0
  15. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_account_update_parameters.rb +66 -0
  16. data/lib/generated/azure_mgmt_cognitive_services/models/cognitive_services_resource_and_sku.rb +55 -0
  17. data/lib/generated/azure_mgmt_cognitive_services/models/error.rb +45 -0
  18. data/lib/generated/azure_mgmt_cognitive_services/models/error_body.rb +54 -0
  19. data/lib/generated/azure_mgmt_cognitive_services/models/key_name.rb +16 -0
  20. data/lib/generated/azure_mgmt_cognitive_services/models/kind.rb +22 -0
  21. data/lib/generated/azure_mgmt_cognitive_services/models/provisioning_state.rb +18 -0
  22. data/lib/generated/azure_mgmt_cognitive_services/models/regenerate_key_parameters.rb +46 -0
  23. data/lib/generated/azure_mgmt_cognitive_services/models/sku.rb +60 -0
  24. data/lib/generated/azure_mgmt_cognitive_services/models/sku_name.rb +20 -0
  25. data/lib/generated/azure_mgmt_cognitive_services/models/sku_tier.rb +17 -0
  26. data/lib/generated/azure_mgmt_cognitive_services/module_definition.rb +8 -0
  27. data/lib/generated/azure_mgmt_cognitive_services/version.rb +8 -0
  28. metadata +140 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1bb3fb41a9cf8a30bf242b7172cbb40de1cff53
4
+ data.tar.gz: 92600250455cc1e9dd218b6aa83a5d601c40769d
5
+ SHA512:
6
+ metadata.gz: 3426eb455cbabe414976e6e1d1a1bb592d99fbafc40bea4a72e6d6c38f1f8207c2e6ecd6f9bf23b859d0ff31c18c7546c33a1b8844b41c48a8cb1ae70f84caa2
7
+ data.tar.gz: b98c96cfbb4c1b0e2467fadf28b7c98701dd48b54b694fbbbaff759c6d72271f329496a4e71e716b901a94884667edd085c8033560f4e65393ec5c4583aae17a
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --color
3
+ --format documentation
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require "bundler/gem_tasks"
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ lib = File.expand_path('../lib', __FILE__)
6
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
+
8
+ require 'generated/azure_mgmt_cognitive_services/module_definition'
9
+ require 'generated/azure_mgmt_cognitive_services/version'
10
+
11
+ Gem::Specification.new do |spec|
12
+ spec.name = 'azure_mgmt_cognitive_services'
13
+ spec.version = Azure::ARM::CognitiveServices::VERSION
14
+ spec.authors = 'Microsoft Corporation'
15
+ spec.email = 'azrubyteam@microsoft.com'
16
+ spec.description = 'Microsoft Azure Cognitive Services Management Client Library for Ruby'
17
+ spec.summary = 'Official Ruby client library to consume Microsoft Azure Cognitive Services Management services.'
18
+ spec.homepage = 'https://aka.ms/azure-sdk-for-ruby'
19
+ spec.license = 'MIT'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = 'bin'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.required_ruby_version = '>= 1.9.3'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.9'
29
+ spec.add_development_dependency 'rake', '~> 10'
30
+ spec.add_development_dependency 'rspec', '~> 3'
31
+ spec.add_development_dependency 'dotenv', '~> 2'
32
+
33
+ spec.add_runtime_dependency 'ms_rest_azure', '~> 0.3.0'
34
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for license information.
4
+
5
+ require 'generated/azure_mgmt_cognitive_services'
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ require 'uri'
7
+ require 'cgi'
8
+ require 'date'
9
+ require 'json'
10
+ require 'base64'
11
+ require 'erb'
12
+ require 'securerandom'
13
+ require 'time'
14
+ require 'timeliness'
15
+ require 'faraday'
16
+ require 'faraday-cookie_jar'
17
+ require 'concurrent'
18
+ require 'ms_rest'
19
+ require 'generated/azure_mgmt_cognitive_services/module_definition'
20
+ require 'ms_rest_azure'
21
+
22
+ module Azure::ARM::CognitiveServices
23
+ autoload :CognitiveServicesAccounts, 'generated/azure_mgmt_cognitive_services/cognitive_services_accounts.rb'
24
+ autoload :CognitiveServicesManagementClient, 'generated/azure_mgmt_cognitive_services/cognitive_services_management_client.rb'
25
+
26
+ module Models
27
+ autoload :CognitiveServicesAccountCreateParameters, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account_create_parameters.rb'
28
+ autoload :Sku, 'generated/azure_mgmt_cognitive_services/models/sku.rb'
29
+ autoload :CognitiveServicesAccountUpdateParameters, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account_update_parameters.rb'
30
+ autoload :CognitiveServicesAccount, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account.rb'
31
+ autoload :CognitiveServicesAccountListResult, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account_list_result.rb'
32
+ autoload :CognitiveServicesAccountKeys, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account_keys.rb'
33
+ autoload :RegenerateKeyParameters, 'generated/azure_mgmt_cognitive_services/models/regenerate_key_parameters.rb'
34
+ autoload :CognitiveServicesAccountEnumerateSkusResult, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_account_enumerate_skus_result.rb'
35
+ autoload :CognitiveServicesResourceAndSku, 'generated/azure_mgmt_cognitive_services/models/cognitive_services_resource_and_sku.rb'
36
+ autoload :Error, 'generated/azure_mgmt_cognitive_services/models/error.rb'
37
+ autoload :ErrorBody, 'generated/azure_mgmt_cognitive_services/models/error_body.rb'
38
+ autoload :SkuName, 'generated/azure_mgmt_cognitive_services/models/sku_name.rb'
39
+ autoload :SkuTier, 'generated/azure_mgmt_cognitive_services/models/sku_tier.rb'
40
+ autoload :Kind, 'generated/azure_mgmt_cognitive_services/models/kind.rb'
41
+ autoload :ProvisioningState, 'generated/azure_mgmt_cognitive_services/models/provisioning_state.rb'
42
+ autoload :KeyName, 'generated/azure_mgmt_cognitive_services/models/key_name.rb'
43
+ end
44
+ end
@@ -0,0 +1,1022 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::CognitiveServices
7
+ #
8
+ # Cognitive Services Management Client
9
+ #
10
+ class CognitiveServicesAccounts
11
+ include Azure::ARM::CognitiveServices::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the CognitiveServicesAccounts class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return reference to the CognitiveServicesManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Create Cognitive Services Account. Accounts is a resource group wide
27
+ # resource type. It holds the keys for developer to access intelligent APIs.
28
+ # It's also the resource type for billing.
29
+ #
30
+ # @param resource_group_name [String] The name of the resource group within
31
+ # the user's subscription.
32
+ # @param account_name [String] The name of the cognitive services account
33
+ # within the specified resource group. Cognitive Services account names must
34
+ # be between 3 and 24 characters in length and use numbers and lower-case
35
+ # letters only.
36
+ # @param parameters [CognitiveServicesAccountCreateParameters] The parameters
37
+ # to provide for the created account.
38
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
39
+ # will be added to the HTTP request.
40
+ #
41
+ # @return [CognitiveServicesAccount] operation results.
42
+ #
43
+ def create(resource_group_name, account_name, parameters, custom_headers = nil)
44
+ response = create_async(resource_group_name, account_name, parameters, custom_headers).value!
45
+ response.body unless response.nil?
46
+ end
47
+
48
+ #
49
+ # Create Cognitive Services Account. Accounts is a resource group wide
50
+ # resource type. It holds the keys for developer to access intelligent APIs.
51
+ # It's also the resource type for billing.
52
+ #
53
+ # @param resource_group_name [String] The name of the resource group within
54
+ # the user's subscription.
55
+ # @param account_name [String] The name of the cognitive services account
56
+ # within the specified resource group. Cognitive Services account names must
57
+ # be between 3 and 24 characters in length and use numbers and lower-case
58
+ # letters only.
59
+ # @param parameters [CognitiveServicesAccountCreateParameters] The parameters
60
+ # to provide for the created account.
61
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
62
+ # will be added to the HTTP request.
63
+ #
64
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
65
+ #
66
+ def create_with_http_info(resource_group_name, account_name, parameters, custom_headers = nil)
67
+ create_async(resource_group_name, account_name, parameters, custom_headers).value!
68
+ end
69
+
70
+ #
71
+ # Create Cognitive Services Account. Accounts is a resource group wide
72
+ # resource type. It holds the keys for developer to access intelligent APIs.
73
+ # It's also the resource type for billing.
74
+ #
75
+ # @param resource_group_name [String] The name of the resource group within
76
+ # the user's subscription.
77
+ # @param account_name [String] The name of the cognitive services account
78
+ # within the specified resource group. Cognitive Services account names must
79
+ # be between 3 and 24 characters in length and use numbers and lower-case
80
+ # letters only.
81
+ # @param parameters [CognitiveServicesAccountCreateParameters] The parameters
82
+ # to provide for the created account.
83
+ # @param [Hash{String => String}] A hash of custom headers that will be added
84
+ # to the HTTP request.
85
+ #
86
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
87
+ #
88
+ def create_async(resource_group_name, account_name, parameters, custom_headers = nil)
89
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
90
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
91
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
92
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
93
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
94
+
95
+
96
+ request_headers = {}
97
+
98
+ # Set Headers
99
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
100
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
101
+
102
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
103
+
104
+ # Serialize Request
105
+ request_mapper = CognitiveServicesAccountCreateParameters.mapper()
106
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
107
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
108
+
109
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
110
+ options = {
111
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
112
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
113
+ query_params: {'api-version' => @client.api_version},
114
+ body: request_content,
115
+ headers: request_headers.merge(custom_headers || {})
116
+ }
117
+
118
+ request_url = @base_url || @client.base_url
119
+
120
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
121
+ promise = request.run_promise do |req|
122
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
123
+ end
124
+
125
+ promise = promise.then do |http_response|
126
+ status_code = http_response.status
127
+ response_content = http_response.body
128
+ unless status_code == 200 || status_code == 201
129
+ error_model = JSON.load(response_content)
130
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
131
+ end
132
+
133
+ # Create Result
134
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
135
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
136
+ # Deserialize Response
137
+ if status_code == 200
138
+ begin
139
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
140
+ result_mapper = CognitiveServicesAccount.mapper()
141
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
142
+ rescue Exception => e
143
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
144
+ end
145
+ end
146
+ # Deserialize Response
147
+ if status_code == 201
148
+ begin
149
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
150
+ result_mapper = CognitiveServicesAccount.mapper()
151
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
152
+ rescue Exception => e
153
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
154
+ end
155
+ end
156
+
157
+ result
158
+ end
159
+
160
+ promise.execute
161
+ end
162
+
163
+ #
164
+ # Updates a Cognitive Services account
165
+ #
166
+ # @param resource_group_name [String] The name of the resource group within
167
+ # the user's subscription.
168
+ # @param account_name [String] The name of the cognitive services account
169
+ # within the specified resource group. Cognitive Services account names must
170
+ # be between 3 and 24 characters in length and use numbers and lower-case
171
+ # letters only.
172
+ # @param sku [Sku]
173
+ # @param tags [Hash{String => String}] Gets or sets a list of key value pairs
174
+ # that describe the resource. These tags can be used in viewing and grouping
175
+ # this resource (across resource groups). A maximum of 15 tags can be
176
+ # provided for a resource. Each tag must have a key no greater than 128
177
+ # characters and value no greater than 256 characters.
178
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
179
+ # will be added to the HTTP request.
180
+ #
181
+ # @return [CognitiveServicesAccount] operation results.
182
+ #
183
+ def update(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil)
184
+ response = update_async(resource_group_name, account_name, sku, tags, custom_headers).value!
185
+ response.body unless response.nil?
186
+ end
187
+
188
+ #
189
+ # Updates a Cognitive Services account
190
+ #
191
+ # @param resource_group_name [String] The name of the resource group within
192
+ # the user's subscription.
193
+ # @param account_name [String] The name of the cognitive services account
194
+ # within the specified resource group. Cognitive Services account names must
195
+ # be between 3 and 24 characters in length and use numbers and lower-case
196
+ # letters only.
197
+ # @param sku [Sku]
198
+ # @param tags [Hash{String => String}] Gets or sets a list of key value pairs
199
+ # that describe the resource. These tags can be used in viewing and grouping
200
+ # this resource (across resource groups). A maximum of 15 tags can be
201
+ # provided for a resource. Each tag must have a key no greater than 128
202
+ # characters and value no greater than 256 characters.
203
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
204
+ # will be added to the HTTP request.
205
+ #
206
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
207
+ #
208
+ def update_with_http_info(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil)
209
+ update_async(resource_group_name, account_name, sku, tags, custom_headers).value!
210
+ end
211
+
212
+ #
213
+ # Updates a Cognitive Services account
214
+ #
215
+ # @param resource_group_name [String] The name of the resource group within
216
+ # the user's subscription.
217
+ # @param account_name [String] The name of the cognitive services account
218
+ # within the specified resource group. Cognitive Services account names must
219
+ # be between 3 and 24 characters in length and use numbers and lower-case
220
+ # letters only.
221
+ # @param sku [Sku]
222
+ # @param tags [Hash{String => String}] Gets or sets a list of key value pairs
223
+ # that describe the resource. These tags can be used in viewing and grouping
224
+ # this resource (across resource groups). A maximum of 15 tags can be
225
+ # provided for a resource. Each tag must have a key no greater than 128
226
+ # characters and value no greater than 256 characters.
227
+ # @param [Hash{String => String}] A hash of custom headers that will be added
228
+ # to the HTTP request.
229
+ #
230
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
231
+ #
232
+ def update_async(resource_group_name, account_name, sku = nil, tags = nil, custom_headers = nil)
233
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
234
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
235
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
236
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
237
+
238
+ body = CognitiveServicesAccountUpdateParameters.new
239
+ unless sku.nil? && tags.nil?
240
+ body.sku = sku
241
+ body.tags = tags
242
+ end
243
+
244
+ request_headers = {}
245
+
246
+ # Set Headers
247
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
248
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
249
+
250
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
251
+
252
+ # Serialize Request
253
+ request_mapper = CognitiveServicesAccountUpdateParameters.mapper()
254
+ request_content = @client.serialize(request_mapper, body, 'body')
255
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
256
+
257
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
258
+ options = {
259
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
260
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
261
+ query_params: {'api-version' => @client.api_version},
262
+ body: request_content,
263
+ headers: request_headers.merge(custom_headers || {})
264
+ }
265
+
266
+ request_url = @base_url || @client.base_url
267
+
268
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :patch, options)
269
+ promise = request.run_promise do |req|
270
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
271
+ end
272
+
273
+ promise = promise.then do |http_response|
274
+ status_code = http_response.status
275
+ response_content = http_response.body
276
+ unless status_code == 200
277
+ error_model = JSON.load(response_content)
278
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
279
+ end
280
+
281
+ # Create Result
282
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
283
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
284
+ # Deserialize Response
285
+ if status_code == 200
286
+ begin
287
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
288
+ result_mapper = CognitiveServicesAccount.mapper()
289
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
290
+ rescue Exception => e
291
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
292
+ end
293
+ end
294
+
295
+ result
296
+ end
297
+
298
+ promise.execute
299
+ end
300
+
301
+ #
302
+ # Deletes a Cognitive Services account from the resource group.
303
+ #
304
+ # @param resource_group_name [String] The name of the resource group within
305
+ # the user's subscription.
306
+ # @param account_name [String] The name of the cognitive services account
307
+ # within the specified resource group. Cognitive Services account names must
308
+ # be between 3 and 24 characters in length and use numbers and lower-case
309
+ # letters only.
310
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
311
+ # will be added to the HTTP request.
312
+ #
313
+ #
314
+ def delete(resource_group_name, account_name, custom_headers = nil)
315
+ response = delete_async(resource_group_name, account_name, custom_headers).value!
316
+ nil
317
+ end
318
+
319
+ #
320
+ # Deletes a Cognitive Services account from the resource group.
321
+ #
322
+ # @param resource_group_name [String] The name of the resource group within
323
+ # the user's subscription.
324
+ # @param account_name [String] The name of the cognitive services account
325
+ # within the specified resource group. Cognitive Services account names must
326
+ # be between 3 and 24 characters in length and use numbers and lower-case
327
+ # letters only.
328
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
329
+ # will be added to the HTTP request.
330
+ #
331
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
332
+ #
333
+ def delete_with_http_info(resource_group_name, account_name, custom_headers = nil)
334
+ delete_async(resource_group_name, account_name, custom_headers).value!
335
+ end
336
+
337
+ #
338
+ # Deletes a Cognitive Services account from the resource group.
339
+ #
340
+ # @param resource_group_name [String] The name of the resource group within
341
+ # the user's subscription.
342
+ # @param account_name [String] The name of the cognitive services account
343
+ # within the specified resource group. Cognitive Services account names must
344
+ # be between 3 and 24 characters in length and use numbers and lower-case
345
+ # letters only.
346
+ # @param [Hash{String => String}] A hash of custom headers that will be added
347
+ # to the HTTP request.
348
+ #
349
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
350
+ #
351
+ def delete_async(resource_group_name, account_name, custom_headers = nil)
352
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
353
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
354
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
355
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
356
+
357
+
358
+ request_headers = {}
359
+
360
+ # Set Headers
361
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
362
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
363
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
364
+ options = {
365
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
366
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
367
+ query_params: {'api-version' => @client.api_version},
368
+ headers: request_headers.merge(custom_headers || {})
369
+ }
370
+
371
+ request_url = @base_url || @client.base_url
372
+
373
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
374
+ promise = request.run_promise do |req|
375
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
376
+ end
377
+
378
+ promise = promise.then do |http_response|
379
+ status_code = http_response.status
380
+ response_content = http_response.body
381
+ unless status_code == 200 || status_code == 204
382
+ error_model = JSON.load(response_content)
383
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
384
+ end
385
+
386
+ # Create Result
387
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
388
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
389
+
390
+ result
391
+ end
392
+
393
+ promise.execute
394
+ end
395
+
396
+ #
397
+ # Returns a Cognitive Services account specified by the parameters.
398
+ #
399
+ # @param resource_group_name [String] The name of the resource group within
400
+ # the user's subscription.
401
+ # @param account_name [String] The name of the cognitive services account
402
+ # within the specified resource group. Cognitive Services account names must
403
+ # be between 3 and 24 characters in length and use numbers and lower-case
404
+ # letters only.
405
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
406
+ # will be added to the HTTP request.
407
+ #
408
+ # @return [CognitiveServicesAccount] operation results.
409
+ #
410
+ def get_properties(resource_group_name, account_name, custom_headers = nil)
411
+ response = get_properties_async(resource_group_name, account_name, custom_headers).value!
412
+ response.body unless response.nil?
413
+ end
414
+
415
+ #
416
+ # Returns a Cognitive Services account specified by the parameters.
417
+ #
418
+ # @param resource_group_name [String] The name of the resource group within
419
+ # the user's subscription.
420
+ # @param account_name [String] The name of the cognitive services account
421
+ # within the specified resource group. Cognitive Services account names must
422
+ # be between 3 and 24 characters in length and use numbers and lower-case
423
+ # letters only.
424
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
425
+ # will be added to the HTTP request.
426
+ #
427
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
428
+ #
429
+ def get_properties_with_http_info(resource_group_name, account_name, custom_headers = nil)
430
+ get_properties_async(resource_group_name, account_name, custom_headers).value!
431
+ end
432
+
433
+ #
434
+ # Returns a Cognitive Services account specified by the parameters.
435
+ #
436
+ # @param resource_group_name [String] The name of the resource group within
437
+ # the user's subscription.
438
+ # @param account_name [String] The name of the cognitive services account
439
+ # within the specified resource group. Cognitive Services account names must
440
+ # be between 3 and 24 characters in length and use numbers and lower-case
441
+ # letters only.
442
+ # @param [Hash{String => String}] A hash of custom headers that will be added
443
+ # to the HTTP request.
444
+ #
445
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
446
+ #
447
+ def get_properties_async(resource_group_name, account_name, custom_headers = nil)
448
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
449
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
450
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
451
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
452
+
453
+
454
+ request_headers = {}
455
+
456
+ # Set Headers
457
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
458
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
459
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'
460
+ options = {
461
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
462
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
463
+ query_params: {'api-version' => @client.api_version},
464
+ headers: request_headers.merge(custom_headers || {})
465
+ }
466
+
467
+ request_url = @base_url || @client.base_url
468
+
469
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
470
+ promise = request.run_promise do |req|
471
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
472
+ end
473
+
474
+ promise = promise.then do |http_response|
475
+ status_code = http_response.status
476
+ response_content = http_response.body
477
+ unless status_code == 200
478
+ error_model = JSON.load(response_content)
479
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
480
+ end
481
+
482
+ # Create Result
483
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
484
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
485
+ # Deserialize Response
486
+ if status_code == 200
487
+ begin
488
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
489
+ result_mapper = CognitiveServicesAccount.mapper()
490
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
491
+ rescue Exception => e
492
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
493
+ end
494
+ end
495
+
496
+ result
497
+ end
498
+
499
+ promise.execute
500
+ end
501
+
502
+ #
503
+ # Returns all the resources of a particular type belonging to a resource group
504
+ #
505
+ # @param resource_group_name [String] The name of the resource group within
506
+ # the user's subscription.
507
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
508
+ # will be added to the HTTP request.
509
+ #
510
+ # @return [CognitiveServicesAccountListResult] operation results.
511
+ #
512
+ def list_by_resource_group(resource_group_name, custom_headers = nil)
513
+ response = list_by_resource_group_async(resource_group_name, custom_headers).value!
514
+ response.body unless response.nil?
515
+ end
516
+
517
+ #
518
+ # Returns all the resources of a particular type belonging to a resource group
519
+ #
520
+ # @param resource_group_name [String] The name of the resource group within
521
+ # the user's subscription.
522
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
523
+ # will be added to the HTTP request.
524
+ #
525
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
526
+ #
527
+ def list_by_resource_group_with_http_info(resource_group_name, custom_headers = nil)
528
+ list_by_resource_group_async(resource_group_name, custom_headers).value!
529
+ end
530
+
531
+ #
532
+ # Returns all the resources of a particular type belonging to a resource group
533
+ #
534
+ # @param resource_group_name [String] The name of the resource group within
535
+ # the user's subscription.
536
+ # @param [Hash{String => String}] A hash of custom headers that will be added
537
+ # to the HTTP request.
538
+ #
539
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
540
+ #
541
+ def list_by_resource_group_async(resource_group_name, custom_headers = nil)
542
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
543
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
544
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
545
+
546
+
547
+ request_headers = {}
548
+
549
+ # Set Headers
550
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
551
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
552
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'
553
+ options = {
554
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
555
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
556
+ query_params: {'api-version' => @client.api_version},
557
+ headers: request_headers.merge(custom_headers || {})
558
+ }
559
+
560
+ request_url = @base_url || @client.base_url
561
+
562
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
563
+ promise = request.run_promise do |req|
564
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
565
+ end
566
+
567
+ promise = promise.then do |http_response|
568
+ status_code = http_response.status
569
+ response_content = http_response.body
570
+ unless status_code == 200
571
+ error_model = JSON.load(response_content)
572
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
573
+ end
574
+
575
+ # Create Result
576
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
577
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
578
+ # Deserialize Response
579
+ if status_code == 200
580
+ begin
581
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
582
+ result_mapper = CognitiveServicesAccountListResult.mapper()
583
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
584
+ rescue Exception => e
585
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
586
+ end
587
+ end
588
+
589
+ result
590
+ end
591
+
592
+ promise.execute
593
+ end
594
+
595
+ #
596
+ # Returns all the resources of a particular type belonging to a subscription.
597
+ #
598
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
599
+ # will be added to the HTTP request.
600
+ #
601
+ # @return [CognitiveServicesAccountListResult] operation results.
602
+ #
603
+ def list(custom_headers = nil)
604
+ response = list_async(custom_headers).value!
605
+ response.body unless response.nil?
606
+ end
607
+
608
+ #
609
+ # Returns all the resources of a particular type belonging to a subscription.
610
+ #
611
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
612
+ # will be added to the HTTP request.
613
+ #
614
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
615
+ #
616
+ def list_with_http_info(custom_headers = nil)
617
+ list_async(custom_headers).value!
618
+ end
619
+
620
+ #
621
+ # Returns all the resources of a particular type belonging to a subscription.
622
+ #
623
+ # @param [Hash{String => String}] A hash of custom headers that will be added
624
+ # to the HTTP request.
625
+ #
626
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
627
+ #
628
+ def list_async(custom_headers = nil)
629
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
630
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
631
+
632
+
633
+ request_headers = {}
634
+
635
+ # Set Headers
636
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
637
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
638
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/accounts'
639
+ options = {
640
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
641
+ path_params: {'subscriptionId' => @client.subscription_id},
642
+ query_params: {'api-version' => @client.api_version},
643
+ headers: request_headers.merge(custom_headers || {})
644
+ }
645
+
646
+ request_url = @base_url || @client.base_url
647
+
648
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
649
+ promise = request.run_promise do |req|
650
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
651
+ end
652
+
653
+ promise = promise.then do |http_response|
654
+ status_code = http_response.status
655
+ response_content = http_response.body
656
+ unless status_code == 200
657
+ error_model = JSON.load(response_content)
658
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
659
+ end
660
+
661
+ # Create Result
662
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
663
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
664
+ # Deserialize Response
665
+ if status_code == 200
666
+ begin
667
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
668
+ result_mapper = CognitiveServicesAccountListResult.mapper()
669
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
670
+ rescue Exception => e
671
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
672
+ end
673
+ end
674
+
675
+ result
676
+ end
677
+
678
+ promise.execute
679
+ end
680
+
681
+ #
682
+ # Lists the account keys for the specified Cognitive Services account.
683
+ #
684
+ # @param resource_group_name [String] The name of the resource group within
685
+ # the user's subscription.
686
+ # @param account_name [String] The name of the cognitive services account
687
+ # within the specified resource group. Congitive Services account names must
688
+ # be between 3 and 24 characters in length and use numbers and lower-case
689
+ # letters only.
690
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
691
+ # will be added to the HTTP request.
692
+ #
693
+ # @return [CognitiveServicesAccountKeys] operation results.
694
+ #
695
+ def list_keys(resource_group_name, account_name, custom_headers = nil)
696
+ response = list_keys_async(resource_group_name, account_name, custom_headers).value!
697
+ response.body unless response.nil?
698
+ end
699
+
700
+ #
701
+ # Lists the account keys for the specified Cognitive Services account.
702
+ #
703
+ # @param resource_group_name [String] The name of the resource group within
704
+ # the user's subscription.
705
+ # @param account_name [String] The name of the cognitive services account
706
+ # within the specified resource group. Congitive Services account names must
707
+ # be between 3 and 24 characters in length and use numbers and lower-case
708
+ # letters only.
709
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
710
+ # will be added to the HTTP request.
711
+ #
712
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
713
+ #
714
+ def list_keys_with_http_info(resource_group_name, account_name, custom_headers = nil)
715
+ list_keys_async(resource_group_name, account_name, custom_headers).value!
716
+ end
717
+
718
+ #
719
+ # Lists the account keys for the specified Cognitive Services account.
720
+ #
721
+ # @param resource_group_name [String] The name of the resource group within
722
+ # the user's subscription.
723
+ # @param account_name [String] The name of the cognitive services account
724
+ # within the specified resource group. Congitive Services account names must
725
+ # be between 3 and 24 characters in length and use numbers and lower-case
726
+ # letters only.
727
+ # @param [Hash{String => String}] A hash of custom headers that will be added
728
+ # to the HTTP request.
729
+ #
730
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
731
+ #
732
+ def list_keys_async(resource_group_name, account_name, custom_headers = nil)
733
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
734
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
735
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
736
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
737
+
738
+
739
+ request_headers = {}
740
+
741
+ # Set Headers
742
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
743
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
744
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'
745
+ options = {
746
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
747
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
748
+ query_params: {'api-version' => @client.api_version},
749
+ headers: request_headers.merge(custom_headers || {})
750
+ }
751
+
752
+ request_url = @base_url || @client.base_url
753
+
754
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
755
+ promise = request.run_promise do |req|
756
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
757
+ end
758
+
759
+ promise = promise.then do |http_response|
760
+ status_code = http_response.status
761
+ response_content = http_response.body
762
+ unless status_code == 200
763
+ error_model = JSON.load(response_content)
764
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
765
+ end
766
+
767
+ # Create Result
768
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
769
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
770
+ # Deserialize Response
771
+ if status_code == 200
772
+ begin
773
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
774
+ result_mapper = CognitiveServicesAccountKeys.mapper()
775
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
776
+ rescue Exception => e
777
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
778
+ end
779
+ end
780
+
781
+ result
782
+ end
783
+
784
+ promise.execute
785
+ end
786
+
787
+ #
788
+ # Regenerates the specified account key for the specified Cognitive Services
789
+ # account.
790
+ #
791
+ # @param resource_group_name [String] The name of the resource group within
792
+ # the user's subscription.
793
+ # @param account_name [String] The name of the cognitive services account
794
+ # within the specified resource group. Cognitive Services account names must
795
+ # be between 3 and 24 characters in length and use numbers and lower-case
796
+ # letters only.
797
+ # @param key_name [KeyName] key name to generate (Key1|Key2). Possible values
798
+ # include: 'Key1', 'Key2'
799
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
800
+ # will be added to the HTTP request.
801
+ #
802
+ # @return [CognitiveServicesAccountKeys] operation results.
803
+ #
804
+ def regenerate_key(resource_group_name, account_name, key_name = nil, custom_headers = nil)
805
+ response = regenerate_key_async(resource_group_name, account_name, key_name, custom_headers).value!
806
+ response.body unless response.nil?
807
+ end
808
+
809
+ #
810
+ # Regenerates the specified account key for the specified Cognitive Services
811
+ # account.
812
+ #
813
+ # @param resource_group_name [String] The name of the resource group within
814
+ # the user's subscription.
815
+ # @param account_name [String] The name of the cognitive services account
816
+ # within the specified resource group. Cognitive Services account names must
817
+ # be between 3 and 24 characters in length and use numbers and lower-case
818
+ # letters only.
819
+ # @param key_name [KeyName] key name to generate (Key1|Key2). Possible values
820
+ # include: 'Key1', 'Key2'
821
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
822
+ # will be added to the HTTP request.
823
+ #
824
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
825
+ #
826
+ def regenerate_key_with_http_info(resource_group_name, account_name, key_name = nil, custom_headers = nil)
827
+ regenerate_key_async(resource_group_name, account_name, key_name, custom_headers).value!
828
+ end
829
+
830
+ #
831
+ # Regenerates the specified account key for the specified Cognitive Services
832
+ # account.
833
+ #
834
+ # @param resource_group_name [String] The name of the resource group within
835
+ # the user's subscription.
836
+ # @param account_name [String] The name of the cognitive services account
837
+ # within the specified resource group. Cognitive Services account names must
838
+ # be between 3 and 24 characters in length and use numbers and lower-case
839
+ # letters only.
840
+ # @param key_name [KeyName] key name to generate (Key1|Key2). Possible values
841
+ # include: 'Key1', 'Key2'
842
+ # @param [Hash{String => String}] A hash of custom headers that will be added
843
+ # to the HTTP request.
844
+ #
845
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
846
+ #
847
+ def regenerate_key_async(resource_group_name, account_name, key_name = nil, custom_headers = nil)
848
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
849
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
850
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
851
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
852
+
853
+ body = RegenerateKeyParameters.new
854
+ unless key_name.nil?
855
+ body.key_name = key_name
856
+ end
857
+
858
+ request_headers = {}
859
+
860
+ # Set Headers
861
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
862
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
863
+
864
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
865
+
866
+ # Serialize Request
867
+ request_mapper = RegenerateKeyParameters.mapper()
868
+ request_content = @client.serialize(request_mapper, body, 'body')
869
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
870
+
871
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'
872
+ options = {
873
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
874
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
875
+ query_params: {'api-version' => @client.api_version},
876
+ body: request_content,
877
+ headers: request_headers.merge(custom_headers || {})
878
+ }
879
+
880
+ request_url = @base_url || @client.base_url
881
+
882
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :post, options)
883
+ promise = request.run_promise do |req|
884
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
885
+ end
886
+
887
+ promise = promise.then do |http_response|
888
+ status_code = http_response.status
889
+ response_content = http_response.body
890
+ unless status_code == 200
891
+ error_model = JSON.load(response_content)
892
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
893
+ end
894
+
895
+ # Create Result
896
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
897
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
898
+ # Deserialize Response
899
+ if status_code == 200
900
+ begin
901
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
902
+ result_mapper = CognitiveServicesAccountKeys.mapper()
903
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
904
+ rescue Exception => e
905
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
906
+ end
907
+ end
908
+
909
+ result
910
+ end
911
+
912
+ promise.execute
913
+ end
914
+
915
+ #
916
+ # List available SKUs for the requested Cognitive Services account
917
+ #
918
+ # @param resource_group_name [String] The name of the resource group within
919
+ # the user's subscription.
920
+ # @param account_name [String] The name of the cognitive services account
921
+ # within the specified resource group. Cognitive Services account names must
922
+ # be between 3 and 24 characters in length and use numbers and lower-case
923
+ # letters only.
924
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
925
+ # will be added to the HTTP request.
926
+ #
927
+ # @return [CognitiveServicesAccountEnumerateSkusResult] operation results.
928
+ #
929
+ def list_skus(resource_group_name, account_name, custom_headers = nil)
930
+ response = list_skus_async(resource_group_name, account_name, custom_headers).value!
931
+ response.body unless response.nil?
932
+ end
933
+
934
+ #
935
+ # List available SKUs for the requested Cognitive Services account
936
+ #
937
+ # @param resource_group_name [String] The name of the resource group within
938
+ # the user's subscription.
939
+ # @param account_name [String] The name of the cognitive services account
940
+ # within the specified resource group. Cognitive Services account names must
941
+ # be between 3 and 24 characters in length and use numbers and lower-case
942
+ # letters only.
943
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
944
+ # will be added to the HTTP request.
945
+ #
946
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
947
+ #
948
+ def list_skus_with_http_info(resource_group_name, account_name, custom_headers = nil)
949
+ list_skus_async(resource_group_name, account_name, custom_headers).value!
950
+ end
951
+
952
+ #
953
+ # List available SKUs for the requested Cognitive Services account
954
+ #
955
+ # @param resource_group_name [String] The name of the resource group within
956
+ # the user's subscription.
957
+ # @param account_name [String] The name of the cognitive services account
958
+ # within the specified resource group. Cognitive Services account names must
959
+ # be between 3 and 24 characters in length and use numbers and lower-case
960
+ # letters only.
961
+ # @param [Hash{String => String}] A hash of custom headers that will be added
962
+ # to the HTTP request.
963
+ #
964
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
965
+ #
966
+ def list_skus_async(resource_group_name, account_name, custom_headers = nil)
967
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
968
+ fail ArgumentError, 'account_name is nil' if account_name.nil?
969
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
970
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
971
+
972
+
973
+ request_headers = {}
974
+
975
+ # Set Headers
976
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
977
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
978
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'
979
+ options = {
980
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
981
+ path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id},
982
+ query_params: {'api-version' => @client.api_version},
983
+ headers: request_headers.merge(custom_headers || {})
984
+ }
985
+
986
+ request_url = @base_url || @client.base_url
987
+
988
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
989
+ promise = request.run_promise do |req|
990
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
991
+ end
992
+
993
+ promise = promise.then do |http_response|
994
+ status_code = http_response.status
995
+ response_content = http_response.body
996
+ unless status_code == 200
997
+ error_model = JSON.load(response_content)
998
+ fail MsRest::HttpOperationError.new(request, http_response, error_model)
999
+ end
1000
+
1001
+ # Create Result
1002
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
1003
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1004
+ # Deserialize Response
1005
+ if status_code == 200
1006
+ begin
1007
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1008
+ result_mapper = CognitiveServicesAccountEnumerateSkusResult.mapper()
1009
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
1010
+ rescue Exception => e
1011
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1012
+ end
1013
+ end
1014
+
1015
+ result
1016
+ end
1017
+
1018
+ promise.execute
1019
+ end
1020
+
1021
+ end
1022
+ end