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