be_azure_cognitiveservices_face 0.19.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/1.0/generated/azure_cognitiveservices_face/face.rb +1711 -0
  4. data/lib/1.0/generated/azure_cognitiveservices_face/face_client.rb +159 -0
  5. data/lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb +1269 -0
  6. data/lib/1.0/generated/azure_cognitiveservices_face/large_face_list_operations.rb +1894 -0
  7. data/lib/1.0/generated/azure_cognitiveservices_face/large_person_group_operations.rb +886 -0
  8. data/lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb +1477 -0
  9. data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory.rb +59 -0
  10. data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory_type.rb +17 -0
  11. data/lib/1.0/generated/azure_cognitiveservices_face/models/apierror.rb +47 -0
  12. data/lib/1.0/generated/azure_cognitiveservices_face/models/apply_snapshot_request.rb +69 -0
  13. data/lib/1.0/generated/azure_cognitiveservices_face/models/blur.rb +60 -0
  14. data/lib/1.0/generated/azure_cognitiveservices_face/models/blur_level.rb +17 -0
  15. data/lib/1.0/generated/azure_cognitiveservices_face/models/coordinate.rb +57 -0
  16. data/lib/1.0/generated/azure_cognitiveservices_face/models/detected_face.rb +95 -0
  17. data/lib/1.0/generated/azure_cognitiveservices_face/models/detection_model.rb +16 -0
  18. data/lib/1.0/generated/azure_cognitiveservices_face/models/emotion.rb +124 -0
  19. data/lib/1.0/generated/azure_cognitiveservices_face/models/error.rb +57 -0
  20. data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure.rb +62 -0
  21. data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure_level.rb +17 -0
  22. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attribute_type.rb +28 -0
  23. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attributes.rb +214 -0
  24. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_landmarks.rb +360 -0
  25. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_list.rb +101 -0
  26. data/lib/1.0/generated/azure_cognitiveservices_face/models/face_rectangle.rb +81 -0
  27. data/lib/1.0/generated/azure_cognitiveservices_face/models/facial_hair.rb +68 -0
  28. data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_match_mode.rb +16 -0
  29. data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_request.rb +143 -0
  30. data/lib/1.0/generated/azure_cognitiveservices_face/models/gender.rb +16 -0
  31. data/lib/1.0/generated/azure_cognitiveservices_face/models/glasses_type.rb +18 -0
  32. data/lib/1.0/generated/azure_cognitiveservices_face/models/group_request.rb +58 -0
  33. data/lib/1.0/generated/azure_cognitiveservices_face/models/group_result.rb +83 -0
  34. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair.rb +80 -0
  35. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color.rb +60 -0
  36. data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color_type.rb +22 -0
  37. data/lib/1.0/generated/azure_cognitiveservices_face/models/head_pose.rb +68 -0
  38. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_candidate.rb +59 -0
  39. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_request.rb +123 -0
  40. data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_result.rb +69 -0
  41. data/lib/1.0/generated/azure_cognitiveservices_face/models/image_url.rb +47 -0
  42. data/lib/1.0/generated/azure_cognitiveservices_face/models/large_face_list.rb +81 -0
  43. data/lib/1.0/generated/azure_cognitiveservices_face/models/large_person_group.rb +81 -0
  44. data/lib/1.0/generated/azure_cognitiveservices_face/models/makeup.rb +59 -0
  45. data/lib/1.0/generated/azure_cognitiveservices_face/models/meta_data_contract.rb +72 -0
  46. data/lib/1.0/generated/azure_cognitiveservices_face/models/name_and_user_data_contract.rb +64 -0
  47. data/lib/1.0/generated/azure_cognitiveservices_face/models/noise.rb +62 -0
  48. data/lib/1.0/generated/azure_cognitiveservices_face/models/noise_level.rb +17 -0
  49. data/lib/1.0/generated/azure_cognitiveservices_face/models/occlusion.rb +70 -0
  50. data/lib/1.0/generated/azure_cognitiveservices_face/models/operation_status.rb +112 -0
  51. data/lib/1.0/generated/azure_cognitiveservices_face/models/operation_status_type.rb +18 -0
  52. data/lib/1.0/generated/azure_cognitiveservices_face/models/persisted_face.rb +63 -0
  53. data/lib/1.0/generated/azure_cognitiveservices_face/models/person.rb +89 -0
  54. data/lib/1.0/generated/azure_cognitiveservices_face/models/person_group.rb +81 -0
  55. data/lib/1.0/generated/azure_cognitiveservices_face/models/recognition_model.rb +16 -0
  56. data/lib/1.0/generated/azure_cognitiveservices_face/models/similar_face.rb +73 -0
  57. data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot.rb +136 -0
  58. data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot_apply_mode.rb +15 -0
  59. data/lib/1.0/generated/azure_cognitiveservices_face/models/snapshot_object_type.rb +18 -0
  60. data/lib/1.0/generated/azure_cognitiveservices_face/models/take_snapshot_request.rb +101 -0
  61. data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status.rb +107 -0
  62. data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status_type.rb +18 -0
  63. data/lib/1.0/generated/azure_cognitiveservices_face/models/update_face_request.rb +50 -0
  64. data/lib/1.0/generated/azure_cognitiveservices_face/models/update_snapshot_request.rb +73 -0
  65. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_face_request.rb +57 -0
  66. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_person_request.rb +95 -0
  67. data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_result.rb +62 -0
  68. data/lib/1.0/generated/azure_cognitiveservices_face/module_definition.rb +9 -0
  69. data/lib/1.0/generated/azure_cognitiveservices_face/person_group_operations.rb +865 -0
  70. data/lib/1.0/generated/azure_cognitiveservices_face/person_group_person.rb +1528 -0
  71. data/lib/1.0/generated/azure_cognitiveservices_face/snapshot_operations.rb +983 -0
  72. data/lib/1.0/generated/azure_cognitiveservices_face.rb +94 -0
  73. data/lib/azure_cognitiveservices_face.rb +6 -0
  74. data/lib/module_definition.rb +7 -0
  75. data/lib/profiles/latest/face_latest_profile_client.rb +38 -0
  76. data/lib/profiles/latest/face_module_definition.rb +8 -0
  77. data/lib/profiles/latest/modules/face_profile_module.rb +309 -0
  78. data/lib/version.rb +7 -0
  79. metadata +196 -0
