azure_mgmt_cognitive_services 0.15.2 → 0.16.0

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