azure_cognitiveservices_face 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/1.0/generated/azure_cognitiveservices_face.rb +78 -0
  4. data/lib/1.0/generated/azure_cognitiveservices_face/face.rb +955 -0
  5. data/lib/1.0/generated/azure_cognitiveservices_face/face_client.rb +145 -0
  6. data/lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb +857 -0
  7. data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory.rb +59 -0
  8. data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory_type.rb +17 -0
  9. data/lib/1.0/generated/azure_cognitiveservices_face/models/apierror.rb +47 -0
  10. data/lib/1.0/generated/azure_cognitiveservices_face/models/azure_regions.rb +26 -0
  11. data/lib/1.0/generated/azure_cognitiveservices_face/models/blur.rb +60 -0
  12. data/lib/1.0/generated/azure_cognitiveservices_face/models/blur_level.rb +17 -0
  13. data/lib/1.0/generated/azure_cognitiveservices_face/models/coordinate.rb +57 -0
  14. data/lib/1.0/generated/azure_cognitiveservices_face/models/detected_face.rb +82 -0
  15. data/lib/1.0/generated/azure_cognitiveservices_face/models/emotion.rb +124 -0
  16. data/lib/1.0/generated/azure_cognitiveservices_face/models/error.rb +57 -0
  17. data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure.rb +62 -0
  18. data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure_level.rb +17 -0
  19. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attribute_type.rb +28 -0
  20. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attributes.rb +214 -0
  21. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_landmarks.rb +360 -0
  22. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_list.rb +92 -0
  23. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_rectangle.rb +81 -0
  24. data/lib/1.0/generated/azure_cognitiveservices_face/models/facial_hair.rb +68 -0
  25. data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_match_mode.rb +16 -0
  26. data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_request.rb +121 -0
  27. data/lib/1.0/generated/azure_cognitiveservices_face/models/gender.rb +17 -0
  28. data/lib/1.0/generated/azure_cognitiveservices_face/models/glasses_type.rb +18 -0
  29. data/lib/1.0/generated/azure_cognitiveservices_face/models/group_request.rb +58 -0
  30. data/lib/1.0/generated/azure_cognitiveservices_face/models/group_result.rb +83 -0
  31. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair.rb +80 -0
  32. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color.rb +60 -0
  33. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color_type.rb +22 -0
  34. data/lib/1.0/generated/azure_cognitiveservices_face/models/head_pose.rb +68 -0
  35. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_candidate.rb +59 -0
  36. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_request.rb +105 -0
  37. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_result.rb +69 -0
  38. data/lib/1.0/generated/azure_cognitiveservices_face/models/image_url.rb +47 -0
  39. data/lib/1.0/generated/azure_cognitiveservices_face/models/makeup.rb +59 -0
  40. data/lib/1.0/generated/azure_cognitiveservices_face/models/name_and_user_data_contract.rb +64 -0
  41. data/lib/1.0/generated/azure_cognitiveservices_face/models/noise.rb +62 -0
  42. data/lib/1.0/generated/azure_cognitiveservices_face/models/noise_level.rb +17 -0
  43. data/lib/1.0/generated/azure_cognitiveservices_face/models/occlusion.rb +70 -0
  44. data/lib/1.0/generated/azure_cognitiveservices_face/models/persisted_face.rb +63 -0
  45. data/lib/1.0/generated/azure_cognitiveservices_face/models/person.rb +89 -0
  46. data/lib/1.0/generated/azure_cognitiveservices_face/models/person_group.rb +72 -0
  47. data/lib/1.0/generated/azure_cognitiveservices_face/models/similar_face.rb +73 -0
  48. data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status.rb +89 -0
  49. data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status_type.rb +18 -0
  50. data/lib/1.0/generated/azure_cognitiveservices_face/models/update_person_face_request.rb +50 -0
  51. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_face_request.rb +57 -0
  52. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_person_request.rb +75 -0
  53. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_result.rb +62 -0
  54. data/lib/1.0/generated/azure_cognitiveservices_face/module_definition.rb +9 -0
  55. data/lib/1.0/generated/azure_cognitiveservices_face/person_group_operations.rb +678 -0
  56. data/lib/1.0/generated/azure_cognitiveservices_face/person_group_person.rb +1121 -0
  57. data/lib/azure_cognitiveservices_face.rb +6 -0
  58. data/lib/module_definition.rb +7 -0
  59. data/lib/profiles/latest/face_latest_profile_client.rb +38 -0
  60. data/lib/profiles/latest/face_module_definition.rb +8 -0
  61. data/lib/profiles/latest/modules/face_profile_module.rb +253 -0
  62. data/lib/version.rb +7 -0
  63. metadata +180 -0
