azure_cognitiveservices_customvisionprediction 0.17.1 → 0.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8382a1f622005a3c871758f1120b63f9c62fbc522acdf7f08d776b756be6dc3f
4
- data.tar.gz: 8bbcd29dd2d56caf4e3cceb8ceb06d663e0338277449a51107806f1beca6e00d
3
+ metadata.gz: ccfcdc8c90153c6fddd7a599a7cea766d9b57189f61364f8d9fb0bd709a83295
4
+ data.tar.gz: 8b1e5ef14a0edb0092f16fa023173b13acc367929e1d419357d453de1e2d3591
5
5
  SHA512:
6
- metadata.gz: 3b8c43a4f12daa1b87b58a55f11bd97327d66a6de007b13fbe05b5527614765531bb6a2ce620d3b0b6359cd85a9acc2ab86278983414f27e72a908691d18eb33
7
- data.tar.gz: 7650c4d77da1c11126c950f15818adb128266b779c152fdd8c3f72504de0532747e378bdb247ec38d0d1cebbfbefb67107ca330404aefa785f8368bf8dc6f127
6
+ metadata.gz: 6082ecb10d505b004b026de0c1a466f19ae646335ec8ee4aa6ae8ad59ad71537f885b1b2c66b74a2a0bdd6339de471cd22030023be7767d22256c51bf22fa8f2
7
+ data.tar.gz: 4e280ac667c76ab9bdcd95855f12731046b3c210b7b5f2b2b9d06678c01688ddd27e23d2905f27a393ee6d9e75c5eb585ca6a1acd70997a42dc1c03bc600214c
@@ -586,7 +586,7 @@ module Azure::CognitiveServices::Customvisionprediction::V2_0
586
586
  #
587
587
  def add_telemetry
588
588
  sdk_information = 'azure_cognitiveservices_customvisionprediction'
589
- sdk_information = "#{sdk_information}/0.17.1"
589
+ sdk_information = "#{sdk_information}/0.17.2"
590
590
  add_user_agent_information(sdk_information)
591
591
  end
592
592
  end