@@ -0,0 +1,1477 @@
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 LargePersonGroupPerson
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the LargePersonGroupPerson 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 large person group.
26
+ #
27
+ # @param large_person_group_id [String] Id referencing a particular large
28
+ # person group.
29
+ # @param name [String] User defined name, maximum length is 128.
30
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
31
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
32
+ # will be added to the HTTP request.
33
+ #
34
+ # @return [Person] operation results.
35
+ #
36
+ def create(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
37
+ response = create_async(large_person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
38
+ response.body unless response.nil?
39
+ end
40
+
41
+ #
42
+ # Create a new person in a specified large person group.
43
+ #
44
+ # @param large_person_group_id [String] Id referencing a particular large
45
+ # person group.
46
+ # @param name [String] User defined name, maximum length is 128.
47
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def create_with_http_info(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
54
+ create_async(large_person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Create a new person in a specified large person group.
59
+ #
60
+ # @param large_person_group_id [String] Id referencing a particular large
61
+ # person group.
62
+ # @param name [String] User defined name, maximum length is 128.
63
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
64
+ # @param [Hash{String => String}] A hash of custom headers that will be added
65
+ # to the HTTP request.
66
+ #
67
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
68
+ #
69
+ def create_async(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
70
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
71
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
72
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
73
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
74
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
75
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
76
+
77
+ body = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.new
78
+ unless name.nil? && user_data.nil?
79
+ body.name = name
80
+ body.user_data = user_data
81
+ end
82
+
83
+ request_headers = {}
84
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
85
+
86
+ # Set Headers
87
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
88
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
89
+
90
+ # Serialize Request
91
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
92
+ request_content = @client.serialize(request_mapper, body)
93
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
94
+
95
+ path_template = 'largepersongroups/{largePersonGroupId}/persons'
96
+
97
+ request_url = @base_url || @client.base_url
98
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
99
+
100
+ options = {
101
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
102
+ path_params: {'largePersonGroupId' => large_person_group_id},
103
+ body: request_content,
104
+ headers: request_headers.merge(custom_headers || {}),
105
+ base_url: request_url
106
+ }
107
+ promise = @client.make_request_async(:post, path_template, options)
108
+
109
+ promise = promise.then do |result|
110
+ http_response = result.response
111
+ status_code = http_response.status
112
+ response_content = http_response.body
113
+ unless status_code == 200
114
+ error_model = JSON.load(response_content)
115
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
116
+ end
117
+
118
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
119
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
120
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
121
+ # Deserialize Response
122
+ if status_code == 200
123
+ begin
124
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
125
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
126
+ result.body = @client.deserialize(result_mapper, parsed_response)
127
+ rescue Exception => e
128
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
129
+ end
130
+ end
131
+
132
+ result
133
+ end
134
+
135
+ promise.execute
136
+ end
137
+
138
+ #
139
+ # List all persons in a large person group, and retrieve person information
140
+ # (including personId, name, userData and persistedFaceIds of registered faces
141
+ # of the person).
142
+ #
143
+ # @param large_person_group_id [String] Id referencing a particular large
144
+ # person group.
145
+ # @param start [String] Starting person id to return (used to list a range of
146
+ # persons).
147
+ # @param top [Integer] Number of persons to return starting with the person id
148
+ # indicated by the 'start' parameter.
149
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
150
+ # will be added to the HTTP request.
151
+ #
152
+ # @return [Array] operation results.
153
+ #
154
+ def list(large_person_group_id, start:nil, top:nil, custom_headers:nil)
155
+ response = list_async(large_person_group_id, start:start, top:top, custom_headers:custom_headers).value!
156
+ response.body unless response.nil?
157
+ end
158
+
159
+ #
160
+ # List all persons in a large person group, and retrieve person information
161
+ # (including personId, name, userData and persistedFaceIds of registered faces
162
+ # of the person).
163
+ #
164
+ # @param large_person_group_id [String] Id referencing a particular large
165
+ # person group.
166
+ # @param start [String] Starting person id to return (used to list a range of
167
+ # persons).
168
+ # @param top [Integer] Number of persons to return starting with the person id
169
+ # indicated by the 'start' parameter.
170
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
171
+ # will be added to the HTTP request.
172
+ #
173
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
174
+ #
175
+ def list_with_http_info(large_person_group_id, start:nil, top:nil, custom_headers:nil)
176
+ list_async(large_person_group_id, start:start, top:top, custom_headers:custom_headers).value!
177
+ end
178
+
179
+ #
180
+ # List all persons in a large person group, and retrieve person information
181
+ # (including personId, name, userData and persistedFaceIds of registered faces
182
+ # of the person).
183
+ #
184
+ # @param large_person_group_id [String] Id referencing a particular large
185
+ # person group.
186
+ # @param start [String] Starting person id to return (used to list a range of
187
+ # persons).
188
+ # @param top [Integer] Number of persons to return starting with the person id
189
+ # indicated by the 'start' parameter.
190
+ # @param [Hash{String => String}] A hash of custom headers that will be added
191
+ # to the HTTP request.
192
+ #
193
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
194
+ #
195
+ def list_async(large_person_group_id, start:nil, top:nil, custom_headers:nil)
196
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
197
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
198
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
199
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
200
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
201
+ fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1
202
+
203
+
204
+ request_headers = {}
205
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
206
+
207
+ # Set Headers
208
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
209
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
210
+ path_template = 'largepersongroups/{largePersonGroupId}/persons'
211
+
212
+ request_url = @base_url || @client.base_url
213
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
214
+
215
+ options = {
216
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
217
+ path_params: {'largePersonGroupId' => large_person_group_id},
218
+ query_params: {'start' => start,'top' => top},
219
+ headers: request_headers.merge(custom_headers || {}),
220
+ base_url: request_url
221
+ }
222
+ promise = @client.make_request_async(:get, path_template, options)
223
+
224
+ promise = promise.then do |result|
225
+ http_response = result.response
226
+ status_code = http_response.status
227
+ response_content = http_response.body
228
+ unless status_code == 200
229
+ error_model = JSON.load(response_content)
230
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
231
+ end
232
+
233
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
234
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
235
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
236
+ # Deserialize Response
237
+ if status_code == 200
238
+ begin
239
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
240
+ result_mapper = {
241
+ client_side_validation: true,
242
+ required: false,
243
+ serialized_name: 'parsed_response',
244
+ type: {
245
+ name: 'Sequence',
246
+ element: {
247
+ client_side_validation: true,
248
+ required: false,
249
+ serialized_name: 'PersonElementType',
250
+ type: {
251
+ name: 'Composite',
252
+ class_name: 'Person'
253
+ }
254
+ }
255
+ }
256
+ }
257
+ result.body = @client.deserialize(result_mapper, parsed_response)
258
+ rescue Exception => e
259
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
260
+ end
261
+ end
262
+
263
+ result
264
+ end
265
+
266
+ promise.execute
267
+ end
268
+
269
+ #
270
+ # Delete an existing person from a large person group. The persistedFaceId,
271
+ # userData, person name and face feature in the person entry will all be
272
+ # deleted.
273
+ #
274
+ # @param large_person_group_id [String] Id referencing a particular large
275
+ # person group.
276
+ # @param person_id Id referencing a particular person.
277
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
278
+ # will be added to the HTTP request.
279
+ #
280
+ #
281
+ def delete(large_person_group_id, person_id, custom_headers:nil)
282
+ response = delete_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
283
+ nil
284
+ end
285
+
286
+ #
287
+ # Delete an existing person from a large person group. The persistedFaceId,
288
+ # userData, person name and face feature in the person entry will all be
289
+ # deleted.
290
+ #
291
+ # @param large_person_group_id [String] Id referencing a particular large
292
+ # person group.
293
+ # @param person_id Id referencing a particular person.
294
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
295
+ # will be added to the HTTP request.
296
+ #
297
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
298
+ #
299
+ def delete_with_http_info(large_person_group_id, person_id, custom_headers:nil)
300
+ delete_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
301
+ end
302
+
303
+ #
304
+ # Delete an existing person from a large person group. The persistedFaceId,
305
+ # userData, person name and face feature in the person entry will all be
306
+ # deleted.
307
+ #
308
+ # @param large_person_group_id [String] Id referencing a particular large
309
+ # person group.
310
+ # @param person_id Id referencing a particular person.
311
+ # @param [Hash{String => String}] A hash of custom headers that will be added
312
+ # to the HTTP request.
313
+ #
314
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
315
+ #
316
+ def delete_async(large_person_group_id, person_id, custom_headers:nil)
317
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
318
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
319
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
320
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
321
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
322
+
323
+
324
+ request_headers = {}
325
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
326
+
327
+ # Set Headers
328
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
329
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
330
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'
331
+
332
+ request_url = @base_url || @client.base_url
333
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
334
+
335
+ options = {
336
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
337
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
338
+ headers: request_headers.merge(custom_headers || {}),
339
+ base_url: request_url
340
+ }
341
+ promise = @client.make_request_async(:delete, path_template, options)
342
+
343
+ promise = promise.then do |result|
344
+ http_response = result.response
345
+ status_code = http_response.status
346
+ response_content = http_response.body
347
+ unless status_code == 200
348
+ error_model = JSON.load(response_content)
349
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
350
+ end
351
+
352
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
353
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
354
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
355
+
356
+ result
357
+ end
358
+
359
+ promise.execute
360
+ end
361
+
362
+ #
363
+ # Retrieve a person's name and userData, and the persisted faceIds representing
364
+ # the registered person face feature.
365
+ #
366
+ # @param large_person_group_id [String] Id referencing a particular large
367
+ # person group.
368
+ # @param person_id Id referencing a particular person.
369
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
370
+ # will be added to the HTTP request.
371
+ #
372
+ # @return [Person] operation results.
373
+ #
374
+ def get(large_person_group_id, person_id, custom_headers:nil)
375
+ response = get_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
376
+ response.body unless response.nil?
377
+ end
378
+
379
+ #
380
+ # Retrieve a person's name and userData, and the persisted faceIds representing
381
+ # the registered person face feature.
382
+ #
383
+ # @param large_person_group_id [String] Id referencing a particular large
384
+ # person group.
385
+ # @param person_id Id referencing a particular person.
386
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
387
+ # will be added to the HTTP request.
388
+ #
389
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
390
+ #
391
+ def get_with_http_info(large_person_group_id, person_id, custom_headers:nil)
392
+ get_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
393
+ end
394
+
395
+ #
396
+ # Retrieve a person's name and userData, and the persisted faceIds representing
397
+ # the registered person face feature.
398
+ #
399
+ # @param large_person_group_id [String] Id referencing a particular large
400
+ # person group.
401
+ # @param person_id Id referencing a particular person.
402
+ # @param [Hash{String => String}] A hash of custom headers that will be added
403
+ # to the HTTP request.
404
+ #
405
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
406
+ #
407
+ def get_async(large_person_group_id, person_id, custom_headers:nil)
408
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
409
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
410
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
411
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
412
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
413
+
414
+
415
+ request_headers = {}
416
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
417
+
418
+ # Set Headers
419
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
420
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
421
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'
422
+
423
+ request_url = @base_url || @client.base_url
424
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
425
+
426
+ options = {
427
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
428
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
429
+ headers: request_headers.merge(custom_headers || {}),
430
+ base_url: request_url
431
+ }
432
+ promise = @client.make_request_async(:get, path_template, options)
433
+
434
+ promise = promise.then do |result|
435
+ http_response = result.response
436
+ status_code = http_response.status
437
+ response_content = http_response.body
438
+ unless status_code == 200
439
+ error_model = JSON.load(response_content)
440
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
441
+ end
442
+
443
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
444
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
445
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
446
+ # Deserialize Response
447
+ if status_code == 200
448
+ begin
449
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
450
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
451
+ result.body = @client.deserialize(result_mapper, parsed_response)
452
+ rescue Exception => e
453
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
454
+ end
455
+ end
456
+
457
+ result
458
+ end
459
+
460
+ promise.execute
461
+ end
462
+
463
+ #
464
+ # Update name or userData of a person.
465
+ #
466
+ # @param large_person_group_id [String] Id referencing a particular large
467
+ # person group.
468
+ # @param person_id Id referencing a particular person.
469
+ # @param name [String] User defined name, maximum length is 128.
470
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
471
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
472
+ # will be added to the HTTP request.
473
+ #
474
+ #
475
+ def update(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
476
+ response = update_async(large_person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
477
+ nil
478
+ end
479
+
480
+ #
481
+ # Update name or userData of a person.
482
+ #
483
+ # @param large_person_group_id [String] Id referencing a particular large
484
+ # person group.
485
+ # @param person_id Id referencing a particular person.
486
+ # @param name [String] User defined name, maximum length is 128.
487
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
488
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
489
+ # will be added to the HTTP request.
490
+ #
491
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
492
+ #
493
+ def update_with_http_info(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
494
+ update_async(large_person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
495
+ end
496
+
497
+ #
498
+ # Update name or userData of a person.
499
+ #
500
+ # @param large_person_group_id [String] Id referencing a particular large
501
+ # person group.
502
+ # @param person_id Id referencing a particular person.
503
+ # @param name [String] User defined name, maximum length is 128.
504
+ # @param user_data [String] User specified data. Length should not exceed 16KB.
505
+ # @param [Hash{String => String}] A hash of custom headers that will be added
506
+ # to the HTTP request.
507
+ #
508
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
509
+ #
510
+ def update_async(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
511
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
512
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
513
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
514
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
515
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
516
+ fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
517
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384
518
+
519
+ body = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.new
520
+ unless name.nil? && user_data.nil?
521
+ body.name = name
522
+ body.user_data = user_data
523
+ end
524
+
525
+ request_headers = {}
526
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
527
+
528
+ # Set Headers
529
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
530
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
531
+
532
+ # Serialize Request
533
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
534
+ request_content = @client.serialize(request_mapper, body)
535
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
536
+
537
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'
538
+
539
+ request_url = @base_url || @client.base_url
540
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
541
+
542
+ options = {
543
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
544
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
545
+ body: request_content,
546
+ headers: request_headers.merge(custom_headers || {}),
547
+ base_url: request_url
548
+ }
549
+ promise = @client.make_request_async(:patch, path_template, options)
550
+
551
+ promise = promise.then do |result|
552
+ http_response = result.response
553
+ status_code = http_response.status
554
+ response_content = http_response.body
555
+ unless status_code == 200
556
+ error_model = JSON.load(response_content)
557
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
558
+ end
559
+
560
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
561
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
562
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
563
+
564
+ result
565
+ end
566
+
567
+ promise.execute
568
+ end
569
+
570
+ #
571
+ # Delete a face from a person in a large person group by specified
572
+ # largePersonGroupId, personId and persistedFaceId.
573
+ # <br /> Adding/deleting faces to/from a same person will be processed
574
+ # sequentially. Adding/deleting faces to/from different persons are processed
575
+ # in parallel.
576
+ #
577
+ # @param large_person_group_id [String] Id referencing a particular large
578
+ # person group.
579
+ # @param person_id Id referencing a particular person.
580
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
581
+ # existing face.
582
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
583
+ # will be added to the HTTP request.
584
+ #
585
+ #
586
+ def delete_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
587
+ response = delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
588
+ nil
589
+ end
590
+
591
+ #
592
+ # Delete a face from a person in a large person group by specified
593
+ # largePersonGroupId, personId and persistedFaceId.
594
+ # <br /> Adding/deleting faces to/from a same person will be processed
595
+ # sequentially. Adding/deleting faces to/from different persons are processed
596
+ # in parallel.
597
+ #
598
+ # @param large_person_group_id [String] Id referencing a particular large
599
+ # person group.
600
+ # @param person_id Id referencing a particular person.
601
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
602
+ # existing face.
603
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
604
+ # will be added to the HTTP request.
605
+ #
606
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
607
+ #
608
+ def delete_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
609
+ delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
610
+ end
611
+
612
+ #
613
+ # Delete a face from a person in a large person group by specified
614
+ # largePersonGroupId, personId and persistedFaceId.
615
+ # <br /> Adding/deleting faces to/from a same person will be processed
616
+ # sequentially. Adding/deleting faces to/from different persons are processed
617
+ # in parallel.
618
+ #
619
+ # @param large_person_group_id [String] Id referencing a particular large
620
+ # person group.
621
+ # @param person_id Id referencing a particular person.
622
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
623
+ # existing face.
624
+ # @param [Hash{String => String}] A hash of custom headers that will be added
625
+ # to the HTTP request.
626
+ #
627
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
628
+ #
629
+ def delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
630
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
631
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
632
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
633
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
634
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
635
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
636
+
637
+
638
+ request_headers = {}
639
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
640
+
641
+ # Set Headers
642
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
643
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
644
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'
645
+
646
+ request_url = @base_url || @client.base_url
647
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
648
+
649
+ options = {
650
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
651
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
652
+ headers: request_headers.merge(custom_headers || {}),
653
+ base_url: request_url
654
+ }
655
+ promise = @client.make_request_async(:delete, path_template, options)
656
+
657
+ promise = promise.then do |result|
658
+ http_response = result.response
659
+ status_code = http_response.status
660
+ response_content = http_response.body
661
+ unless status_code == 200
662
+ error_model = JSON.load(response_content)
663
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
664
+ end
665
+
666
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
667
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
668
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
669
+
670
+ result
671
+ end
672
+
673
+ promise.execute
674
+ end
675
+
676
+ #
677
+ # Retrieve information about a persisted face (specified by persistedFaceId,
678
+ # personId and its belonging largePersonGroupId).
679
+ #
680
+ # @param large_person_group_id [String] Id referencing a particular large
681
+ # person group.
682
+ # @param person_id Id referencing a particular person.
683
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
684
+ # existing face.
685
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
686
+ # will be added to the HTTP request.
687
+ #
688
+ # @return [PersistedFace] operation results.
689
+ #
690
+ def get_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
691
+ response = get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
692
+ response.body unless response.nil?
693
+ end
694
+
695
+ #
696
+ # Retrieve information about a persisted face (specified by persistedFaceId,
697
+ # personId and its belonging largePersonGroupId).
698
+ #
699
+ # @param large_person_group_id [String] Id referencing a particular large
700
+ # person group.
701
+ # @param person_id Id referencing a particular person.
702
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
703
+ # existing face.
704
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
705
+ # will be added to the HTTP request.
706
+ #
707
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
708
+ #
709
+ def get_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
710
+ get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
711
+ end
712
+
713
+ #
714
+ # Retrieve information about a persisted face (specified by persistedFaceId,
715
+ # personId and its belonging largePersonGroupId).
716
+ #
717
+ # @param large_person_group_id [String] Id referencing a particular large
718
+ # person group.
719
+ # @param person_id Id referencing a particular person.
720
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
721
+ # existing face.
722
+ # @param [Hash{String => String}] A hash of custom headers that will be added
723
+ # to the HTTP request.
724
+ #
725
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
726
+ #
727
+ def get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
728
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
729
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
730
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
731
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
732
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
733
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
734
+
735
+
736
+ request_headers = {}
737
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
738
+
739
+ # Set Headers
740
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
741
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
742
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'
743
+
744
+ request_url = @base_url || @client.base_url
745
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
746
+
747
+ options = {
748
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
749
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
750
+ headers: request_headers.merge(custom_headers || {}),
751
+ base_url: request_url
752
+ }
753
+ promise = @client.make_request_async(:get, path_template, options)
754
+
755
+ promise = promise.then do |result|
756
+ http_response = result.response
757
+ status_code = http_response.status
758
+ response_content = http_response.body
759
+ unless status_code == 200
760
+ error_model = JSON.load(response_content)
761
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
762
+ end
763
+
764
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
765
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
766
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
767
+ # Deserialize Response
768
+ if status_code == 200
769
+ begin
770
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
771
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
772
+ result.body = @client.deserialize(result_mapper, parsed_response)
773
+ rescue Exception => e
774
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
775
+ end
776
+ end
777
+
778
+ result
779
+ end
780
+
781
+ promise.execute
782
+ end
783
+
784
+ #
785
+ # Update a person persisted face's userData field.
786
+ #
787
+ # @param large_person_group_id [String] Id referencing a particular large
788
+ # person group.
789
+ # @param person_id Id referencing a particular person.
790
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
791
+ # existing face.
792
+ # @param user_data [String] User-provided data attached to the face. The size
793
+ # limit is 1KB.
794
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
795
+ # will be added to the HTTP request.
796
+ #
797
+ #
798
+ def update_face(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
799
+ response = update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
800
+ nil
801
+ end
802
+
803
+ #
804
+ # Update a person persisted face's userData field.
805
+ #
806
+ # @param large_person_group_id [String] Id referencing a particular large
807
+ # person group.
808
+ # @param person_id Id referencing a particular person.
809
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
810
+ # existing face.
811
+ # @param user_data [String] User-provided data attached to the face. The size
812
+ # limit is 1KB.
813
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
814
+ # will be added to the HTTP request.
815
+ #
816
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
817
+ #
818
+ def update_face_with_http_info(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
819
+ update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
820
+ end
821
+
822
+ #
823
+ # Update a person persisted face's userData field.
824
+ #
825
+ # @param large_person_group_id [String] Id referencing a particular large
826
+ # person group.
827
+ # @param person_id Id referencing a particular person.
828
+ # @param persisted_face_id Id referencing a particular persistedFaceId of an
829
+ # existing face.
830
+ # @param user_data [String] User-provided data attached to the face. The size
831
+ # limit is 1KB.
832
+ # @param [Hash{String => String}] A hash of custom headers that will be added
833
+ # to the HTTP request.
834
+ #
835
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
836
+ #
837
+ def update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
838
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
839
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
840
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
841
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
842
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
843
+ fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
844
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
845
+
846
+ body = UpdateFaceRequest.new
847
+ unless user_data.nil?
848
+ body.user_data = user_data
849
+ end
850
+
851
+ request_headers = {}
852
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
853
+
854
+ # Set Headers
855
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
856
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
857
+
858
+ # Serialize Request
859
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::UpdateFaceRequest.mapper()
860
+ request_content = @client.serialize(request_mapper, body)
861
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
862
+
863
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'
864
+
865
+ request_url = @base_url || @client.base_url
866
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
867
+
868
+ options = {
869
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
870
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
871
+ body: request_content,
872
+ headers: request_headers.merge(custom_headers || {}),
873
+ base_url: request_url
874
+ }
875
+ promise = @client.make_request_async(:patch, path_template, options)
876
+
877
+ promise = promise.then do |result|
878
+ http_response = result.response
879
+ status_code = http_response.status
880
+ response_content = http_response.body
881
+ unless status_code == 200
882
+ error_model = JSON.load(response_content)
883
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
884
+ end
885
+
886
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
887
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
888
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
889
+
890
+ result
891
+ end
892
+
893
+ promise.execute
894
+ end
895
+
896
+ #
897
+ # Add a face to a person into a large person group for face identification or
898
+ # verification. To deal with an image contains multiple faces, input face can
899
+ # be specified as an image with a targetFace rectangle. It returns a
900
+ # persistedFaceId representing the added face. No image will be stored. Only
901
+ # the extracted face feature will be stored on server until [LargePersonGroup
902
+ # PersonFace -
903
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
904
+ # [LargePersonGroup Person -
905
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
906
+ # or [LargePersonGroup -
907
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
908
+ # is called.
909
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
910
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
911
+ # * Higher face image quality means better recognition precision. Please
912
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
913
+ # (100 pixels between eyes) or bigger.
914
+ # * Each person entry can hold up to 248 faces.
915
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
916
+ # image file size is from 1KB to 6MB.
917
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
918
+ # be regarded as an error. If the provided "targetFace" rectangle is not
919
+ # returned from [Face -
920
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
921
+ # there’s no guarantee to detect and add the face successfully.
922
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
923
+ # large occlusions will cause failures.
924
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
925
+ # Adding/deleting faces to/from different persons are processed in parallel.
926
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
927
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
928
+ # need a proportionally larger minimum face size.
929
+ # * Different 'detectionModel' values can be provided. To use and compare
930
+ # different detection models, please refer to [How to specify a detection
931
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
932
+ # | Model | Recommended use-case(s) |
933
+ # | ---------- | -------- |
934
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
935
+ # - Add
936
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
937
+ # Recommend for near frontal face detection. For scenarios with exceptionally
938
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
939
+ # faces in such cases may not be detected. |
940
+ # | 'detection_02': | Detection model released in 2019 May with improved
941
+ # accuracy especially on small, side and blurry faces. |
942
+ #
943
+ # @param large_person_group_id [String] Id referencing a particular large
944
+ # person group.
945
+ # @param person_id Id referencing a particular person.
946
+ # @param url [String] Publicly reachable URL of an image
947
+ # @param user_data [String] User-specified data about the face for any purpose.
948
+ # The maximum length is 1KB.
949
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
950
+ # face to be added to a person in the format of
951
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
952
+ # is more than one face in the image, targetFace is required to specify which
953
+ # face to add. No targetFace means there is only one face detected in the
954
+ # entire image.
955
+ # @param detection_model [DetectionModel] Name of detection model. Detection
956
+ # model is used to detect faces in the submitted image. A detection model name
957
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
958
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
959
+ # another model is needed, please explicitly specify it. Possible values
960
+ # include: 'detection_01', 'detection_02'
961
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
962
+ # will be added to the HTTP request.
963
+ #
964
+ # @return [PersistedFace] operation results.
965
+ #
966
+ def add_face_from_url(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
967
+ response = add_face_from_url_async(large_person_group_id, person_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
968
+ response.body unless response.nil?
969
+ end
970
+
971
+ #
972
+ # Add a face to a person into a large person group for face identification or
973
+ # verification. To deal with an image contains multiple faces, input face can
974
+ # be specified as an image with a targetFace rectangle. It returns a
975
+ # persistedFaceId representing the added face. No image will be stored. Only
976
+ # the extracted face feature will be stored on server until [LargePersonGroup
977
+ # PersonFace -
978
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
979
+ # [LargePersonGroup Person -
980
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
981
+ # or [LargePersonGroup -
982
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
983
+ # is called.
984
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
985
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
986
+ # * Higher face image quality means better recognition precision. Please
987
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
988
+ # (100 pixels between eyes) or bigger.
989
+ # * Each person entry can hold up to 248 faces.
990
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
991
+ # image file size is from 1KB to 6MB.
992
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
993
+ # be regarded as an error. If the provided "targetFace" rectangle is not
994
+ # returned from [Face -
995
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
996
+ # there’s no guarantee to detect and add the face successfully.
997
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
998
+ # large occlusions will cause failures.
999
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
1000
+ # Adding/deleting faces to/from different persons are processed in parallel.
1001
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1002
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1003
+ # need a proportionally larger minimum face size.
1004
+ # * Different 'detectionModel' values can be provided. To use and compare
1005
+ # different detection models, please refer to [How to specify a detection
1006
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1007
+ # | Model | Recommended use-case(s) |
1008
+ # | ---------- | -------- |
1009
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
1010
+ # - Add
1011
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
1012
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1013
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1014
+ # faces in such cases may not be detected. |
1015
+ # | 'detection_02': | Detection model released in 2019 May with improved
1016
+ # accuracy especially on small, side and blurry faces. |
1017
+ #
1018
+ # @param large_person_group_id [String] Id referencing a particular large
1019
+ # person group.
1020
+ # @param person_id Id referencing a particular person.
1021
+ # @param url [String] Publicly reachable URL of an image
1022
+ # @param user_data [String] User-specified data about the face for any purpose.
1023
+ # The maximum length is 1KB.
1024
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1025
+ # face to be added to a person in the format of
1026
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1027
+ # is more than one face in the image, targetFace is required to specify which
1028
+ # face to add. No targetFace means there is only one face detected in the
1029
+ # entire image.
1030
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1031
+ # model is used to detect faces in the submitted image. A detection model name
1032
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1033
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1034
+ # another model is needed, please explicitly specify it. Possible values
1035
+ # include: 'detection_01', 'detection_02'
1036
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1037
+ # will be added to the HTTP request.
1038
+ #
1039
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1040
+ #
1041
+ def add_face_from_url_with_http_info(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1042
+ add_face_from_url_async(large_person_group_id, person_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1043
+ end
1044
+
1045
+ #
1046
+ # Add a face to a person into a large person group for face identification or
1047
+ # verification. To deal with an image contains multiple faces, input face can
1048
+ # be specified as an image with a targetFace rectangle. It returns a
1049
+ # persistedFaceId representing the added face. No image will be stored. Only
1050
+ # the extracted face feature will be stored on server until [LargePersonGroup
1051
+ # PersonFace -
1052
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
1053
+ # [LargePersonGroup Person -
1054
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
1055
+ # or [LargePersonGroup -
1056
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
1057
+ # is called.
1058
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1059
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1060
+ # * Higher face image quality means better recognition precision. Please
1061
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1062
+ # (100 pixels between eyes) or bigger.
1063
+ # * Each person entry can hold up to 248 faces.
1064
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1065
+ # image file size is from 1KB to 6MB.
1066
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1067
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1068
+ # returned from [Face -
1069
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1070
+ # there’s no guarantee to detect and add the face successfully.
1071
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1072
+ # large occlusions will cause failures.
1073
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
1074
+ # Adding/deleting faces to/from different persons are processed in parallel.
1075
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1076
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1077
+ # need a proportionally larger minimum face size.
1078
+ # * Different 'detectionModel' values can be provided. To use and compare
1079
+ # different detection models, please refer to [How to specify a detection
1080
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1081
+ # | Model | Recommended use-case(s) |
1082
+ # | ---------- | -------- |
1083
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
1084
+ # - Add
1085
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
1086
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1087
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1088
+ # faces in such cases may not be detected. |
1089
+ # | 'detection_02': | Detection model released in 2019 May with improved
1090
+ # accuracy especially on small, side and blurry faces. |
1091
+ #
1092
+ # @param large_person_group_id [String] Id referencing a particular large
1093
+ # person group.
1094
+ # @param person_id Id referencing a particular person.
1095
+ # @param url [String] Publicly reachable URL of an image
1096
+ # @param user_data [String] User-specified data about the face for any purpose.
1097
+ # The maximum length is 1KB.
1098
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1099
+ # face to be added to a person in the format of
1100
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1101
+ # is more than one face in the image, targetFace is required to specify which
1102
+ # face to add. No targetFace means there is only one face detected in the
1103
+ # entire image.
1104
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1105
+ # model is used to detect faces in the submitted image. A detection model name
1106
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1107
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1108
+ # another model is needed, please explicitly specify it. Possible values
1109
+ # include: 'detection_01', 'detection_02'
1110
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1111
+ # to the HTTP request.
1112
+ #
1113
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1114
+ #
1115
+ def add_face_from_url_async(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1116
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1117
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
1118
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
1119
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
1120
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
1121
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1122
+ fail ArgumentError, 'url is nil' if url.nil?
1123
+
1124
+ image_url = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.new
1125
+ unless url.nil?
1126
+ image_url.url = url
1127
+ end
1128
+
1129
+ request_headers = {}
1130
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1131
+
1132
+ # Set Headers
1133
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1134
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1135
+
1136
+ # Serialize Request
1137
+ request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
1138
+ request_content = @client.serialize(request_mapper, image_url)
1139
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
1140
+
1141
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'
1142
+
1143
+ request_url = @base_url || @client.base_url
1144
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1145
+
1146
+ options = {
1147
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1148
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
1149
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
1150
+ body: request_content,
1151
+ headers: request_headers.merge(custom_headers || {}),
1152
+ base_url: request_url
1153
+ }
1154
+ promise = @client.make_request_async(:post, path_template, options)
1155
+
1156
+ promise = promise.then do |result|
1157
+ http_response = result.response
1158
+ status_code = http_response.status
1159
+ response_content = http_response.body
1160
+ unless status_code == 200
1161
+ error_model = JSON.load(response_content)
1162
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1163
+ end
1164
+
1165
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1166
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1167
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1168
+ # Deserialize Response
1169
+ if status_code == 200
1170
+ begin
1171
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1172
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1173
+ result.body = @client.deserialize(result_mapper, parsed_response)
1174
+ rescue Exception => e
1175
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1176
+ end
1177
+ end
1178
+
1179
+ result
1180
+ end
1181
+
1182
+ promise.execute
1183
+ end
1184
+
1185
+ #
1186
+ # Add a face to a person into a large person group for face identification or
1187
+ # verification. To deal with an image contains multiple faces, input face can
1188
+ # be specified as an image with a targetFace rectangle. It returns a
1189
+ # persistedFaceId representing the added face. No image will be stored. Only
1190
+ # the extracted face feature will be stored on server until [LargePersonGroup
1191
+ # PersonFace -
1192
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
1193
+ # [LargePersonGroup Person -
1194
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
1195
+ # or [LargePersonGroup -
1196
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
1197
+ # is called.
1198
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1199
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1200
+ # * Higher face image quality means better recognition precision. Please
1201
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1202
+ # (100 pixels between eyes) or bigger.
1203
+ # * Each person entry can hold up to 248 faces.
1204
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1205
+ # image file size is from 1KB to 6MB.
1206
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1207
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1208
+ # returned from [Face -
1209
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1210
+ # there’s no guarantee to detect and add the face successfully.
1211
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1212
+ # large occlusions will cause failures.
1213
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
1214
+ # Adding/deleting faces to/from different persons are processed in parallel.
1215
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1216
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1217
+ # need a proportionally larger minimum face size.
1218
+ # * Different 'detectionModel' values can be provided. To use and compare
1219
+ # different detection models, please refer to [How to specify a detection
1220
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1221
+ # | Model | Recommended use-case(s) |
1222
+ # | ---------- | -------- |
1223
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
1224
+ # - Add
1225
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
1226
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1227
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1228
+ # faces in such cases may not be detected. |
1229
+ # | 'detection_02': | Detection model released in 2019 May with improved
1230
+ # accuracy especially on small, side and blurry faces. |
1231
+ #
1232
+ # @param large_person_group_id [String] Id referencing a particular large
1233
+ # person group.
1234
+ # @param person_id Id referencing a particular person.
1235
+ # @param image An image stream.
1236
+ # @param user_data [String] User-specified data about the face for any purpose.
1237
+ # The maximum length is 1KB.
1238
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1239
+ # face to be added to a person in the format of
1240
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1241
+ # is more than one face in the image, targetFace is required to specify which
1242
+ # face to add. No targetFace means there is only one face detected in the
1243
+ # entire image.
1244
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1245
+ # model is used to detect faces in the submitted image. A detection model name
1246
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1247
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1248
+ # another model is needed, please explicitly specify it. Possible values
1249
+ # include: 'detection_01', 'detection_02'
1250
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1251
+ # will be added to the HTTP request.
1252
+ #
1253
+ # @return [PersistedFace] operation results.
1254
+ #
1255
+ def add_face_from_stream(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1256
+ response = add_face_from_stream_async(large_person_group_id, person_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1257
+ response.body unless response.nil?
1258
+ end
1259
+
1260
+ #
1261
+ # Add a face to a person into a large person group for face identification or
1262
+ # verification. To deal with an image contains multiple faces, input face can
1263
+ # be specified as an image with a targetFace rectangle. It returns a
1264
+ # persistedFaceId representing the added face. No image will be stored. Only
1265
+ # the extracted face feature will be stored on server until [LargePersonGroup
1266
+ # PersonFace -
1267
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
1268
+ # [LargePersonGroup Person -
1269
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
1270
+ # or [LargePersonGroup -
1271
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
1272
+ # is called.
1273
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1274
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1275
+ # * Higher face image quality means better recognition precision. Please
1276
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1277
+ # (100 pixels between eyes) or bigger.
1278
+ # * Each person entry can hold up to 248 faces.
1279
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1280
+ # image file size is from 1KB to 6MB.
1281
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1282
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1283
+ # returned from [Face -
1284
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1285
+ # there’s no guarantee to detect and add the face successfully.
1286
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1287
+ # large occlusions will cause failures.
1288
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
1289
+ # Adding/deleting faces to/from different persons are processed in parallel.
1290
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1291
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1292
+ # need a proportionally larger minimum face size.
1293
+ # * Different 'detectionModel' values can be provided. To use and compare
1294
+ # different detection models, please refer to [How to specify a detection
1295
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1296
+ # | Model | Recommended use-case(s) |
1297
+ # | ---------- | -------- |
1298
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
1299
+ # - Add
1300
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
1301
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1302
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1303
+ # faces in such cases may not be detected. |
1304
+ # | 'detection_02': | Detection model released in 2019 May with improved
1305
+ # accuracy especially on small, side and blurry faces. |
1306
+ #
1307
+ # @param large_person_group_id [String] Id referencing a particular large
1308
+ # person group.
1309
+ # @param person_id Id referencing a particular person.
1310
+ # @param image An image stream.
1311
+ # @param user_data [String] User-specified data about the face for any purpose.
1312
+ # The maximum length is 1KB.
1313
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1314
+ # face to be added to a person in the format of
1315
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1316
+ # is more than one face in the image, targetFace is required to specify which
1317
+ # face to add. No targetFace means there is only one face detected in the
1318
+ # entire image.
1319
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1320
+ # model is used to detect faces in the submitted image. A detection model name
1321
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1322
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1323
+ # another model is needed, please explicitly specify it. Possible values
1324
+ # include: 'detection_01', 'detection_02'
1325
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1326
+ # will be added to the HTTP request.
1327
+ #
1328
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1329
+ #
1330
+ def add_face_from_stream_with_http_info(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1331
+ add_face_from_stream_async(large_person_group_id, person_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
1332
+ end
1333
+
1334
+ #
1335
+ # Add a face to a person into a large person group for face identification or
1336
+ # verification. To deal with an image contains multiple faces, input face can
1337
+ # be specified as an image with a targetFace rectangle. It returns a
1338
+ # persistedFaceId representing the added face. No image will be stored. Only
1339
+ # the extracted face feature will be stored on server until [LargePersonGroup
1340
+ # PersonFace -
1341
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3),
1342
+ # [LargePersonGroup Person -
1343
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2)
1344
+ # or [LargePersonGroup -
1345
+ # Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f)
1346
+ # is called.
1347
+ # <br /> Note persistedFaceId is different from faceId generated by [Face -
1348
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).
1349
+ # * Higher face image quality means better recognition precision. Please
1350
+ # consider high-quality faces: frontal, clear, and face size is 200x200 pixels
1351
+ # (100 pixels between eyes) or bigger.
1352
+ # * Each person entry can hold up to 248 faces.
1353
+ # * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed
1354
+ # image file size is from 1KB to 6MB.
1355
+ # * "targetFace" rectangle should contain one face. Zero or multiple faces will
1356
+ # be regarded as an error. If the provided "targetFace" rectangle is not
1357
+ # returned from [Face -
1358
+ # Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236),
1359
+ # there’s no guarantee to detect and add the face successfully.
1360
+ # * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or
1361
+ # large occlusions will cause failures.
1362
+ # * Adding/deleting faces to/from a same person will be processed sequentially.
1363
+ # Adding/deleting faces to/from different persons are processed in parallel.
1364
+ # * The minimum detectable face size is 36x36 pixels in an image no larger than
1365
+ # 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will
1366
+ # need a proportionally larger minimum face size.
1367
+ # * Different 'detectionModel' values can be provided. To use and compare
1368
+ # different detection models, please refer to [How to specify a detection
1369
+ # model](https://docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model)
1370
+ # | Model | Recommended use-case(s) |
1371
+ # | ---------- | -------- |
1372
+ # | 'detection_01': | The default detection model for [LargePersonGroup Person
1373
+ # - Add
1374
+ # Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42).
1375
+ # Recommend for near frontal face detection. For scenarios with exceptionally
1376
+ # large angle (head-pose) faces, occluded faces or wrong image orientation, the
1377
+ # faces in such cases may not be detected. |
1378
+ # | 'detection_02': | Detection model released in 2019 May with improved
1379
+ # accuracy especially on small, side and blurry faces. |
1380
+ #
1381
+ # @param large_person_group_id [String] Id referencing a particular large
1382
+ # person group.
1383
+ # @param person_id Id referencing a particular person.
1384
+ # @param image An image stream.
1385
+ # @param user_data [String] User-specified data about the face for any purpose.
1386
+ # The maximum length is 1KB.
1387
+ # @param target_face [Array<Integer>] A face rectangle to specify the target
1388
+ # face to be added to a person in the format of
1389
+ # "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there
1390
+ # is more than one face in the image, targetFace is required to specify which
1391
+ # face to add. No targetFace means there is only one face detected in the
1392
+ # entire image.
1393
+ # @param detection_model [DetectionModel] Name of detection model. Detection
1394
+ # model is used to detect faces in the submitted image. A detection model name
1395
+ # can be provided when performing Face - Detect or (Large)FaceList - Add Face
1396
+ # or (Large)PersonGroup - Add Face. The default value is 'detection_01', if
1397
+ # another model is needed, please explicitly specify it. Possible values
1398
+ # include: 'detection_01', 'detection_02'
1399
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1400
+ # to the HTTP request.
1401
+ #
1402
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1403
+ #
1404
+ def add_face_from_stream_async(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
1405
+ fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
1406
+ fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
1407
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
1408
+ fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
1409
+ fail ArgumentError, 'person_id is nil' if person_id.nil?
1410
+ fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
1411
+ fail ArgumentError, 'image is nil' if image.nil?
1412
+
1413
+
1414
+ request_headers = {}
1415
+ request_headers['Content-Type'] = 'application/octet-stream'
1416
+
1417
+ # Set Headers
1418
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1419
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1420
+
1421
+ # Serialize Request
1422
+ request_mapper = {
1423
+ client_side_validation: true,
1424
+ required: true,
1425
+ serialized_name: 'Image',
1426
+ type: {
1427
+ name: 'Stream'
1428
+ }
1429
+ }
1430
+ request_content = @client.serialize(request_mapper, image)
1431
+
1432
+ path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'
1433
+
1434
+ request_url = @base_url || @client.base_url
1435
+ request_url = request_url.gsub('{Endpoint}', @client.endpoint)
1436
+
1437
+ options = {
1438
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1439
+ path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
1440
+ query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
1441
+ body: request_content,
1442
+ headers: request_headers.merge(custom_headers || {}),
1443
+ base_url: request_url
1444
+ }
1445
+ promise = @client.make_request_async(:post, path_template, options)
1446
+
1447
+ promise = promise.then do |result|
1448
+ http_response = result.response
1449
+ status_code = http_response.status
1450
+ response_content = http_response.body
1451
+ unless status_code == 200
1452
+ error_model = JSON.load(response_content)
1453
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1454
+ end
1455
+
1456
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1457
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
1458
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
1459
+ # Deserialize Response
1460
+ if status_code == 200
1461
+ begin
1462
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1463
+ result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
1464
+ result.body = @client.deserialize(result_mapper, parsed_response)
1465
+ rescue Exception => e
1466
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1467
+ end
1468
+ end
1469
+
1470
+ result
1471
+ end
1472
+
1473
+ promise.execute
1474
+ end
1475
+
1476
+ end
1477
+ end