@@ -0,0 +1,1121 @@
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::Face::V1_0
7
+ #
8
+ # An API for face detection, verification, and identification.
9
+ #
10
+ class PersonGroupPerson
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the PersonGroupPerson class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [FaceClient] reference to the FaceClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Create a new person in a specified person group.
26
+ #
27
+ # @param person_group_id [String] Id referencing a particular person group.
28
+ # @param name [String] User defined name, maximum length is 128.
29
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
30
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
31
+ # will be added to the HTTP request.
32
+ #
33
+ # @return [Person] operation results.
34
+ #
35
+ def create(person_group_id, name:nil, user_data:nil, custom_headers:nil)
36
+ response = create_async(person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
37
+ response.body unless response.nil?
38
+ end
39
+
40
+ #
41
+ # Create a new person in a specified person group.
42
+ #
43
+ # @param person_group_id [String] Id referencing a particular person group.
44
+ # @param name [String] User defined name, maximum length is 128.
45
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
46
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
47
+ # will be added to the HTTP request.
48
+ #
49
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
50
+ #
51
+ def create_with_http_info(person_group_id, name:nil, user_data:nil, custom_headers:nil)
52
+ create_async(person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
53
+ end
54
+
55
+ #
56
+ # Create a new person in a specified person group.
57
+ #
58
+ # @param person_group_id [String] Id referencing a particular person group.
59
+ # @param name [String] User defined name, maximum length is 128.
60
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
61
+ # @param [Hash{String => String}] A hash of custom headers that will be added
62
+ # to the HTTP request.
63
+ #
64
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
65
+ #
66
+ def create_async(person_group_id, name:nil, user_data:nil, custom_headers:nil)
67
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
68
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
69
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
70
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
71
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
72
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
73
+
74
+ body = NameAndUserDataContract.new
75
+ unless name.nil? && user_data.nil?
76
+ body.name = name
77
+ body.user_data = user_data
78
+ end
79
+
80
+ request_headers = {}
81
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
82
+
83
+ # Set Headers
84
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
85
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
86
+
87
+ # Serialize Request
88
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
89
+ request_content = @client.serialize(request_mapper, body)
90
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
91
+
92
+ path_template = 'persongroups/{personGroupId}/persons'
93
+
94
+ request_url = @base_url || @client.base_url
95
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
96
+
97
+ options = {
98
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
99
+ path_params: {'personGroupId' => person_group_id},
100
+ body: request_content,
101
+ headers: request_headers.merge(custom_headers || {}),
102
+ base_url: request_url
103
+ }
104
+ promise = @client.make_request_async(:post, path_template, options)
105
+
106
+ promise = promise.then do |result|
107
+ http_response = result.response
108
+ status_code = http_response.status
109
+ response_content = http_response.body
110
+ unless status_code == 200
111
+ error_model = JSON.load(response_content)
112
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
113
+ end
114
+
115
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
116
+ # Deserialize Response
117
+ if status_code == 200
118
+ begin
119
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
120
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
121
+ result.body = @client.deserialize(result_mapper, parsed_response)
122
+ rescue Exception => e
123
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
124
+ end
125
+ end
126
+
127
+ result
128
+ end
129
+
130
+ promise.execute
131
+ end
132
+
133
+ #
134
+ # List all persons in a person group, and retrieve person information
135
+ # (including personId, name, userData and persistedFaceIds of registered faces
136
+ # of the person).
137
+ #
138
+ # @param person_group_id [String] Id referencing a particular person group.
139
+ # @param start [String] Starting person id to return (used to list a range of
140
+ # persons).
141
+ # @param top [Integer] Number of persons to return starting with the person id
142
+ # indicated by the 'start' parameter.
143
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
144
+ # will be added to the HTTP request.
145
+ #
146
+ # @return [Array] operation results.
147
+ #
148
+ def list(person_group_id, start:nil, top:nil, custom_headers:nil)
149
+ response = list_async(person_group_id, start:start, top:top, custom_headers:custom_headers).value!
150
+ response.body unless response.nil?
151
+ end
152
+
153
+ #
154
+ # List all persons in a person group, and retrieve person information
155
+ # (including personId, name, userData and persistedFaceIds of registered faces
156
+ # of the person).
157
+ #
158
+ # @param person_group_id [String] Id referencing a particular person group.
159
+ # @param start [String] Starting person id to return (used to list a range of
160
+ # persons).
161
+ # @param top [Integer] Number of persons to return starting with the person id
162
+ # indicated by the 'start' parameter.
163
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
164
+ # will be added to the HTTP request.
165
+ #
166
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
167
+ #
168
+ def list_with_http_info(person_group_id, start:nil, top:nil, custom_headers:nil)
169
+ list_async(person_group_id, start:start, top:top, custom_headers:custom_headers).value!
170
+ end
171
+
172
+ #
173
+ # List all persons in a person group, and retrieve person information
174
+ # (including personId, name, userData and persistedFaceIds of registered faces
175
+ # of the person).
176
+ #
177
+ # @param person_group_id [String] Id referencing a particular person group.
178
+ # @param start [String] Starting person id to return (used to list a range of
179
+ # persons).
180
+ # @param top [Integer] Number of persons to return starting with the person id
181
+ # indicated by the 'start' parameter.
182
+ # @param [Hash{String => String}] A hash of custom headers that will be added
183
+ # to the HTTP request.
184
+ #
185
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
186
+ #
187
+ def list_async(person_group_id, start:nil, top:nil, custom_headers:nil)
188
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
189
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
190
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
191
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
192
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
193
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1
194
+
195
+
196
+ request_headers = {}
197
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
198
+
199
+ # Set Headers
200
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
201
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
202
+ path_template = 'persongroups/{personGroupId}/persons'
203
+
204
+ request_url = @base_url || @client.base_url
205
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
206
+
207
+ options = {
208
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
209
+ path_params: {'personGroupId' => person_group_id},
210
+ query_params: {'start' => start,'top' => top},
211
+ headers: request_headers.merge(custom_headers || {}),
212
+ base_url: request_url
213
+ }
214
+ promise = @client.make_request_async(:get, path_template, options)
215
+
216
+ promise = promise.then do |result|
217
+ http_response = result.response
218
+ status_code = http_response.status
219
+ response_content = http_response.body
220
+ unless status_code == 200
221
+ error_model = JSON.load(response_content)
222
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
223
+ end
224
+
225
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
226
+ # Deserialize Response
227
+ if status_code == 200
228
+ begin
229
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
230
+ result_mapper = {
231
+ client_side_validation: true,
232
+ required: false,
233
+ serialized_name: 'parsed_response',
234
+ type: {
235
+ name: 'Sequence',
236
+ element: {
237
+ client_side_validation: true,
238
+ required: false,
239
+ serialized_name: 'PersonElementType',
240
+ type: {
241
+ name: 'Composite',
242
+ class_name: 'Person'
243
+ }
244
+ }
245
+ }
246
+ }
247
+ result.body = @client.deserialize(result_mapper, parsed_response)
248
+ rescue Exception => e
249
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
250
+ end
251
+ end
252
+
253
+ result
254
+ end
255
+
256
+ promise.execute
257
+ end
258
+
259
+ #
260
+ # Delete an existing person from a person group. Persisted face images of the
261
+ # person will also be deleted.
262
+ #
263
+ # @param person_group_id [String] Id referencing a particular person group.
264
+ # @param person_id Id referencing a particular person.
265
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
266
+ # will be added to the HTTP request.
267
+ #
268
+ #
269
+ def delete(person_group_id, person_id, custom_headers:nil)
270
+ response = delete_async(person_group_id, person_id, custom_headers:custom_headers).value!
271
+ nil
272
+ end
273
+
274
+ #
275
+ # Delete an existing person from a person group. Persisted face images of the
276
+ # person will also be deleted.
277
+ #
278
+ # @param person_group_id [String] Id referencing a particular person group.
279
+ # @param person_id Id referencing a particular person.
280
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
281
+ # will be added to the HTTP request.
282
+ #
283
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
284
+ #
285
+ def delete_with_http_info(person_group_id, person_id, custom_headers:nil)
286
+ delete_async(person_group_id, person_id, custom_headers:custom_headers).value!
287
+ end
288
+
289
+ #
290
+ # Delete an existing person from a person group. Persisted face images of the
291
+ # person will also be deleted.
292
+ #
293
+ # @param person_group_id [String] Id referencing a particular person group.
294
+ # @param person_id Id referencing a particular person.
295
+ # @param [Hash{String => String}] A hash of custom headers that will be added
296
+ # to the HTTP request.
297
+ #
298
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
299
+ #
300
+ def delete_async(person_group_id, person_id, custom_headers:nil)
301
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
302
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
303
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
304
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
305
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
306
+
307
+
308
+ request_headers = {}
309
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
310
+
311
+ # Set Headers
312
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
313
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
314
+ path_template = 'persongroups/{personGroupId}/persons/{personId}'
315
+
316
+ request_url = @base_url || @client.base_url
317
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
318
+
319
+ options = {
320
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
321
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id},
322
+ headers: request_headers.merge(custom_headers || {}),
323
+ base_url: request_url
324
+ }
325
+ promise = @client.make_request_async(:delete, path_template, options)
326
+
327
+ promise = promise.then do |result|
328
+ http_response = result.response
329
+ status_code = http_response.status
330
+ response_content = http_response.body
331
+ unless status_code == 200
332
+ error_model = JSON.load(response_content)
333
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
334
+ end
335
+
336
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
337
+
338
+ result
339
+ end
340
+
341
+ promise.execute
342
+ end
343
+
344
+ #
345
+ # Retrieve a person's information, including registered persisted faces, name
346
+ # and userData.
347
+ #
348
+ # @param person_group_id [String] Id referencing a particular person group.
349
+ # @param person_id Id referencing a particular person.
350
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
351
+ # will be added to the HTTP request.
352
+ #
353
+ # @return [Person] operation results.
354
+ #
355
+ def get(person_group_id, person_id, custom_headers:nil)
356
+ response = get_async(person_group_id, person_id, custom_headers:custom_headers).value!
357
+ response.body unless response.nil?
358
+ end
359
+
360
+ #
361
+ # Retrieve a person's information, including registered persisted faces, name
362
+ # and userData.
363
+ #
364
+ # @param person_group_id [String] Id referencing a particular person group.
365
+ # @param person_id Id referencing a particular person.
366
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
367
+ # will be added to the HTTP request.
368
+ #
369
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
370
+ #
371
+ def get_with_http_info(person_group_id, person_id, custom_headers:nil)
372
+ get_async(person_group_id, person_id, custom_headers:custom_headers).value!
373
+ end
374
+
375
+ #
376
+ # Retrieve a person's information, including registered persisted faces, name
377
+ # and userData.
378
+ #
379
+ # @param person_group_id [String] Id referencing a particular person group.
380
+ # @param person_id Id referencing a particular person.
381
+ # @param [Hash{String => String}] A hash of custom headers that will be added
382
+ # to the HTTP request.
383
+ #
384
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
385
+ #
386
+ def get_async(person_group_id, person_id, custom_headers:nil)
387
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
388
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
389
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
390
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
391
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
392
+
393
+
394
+ request_headers = {}
395
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
396
+
397
+ # Set Headers
398
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
399
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
400
+ path_template = 'persongroups/{personGroupId}/persons/{personId}'
401
+
402
+ request_url = @base_url || @client.base_url
403
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
404
+
405
+ options = {
406
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
407
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id},
408
+ headers: request_headers.merge(custom_headers || {}),
409
+ base_url: request_url
410
+ }
411
+ promise = @client.make_request_async(:get, path_template, options)
412
+
413
+ promise = promise.then do |result|
414
+ http_response = result.response
415
+ status_code = http_response.status
416
+ response_content = http_response.body
417
+ unless status_code == 200
418
+ error_model = JSON.load(response_content)
419
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
420
+ end
421
+
422
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
423
+ # Deserialize Response
424
+ if status_code == 200
425
+ begin
426
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
427
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
428
+ result.body = @client.deserialize(result_mapper, parsed_response)
429
+ rescue Exception => e
430
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
431
+ end
432
+ end
433
+
434
+ result
435
+ end
436
+
437
+ promise.execute
438
+ end
439
+
440
+ #
441
+ # Update name or userData of a person.
442
+ #
443
+ # @param person_group_id [String] Id referencing a particular person group.
444
+ # @param person_id Id referencing a particular person.
445
+ # @param name [String] User defined name, maximum length is 128.
446
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
447
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
448
+ # will be added to the HTTP request.
449
+ #
450
+ #
451
+ def update(person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
452
+ response = update_async(person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
453
+ nil
454
+ end
455
+
456
+ #
457
+ # Update name or userData of a person.
458
+ #
459
+ # @param person_group_id [String] Id referencing a particular person group.
460
+ # @param person_id Id referencing a particular person.
461
+ # @param name [String] User defined name, maximum length is 128.
462
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
463
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
464
+ # will be added to the HTTP request.
465
+ #
466
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
467
+ #
468
+ def update_with_http_info(person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
469
+ update_async(person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
470
+ end
471
+
472
+ #
473
+ # Update name or userData of a person.
474
+ #
475
+ # @param person_group_id [String] Id referencing a particular person group.
476
+ # @param person_id Id referencing a particular person.
477
+ # @param name [String] User defined name, maximum length is 128.
478
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
479
+ # @param [Hash{String => String}] A hash of custom headers that will be added
480
+ # to the HTTP request.
481
+ #
482
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
483
+ #
484
+ def update_async(person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
485
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
486
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
487
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
488
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
489
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
490
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
491
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
492
+
493
+ body = NameAndUserDataContract.new
494
+ unless name.nil? && user_data.nil?
495
+ body.name = name
496
+ body.user_data = user_data
497
+ end
498
+
499
+ request_headers = {}
500
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
501
+
502
+ # Set Headers
503
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
504
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
505
+
506
+ # Serialize Request
507
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
508
+ request_content = @client.serialize(request_mapper, body)
509
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
510
+
511
+ path_template = 'persongroups/{personGroupId}/persons/{personId}'
512
+
513
+ request_url = @base_url || @client.base_url
514
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
515
+
516
+ options = {
517
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
518
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id},
519
+ body: request_content,
520
+ headers: request_headers.merge(custom_headers || {}),
521
+ base_url: request_url
522
+ }
523
+ promise = @client.make_request_async(:patch, path_template, options)
524
+
525
+ promise = promise.then do |result|
526
+ http_response = result.response
527
+ status_code = http_response.status
528
+ response_content = http_response.body
529
+ unless status_code == 200
530
+ error_model = JSON.load(response_content)
531
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
532
+ end
533
+
534
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
535
+
536
+ result
537
+ end
538
+
539
+ promise.execute
540
+ end
541
+
542
+ #
543
+ # Delete a face from a person. Relative image for the persisted face will also
544
+ # be deleted.
545
+ #
546
+ # @param person_group_id [String] Id referencing a particular person group.
547
+ # @param person_id Id referencing a particular person.
548
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
549
+ # existing face.
550
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
551
+ # will be added to the HTTP request.
552
+ #
553
+ #
554
+ def delete_face(person_group_id, person_id, persisted_face_id, custom_headers:nil)
555
+ response = delete_face_async(person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
556
+ nil
557
+ end
558
+
559
+ #
560
+ # Delete a face from a person. Relative image for the persisted face will also
561
+ # be deleted.
562
+ #
563
+ # @param person_group_id [String] Id referencing a particular person group.
564
+ # @param person_id Id referencing a particular person.
565
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
566
+ # existing face.
567
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
568
+ # will be added to the HTTP request.
569
+ #
570
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
571
+ #
572
+ def delete_face_with_http_info(person_group_id, person_id, persisted_face_id, custom_headers:nil)
573
+ delete_face_async(person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
574
+ end
575
+
576
+ #
577
+ # Delete a face from a person. Relative image for the persisted face will also
578
+ # be deleted.
579
+ #
580
+ # @param person_group_id [String] Id referencing a particular person group.
581
+ # @param person_id Id referencing a particular person.
582
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
583
+ # existing face.
584
+ # @param [Hash{String => String}] A hash of custom headers that will be added
585
+ # to the HTTP request.
586
+ #
587
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
588
+ #
589
+ def delete_face_async(person_group_id, person_id, persisted_face_id, custom_headers:nil)
590
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
591
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
592
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
593
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
594
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
595
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
596
+
597
+
598
+ request_headers = {}
599
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
600
+
601
+ # Set Headers
602
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
603
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
604
+ path_template = 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'
605
+
606
+ request_url = @base_url || @client.base_url
607
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
608
+
609
+ options = {
610
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
611
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
612
+ headers: request_headers.merge(custom_headers || {}),
613
+ base_url: request_url
614
+ }
615
+ promise = @client.make_request_async(:delete, path_template, options)
616
+
617
+ promise = promise.then do |result|
618
+ http_response = result.response
619
+ status_code = http_response.status
620
+ response_content = http_response.body
621
+ unless status_code == 200
622
+ error_model = JSON.load(response_content)
623
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
624
+ end
625
+
626
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
627
+
628
+ result
629
+ end
630
+
631
+ promise.execute
632
+ end
633
+
634
+ #
635
+ # Retrieve information about a persisted face (specified by persistedFaceId,
636
+ # personId and its belonging personGroupId).
637
+ #
638
+ # @param person_group_id [String] Id referencing a particular person group.
639
+ # @param person_id Id referencing a particular person.
640
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
641
+ # existing face.
642
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
643
+ # will be added to the HTTP request.
644
+ #
645
+ # @return [PersistedFace] operation results.
646
+ #
647
+ def get_face(person_group_id, person_id, persisted_face_id, custom_headers:nil)
648
+ response = get_face_async(person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
649
+ response.body unless response.nil?
650
+ end
651
+
652
+ #
653
+ # Retrieve information about a persisted face (specified by persistedFaceId,
654
+ # personId and its belonging personGroupId).
655
+ #
656
+ # @param person_group_id [String] Id referencing a particular person group.
657
+ # @param person_id Id referencing a particular person.
658
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
659
+ # existing face.
660
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
661
+ # will be added to the HTTP request.
662
+ #
663
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
664
+ #
665
+ def get_face_with_http_info(person_group_id, person_id, persisted_face_id, custom_headers:nil)
666
+ get_face_async(person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
667
+ end
668
+
669
+ #
670
+ # Retrieve information about a persisted face (specified by persistedFaceId,
671
+ # personId and its belonging personGroupId).
672
+ #
673
+ # @param person_group_id [String] Id referencing a particular person group.
674
+ # @param person_id Id referencing a particular person.
675
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
676
+ # existing face.
677
+ # @param [Hash{String => String}] A hash of custom headers that will be added
678
+ # to the HTTP request.
679
+ #
680
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
681
+ #
682
+ def get_face_async(person_group_id, person_id, persisted_face_id, custom_headers:nil)
683
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
684
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
685
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
686
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
687
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
688
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
689
+
690
+
691
+ request_headers = {}
692
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
693
+
694
+ # Set Headers
695
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
696
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
697
+ path_template = 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'
698
+
699
+ request_url = @base_url || @client.base_url
700
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
701
+
702
+ options = {
703
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
704
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
705
+ headers: request_headers.merge(custom_headers || {}),
706
+ base_url: request_url
707
+ }
708
+ promise = @client.make_request_async(:get, path_template, options)
709
+
710
+ promise = promise.then do |result|
711
+ http_response = result.response
712
+ status_code = http_response.status
713
+ response_content = http_response.body
714
+ unless status_code == 200
715
+ error_model = JSON.load(response_content)
716
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
717
+ end
718
+
719
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
720
+ # Deserialize Response
721
+ if status_code == 200
722
+ begin
723
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
724
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
725
+ result.body = @client.deserialize(result_mapper, parsed_response)
726
+ rescue Exception => e
727
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
728
+ end
729
+ end
730
+
731
+ result
732
+ end
733
+
734
+ promise.execute
735
+ end
736
+
737
+ #
738
+ # Update a person persisted face's userData field.
739
+ #
740
+ # @param person_group_id [String] Id referencing a particular person group.
741
+ # @param person_id Id referencing a particular person.
742
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
743
+ # existing face.
744
+ # @param user_data [String] User-provided data attached to the face. The size
745
+ # limit is 1KB.
746
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
747
+ # will be added to the HTTP request.
748
+ #
749
+ #
750
+ def update_face(person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
751
+ response = update_face_async(person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
752
+ nil
753
+ end
754
+
755
+ #
756
+ # Update a person persisted face's userData field.
757
+ #
758
+ # @param person_group_id [String] Id referencing a particular person group.
759
+ # @param person_id Id referencing a particular person.
760
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
761
+ # existing face.
762
+ # @param user_data [String] User-provided data attached to the face. The size
763
+ # limit is 1KB.
764
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
765
+ # will be added to the HTTP request.
766
+ #
767
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
768
+ #
769
+ def update_face_with_http_info(person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
770
+ update_face_async(person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
771
+ end
772
+
773
+ #
774
+ # Update a person persisted face's userData field.
775
+ #
776
+ # @param person_group_id [String] Id referencing a particular person group.
777
+ # @param person_id Id referencing a particular person.
778
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
779
+ # existing face.
780
+ # @param user_data [String] User-provided data attached to the face. The size
781
+ # limit is 1KB.
782
+ # @param [Hash{String => String}] A hash of custom headers that will be added
783
+ # to the HTTP request.
784
+ #
785
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
786
+ #
787
+ def update_face_async(person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
788
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
789
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
790
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
791
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
792
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
793
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
794
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
795
+
796
+ body = UpdatePersonFaceRequest.new
797
+ unless user_data.nil?
798
+ body.user_data = user_data
799
+ end
800
+
801
+ request_headers = {}
802
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
803
+
804
+ # Set Headers
805
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
806
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
807
+
808
+ # Serialize Request
809
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::UpdatePersonFaceRequest.mapper()
810
+ request_content = @client.serialize(request_mapper, body)
811
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
812
+
813
+ path_template = 'persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}'
814
+
815
+ request_url = @base_url || @client.base_url
816
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
817
+
818
+ options = {
819
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
820
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
821
+ body: request_content,
822
+ headers: request_headers.merge(custom_headers || {}),
823
+ base_url: request_url
824
+ }
825
+ promise = @client.make_request_async(:patch, path_template, options)
826
+
827
+ promise = promise.then do |result|
828
+ http_response = result.response
829
+ status_code = http_response.status
830
+ response_content = http_response.body
831
+ unless status_code == 200
832
+ error_model = JSON.load(response_content)
833
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
834
+ end
835
+
836
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
837
+
838
+ result
839
+ end
840
+
841
+ promise.execute
842
+ end
843
+
844
+ #
845
+ # Add a representative face to a person for identification. The input face is
846
+ # specified as an image with a targetFace rectangle.
847
+ #
848
+ # @param person_group_id [String] Id referencing a particular person group.
849
+ # @param person_id Id referencing a particular person.
850
+ # @param url [String]
851
+ # @param user_data [String] User-specified data about the face for any purpose.
852
+ # The maximum length is 1KB.
853
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
854
+ # face to be added to a person in the format of
855
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
856
+ # is more than one face in the image, targetFace is required to specify which
857
+ # face to add. No targetFace means there is only one face detected in the
858
+ # entire image.
859
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
860
+ # will be added to the HTTP request.
861
+ #
862
+ # @return [PersistedFace] operation results.
863
+ #
864
+ def add_person_face_from_url(person_group_id, person_id, url, user_data:nil, target_face:nil, custom_headers:nil)
865
+ response = add_person_face_from_url_async(person_group_id, person_id, url, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
866
+ response.body unless response.nil?
867
+ end
868
+
869
+ #
870
+ # Add a representative face to a person for identification. The input face is
871
+ # specified as an image with a targetFace rectangle.
872
+ #
873
+ # @param person_group_id [String] Id referencing a particular person group.
874
+ # @param person_id Id referencing a particular person.
875
+ # @param url [String]
876
+ # @param user_data [String] User-specified data about the face for any purpose.
877
+ # The maximum length is 1KB.
878
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
879
+ # face to be added to a person in the format of
880
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
881
+ # is more than one face in the image, targetFace is required to specify which
882
+ # face to add. No targetFace means there is only one face detected in the
883
+ # entire image.
884
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
885
+ # will be added to the HTTP request.
886
+ #
887
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
888
+ #
889
+ def add_person_face_from_url_with_http_info(person_group_id, person_id, url, user_data:nil, target_face:nil, custom_headers:nil)
890
+ add_person_face_from_url_async(person_group_id, person_id, url, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
891
+ end
892
+
893
+ #
894
+ # Add a representative face to a person for identification. The input face is
895
+ # specified as an image with a targetFace rectangle.
896
+ #
897
+ # @param person_group_id [String] Id referencing a particular person group.
898
+ # @param person_id Id referencing a particular person.
899
+ # @param url [String]
900
+ # @param user_data [String] User-specified data about the face for any purpose.
901
+ # The maximum length is 1KB.
902
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
903
+ # face to be added to a person in the format of
904
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
905
+ # is more than one face in the image, targetFace is required to specify which
906
+ # face to add. No targetFace means there is only one face detected in the
907
+ # entire image.
908
+ # @param [Hash{String => String}] A hash of custom headers that will be added
909
+ # to the HTTP request.
910
+ #
911
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
912
+ #
913
+ def add_person_face_from_url_async(person_group_id, person_id, url, user_data:nil, target_face:nil, custom_headers:nil)
914
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
915
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
916
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
917
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
918
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
919
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
920
+ fail ArgumentError, 'url is nil' if url.nil?
921
+
922
+ image_url = ImageUrl.new
923
+ unless url.nil?
924
+ image_url.url = url
925
+ end
926
+
927
+ request_headers = {}
928
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
929
+
930
+ # Set Headers
931
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
932
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
933
+
934
+ # Serialize Request
935
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
936
+ request_content = @client.serialize(request_mapper, image_url)
937
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
938
+
939
+ path_template = 'persongroups/{personGroupId}/persons/{personId}/persistedFaces'
940
+
941
+ request_url = @base_url || @client.base_url
942
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
943
+
944
+ options = {
945
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
946
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id},
947
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(',')},
948
+ body: request_content,
949
+ headers: request_headers.merge(custom_headers || {}),
950
+ base_url: request_url
951
+ }
952
+ promise = @client.make_request_async(:post, path_template, options)
953
+
954
+ promise = promise.then do |result|
955
+ http_response = result.response
956
+ status_code = http_response.status
957
+ response_content = http_response.body
958
+ unless status_code == 200
959
+ error_model = JSON.load(response_content)
960
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
961
+ end
962
+
963
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
964
+ # Deserialize Response
965
+ if status_code == 200
966
+ begin
967
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
968
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
969
+ result.body = @client.deserialize(result_mapper, parsed_response)
970
+ rescue Exception => e
971
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
972
+ end
973
+ end
974
+
975
+ result
976
+ end
977
+
978
+ promise.execute
979
+ end
980
+
981
+ #
982
+ # Add a representative face to a person for identification. The input face is
983
+ # specified as an image with a targetFace rectangle.
984
+ #
985
+ # @param person_group_id [String] Id referencing a particular person group.
986
+ # @param person_id Id referencing a particular person.
987
+ # @param image An image stream.
988
+ # @param user_data [String] User-specified data about the face for any purpose.
989
+ # The maximum length is 1KB.
990
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
991
+ # face to be added to a person in the format of
992
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
993
+ # is more than one face in the image, targetFace is required to specify which
994
+ # face to add. No targetFace means there is only one face detected in the
995
+ # entire image.
996
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
997
+ # will be added to the HTTP request.
998
+ #
999
+ # @return [PersistedFace] operation results.
1000
+ #
1001
+ def add_person_face_from_stream(person_group_id, person_id, image, user_data:nil, target_face:nil, custom_headers:nil)
1002
+ response = add_person_face_from_stream_async(person_group_id, person_id, image, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
1003
+ response.body unless response.nil?
1004
+ end
1005
+
1006
+ #
1007
+ # Add a representative face to a person for identification. The input face is
1008
+ # specified as an image with a targetFace rectangle.
1009
+ #
1010
+ # @param person_group_id [String] Id referencing a particular person group.
1011
+ # @param person_id Id referencing a particular person.
1012
+ # @param image An image stream.
1013
+ # @param user_data [String] User-specified data about the face for any purpose.
1014
+ # The maximum length is 1KB.
1015
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1016
+ # face to be added to a person in the format of
1017
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1018
+ # is more than one face in the image, targetFace is required to specify which
1019
+ # face to add. No targetFace means there is only one face detected in the
1020
+ # entire image.
1021
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1022
+ # will be added to the HTTP request.
1023
+ #
1024
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1025
+ #
1026
+ def add_person_face_from_stream_with_http_info(person_group_id, person_id, image, user_data:nil, target_face:nil, custom_headers:nil)
1027
+ add_person_face_from_stream_async(person_group_id, person_id, image, user_data:user_data, target_face:target_face, custom_headers:custom_headers).value!
1028
+ end
1029
+
1030
+ #
1031
+ # Add a representative face to a person for identification. The input face is
1032
+ # specified as an image with a targetFace rectangle.
1033
+ #
1034
+ # @param person_group_id [String] Id referencing a particular person group.
1035
+ # @param person_id Id referencing a particular person.
1036
+ # @param image An image stream.
1037
+ # @param user_data [String] User-specified data about the face for any purpose.
1038
+ # The maximum length is 1KB.
1039
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1040
+ # face to be added to a person in the format of
1041
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1042
+ # is more than one face in the image, targetFace is required to specify which
1043
+ # face to add. No targetFace means there is only one face detected in the
1044
+ # entire image.
1045
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1046
+ # to the HTTP request.
1047
+ #
1048
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1049
+ #
1050
+ def add_person_face_from_stream_async(person_group_id, person_id, image, user_data:nil, target_face:nil, custom_headers:nil)
1051
+ fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
1052
+ fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
1053
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
1054
+ fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
1055
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
1056
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1057
+ fail ArgumentError, 'image is nil' if image.nil?
1058
+
1059
+
1060
+ request_headers = {}
1061
+ request_headers['Content-Type'] = 'application/octet-stream'
1062
+
1063
+ # Set Headers
1064
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1065
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1066
+
1067
+ # Serialize Request
1068
+ request_mapper = {
1069
+ client_side_validation: true,
1070
+ required: true,
1071
+ serialized_name: 'Image',
1072
+ type: {
1073
+ name: 'Stream'
1074
+ }
1075
+ }
1076
+ request_content = @client.serialize(request_mapper, image)
1077
+
1078
+ path_template = 'persongroups/{personGroupId}/persons/{personId}/persistedFaces'
1079
+
1080
+ request_url = @base_url || @client.base_url
1081
+ request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
1082
+
1083
+ options = {
1084
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1085
+ path_params: {'personGroupId' => person_group_id,'personId' => person_id},
1086
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(',')},
1087
+ body: request_content,
1088
+ headers: request_headers.merge(custom_headers || {}),
1089
+ base_url: request_url
1090
+ }
1091
+ promise = @client.make_request_async(:post, path_template, options)
1092
+
1093
+ promise = promise.then do |result|
1094
+ http_response = result.response
1095
+ status_code = http_response.status
1096
+ response_content = http_response.body
1097
+ unless status_code == 200
1098
+ error_model = JSON.load(response_content)
1099
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1100
+ end
1101
+
1102
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1103
+ # Deserialize Response
1104
+ if status_code == 200
1105
+ begin
1106
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1107
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1108
+ result.body = @client.deserialize(result_mapper, parsed_response)
1109
+ rescue Exception => e
1110
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1111
+ end
1112
+ end
1113
+
1114
+ result
1115
+ end
1116
+
1117
+ promise.execute
1118
+ end
1119
+
1120
+ end
1121
+ end