@@ -0,0 +1,33 @@
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 '3.0/generated/azure_cognitiveservices_customvisionprediction/module_definition'
20
+ require 'ms_rest_azure'
21
+
22
+ module Azure::CognitiveServices::Customvisionprediction::V3_0
23
+ autoload :CustomvisionpredictionClient, '3.0/generated/azure_cognitiveservices_customvisionprediction/customvisionprediction_client.rb'
24
+
25
+ module Models
26
+ autoload :Prediction, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/prediction.rb'
27
+ autoload :ImagePrediction, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/image_prediction.rb'
28
+ autoload :BoundingBox, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/bounding_box.rb'
29
+ autoload :CustomVisionError, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/custom_vision_error.rb'
30
+ autoload :ImageUrl, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/image_url.rb'
31
+ autoload :CustomVisionErrorCodes, '3.0/generated/azure_cognitiveservices_customvisionprediction/models/custom_vision_error_codes.rb'
32
+ end
33
+ end
@@ -0,0 +1,1057 @@
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::Customvisionprediction::V3_0
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class CustomvisionpredictionClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_reader :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials
19
+
20
+ # @return [String] API key.
21
+ attr_accessor :api_key
22
+
23
+ # @return [String] Supported Cognitive Services endpoints.
24
+ attr_accessor :endpoint
25
+
26
+ # @return [String] The preferred language for the response.
27
+ attr_accessor :accept_language
28
+
29
+ # @return [Integer] The retry timeout in seconds for Long Running
30
+ # Operations. Default value is 30.
31
+ attr_accessor :long_running_operation_retry_timeout
32
+
33
+ # @return [Boolean] Whether a unique x-ms-client-request-id should be
34
+ # generated. When set to true a unique x-ms-client-request-id value is
35
+ # generated and included in each request. Default is true.
36
+ attr_accessor :generate_client_request_id
37
+
38
+ #
39
+ # Creates initializes a new instance of the CustomvisionpredictionClient class.
40
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
41
+ # @param options [Array] filters to be applied to the HTTP requests.
42
+ #
43
+ def initialize(credentials = nil, options = nil)
44
+ super(credentials, options)
45
+ @base_url = '{Endpoint}/customvision/v3.0/prediction'
46
+
47
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
48
+ @credentials = credentials
49
+
50
+ @accept_language = 'en-US'
51
+ @long_running_operation_retry_timeout = 30
52
+ @generate_client_request_id = true
53
+ add_telemetry
54
+ end
55
+
56
+ #
57
+ # Makes a request and returns the body of the response.
58
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
59
+ # @param path [String] the path, relative to {base_url}.
60
+ # @param options [Hash{String=>String}] specifying any request options like :body.
61
+ # @return [Hash{String=>String}] containing the body of the response.
62
+ # Example:
63
+ #
64
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
65
+ # path = "/path"
66
+ # options = {
67
+ # body: request_content,
68
+ # query_params: {'api-version' => '2016-02-01'}
69
+ # }
70
+ # result = @client.make_request(:put, path, options)
71
+ #
72
+ def make_request(method, path, options = {})
73
+ result = make_request_with_http_info(method, path, options)
74
+ result.body unless result.nil?
75
+ end
76
+
77
+ #
78
+ # Makes a request and returns the operation response.
79
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
80
+ # @param path [String] the path, relative to {base_url}.
81
+ # @param options [Hash{String=>String}] specifying any request options like :body.
82
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
83
+ #
84
+ def make_request_with_http_info(method, path, options = {})
85
+ result = make_request_async(method, path, options).value!
86
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
87
+ result
88
+ end
89
+
90
+ #
91
+ # Makes a request asynchronously.
92
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
93
+ # @param path [String] the path, relative to {base_url}.
94
+ # @param options [Hash{String=>String}] specifying any request options like :body.
95
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
96
+ #
97
+ def make_request_async(method, path, options = {})
98
+ fail ArgumentError, 'method is nil' if method.nil?
99
+ fail ArgumentError, 'path is nil' if path.nil?
100
+
101
+ request_url = options[:base_url] || @base_url
102
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
103
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
104
+ end
105
+
106
+ request_headers = @request_headers
107
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
108
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
109
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
110
+
111
+ super(request_url, method, path, options)
112
+ end
113
+
114
+ #
115
+ # Classify an image url and saves the result.
116
+ #
117
+ # @param project_id The project id.
118
+ # @param published_name [String] Specifies the name of the model to evaluate
119
+ # against.
120
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
121
+ # be evaluated.
122
+ # @param application [String] Optional. Specifies the name of application using
123
+ # the endpoint.
124
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
125
+ # will be added to the HTTP request.
126
+ #
127
+ # @return [ImagePrediction] operation results.
128
+ #
129
+ def classify_image_url(project_id, published_name, image_url, application:nil, custom_headers:nil)
130
+ response = classify_image_url_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
131
+ response.body unless response.nil?
132
+ end
133
+
134
+ #
135
+ # Classify an image url and saves the result.
136
+ #
137
+ # @param project_id The project id.
138
+ # @param published_name [String] Specifies the name of the model to evaluate
139
+ # against.
140
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
141
+ # be evaluated.
142
+ # @param application [String] Optional. Specifies the name of application using
143
+ # the endpoint.
144
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
145
+ # will be added to the HTTP request.
146
+ #
147
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
148
+ #
149
+ def classify_image_url_with_http_info(project_id, published_name, image_url, application:nil, custom_headers:nil)
150
+ classify_image_url_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
151
+ end
152
+
153
+ #
154
+ # Classify an image url and saves the result.
155
+ #
156
+ # @param project_id The project id.
157
+ # @param published_name [String] Specifies the name of the model to evaluate
158
+ # against.
159
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
160
+ # be evaluated.
161
+ # @param application [String] Optional. Specifies the name of application using
162
+ # the endpoint.
163
+ # @param [Hash{String => String}] A hash of custom headers that will be added
164
+ # to the HTTP request.
165
+ #
166
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
167
+ #
168
+ def classify_image_url_async(project_id, published_name, image_url, application:nil, custom_headers:nil)
169
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
170
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
171
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
172
+ fail ArgumentError, 'image_url is nil' if image_url.nil?
173
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
174
+
175
+
176
+ request_headers = {}
177
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
178
+
179
+ # Set Headers
180
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
181
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
182
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
183
+
184
+ # Serialize Request
185
+ request_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImageUrl.mapper()
186
+ request_content = self.serialize(request_mapper, image_url)
187
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
188
+
189
+ path_template = '{projectId}/classify/iterations/{publishedName}/url'
190
+
191
+ request_url = @base_url || self.base_url
192
+ request_url = request_url.gsub('{Endpoint}', endpoint)
193
+
194
+ options = {
195
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
196
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
197
+ query_params: {'application' => application},
198
+ body: request_content,
199
+ headers: request_headers.merge(custom_headers || {}),
200
+ base_url: request_url
201
+ }
202
+ promise = self.make_request_async(:post, path_template, options)
203
+
204
+ promise = promise.then do |result|
205
+ http_response = result.response
206
+ status_code = http_response.status
207
+ response_content = http_response.body
208
+ unless status_code == 200
209
+ error_model = JSON.load(response_content)
210
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
211
+ end
212
+
213
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
214
+ # Deserialize Response
215
+ if status_code == 200
216
+ begin
217
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
218
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
219
+ result.body = self.deserialize(result_mapper, parsed_response)
220
+ rescue Exception => e
221
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
222
+ end
223
+ end
224
+
225
+ result
226
+ end
227
+
228
+ promise.execute
229
+ end
230
+
231
+ #
232
+ # Classify an image and saves the result.
233
+ #
234
+ # @param project_id The project id.
235
+ # @param published_name [String] Specifies the name of the model to evaluate
236
+ # against.
237
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
238
+ # and BMP. Supports images up to 4MB.
239
+ # @param application [String] Optional. Specifies the name of application using
240
+ # the endpoint.
241
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
242
+ # will be added to the HTTP request.
243
+ #
244
+ # @return [ImagePrediction] operation results.
245
+ #
246
+ def classify_image(project_id, published_name, image_data, application:nil, custom_headers:nil)
247
+ response = classify_image_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
248
+ response.body unless response.nil?
249
+ end
250
+
251
+ #
252
+ # Classify an image and saves the result.
253
+ #
254
+ # @param project_id The project id.
255
+ # @param published_name [String] Specifies the name of the model to evaluate
256
+ # against.
257
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
258
+ # and BMP. Supports images up to 4MB.
259
+ # @param application [String] Optional. Specifies the name of application using
260
+ # the endpoint.
261
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
262
+ # will be added to the HTTP request.
263
+ #
264
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
265
+ #
266
+ def classify_image_with_http_info(project_id, published_name, image_data, application:nil, custom_headers:nil)
267
+ classify_image_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
268
+ end
269
+
270
+ #
271
+ # Classify an image and saves the result.
272
+ #
273
+ # @param project_id The project id.
274
+ # @param published_name [String] Specifies the name of the model to evaluate
275
+ # against.
276
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
277
+ # and BMP. Supports images up to 4MB.
278
+ # @param application [String] Optional. Specifies the name of application using
279
+ # the endpoint.
280
+ # @param [Hash{String => String}] A hash of custom headers that will be added
281
+ # to the HTTP request.
282
+ #
283
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
284
+ #
285
+ def classify_image_async(project_id, published_name, image_data, application:nil, custom_headers:nil)
286
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
287
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
288
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
289
+ fail ArgumentError, 'image_data is nil' if image_data.nil?
290
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
291
+
292
+
293
+ request_headers = {}
294
+ request_headers['Content-Type'] = 'multipart/form-data'
295
+
296
+ # Set Headers
297
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
298
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
299
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
300
+
301
+ # Set Form Data
302
+ form_data = {}
303
+ form_data['imageData'] = image_data.to_s unless image_data.to_s.nil?
304
+
305
+ path_template = '{projectId}/classify/iterations/{publishedName}/image'
306
+
307
+ request_url = @base_url || self.base_url
308
+ request_url = request_url.gsub('{Endpoint}', endpoint)
309
+
310
+ options = {
311
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
312
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
313
+ query_params: {'application' => application},
314
+ headers: request_headers.merge(custom_headers || {}),
315
+ body: URI.encode_www_form(form_data),
316
+ base_url: request_url
317
+ }
318
+ promise = self.make_request_async(:post, path_template, options)
319
+
320
+ promise = promise.then do |result|
321
+ http_response = result.response
322
+ status_code = http_response.status
323
+ response_content = http_response.body
324
+ unless status_code == 200
325
+ error_model = JSON.load(response_content)
326
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
327
+ end
328
+
329
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
330
+ # Deserialize Response
331
+ if status_code == 200
332
+ begin
333
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
334
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
335
+ result.body = self.deserialize(result_mapper, parsed_response)
336
+ rescue Exception => e
337
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
338
+ end
339
+ end
340
+
341
+ result
342
+ end
343
+
344
+ promise.execute
345
+ end
346
+
347
+ #
348
+ # Classify an image url without saving the result.
349
+ #
350
+ # @param project_id The project id.
351
+ # @param published_name [String] Specifies the name of the model to evaluate
352
+ # against.
353
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
354
+ # the url of the image to be evaluated.
355
+ # @param application [String] Optional. Specifies the name of application using
356
+ # the endpoint.
357
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
358
+ # will be added to the HTTP request.
359
+ #
360
+ # @return [ImagePrediction] operation results.
361
+ #
362
+ def classify_image_url_with_no_store(project_id, published_name, image_url, application:nil, custom_headers:nil)
363
+ response = classify_image_url_with_no_store_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
364
+ response.body unless response.nil?
365
+ end
366
+
367
+ #
368
+ # Classify an image url without saving the result.
369
+ #
370
+ # @param project_id The project id.
371
+ # @param published_name [String] Specifies the name of the model to evaluate
372
+ # against.
373
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
374
+ # the url of the image to be evaluated.
375
+ # @param application [String] Optional. Specifies the name of application using
376
+ # the endpoint.
377
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
378
+ # will be added to the HTTP request.
379
+ #
380
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
381
+ #
382
+ def classify_image_url_with_no_store_with_http_info(project_id, published_name, image_url, application:nil, custom_headers:nil)
383
+ classify_image_url_with_no_store_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
384
+ end
385
+
386
+ #
387
+ # Classify an image url without saving the result.
388
+ #
389
+ # @param project_id The project id.
390
+ # @param published_name [String] Specifies the name of the model to evaluate
391
+ # against.
392
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
393
+ # the url of the image to be evaluated.
394
+ # @param application [String] Optional. Specifies the name of application using
395
+ # the endpoint.
396
+ # @param [Hash{String => String}] A hash of custom headers that will be added
397
+ # to the HTTP request.
398
+ #
399
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
400
+ #
401
+ def classify_image_url_with_no_store_async(project_id, published_name, image_url, application:nil, custom_headers:nil)
402
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
403
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
404
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
405
+ fail ArgumentError, 'image_url is nil' if image_url.nil?
406
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
407
+
408
+
409
+ request_headers = {}
410
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
411
+
412
+ # Set Headers
413
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
414
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
415
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
416
+
417
+ # Serialize Request
418
+ request_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImageUrl.mapper()
419
+ request_content = self.serialize(request_mapper, image_url)
420
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
421
+
422
+ path_template = '{projectId}/classify/iterations/{publishedName}/url/nostore'
423
+
424
+ request_url = @base_url || self.base_url
425
+ request_url = request_url.gsub('{Endpoint}', endpoint)
426
+
427
+ options = {
428
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
429
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
430
+ query_params: {'application' => application},
431
+ body: request_content,
432
+ headers: request_headers.merge(custom_headers || {}),
433
+ base_url: request_url
434
+ }
435
+ promise = self.make_request_async(:post, path_template, options)
436
+
437
+ promise = promise.then do |result|
438
+ http_response = result.response
439
+ status_code = http_response.status
440
+ response_content = http_response.body
441
+ unless status_code == 200
442
+ error_model = JSON.load(response_content)
443
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
444
+ end
445
+
446
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
447
+ # Deserialize Response
448
+ if status_code == 200
449
+ begin
450
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
451
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
452
+ result.body = self.deserialize(result_mapper, parsed_response)
453
+ rescue Exception => e
454
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
455
+ end
456
+ end
457
+
458
+ result
459
+ end
460
+
461
+ promise.execute
462
+ end
463
+
464
+ #
465
+ # Classify an image without saving the result.
466
+ #
467
+ # @param project_id The project id.
468
+ # @param published_name [String] Specifies the name of the model to evaluate
469
+ # against.
470
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
471
+ # and BMP. Supports images up to 0MB.
472
+ # @param application [String] Optional. Specifies the name of application using
473
+ # the endpoint.
474
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
475
+ # will be added to the HTTP request.
476
+ #
477
+ # @return [ImagePrediction] operation results.
478
+ #
479
+ def classify_image_with_no_store(project_id, published_name, image_data, application:nil, custom_headers:nil)
480
+ response = classify_image_with_no_store_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
481
+ response.body unless response.nil?
482
+ end
483
+
484
+ #
485
+ # Classify an image without saving the result.
486
+ #
487
+ # @param project_id The project id.
488
+ # @param published_name [String] Specifies the name of the model to evaluate
489
+ # against.
490
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
491
+ # and BMP. Supports images up to 0MB.
492
+ # @param application [String] Optional. Specifies the name of application using
493
+ # the endpoint.
494
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
495
+ # will be added to the HTTP request.
496
+ #
497
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
498
+ #
499
+ def classify_image_with_no_store_with_http_info(project_id, published_name, image_data, application:nil, custom_headers:nil)
500
+ classify_image_with_no_store_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
501
+ end
502
+
503
+ #
504
+ # Classify an image without saving the result.
505
+ #
506
+ # @param project_id The project id.
507
+ # @param published_name [String] Specifies the name of the model to evaluate
508
+ # against.
509
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
510
+ # and BMP. Supports images up to 0MB.
511
+ # @param application [String] Optional. Specifies the name of application using
512
+ # the endpoint.
513
+ # @param [Hash{String => String}] A hash of custom headers that will be added
514
+ # to the HTTP request.
515
+ #
516
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
517
+ #
518
+ def classify_image_with_no_store_async(project_id, published_name, image_data, application:nil, custom_headers:nil)
519
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
520
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
521
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
522
+ fail ArgumentError, 'image_data is nil' if image_data.nil?
523
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
524
+
525
+
526
+ request_headers = {}
527
+ request_headers['Content-Type'] = 'multipart/form-data'
528
+
529
+ # Set Headers
530
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
531
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
532
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
533
+
534
+ # Set Form Data
535
+ form_data = {}
536
+ form_data['imageData'] = image_data.to_s unless image_data.to_s.nil?
537
+
538
+ path_template = '{projectId}/classify/iterations/{publishedName}/image/nostore'
539
+
540
+ request_url = @base_url || self.base_url
541
+ request_url = request_url.gsub('{Endpoint}', endpoint)
542
+
543
+ options = {
544
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
545
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
546
+ query_params: {'application' => application},
547
+ headers: request_headers.merge(custom_headers || {}),
548
+ body: URI.encode_www_form(form_data),
549
+ base_url: request_url
550
+ }
551
+ promise = self.make_request_async(:post, path_template, options)
552
+
553
+ promise = promise.then do |result|
554
+ http_response = result.response
555
+ status_code = http_response.status
556
+ response_content = http_response.body
557
+ unless status_code == 200
558
+ error_model = JSON.load(response_content)
559
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
560
+ end
561
+
562
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
563
+ # Deserialize Response
564
+ if status_code == 200
565
+ begin
566
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
567
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
568
+ result.body = self.deserialize(result_mapper, parsed_response)
569
+ rescue Exception => e
570
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
571
+ end
572
+ end
573
+
574
+ result
575
+ end
576
+
577
+ promise.execute
578
+ end
579
+
580
+ #
581
+ # Detect objects in an image url and saves the result.
582
+ #
583
+ # @param project_id The project id.
584
+ # @param published_name [String] Specifies the name of the model to evaluate
585
+ # against.
586
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
587
+ # be evaluated.
588
+ # @param application [String] Optional. Specifies the name of application using
589
+ # the endpoint.
590
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
591
+ # will be added to the HTTP request.
592
+ #
593
+ # @return [ImagePrediction] operation results.
594
+ #
595
+ def detect_image_url(project_id, published_name, image_url, application:nil, custom_headers:nil)
596
+ response = detect_image_url_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
597
+ response.body unless response.nil?
598
+ end
599
+
600
+ #
601
+ # Detect objects in an image url and saves the result.
602
+ #
603
+ # @param project_id The project id.
604
+ # @param published_name [String] Specifies the name of the model to evaluate
605
+ # against.
606
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
607
+ # be evaluated.
608
+ # @param application [String] Optional. Specifies the name of application using
609
+ # the endpoint.
610
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
611
+ # will be added to the HTTP request.
612
+ #
613
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
614
+ #
615
+ def detect_image_url_with_http_info(project_id, published_name, image_url, application:nil, custom_headers:nil)
616
+ detect_image_url_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
617
+ end
618
+
619
+ #
620
+ # Detect objects in an image url and saves the result.
621
+ #
622
+ # @param project_id The project id.
623
+ # @param published_name [String] Specifies the name of the model to evaluate
624
+ # against.
625
+ # @param image_url [ImageUrl] An ImageUrl that contains the url of the image to
626
+ # be evaluated.
627
+ # @param application [String] Optional. Specifies the name of application using
628
+ # the endpoint.
629
+ # @param [Hash{String => String}] A hash of custom headers that will be added
630
+ # to the HTTP request.
631
+ #
632
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
633
+ #
634
+ def detect_image_url_async(project_id, published_name, image_url, application:nil, custom_headers:nil)
635
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
636
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
637
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
638
+ fail ArgumentError, 'image_url is nil' if image_url.nil?
639
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
640
+
641
+
642
+ request_headers = {}
643
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
644
+
645
+ # Set Headers
646
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
647
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
648
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
649
+
650
+ # Serialize Request
651
+ request_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImageUrl.mapper()
652
+ request_content = self.serialize(request_mapper, image_url)
653
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
654
+
655
+ path_template = '{projectId}/detect/iterations/{publishedName}/url'
656
+
657
+ request_url = @base_url || self.base_url
658
+ request_url = request_url.gsub('{Endpoint}', endpoint)
659
+
660
+ options = {
661
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
662
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
663
+ query_params: {'application' => application},
664
+ body: request_content,
665
+ headers: request_headers.merge(custom_headers || {}),
666
+ base_url: request_url
667
+ }
668
+ promise = self.make_request_async(:post, path_template, options)
669
+
670
+ promise = promise.then do |result|
671
+ http_response = result.response
672
+ status_code = http_response.status
673
+ response_content = http_response.body
674
+ unless status_code == 200
675
+ error_model = JSON.load(response_content)
676
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
677
+ end
678
+
679
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
680
+ # Deserialize Response
681
+ if status_code == 200
682
+ begin
683
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
684
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
685
+ result.body = self.deserialize(result_mapper, parsed_response)
686
+ rescue Exception => e
687
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
688
+ end
689
+ end
690
+
691
+ result
692
+ end
693
+
694
+ promise.execute
695
+ end
696
+
697
+ #
698
+ # Detect objects in an image and saves the result.
699
+ #
700
+ # @param project_id The project id.
701
+ # @param published_name [String] Specifies the name of the model to evaluate
702
+ # against.
703
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
704
+ # and BMP. Supports images up to 4MB.
705
+ # @param application [String] Optional. Specifies the name of application using
706
+ # the endpoint.
707
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
708
+ # will be added to the HTTP request.
709
+ #
710
+ # @return [ImagePrediction] operation results.
711
+ #
712
+ def detect_image(project_id, published_name, image_data, application:nil, custom_headers:nil)
713
+ response = detect_image_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
714
+ response.body unless response.nil?
715
+ end
716
+
717
+ #
718
+ # Detect objects in an image and saves the result.
719
+ #
720
+ # @param project_id The project id.
721
+ # @param published_name [String] Specifies the name of the model to evaluate
722
+ # against.
723
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
724
+ # and BMP. Supports images up to 4MB.
725
+ # @param application [String] Optional. Specifies the name of application using
726
+ # the endpoint.
727
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
728
+ # will be added to the HTTP request.
729
+ #
730
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
731
+ #
732
+ def detect_image_with_http_info(project_id, published_name, image_data, application:nil, custom_headers:nil)
733
+ detect_image_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
734
+ end
735
+
736
+ #
737
+ # Detect objects in an image and saves the result.
738
+ #
739
+ # @param project_id The project id.
740
+ # @param published_name [String] Specifies the name of the model to evaluate
741
+ # against.
742
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
743
+ # and BMP. Supports images up to 4MB.
744
+ # @param application [String] Optional. Specifies the name of application using
745
+ # the endpoint.
746
+ # @param [Hash{String => String}] A hash of custom headers that will be added
747
+ # to the HTTP request.
748
+ #
749
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
750
+ #
751
+ def detect_image_async(project_id, published_name, image_data, application:nil, custom_headers:nil)
752
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
753
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
754
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
755
+ fail ArgumentError, 'image_data is nil' if image_data.nil?
756
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
757
+
758
+
759
+ request_headers = {}
760
+ request_headers['Content-Type'] = 'multipart/form-data'
761
+
762
+ # Set Headers
763
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
764
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
765
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
766
+
767
+ # Set Form Data
768
+ form_data = {}
769
+ form_data['imageData'] = image_data.to_s unless image_data.to_s.nil?
770
+
771
+ path_template = '{projectId}/detect/iterations/{publishedName}/image'
772
+
773
+ request_url = @base_url || self.base_url
774
+ request_url = request_url.gsub('{Endpoint}', endpoint)
775
+
776
+ options = {
777
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
778
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
779
+ query_params: {'application' => application},
780
+ headers: request_headers.merge(custom_headers || {}),
781
+ body: URI.encode_www_form(form_data),
782
+ base_url: request_url
783
+ }
784
+ promise = self.make_request_async(:post, path_template, options)
785
+
786
+ promise = promise.then do |result|
787
+ http_response = result.response
788
+ status_code = http_response.status
789
+ response_content = http_response.body
790
+ unless status_code == 200
791
+ error_model = JSON.load(response_content)
792
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
793
+ end
794
+
795
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
796
+ # Deserialize Response
797
+ if status_code == 200
798
+ begin
799
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
800
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
801
+ result.body = self.deserialize(result_mapper, parsed_response)
802
+ rescue Exception => e
803
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
804
+ end
805
+ end
806
+
807
+ result
808
+ end
809
+
810
+ promise.execute
811
+ end
812
+
813
+ #
814
+ # Detect objects in an image url without saving the result.
815
+ #
816
+ # @param project_id The project id.
817
+ # @param published_name [String] Specifies the name of the model to evaluate
818
+ # against.
819
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
820
+ # the url of the image to be evaluated.
821
+ # @param application [String] Optional. Specifies the name of application using
822
+ # the endpoint.
823
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
824
+ # will be added to the HTTP request.
825
+ #
826
+ # @return [ImagePrediction] operation results.
827
+ #
828
+ def detect_image_url_with_no_store(project_id, published_name, image_url, application:nil, custom_headers:nil)
829
+ response = detect_image_url_with_no_store_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
830
+ response.body unless response.nil?
831
+ end
832
+
833
+ #
834
+ # Detect objects in an image url without saving the result.
835
+ #
836
+ # @param project_id The project id.
837
+ # @param published_name [String] Specifies the name of the model to evaluate
838
+ # against.
839
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
840
+ # the url of the image to be evaluated.
841
+ # @param application [String] Optional. Specifies the name of application using
842
+ # the endpoint.
843
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
844
+ # will be added to the HTTP request.
845
+ #
846
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
847
+ #
848
+ def detect_image_url_with_no_store_with_http_info(project_id, published_name, image_url, application:nil, custom_headers:nil)
849
+ detect_image_url_with_no_store_async(project_id, published_name, image_url, application:application, custom_headers:custom_headers).value!
850
+ end
851
+
852
+ #
853
+ # Detect objects in an image url without saving the result.
854
+ #
855
+ # @param project_id The project id.
856
+ # @param published_name [String] Specifies the name of the model to evaluate
857
+ # against.
858
+ # @param image_url [ImageUrl] An {Iris.Web.Api.Models.ImageUrl} that contains
859
+ # the url of the image to be evaluated.
860
+ # @param application [String] Optional. Specifies the name of application using
861
+ # the endpoint.
862
+ # @param [Hash{String => String}] A hash of custom headers that will be added
863
+ # to the HTTP request.
864
+ #
865
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
866
+ #
867
+ def detect_image_url_with_no_store_async(project_id, published_name, image_url, application:nil, custom_headers:nil)
868
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
869
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
870
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
871
+ fail ArgumentError, 'image_url is nil' if image_url.nil?
872
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
873
+
874
+
875
+ request_headers = {}
876
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
877
+
878
+ # Set Headers
879
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
880
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
881
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
882
+
883
+ # Serialize Request
884
+ request_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImageUrl.mapper()
885
+ request_content = self.serialize(request_mapper, image_url)
886
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
887
+
888
+ path_template = '{projectId}/detect/iterations/{publishedName}/url/nostore'
889
+
890
+ request_url = @base_url || self.base_url
891
+ request_url = request_url.gsub('{Endpoint}', endpoint)
892
+
893
+ options = {
894
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
895
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
896
+ query_params: {'application' => application},
897
+ body: request_content,
898
+ headers: request_headers.merge(custom_headers || {}),
899
+ base_url: request_url
900
+ }
901
+ promise = self.make_request_async(:post, path_template, options)
902
+
903
+ promise = promise.then do |result|
904
+ http_response = result.response
905
+ status_code = http_response.status
906
+ response_content = http_response.body
907
+ unless status_code == 200
908
+ error_model = JSON.load(response_content)
909
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
910
+ end
911
+
912
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
913
+ # Deserialize Response
914
+ if status_code == 200
915
+ begin
916
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
917
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
918
+ result.body = self.deserialize(result_mapper, parsed_response)
919
+ rescue Exception => e
920
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
921
+ end
922
+ end
923
+
924
+ result
925
+ end
926
+
927
+ promise.execute
928
+ end
929
+
930
+ #
931
+ # Detect objects in an image without saving the result.
932
+ #
933
+ # @param project_id The project id.
934
+ # @param published_name [String] Specifies the name of the model to evaluate
935
+ # against.
936
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
937
+ # and BMP. Supports images up to 0MB.
938
+ # @param application [String] Optional. Specifies the name of application using
939
+ # the endpoint.
940
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
941
+ # will be added to the HTTP request.
942
+ #
943
+ # @return [ImagePrediction] operation results.
944
+ #
945
+ def detect_image_with_no_store(project_id, published_name, image_data, application:nil, custom_headers:nil)
946
+ response = detect_image_with_no_store_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
947
+ response.body unless response.nil?
948
+ end
949
+
950
+ #
951
+ # Detect objects in an image without saving the result.
952
+ #
953
+ # @param project_id The project id.
954
+ # @param published_name [String] Specifies the name of the model to evaluate
955
+ # against.
956
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
957
+ # and BMP. Supports images up to 0MB.
958
+ # @param application [String] Optional. Specifies the name of application using
959
+ # the endpoint.
960
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
961
+ # will be added to the HTTP request.
962
+ #
963
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
964
+ #
965
+ def detect_image_with_no_store_with_http_info(project_id, published_name, image_data, application:nil, custom_headers:nil)
966
+ detect_image_with_no_store_async(project_id, published_name, image_data, application:application, custom_headers:custom_headers).value!
967
+ end
968
+
969
+ #
970
+ # Detect objects in an image without saving the result.
971
+ #
972
+ # @param project_id The project id.
973
+ # @param published_name [String] Specifies the name of the model to evaluate
974
+ # against.
975
+ # @param image_data Binary image data. Supported formats are JPEG, GIF, PNG,
976
+ # and BMP. Supports images up to 0MB.
977
+ # @param application [String] Optional. Specifies the name of application using
978
+ # the endpoint.
979
+ # @param [Hash{String => String}] A hash of custom headers that will be added
980
+ # to the HTTP request.
981
+ #
982
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
983
+ #
984
+ def detect_image_with_no_store_async(project_id, published_name, image_data, application:nil, custom_headers:nil)
985
+ fail ArgumentError, 'endpoint is nil' if endpoint.nil?
986
+ fail ArgumentError, 'project_id is nil' if project_id.nil?
987
+ fail ArgumentError, 'published_name is nil' if published_name.nil?
988
+ fail ArgumentError, 'image_data is nil' if image_data.nil?
989
+ fail ArgumentError, 'api_key is nil' if api_key.nil?
990
+
991
+
992
+ request_headers = {}
993
+ request_headers['Content-Type'] = 'multipart/form-data'
994
+
995
+ # Set Headers
996
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
997
+ request_headers['Prediction-Key'] = api_key unless api_key.nil?
998
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
999
+
1000
+ # Set Form Data
1001
+ form_data = {}
1002
+ form_data['imageData'] = image_data.to_s unless image_data.to_s.nil?
1003
+
1004
+ path_template = '{projectId}/detect/iterations/{publishedName}/image/nostore'
1005
+
1006
+ request_url = @base_url || self.base_url
1007
+ request_url = request_url.gsub('{Endpoint}', endpoint)
1008
+
1009
+ options = {
1010
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1011
+ path_params: {'projectId' => project_id,'publishedName' => published_name},
1012
+ query_params: {'application' => application},
1013
+ headers: request_headers.merge(custom_headers || {}),
1014
+ body: URI.encode_www_form(form_data),
1015
+ base_url: request_url
1016
+ }
1017
+ promise = self.make_request_async(:post, path_template, options)
1018
+
1019
+ promise = promise.then do |result|
1020
+ http_response = result.response
1021
+ status_code = http_response.status
1022
+ response_content = http_response.body
1023
+ unless status_code == 200
1024
+ error_model = JSON.load(response_content)
1025
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1026
+ end
1027
+
1028
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1029
+ # Deserialize Response
1030
+ if status_code == 200
1031
+ begin
1032
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1033
+ result_mapper = Azure::CognitiveServices::Customvisionprediction::V3_0::Models::ImagePrediction.mapper()
1034
+ result.body = self.deserialize(result_mapper, parsed_response)
1035
+ rescue Exception => e
1036
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1037
+ end
1038
+ end
1039
+
1040
+ result
1041
+ end
1042
+
1043
+ promise.execute
1044
+ end
1045
+
1046
+
1047
+ private
1048
+ #
1049
+ # Adds telemetry information.
1050
+ #
1051
+ def add_telemetry
1052
+ sdk_information = 'azure_cognitiveservices_customvisionprediction'
1053
+ sdk_information = "#{sdk_information}/0.17.2"
1054
+ add_user_agent_information(sdk_information)
1055
+ end
1056
+ end
1057
+ end