diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java new file mode 100644 index 0000000000000..aae5e308b8dee --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.AzureClient; +import com.microsoft.rest.RestClient; + +/** + * The interface for FaceClient class. + */ +public interface FaceClient { + /** + * Gets the REST client. + * + * @return the {@link RestClient} object. + */ + RestClient restClient(); + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + AzureClient getAzureClient(); + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + String userAgent(); + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * + * @return the endpoint value. + */ + String endpoint(); + + /** + * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + FaceClient withEndpoint(String endpoint); + + /** + * Gets Gets or sets the preferred language for the response.. + * + * @return the acceptLanguage value. + */ + String acceptLanguage(); + + /** + * Sets Gets or sets the preferred language for the response.. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + FaceClient withAcceptLanguage(String acceptLanguage); + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @return the longRunningOperationRetryTimeout value. + */ + int longRunningOperationRetryTimeout(); + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + FaceClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @return the generateClientRequestId value. + */ + boolean generateClientRequestId(); + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + FaceClient withGenerateClientRequestId(boolean generateClientRequestId); + + /** + * Gets the Faces object to access its operations. + * @return the Faces object. + */ + Faces faces(); + + /** + * Gets the PersonGroupPersons object to access its operations. + * @return the PersonGroupPersons object. + */ + PersonGroupPersons personGroupPersons(); + + /** + * Gets the PersonGroups object to access its operations. + * @return the PersonGroups object. + */ + PersonGroups personGroups(); + + /** + * Gets the FaceLists object to access its operations. + * @return the FaceLists object. + */ + FaceLists faceLists(); + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java new file mode 100644 index 0000000000000..6acd1685d19b9 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java @@ -0,0 +1,533 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceList; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in FaceLists. + */ +public interface FaceLists { + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String faceListId); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String faceListId, final ServiceCallback serviceCallback); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String faceListId); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String faceListId); + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String faceListId, String name, String userData); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String faceListId, String name, String userData); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String faceListId, String name, String userData); + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the FaceList object if successful. + */ + FaceList get(String faceListId); + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String faceListId, final ServiceCallback serviceCallback); + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the FaceList object + */ + Observable getAsync(String faceListId); + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the FaceList object + */ + Observable> getWithServiceResponseAsync(String faceListId); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String faceListId); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String faceListId, final ServiceCallback serviceCallback); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String faceListId); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String faceListId); + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String faceListId, String name, String userData); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String faceListId, String name, String userData); + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String faceListId, String name, String userData); + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String faceListId); + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String faceListId, final ServiceCallback serviceCallback); + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String faceListId); + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String faceListId); + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<FaceList> object if successful. + */ + List list(); + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<FaceList> object + */ + Observable> listAsync(); + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<FaceList> object + */ + Observable>> listWithServiceResponseAsync(); + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void deleteFace(String faceListId, UUID persistedFaceId); + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteFaceAsync(String faceListId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteFaceAsync(String faceListId, UUID persistedFaceId); + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String faceListId, UUID persistedFaceId); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String faceListId, String url); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String faceListId, String url, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String faceListId, String url); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String faceListId, String url, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String faceListId, byte[] image); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String faceListId, byte[] image); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String faceListId, byte[] image, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image, String userData, List targetFace); + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java new file mode 100644 index 0000000000000..2e9ef5128c01c --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java @@ -0,0 +1,525 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceAttributeType; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FindSimilarMatchMode; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.GroupResult; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyResult; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SimilarFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.VerifyResult; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Faces. + */ +public interface Faces { + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + List findSimilar(UUID faceId); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> findSimilarAsync(UUID faceId, final ServiceCallback> serviceCallback); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable> findSimilarAsync(UUID faceId); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable>> findSimilarWithServiceResponseAsync(UUID faceId); + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + List findSimilar(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> findSimilarAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode, final ServiceCallback> serviceCallback); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable> findSimilarAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable>> findSimilarWithServiceResponseAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the GroupResult object if successful. + */ + GroupResult group(List faceIds); + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture groupAsync(List faceIds, final ServiceCallback serviceCallback); + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the GroupResult object + */ + Observable groupAsync(List faceIds); + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the GroupResult object + */ + Observable> groupWithServiceResponseAsync(List faceIds); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + List identify(String personGroupId, List faceIds); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> identifyAsync(String personGroupId, List faceIds, final ServiceCallback> serviceCallback); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable> identifyAsync(String personGroupId, List faceIds); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds); + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + List identify(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> identifyAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold, final ServiceCallback> serviceCallback); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable> identifyAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VerifyResult object if successful. + */ + VerifyResult verifyFaceToFace(UUID faceId1, UUID faceId2); + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture verifyFaceToFaceAsync(UUID faceId1, UUID faceId2, final ServiceCallback serviceCallback); + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable verifyFaceToFaceAsync(UUID faceId1, UUID faceId2); + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable> verifyFaceToFaceWithServiceResponseAsync(UUID faceId1, UUID faceId2); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithUrl(String url); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithUrlAsync(String url, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithUrlAsync(String url); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithUrlWithServiceResponseAsync(String url); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithUrl(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithUrlWithServiceResponseAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VerifyResult object if successful. + */ + VerifyResult verifyFaceToPerson(UUID faceId, String personGroupId, UUID personId); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, String personGroupId, UUID personId); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithStream(byte[] image); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithStreamAsync(byte[] image, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithStreamAsync(byte[] image); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithStreamWithServiceResponseAsync(byte[] image); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithStream(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithStreamWithServiceResponseAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java new file mode 100644 index 0000000000000..df1480ab2a015 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java @@ -0,0 +1,763 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in PersonGroupPersons. + */ +public interface PersonGroupPersons { + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person create(String personGroupId); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable createAsync(String personGroupId); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> createWithServiceResponseAsync(String personGroupId); + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person create(String personGroupId, String name, String userData); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable createAsync(String personGroupId, String name, String userData); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String personGroupId); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String personGroupId, final ServiceCallback> serviceCallback); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable> listAsync(String personGroupId); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String personGroupId); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String personGroupId, String start, Integer top); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String personGroupId, String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable> listAsync(String personGroupId, String start, Integer top); + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String personGroupId, String start, Integer top); + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String personGroupId, UUID personId); + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String personGroupId, UUID personId); + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String personGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person get(String personGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable getAsync(String personGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> getWithServiceResponseAsync(String personGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId); + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId, UUID personId, String name, String userData); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId, UUID personId, String name, String userData); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId, String name, String userData); + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void deleteFace(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace getFace(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> getFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java new file mode 100644 index 0000000000000..ce6c8c622147f --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java @@ -0,0 +1,423 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersonGroup; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in PersonGroups. + */ +public interface PersonGroups { + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String personGroupId); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String personGroupId); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String personGroupId); + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String personGroupId, String name, String userData); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String personGroupId, String name, String userData); + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData); + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String personGroupId); + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String personGroupId); + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String personGroupId); + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersonGroup object if successful. + */ + PersonGroup get(String personGroupId); + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersonGroup object + */ + Observable getAsync(String personGroupId); + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersonGroup object + */ + Observable> getWithServiceResponseAsync(String personGroupId); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId); + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId, String name, String userData); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId, String name, String userData); + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, String name, String userData); + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + TrainingStatus getTrainingStatus(String personGroupId); + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getTrainingStatusAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable getTrainingStatusAsync(String personGroupId); + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable> getTrainingStatusWithServiceResponseAsync(String personGroupId); + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + List list(); + + /** + * List person groups and their information. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + Observable> listAsync(); + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + Observable>> listWithServiceResponseAsync(); + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + List list(String start, Integer top); + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + Observable> listAsync(String start, Integer top); + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + Observable>> listWithServiceResponseAsync(String start, Integer top); + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void train(String personGroupId); + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture trainAsync(String personGroupId, final ServiceCallback serviceCallback); + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable trainAsync(String personGroupId); + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> trainWithServiceResponseAsync(String personGroupId); + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java new file mode 100644 index 0000000000000..bb753dde56497 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java @@ -0,0 +1,230 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceClient; +import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists; +import com.microsoft.azure.cognitiveservices.vision.faceapi.Faces; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the FaceClientImpl class. + */ +public class FaceClientImpl extends AzureServiceClient implements FaceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). */ + private String endpoint; + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * + * @return the endpoint value. + */ + public String endpoint() { + return this.endpoint; + } + + /** + * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + public FaceClientImpl withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public FaceClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public FaceClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public FaceClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The Faces object to access its operations. + */ + private Faces faces; + + /** + * Gets the Faces object to access its operations. + * @return the Faces object. + */ + public Faces faces() { + return this.faces; + } + + /** + * The PersonGroupPersons object to access its operations. + */ + private PersonGroupPersons personGroupPersons; + + /** + * Gets the PersonGroupPersons object to access its operations. + * @return the PersonGroupPersons object. + */ + public PersonGroupPersons personGroupPersons() { + return this.personGroupPersons; + } + + /** + * The PersonGroups object to access its operations. + */ + private PersonGroups personGroups; + + /** + * Gets the PersonGroups object to access its operations. + * @return the PersonGroups object. + */ + public PersonGroups personGroups() { + return this.personGroups; + } + + /** + * The FaceLists object to access its operations. + */ + private FaceLists faceLists; + + /** + * Gets the FaceLists object to access its operations. + * @return the FaceLists object. + */ + public FaceLists faceLists() { + return this.faceLists; + } + + /** + * Initializes an instance of FaceClient client. + * + * @param credentials the management credentials for Azure + */ + public FaceClientImpl(ServiceClientCredentials credentials) { + this("https://{Endpoint}/face/v1.0", credentials); + } + + /** + * Initializes an instance of FaceClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + private FaceClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of FaceClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public FaceClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.faces = new FacesImpl(restClient().retrofit(), this); + this.personGroupPersons = new PersonGroupPersonsImpl(restClient().retrofit(), this); + this.personGroups = new PersonGroupsImpl(restClient().retrofit(), this); + this.faceLists = new FaceListsImpl(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "FaceClient", "1.0"); + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java new file mode 100644 index 0000000000000..75b62d84a5545 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java @@ -0,0 +1,1086 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceList; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ImageUrl; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in FaceLists. + */ +public class FaceListsImpl implements FaceLists { + /** The Retrofit service to perform REST calls. */ + private FaceListsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of FaceListsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public FaceListsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(FaceListsService.class); + this.client = client; + } + + /** + * The interface defining all the services for FaceLists to be + * used by Retrofit to perform actually REST calls. + */ + interface FaceListsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists create" }) + @PUT("facelists/{faceListId}") + Observable> create(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists get" }) + @GET("facelists/{faceListId}") + Observable> get(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists update" }) + @PATCH("facelists/{faceListId}") + Observable> update(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists delete" }) + @HTTP(path = "facelists/{faceListId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists list" }) + @GET("facelists") + Observable> list(@Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists deleteFace" }) + @HTTP(path = "facelists/{faceListId}/persistedFaces/{persistedFaceId}", method = "DELETE", hasBody = true) + Observable> deleteFace(@Path("faceListId") String faceListId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists addFaceFromUrl" }) + @POST("facelists/{faceListId}/persistedFaces") + Observable> addFaceFromUrl(@Path("faceListId") String faceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists addFaceFromStream" }) + @POST("facelists/{faceListId}/persistedFaces") + Observable> addFaceFromStream(@Path("faceListId") String faceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String faceListId) { + createWithServiceResponseAsync(faceListId).toBlocking().single().body(); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(faceListId), serviceCallback); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String faceListId) { + return createWithServiceResponseAsync(faceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String faceListId, String name, String userData) { + createWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(faceListId, name, userData), serviceCallback); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String faceListId, String name, String userData) { + return createWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String faceListId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the FaceList object if successful. + */ + public FaceList get(String faceListId) { + return getWithServiceResponseAsync(faceListId).toBlocking().single().body(); + } + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(faceListId), serviceCallback); + } + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the FaceList object + */ + public Observable getAsync(String faceListId) { + return getWithServiceResponseAsync(faceListId).map(new Func1, FaceList>() { + @Override + public FaceList call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the FaceList object + */ + public Observable> getWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(faceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String faceListId) { + updateWithServiceResponseAsync(faceListId).toBlocking().single().body(); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(faceListId), serviceCallback); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String faceListId) { + return updateWithServiceResponseAsync(faceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String faceListId, String name, String userData) { + updateWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(faceListId, name, userData), serviceCallback); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String faceListId, String name, String userData) { + return updateWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String faceListId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String faceListId) { + deleteWithServiceResponseAsync(faceListId).toBlocking().single().body(); + } + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(faceListId), serviceCallback); + } + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String faceListId) { + return deleteWithServiceResponseAsync(faceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(faceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<FaceList> object if successful. + */ + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<FaceList> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<FaceList> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteFace(String faceListId, UUID persistedFaceId) { + deleteFaceWithServiceResponseAsync(faceListId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteFaceAsync(String faceListId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteFaceWithServiceResponseAsync(faceListId, persistedFaceId), serviceCallback); + } + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteFaceAsync(String faceListId, UUID persistedFaceId) { + return deleteFaceWithServiceResponseAsync(faceListId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteFaceWithServiceResponseAsync(String faceListId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.deleteFace(faceListId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String faceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String faceListId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(faceListId, url), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String faceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(faceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String faceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + Validator.validate(targetFace); + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(faceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String faceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(faceListId, image), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String faceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(faceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String faceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceListId == null) { + throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + Validator.validate(targetFace); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(faceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java new file mode 100644 index 0000000000000..5450e1d4b0a6f --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java @@ -0,0 +1,1065 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.Faces; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceAttributeType; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FindSimilarMatchMode; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FindSimilarRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.GroupRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.GroupResult; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyResult; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ImageUrl; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SimilarFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.VerifyFaceToFaceRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.VerifyFaceToPersonRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.VerifyResult; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Faces. + */ +public class FacesImpl implements Faces { + /** The Retrofit service to perform REST calls. */ + private FacesService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of FacesImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public FacesImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(FacesService.class); + this.client = client; + } + + /** + * The interface defining all the services for Faces to be + * used by Retrofit to perform actually REST calls. + */ + interface FacesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces findSimilar" }) + @POST("findsimilars") + Observable> findSimilar(@Header("accept-language") String acceptLanguage, @Body FindSimilarRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces group" }) + @POST("group") + Observable> group(@Header("accept-language") String acceptLanguage, @Body GroupRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces identify" }) + @POST("identify") + Observable> identify(@Header("accept-language") String acceptLanguage, @Body IdentifyRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces verifyFaceToFace" }) + @POST("verify") + Observable> verifyFaceToFace(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces detectWithUrl" }) + @POST("detect") + Observable> detectWithUrl(@Query("returnFaceId") Boolean returnFaceId, @Query("returnFaceLandmarks") Boolean returnFaceLandmarks, @Query("returnFaceAttributes") String returnFaceAttributes, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces verifyFaceToPerson" }) + @POST("verify") + Observable> verifyFaceToPerson(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToPersonRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces detectWithStream" }) + @POST("detect") + Observable> detectWithStream(@Query("returnFaceId") Boolean returnFaceId, @Query("returnFaceLandmarks") Boolean returnFaceLandmarks, @Query("returnFaceAttributes") String returnFaceAttributes, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + public List findSimilar(UUID faceId) { + return findSimilarWithServiceResponseAsync(faceId).toBlocking().single().body(); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> findSimilarAsync(UUID faceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(findSimilarWithServiceResponseAsync(faceId), serviceCallback); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + public Observable> findSimilarAsync(UUID faceId) { + return findSimilarWithServiceResponseAsync(faceId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + public Observable>> findSimilarWithServiceResponseAsync(UUID faceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceId == null) { + throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); + } + final String faceListId = null; + final List faceIds = null; + final Integer maxNumOfCandidatesReturned = null; + final FindSimilarMatchMode mode = null; + FindSimilarRequest body = new FindSimilarRequest(); + body.withFaceId(faceId); + body.withFaceListId(null); + body.withFaceIds(null); + body.withMaxNumOfCandidatesReturned(null); + body.withMode(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.findSimilar(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = findSimilarDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + public List findSimilar(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + return findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode).toBlocking().single().body(); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> findSimilarAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode), serviceCallback); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + public Observable> findSimilarAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + return findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + public Observable>> findSimilarWithServiceResponseAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceId == null) { + throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); + } + Validator.validate(faceIds); + FindSimilarRequest body = new FindSimilarRequest(); + body.withFaceId(faceId); + body.withFaceListId(faceListId); + body.withFaceIds(faceIds); + body.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); + body.withMode(mode); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.findSimilar(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = findSimilarDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> findSimilarDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the GroupResult object if successful. + */ + public GroupResult group(List faceIds) { + return groupWithServiceResponseAsync(faceIds).toBlocking().single().body(); + } + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture groupAsync(List faceIds, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(groupWithServiceResponseAsync(faceIds), serviceCallback); + } + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the GroupResult object + */ + public Observable groupAsync(List faceIds) { + return groupWithServiceResponseAsync(faceIds).map(new Func1, GroupResult>() { + @Override + public GroupResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the GroupResult object + */ + public Observable> groupWithServiceResponseAsync(List faceIds) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceIds == null) { + throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); + } + Validator.validate(faceIds); + GroupRequest body = new GroupRequest(); + body.withFaceIds(faceIds); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.group(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = groupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse groupDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + public List identify(String personGroupId, List faceIds) { + return identifyWithServiceResponseAsync(personGroupId, faceIds).toBlocking().single().body(); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> identifyAsync(String personGroupId, List faceIds, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(identifyWithServiceResponseAsync(personGroupId, faceIds), serviceCallback); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + public Observable> identifyAsync(String personGroupId, List faceIds) { + return identifyWithServiceResponseAsync(personGroupId, faceIds).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + public Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (faceIds == null) { + throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); + } + Validator.validate(faceIds); + final Integer maxNumOfCandidatesReturned = null; + final Double confidenceThreshold = null; + IdentifyRequest body = new IdentifyRequest(); + body.withPersonGroupId(personGroupId); + body.withFaceIds(faceIds); + body.withMaxNumOfCandidatesReturned(null); + body.withConfidenceThreshold(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.identify(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = identifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + public List identify(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + return identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold).toBlocking().single().body(); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> identifyAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold), serviceCallback); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + public Observable> identifyAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + return identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Identify unknown faces from a person group. + * + * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + public Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (faceIds == null) { + throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); + } + Validator.validate(faceIds); + IdentifyRequest body = new IdentifyRequest(); + body.withPersonGroupId(personGroupId); + body.withFaceIds(faceIds); + body.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); + body.withConfidenceThreshold(confidenceThreshold); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.identify(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = identifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> identifyDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VerifyResult object if successful. + */ + public VerifyResult verifyFaceToFace(UUID faceId1, UUID faceId2) { + return verifyFaceToFaceWithServiceResponseAsync(faceId1, faceId2).toBlocking().single().body(); + } + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture verifyFaceToFaceAsync(UUID faceId1, UUID faceId2, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(verifyFaceToFaceWithServiceResponseAsync(faceId1, faceId2), serviceCallback); + } + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable verifyFaceToFaceAsync(UUID faceId1, UUID faceId2) { + return verifyFaceToFaceWithServiceResponseAsync(faceId1, faceId2).map(new Func1, VerifyResult>() { + @Override + public VerifyResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable> verifyFaceToFaceWithServiceResponseAsync(UUID faceId1, UUID faceId2) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceId1 == null) { + throw new IllegalArgumentException("Parameter faceId1 is required and cannot be null."); + } + if (faceId2 == null) { + throw new IllegalArgumentException("Parameter faceId2 is required and cannot be null."); + } + VerifyFaceToFaceRequest body = new VerifyFaceToFaceRequest(); + body.withFaceId1(faceId1); + body.withFaceId2(faceId2); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.verifyFaceToFace(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyFaceToFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse verifyFaceToFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithUrl(String url) { + return detectWithUrlWithServiceResponseAsync(url).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithUrlAsync(String url, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithUrlWithServiceResponseAsync(url), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithUrlAsync(String url) { + return detectWithUrlWithServiceResponseAsync(url).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable>> detectWithUrlWithServiceResponseAsync(String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final Boolean returnFaceId = null; + final Boolean returnFaceLandmarks = null; + final List returnFaceAttributes = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV); + return service.detectWithUrl(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithUrl(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable>> detectWithUrlWithServiceResponseAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + Validator.validate(returnFaceAttributes); + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV); + return service.detectWithUrl(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> detectWithUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VerifyResult object if successful. + */ + public VerifyResult verifyFaceToPerson(UUID faceId, String personGroupId, UUID personId) { + return verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId).toBlocking().single().body(); + } + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId), serviceCallback); + } + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId) { + return verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId).map(new Func1, VerifyResult>() { + @Override + public VerifyResult call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId the face, comes from Face - Detect + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, String personGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (faceId == null) { + throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + VerifyFaceToPersonRequest body = new VerifyFaceToPersonRequest(); + body.withFaceId(faceId); + body.withPersonGroupId(personGroupId); + body.withPersonId(personId); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.verifyFaceToPerson(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyFaceToPersonDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse verifyFaceToPersonDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithStream(byte[] image) { + return detectWithStreamWithServiceResponseAsync(image).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithStreamAsync(byte[] image, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithStreamWithServiceResponseAsync(image), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithStreamAsync(byte[] image) { + return detectWithStreamWithServiceResponseAsync(image).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable>> detectWithStreamWithServiceResponseAsync(byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + final Boolean returnFaceId = null; + final Boolean returnFaceLandmarks = null; + final List returnFaceAttributes = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.detectWithStream(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithStream(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable>> detectWithStreamWithServiceResponseAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + Validator.validate(returnFaceAttributes); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.detectWithStream(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> detectWithStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java new file mode 100644 index 0000000000000..120ee2a44160a --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java @@ -0,0 +1,1519 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ImageUrl; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonFaceRequest; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in PersonGroupPersons. + */ +public class PersonGroupPersonsImpl implements PersonGroupPersons { + /** The Retrofit service to perform REST calls. */ + private PersonGroupPersonsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of PersonGroupPersonsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PersonGroupPersonsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(PersonGroupPersonsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PersonGroupPersons to be + * used by Retrofit to perform actually REST calls. + */ + interface PersonGroupPersonsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons create" }) + @POST("persongroups/{personGroupId}/persons") + Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons list" }) + @GET("persongroups/{personGroupId}/persons") + Observable> list(@Path("personGroupId") String personGroupId, @Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons delete" }) + @HTTP(path = "persongroups/{personGroupId}/persons/{personId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons get" }) + @GET("persongroups/{personGroupId}/persons/{personId}") + Observable> get(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons update" }) + @PATCH("persongroups/{personGroupId}/persons/{personId}") + Observable> update(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons deleteFace" }) + @HTTP(path = "persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", method = "DELETE", hasBody = true) + Observable> deleteFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons getFace" }) + @GET("persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}") + Observable> getFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons updateFace" }) + @PATCH("persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}") + Observable> updateFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Body UpdatePersonFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addPersonFaceFromUrl" }) + @POST("persongroups/{personGroupId}/persons/{personId}/persistedFaces") + Observable> addPersonFaceFromUrl(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addPersonFaceFromStream" }) + @POST("persongroups/{personGroupId}/persons/{personId}/persistedFaces") + Observable> addPersonFaceFromStream(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person create(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable createAsync(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> createWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person create(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable createAsync(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + public List list(String personGroupId) { + return listWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String personGroupId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable> listAsync(String personGroupId) { + return listWithServiceResponseAsync(personGroupId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable>> listWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(personGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + public List list(String personGroupId, String start, Integer top) { + return listWithServiceResponseAsync(personGroupId, start, top).toBlocking().single().body(); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String personGroupId, String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(personGroupId, start, top), serviceCallback); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable> listAsync(String personGroupId, String start, Integer top) { + return listWithServiceResponseAsync(personGroupId, start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable>> listWithServiceResponseAsync(String personGroupId, String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(personGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String personGroupId, UUID personId) { + deleteWithServiceResponseAsync(personGroupId, personId).toBlocking().single().body(); + } + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(personGroupId, personId), serviceCallback); + } + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String personGroupId, UUID personId) { + return deleteWithServiceResponseAsync(personGroupId, personId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String personGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(personGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person get(String personGroupId, UUID personId) { + return getWithServiceResponseAsync(personGroupId, personId).toBlocking().single().body(); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(personGroupId, personId), serviceCallback); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable getAsync(String personGroupId, UUID personId) { + return getWithServiceResponseAsync(personGroupId, personId).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> getWithServiceResponseAsync(String personGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(personGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId, UUID personId) { + updateWithServiceResponseAsync(personGroupId, personId).toBlocking().single().body(); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, personId), serviceCallback); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId, UUID personId) { + return updateWithServiceResponseAsync(personGroupId, personId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId, UUID personId, String name, String userData) { + updateWithServiceResponseAsync(personGroupId, personId, name, userData).toBlocking().single().body(); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, personId, name, userData), serviceCallback); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId, UUID personId, String name, String userData) { + return updateWithServiceResponseAsync(personGroupId, personId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteFace(String personGroupId, UUID personId, UUID persistedFaceId) { + deleteFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + return deleteFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete a face from a person. Relative image for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.deleteFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace getFace(String personGroupId, UUID personId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> getFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId) { + updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + final String userData = null; + UpdatePersonFaceRequest body = new UpdatePersonFaceRequest(); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { + updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).toBlocking().single().body(); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData), serviceCallback); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { + return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + UpdatePersonFaceRequest body = new UpdatePersonFaceRequest(); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url) { + return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url) { + return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addPersonFaceFromUrl(personGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addPersonFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url, String userData, List targetFace) { + return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace) { + return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + Validator.validate(targetFace); + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addPersonFaceFromUrl(personGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addPersonFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addPersonFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image) { + return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image) { + return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addPersonFaceFromStream(personGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addPersonFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + Validator.validate(targetFace); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addPersonFaceFromStream(personGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addPersonFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addPersonFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java new file mode 100644 index 0000000000000..4b7f316d8e12c --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java @@ -0,0 +1,866 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersonGroup; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in PersonGroups. + */ +public class PersonGroupsImpl implements PersonGroups { + /** The Retrofit service to perform REST calls. */ + private PersonGroupsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of PersonGroupsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public PersonGroupsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(PersonGroupsService.class); + this.client = client; + } + + /** + * The interface defining all the services for PersonGroups to be + * used by Retrofit to perform actually REST calls. + */ + interface PersonGroupsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups create" }) + @PUT("persongroups/{personGroupId}") + Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups delete" }) + @HTTP(path = "persongroups/{personGroupId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups get" }) + @GET("persongroups/{personGroupId}") + Observable> get(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups update" }) + @PATCH("persongroups/{personGroupId}") + Observable> update(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups getTrainingStatus" }) + @GET("persongroups/{personGroupId}/training") + Observable> getTrainingStatus(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups list" }) + @GET("persongroups") + Observable> list(@Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups train" }) + @POST("persongroups/{personGroupId}/train") + Observable> train(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String personGroupId) { + createWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String personGroupId, String name, String userData) { + createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String personGroupId) { + deleteWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String personGroupId) { + return deleteWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersonGroup object if successful. + */ + public PersonGroup get(String personGroupId) { + return getWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersonGroup object + */ + public Observable getAsync(String personGroupId) { + return getWithServiceResponseAsync(personGroupId).map(new Func1, PersonGroup>() { + @Override + public PersonGroup call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersonGroup object + */ + public Observable> getWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId) { + updateWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId) { + return updateWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId, String name, String userData) { + updateWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId, String name, String userData) { + return updateWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String personGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + public TrainingStatus getTrainingStatus(String personGroupId) { + return getTrainingStatusWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getTrainingStatusAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getTrainingStatusWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable getTrainingStatusAsync(String personGroupId) { + return getTrainingStatusWithServiceResponseAsync(personGroupId).map(new Func1, TrainingStatus>() { + @Override + public TrainingStatus call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable> getTrainingStatusWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getTrainingStatus(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getTrainingStatusDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getTrainingStatusDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * List person groups and their information. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + public List list(String start, Integer top) { + return listWithServiceResponseAsync(start, top).toBlocking().single().body(); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(start, top), serviceCallback); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + public Observable> listAsync(String start, Integer top) { + return listWithServiceResponseAsync(start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + public Observable>> listWithServiceResponseAsync(String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void train(String personGroupId) { + trainWithServiceResponseAsync(personGroupId).toBlocking().single().body(); + } + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture trainAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(trainWithServiceResponseAsync(personGroupId), serviceCallback); + } + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable trainAsync(String personGroupId) { + return trainWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> trainWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (personGroupId == null) { + throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.train(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = trainDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse trainDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java new file mode 100644 index 0000000000000..34c335c4ef0d8 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for FaceClient. + * An API for face detection, verification, and identification. + */ +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIError.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIError.java new file mode 100644 index 0000000000000..259c49c2574aa --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIError.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error information returned by the API. + */ +public class APIError { + /** + * The error property. + */ + @JsonProperty(value = "error") + private Error error; + + /** + * Get the error value. + * + * @return the error value + */ + public Error error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the APIError object itself. + */ + public APIError withError(Error error) { + this.error = error; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIErrorException.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIErrorException.java new file mode 100644 index 0000000000000..cfa2078f1f92b --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/APIErrorException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with APIError information. + */ +public class APIErrorException extends RestException { + /** + * Initializes a new instance of the APIErrorException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public APIErrorException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the APIErrorException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public APIErrorException(final String message, final Response response, final APIError body) { + super(message, response, body); + } + + @Override + public APIError body() { + return (APIError) super.body(); + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java new file mode 100644 index 0000000000000..f09314a9ce903 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Accessory item and corresponding confidence level. + */ +public class Accessory { + /** + * Type of an accessory. Possible values include: 'headWear', 'glasses', + * 'mask'. + */ + @JsonProperty(value = "type") + private AccessoryType type; + + /** + * Confidence level of an accessory. + */ + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Get type of an accessory. Possible values include: 'headWear', 'glasses', 'mask'. + * + * @return the type value + */ + public AccessoryType type() { + return this.type; + } + + /** + * Set type of an accessory. Possible values include: 'headWear', 'glasses', 'mask'. + * + * @param type the type value to set + * @return the Accessory object itself. + */ + public Accessory withType(AccessoryType type) { + this.type = type; + return this; + } + + /** + * Get confidence level of an accessory. + * + * @return the confidence value + */ + public double confidence() { + return this.confidence; + } + + /** + * Set confidence level of an accessory. + * + * @param confidence the confidence value to set + * @return the Accessory object itself. + */ + public Accessory withConfidence(double confidence) { + this.confidence = confidence; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/AccessoryType.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/AccessoryType.java new file mode 100644 index 0000000000000..d0615c9c76c2d --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/AccessoryType.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for AccessoryType. + */ +public enum AccessoryType { + /** Enum value headWear. */ + HEAD_WEAR("headWear"), + + /** Enum value glasses. */ + GLASSES("glasses"), + + /** Enum value mask. */ + MASK("mask"); + + /** The actual serialized value for a AccessoryType instance. */ + private String value; + + AccessoryType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a AccessoryType instance. + * + * @param value the serialized value to parse. + * @return the parsed AccessoryType object, or null if unable to parse. + */ + @JsonCreator + public static AccessoryType fromString(String value) { + AccessoryType[] items = AccessoryType.values(); + for (AccessoryType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java new file mode 100644 index 0000000000000..24fa48618f9b4 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing any presence of blur within the image. + */ +public class Blur { + /** + * An enum value indicating level of blurriness. Possible values include: + * 'Low', 'Medium', 'High'. + */ + @JsonProperty(value = "blurLevel") + private BlurLevel blurLevel; + + /** + * A number indicating level of blurriness ranging from 0 to 1. + */ + @JsonProperty(value = "value") + private double value; + + /** + * Get an enum value indicating level of blurriness. Possible values include: 'Low', 'Medium', 'High'. + * + * @return the blurLevel value + */ + public BlurLevel blurLevel() { + return this.blurLevel; + } + + /** + * Set an enum value indicating level of blurriness. Possible values include: 'Low', 'Medium', 'High'. + * + * @param blurLevel the blurLevel value to set + * @return the Blur object itself. + */ + public Blur withBlurLevel(BlurLevel blurLevel) { + this.blurLevel = blurLevel; + return this; + } + + /** + * Get a number indicating level of blurriness ranging from 0 to 1. + * + * @return the value value + */ + public double value() { + return this.value; + } + + /** + * Set a number indicating level of blurriness ranging from 0 to 1. + * + * @param value the value value to set + * @return the Blur object itself. + */ + public Blur withValue(double value) { + this.value = value; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/BlurLevel.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/BlurLevel.java new file mode 100644 index 0000000000000..3d9cf25750bc9 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/BlurLevel.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for BlurLevel. + */ +public enum BlurLevel { + /** Enum value Low. */ + LOW("Low"), + + /** Enum value Medium. */ + MEDIUM("Medium"), + + /** Enum value High. */ + HIGH("High"); + + /** The actual serialized value for a BlurLevel instance. */ + private String value; + + BlurLevel(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a BlurLevel instance. + * + * @param value the serialized value to parse. + * @return the parsed BlurLevel object, or null if unable to parse. + */ + @JsonCreator + public static BlurLevel fromString(String value) { + BlurLevel[] items = BlurLevel.values(); + for (BlurLevel item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java new file mode 100644 index 0000000000000..9615465ef3126 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Coordinates within an image. + */ +public class Coordinate { + /** + * The horizontal component, in pixels. + */ + @JsonProperty(value = "x", required = true) + private double x; + + /** + * The vertical component, in pixels. + */ + @JsonProperty(value = "y", required = true) + private double y; + + /** + * Get the horizontal component, in pixels. + * + * @return the x value + */ + public double x() { + return this.x; + } + + /** + * Set the horizontal component, in pixels. + * + * @param x the x value to set + * @return the Coordinate object itself. + */ + public Coordinate withX(double x) { + this.x = x; + return this; + } + + /** + * Get the vertical component, in pixels. + * + * @return the y value + */ + public double y() { + return this.y; + } + + /** + * Set the vertical component, in pixels. + * + * @param y the y value to set + * @return the Coordinate object itself. + */ + public Coordinate withY(double y) { + this.y = y; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/DetectedFace.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/DetectedFace.java new file mode 100644 index 0000000000000..ef7ca60b13303 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/DetectedFace.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Detected Face object. + */ +public class DetectedFace { + /** + * The faceId property. + */ + @JsonProperty(value = "faceId") + private UUID faceId; + + /** + * The faceRectangle property. + */ + @JsonProperty(value = "faceRectangle", required = true) + private FaceRectangle faceRectangle; + + /** + * The faceLandmarks property. + */ + @JsonProperty(value = "faceLandmarks") + private FaceLandmarks faceLandmarks; + + /** + * The faceAttributes property. + */ + @JsonProperty(value = "faceAttributes") + private FaceAttributes faceAttributes; + + /** + * Get the faceId value. + * + * @return the faceId value + */ + public UUID faceId() { + return this.faceId; + } + + /** + * Set the faceId value. + * + * @param faceId the faceId value to set + * @return the DetectedFace object itself. + */ + public DetectedFace withFaceId(UUID faceId) { + this.faceId = faceId; + return this; + } + + /** + * Get the faceRectangle value. + * + * @return the faceRectangle value + */ + public FaceRectangle faceRectangle() { + return this.faceRectangle; + } + + /** + * Set the faceRectangle value. + * + * @param faceRectangle the faceRectangle value to set + * @return the DetectedFace object itself. + */ + public DetectedFace withFaceRectangle(FaceRectangle faceRectangle) { + this.faceRectangle = faceRectangle; + return this; + } + + /** + * Get the faceLandmarks value. + * + * @return the faceLandmarks value + */ + public FaceLandmarks faceLandmarks() { + return this.faceLandmarks; + } + + /** + * Set the faceLandmarks value. + * + * @param faceLandmarks the faceLandmarks value to set + * @return the DetectedFace object itself. + */ + public DetectedFace withFaceLandmarks(FaceLandmarks faceLandmarks) { + this.faceLandmarks = faceLandmarks; + return this; + } + + /** + * Get the faceAttributes value. + * + * @return the faceAttributes value + */ + public FaceAttributes faceAttributes() { + return this.faceAttributes; + } + + /** + * Set the faceAttributes value. + * + * @param faceAttributes the faceAttributes value to set + * @return the DetectedFace object itself. + */ + public DetectedFace withFaceAttributes(FaceAttributes faceAttributes) { + this.faceAttributes = faceAttributes; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Emotion.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Emotion.java new file mode 100644 index 0000000000000..64f799e1d233d --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Emotion.java @@ -0,0 +1,226 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing facial emotion in form of confidence ranging from 0 to + * 1. + */ +public class Emotion { + /** + * The anger property. + */ + @JsonProperty(value = "anger") + private double anger; + + /** + * The contempt property. + */ + @JsonProperty(value = "contempt") + private double contempt; + + /** + * The disgust property. + */ + @JsonProperty(value = "disgust") + private double disgust; + + /** + * The fear property. + */ + @JsonProperty(value = "fear") + private double fear; + + /** + * The happiness property. + */ + @JsonProperty(value = "happiness") + private double happiness; + + /** + * The neutral property. + */ + @JsonProperty(value = "neutral") + private double neutral; + + /** + * The sadness property. + */ + @JsonProperty(value = "sadness") + private double sadness; + + /** + * The surprise property. + */ + @JsonProperty(value = "surprise") + private double surprise; + + /** + * Get the anger value. + * + * @return the anger value + */ + public double anger() { + return this.anger; + } + + /** + * Set the anger value. + * + * @param anger the anger value to set + * @return the Emotion object itself. + */ + public Emotion withAnger(double anger) { + this.anger = anger; + return this; + } + + /** + * Get the contempt value. + * + * @return the contempt value + */ + public double contempt() { + return this.contempt; + } + + /** + * Set the contempt value. + * + * @param contempt the contempt value to set + * @return the Emotion object itself. + */ + public Emotion withContempt(double contempt) { + this.contempt = contempt; + return this; + } + + /** + * Get the disgust value. + * + * @return the disgust value + */ + public double disgust() { + return this.disgust; + } + + /** + * Set the disgust value. + * + * @param disgust the disgust value to set + * @return the Emotion object itself. + */ + public Emotion withDisgust(double disgust) { + this.disgust = disgust; + return this; + } + + /** + * Get the fear value. + * + * @return the fear value + */ + public double fear() { + return this.fear; + } + + /** + * Set the fear value. + * + * @param fear the fear value to set + * @return the Emotion object itself. + */ + public Emotion withFear(double fear) { + this.fear = fear; + return this; + } + + /** + * Get the happiness value. + * + * @return the happiness value + */ + public double happiness() { + return this.happiness; + } + + /** + * Set the happiness value. + * + * @param happiness the happiness value to set + * @return the Emotion object itself. + */ + public Emotion withHappiness(double happiness) { + this.happiness = happiness; + return this; + } + + /** + * Get the neutral value. + * + * @return the neutral value + */ + public double neutral() { + return this.neutral; + } + + /** + * Set the neutral value. + * + * @param neutral the neutral value to set + * @return the Emotion object itself. + */ + public Emotion withNeutral(double neutral) { + this.neutral = neutral; + return this; + } + + /** + * Get the sadness value. + * + * @return the sadness value + */ + public double sadness() { + return this.sadness; + } + + /** + * Set the sadness value. + * + * @param sadness the sadness value to set + * @return the Emotion object itself. + */ + public Emotion withSadness(double sadness) { + this.sadness = sadness; + return this; + } + + /** + * Get the surprise value. + * + * @return the surprise value + */ + public double surprise() { + return this.surprise; + } + + /** + * Set the surprise value. + * + * @param surprise the surprise value to set + * @return the Emotion object itself. + */ + public Emotion withSurprise(double surprise) { + this.surprise = surprise; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Error.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Error.java new file mode 100644 index 0000000000000..e7bf607f22102 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Error.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error body. + */ +public class Error { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the Error object itself. + */ + public Error withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the Error object itself. + */ + public Error withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java new file mode 100644 index 0000000000000..822f1888ace82 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing exposure level of the image. + */ +public class Exposure { + /** + * An enum value indicating level of exposure. Possible values include: + * 'UnderExposure', 'GoodExposure', 'OverExposure'. + */ + @JsonProperty(value = "exposureLevel") + private ExposureLevel exposureLevel; + + /** + * A number indicating level of exposure level ranging from 0 to 1. [0, + * 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is + * over exposure. + */ + @JsonProperty(value = "value") + private double value; + + /** + * Get an enum value indicating level of exposure. Possible values include: 'UnderExposure', 'GoodExposure', 'OverExposure'. + * + * @return the exposureLevel value + */ + public ExposureLevel exposureLevel() { + return this.exposureLevel; + } + + /** + * Set an enum value indicating level of exposure. Possible values include: 'UnderExposure', 'GoodExposure', 'OverExposure'. + * + * @param exposureLevel the exposureLevel value to set + * @return the Exposure object itself. + */ + public Exposure withExposureLevel(ExposureLevel exposureLevel) { + this.exposureLevel = exposureLevel; + return this; + } + + /** + * Get a number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. + * + * @return the value value + */ + public double value() { + return this.value; + } + + /** + * Set a number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. + * + * @param value the value value to set + * @return the Exposure object itself. + */ + public Exposure withValue(double value) { + this.value = value; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ExposureLevel.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ExposureLevel.java new file mode 100644 index 0000000000000..3171083b09641 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ExposureLevel.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ExposureLevel. + */ +public enum ExposureLevel { + /** Enum value UnderExposure. */ + UNDER_EXPOSURE("UnderExposure"), + + /** Enum value GoodExposure. */ + GOOD_EXPOSURE("GoodExposure"), + + /** Enum value OverExposure. */ + OVER_EXPOSURE("OverExposure"); + + /** The actual serialized value for a ExposureLevel instance. */ + private String value; + + ExposureLevel(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ExposureLevel instance. + * + * @param value the serialized value to parse. + * @return the parsed ExposureLevel object, or null if unable to parse. + */ + @JsonCreator + public static ExposureLevel fromString(String value) { + ExposureLevel[] items = ExposureLevel.values(); + for (ExposureLevel item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributeType.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributeType.java new file mode 100644 index 0000000000000..75ad5c2bcd6b6 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributeType.java @@ -0,0 +1,89 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for FaceAttributeType. + */ +public enum FaceAttributeType { + /** Enum value age. */ + AGE("age"), + + /** Enum value gender. */ + GENDER("gender"), + + /** Enum value headPose. */ + HEAD_POSE("headPose"), + + /** Enum value smile. */ + SMILE("smile"), + + /** Enum value facialHair. */ + FACIAL_HAIR("facialHair"), + + /** Enum value glasses. */ + GLASSES("glasses"), + + /** Enum value emotion. */ + EMOTION("emotion"), + + /** Enum value hair. */ + HAIR("hair"), + + /** Enum value makeup. */ + MAKEUP("makeup"), + + /** Enum value occlusion. */ + OCCLUSION("occlusion"), + + /** Enum value accessories. */ + ACCESSORIES("accessories"), + + /** Enum value blur. */ + BLUR("blur"), + + /** Enum value exposure. */ + EXPOSURE("exposure"), + + /** Enum value noise. */ + NOISE("noise"); + + /** The actual serialized value for a FaceAttributeType instance. */ + private String value; + + FaceAttributeType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a FaceAttributeType instance. + * + * @param value the serialized value to parse. + * @return the parsed FaceAttributeType object, or null if unable to parse. + */ + @JsonCreator + public static FaceAttributeType fromString(String value) { + FaceAttributeType[] items = FaceAttributeType.values(); + for (FaceAttributeType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java new file mode 100644 index 0000000000000..dee079c669257 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java @@ -0,0 +1,385 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Face Attributes. + */ +public class FaceAttributes { + /** + * Age in years. + */ + @JsonProperty(value = "age") + private Double age; + + /** + * Possible gender of the face. Possible values include: 'male', 'female', + * 'genderless'. + */ + @JsonProperty(value = "gender") + private Gender gender; + + /** + * Smile intensity, a number between [0,1]. + */ + @JsonProperty(value = "smile") + private Double smile; + + /** + * Properties describing facial hair attributes. + */ + @JsonProperty(value = "facialHair") + private FacialHair facialHair; + + /** + * Glasses type if any of the face. Possible values include: 'noGlasses', + * 'readingGlasses', 'sunglasses', 'swimmingGoggles'. + */ + @JsonProperty(value = "glasses") + private GlassesType glasses; + + /** + * Properties indicating head pose of the face. + */ + @JsonProperty(value = "headPose") + private HeadPose headPose; + + /** + * Properties describing facial emotion in form of confidence ranging from + * 0 to 1. + */ + @JsonProperty(value = "emotion") + private Emotion emotion; + + /** + * Properties describing hair attributes. + */ + @JsonProperty(value = "hair") + private Hair hair; + + /** + * Properties describing present makeups on a given face. + */ + @JsonProperty(value = "makeup") + private Makeup makeup; + + /** + * Properties describing occlusions on a given face. + */ + @JsonProperty(value = "occlusion") + private Occlusion occlusion; + + /** + * Properties describing any accessories on a given face. + */ + @JsonProperty(value = "accessories") + private List accessories; + + /** + * Properties describing any presence of blur within the image. + */ + @JsonProperty(value = "blur") + private Blur blur; + + /** + * Properties describing exposure level of the image. + */ + @JsonProperty(value = "exposure") + private Exposure exposure; + + /** + * Properties describing noise level of the image. + */ + @JsonProperty(value = "noise") + private Noise noise; + + /** + * Get age in years. + * + * @return the age value + */ + public Double age() { + return this.age; + } + + /** + * Set age in years. + * + * @param age the age value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withAge(Double age) { + this.age = age; + return this; + } + + /** + * Get possible gender of the face. Possible values include: 'male', 'female', 'genderless'. + * + * @return the gender value + */ + public Gender gender() { + return this.gender; + } + + /** + * Set possible gender of the face. Possible values include: 'male', 'female', 'genderless'. + * + * @param gender the gender value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withGender(Gender gender) { + this.gender = gender; + return this; + } + + /** + * Get smile intensity, a number between [0,1]. + * + * @return the smile value + */ + public Double smile() { + return this.smile; + } + + /** + * Set smile intensity, a number between [0,1]. + * + * @param smile the smile value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withSmile(Double smile) { + this.smile = smile; + return this; + } + + /** + * Get properties describing facial hair attributes. + * + * @return the facialHair value + */ + public FacialHair facialHair() { + return this.facialHair; + } + + /** + * Set properties describing facial hair attributes. + * + * @param facialHair the facialHair value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withFacialHair(FacialHair facialHair) { + this.facialHair = facialHair; + return this; + } + + /** + * Get glasses type if any of the face. Possible values include: 'noGlasses', 'readingGlasses', 'sunglasses', 'swimmingGoggles'. + * + * @return the glasses value + */ + public GlassesType glasses() { + return this.glasses; + } + + /** + * Set glasses type if any of the face. Possible values include: 'noGlasses', 'readingGlasses', 'sunglasses', 'swimmingGoggles'. + * + * @param glasses the glasses value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withGlasses(GlassesType glasses) { + this.glasses = glasses; + return this; + } + + /** + * Get properties indicating head pose of the face. + * + * @return the headPose value + */ + public HeadPose headPose() { + return this.headPose; + } + + /** + * Set properties indicating head pose of the face. + * + * @param headPose the headPose value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withHeadPose(HeadPose headPose) { + this.headPose = headPose; + return this; + } + + /** + * Get properties describing facial emotion in form of confidence ranging from 0 to 1. + * + * @return the emotion value + */ + public Emotion emotion() { + return this.emotion; + } + + /** + * Set properties describing facial emotion in form of confidence ranging from 0 to 1. + * + * @param emotion the emotion value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withEmotion(Emotion emotion) { + this.emotion = emotion; + return this; + } + + /** + * Get properties describing hair attributes. + * + * @return the hair value + */ + public Hair hair() { + return this.hair; + } + + /** + * Set properties describing hair attributes. + * + * @param hair the hair value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withHair(Hair hair) { + this.hair = hair; + return this; + } + + /** + * Get properties describing present makeups on a given face. + * + * @return the makeup value + */ + public Makeup makeup() { + return this.makeup; + } + + /** + * Set properties describing present makeups on a given face. + * + * @param makeup the makeup value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withMakeup(Makeup makeup) { + this.makeup = makeup; + return this; + } + + /** + * Get properties describing occlusions on a given face. + * + * @return the occlusion value + */ + public Occlusion occlusion() { + return this.occlusion; + } + + /** + * Set properties describing occlusions on a given face. + * + * @param occlusion the occlusion value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withOcclusion(Occlusion occlusion) { + this.occlusion = occlusion; + return this; + } + + /** + * Get properties describing any accessories on a given face. + * + * @return the accessories value + */ + public List accessories() { + return this.accessories; + } + + /** + * Set properties describing any accessories on a given face. + * + * @param accessories the accessories value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withAccessories(List accessories) { + this.accessories = accessories; + return this; + } + + /** + * Get properties describing any presence of blur within the image. + * + * @return the blur value + */ + public Blur blur() { + return this.blur; + } + + /** + * Set properties describing any presence of blur within the image. + * + * @param blur the blur value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withBlur(Blur blur) { + this.blur = blur; + return this; + } + + /** + * Get properties describing exposure level of the image. + * + * @return the exposure value + */ + public Exposure exposure() { + return this.exposure; + } + + /** + * Set properties describing exposure level of the image. + * + * @param exposure the exposure value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withExposure(Exposure exposure) { + this.exposure = exposure; + return this; + } + + /** + * Get properties describing noise level of the image. + * + * @return the noise value + */ + public Noise noise() { + return this.noise; + } + + /** + * Set properties describing noise level of the image. + * + * @param noise the noise value to set + * @return the FaceAttributes object itself. + */ + public FaceAttributes withNoise(Noise noise) { + this.noise = noise; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceLandmarks.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceLandmarks.java new file mode 100644 index 0000000000000..45fcde0dcbe8d --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceLandmarks.java @@ -0,0 +1,720 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A collection of 27-point face landmarks pointing to the important positions + * of face components. + */ +public class FaceLandmarks { + /** + * The pupilLeft property. + */ + @JsonProperty(value = "pupilLeft") + private Coordinate pupilLeft; + + /** + * The pupilRight property. + */ + @JsonProperty(value = "pupilRight") + private Coordinate pupilRight; + + /** + * The noseTip property. + */ + @JsonProperty(value = "noseTip") + private Coordinate noseTip; + + /** + * The mouthLeft property. + */ + @JsonProperty(value = "mouthLeft") + private Coordinate mouthLeft; + + /** + * The mouthRight property. + */ + @JsonProperty(value = "mouthRight") + private Coordinate mouthRight; + + /** + * The eyebrowLeftOuter property. + */ + @JsonProperty(value = "eyebrowLeftOuter") + private Coordinate eyebrowLeftOuter; + + /** + * The eyebrowLeftInner property. + */ + @JsonProperty(value = "eyebrowLeftInner") + private Coordinate eyebrowLeftInner; + + /** + * The eyeLeftOuter property. + */ + @JsonProperty(value = "eyeLeftOuter") + private Coordinate eyeLeftOuter; + + /** + * The eyeLeftTop property. + */ + @JsonProperty(value = "eyeLeftTop") + private Coordinate eyeLeftTop; + + /** + * The eyeLeftBottom property. + */ + @JsonProperty(value = "eyeLeftBottom") + private Coordinate eyeLeftBottom; + + /** + * The eyeLeftInner property. + */ + @JsonProperty(value = "eyeLeftInner") + private Coordinate eyeLeftInner; + + /** + * The eyebrowRightInner property. + */ + @JsonProperty(value = "eyebrowRightInner") + private Coordinate eyebrowRightInner; + + /** + * The eyebrowRightOuter property. + */ + @JsonProperty(value = "eyebrowRightOuter") + private Coordinate eyebrowRightOuter; + + /** + * The eyeRightInner property. + */ + @JsonProperty(value = "eyeRightInner") + private Coordinate eyeRightInner; + + /** + * The eyeRightTop property. + */ + @JsonProperty(value = "eyeRightTop") + private Coordinate eyeRightTop; + + /** + * The eyeRightBottom property. + */ + @JsonProperty(value = "eyeRightBottom") + private Coordinate eyeRightBottom; + + /** + * The eyeRightOuter property. + */ + @JsonProperty(value = "eyeRightOuter") + private Coordinate eyeRightOuter; + + /** + * The noseRootLeft property. + */ + @JsonProperty(value = "noseRootLeft") + private Coordinate noseRootLeft; + + /** + * The noseRootRight property. + */ + @JsonProperty(value = "noseRootRight") + private Coordinate noseRootRight; + + /** + * The noseLeftAlarTop property. + */ + @JsonProperty(value = "noseLeftAlarTop") + private Coordinate noseLeftAlarTop; + + /** + * The noseRightAlarTop property. + */ + @JsonProperty(value = "noseRightAlarTop") + private Coordinate noseRightAlarTop; + + /** + * The noseLeftAlarOutTip property. + */ + @JsonProperty(value = "noseLeftAlarOutTip") + private Coordinate noseLeftAlarOutTip; + + /** + * The noseRightAlarOutTip property. + */ + @JsonProperty(value = "noseRightAlarOutTip") + private Coordinate noseRightAlarOutTip; + + /** + * The upperLipTop property. + */ + @JsonProperty(value = "upperLipTop") + private Coordinate upperLipTop; + + /** + * The upperLipBottom property. + */ + @JsonProperty(value = "upperLipBottom") + private Coordinate upperLipBottom; + + /** + * The underLipTop property. + */ + @JsonProperty(value = "underLipTop") + private Coordinate underLipTop; + + /** + * The underLipBottom property. + */ + @JsonProperty(value = "underLipBottom") + private Coordinate underLipBottom; + + /** + * Get the pupilLeft value. + * + * @return the pupilLeft value + */ + public Coordinate pupilLeft() { + return this.pupilLeft; + } + + /** + * Set the pupilLeft value. + * + * @param pupilLeft the pupilLeft value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withPupilLeft(Coordinate pupilLeft) { + this.pupilLeft = pupilLeft; + return this; + } + + /** + * Get the pupilRight value. + * + * @return the pupilRight value + */ + public Coordinate pupilRight() { + return this.pupilRight; + } + + /** + * Set the pupilRight value. + * + * @param pupilRight the pupilRight value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withPupilRight(Coordinate pupilRight) { + this.pupilRight = pupilRight; + return this; + } + + /** + * Get the noseTip value. + * + * @return the noseTip value + */ + public Coordinate noseTip() { + return this.noseTip; + } + + /** + * Set the noseTip value. + * + * @param noseTip the noseTip value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseTip(Coordinate noseTip) { + this.noseTip = noseTip; + return this; + } + + /** + * Get the mouthLeft value. + * + * @return the mouthLeft value + */ + public Coordinate mouthLeft() { + return this.mouthLeft; + } + + /** + * Set the mouthLeft value. + * + * @param mouthLeft the mouthLeft value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withMouthLeft(Coordinate mouthLeft) { + this.mouthLeft = mouthLeft; + return this; + } + + /** + * Get the mouthRight value. + * + * @return the mouthRight value + */ + public Coordinate mouthRight() { + return this.mouthRight; + } + + /** + * Set the mouthRight value. + * + * @param mouthRight the mouthRight value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withMouthRight(Coordinate mouthRight) { + this.mouthRight = mouthRight; + return this; + } + + /** + * Get the eyebrowLeftOuter value. + * + * @return the eyebrowLeftOuter value + */ + public Coordinate eyebrowLeftOuter() { + return this.eyebrowLeftOuter; + } + + /** + * Set the eyebrowLeftOuter value. + * + * @param eyebrowLeftOuter the eyebrowLeftOuter value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyebrowLeftOuter(Coordinate eyebrowLeftOuter) { + this.eyebrowLeftOuter = eyebrowLeftOuter; + return this; + } + + /** + * Get the eyebrowLeftInner value. + * + * @return the eyebrowLeftInner value + */ + public Coordinate eyebrowLeftInner() { + return this.eyebrowLeftInner; + } + + /** + * Set the eyebrowLeftInner value. + * + * @param eyebrowLeftInner the eyebrowLeftInner value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyebrowLeftInner(Coordinate eyebrowLeftInner) { + this.eyebrowLeftInner = eyebrowLeftInner; + return this; + } + + /** + * Get the eyeLeftOuter value. + * + * @return the eyeLeftOuter value + */ + public Coordinate eyeLeftOuter() { + return this.eyeLeftOuter; + } + + /** + * Set the eyeLeftOuter value. + * + * @param eyeLeftOuter the eyeLeftOuter value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeLeftOuter(Coordinate eyeLeftOuter) { + this.eyeLeftOuter = eyeLeftOuter; + return this; + } + + /** + * Get the eyeLeftTop value. + * + * @return the eyeLeftTop value + */ + public Coordinate eyeLeftTop() { + return this.eyeLeftTop; + } + + /** + * Set the eyeLeftTop value. + * + * @param eyeLeftTop the eyeLeftTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeLeftTop(Coordinate eyeLeftTop) { + this.eyeLeftTop = eyeLeftTop; + return this; + } + + /** + * Get the eyeLeftBottom value. + * + * @return the eyeLeftBottom value + */ + public Coordinate eyeLeftBottom() { + return this.eyeLeftBottom; + } + + /** + * Set the eyeLeftBottom value. + * + * @param eyeLeftBottom the eyeLeftBottom value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeLeftBottom(Coordinate eyeLeftBottom) { + this.eyeLeftBottom = eyeLeftBottom; + return this; + } + + /** + * Get the eyeLeftInner value. + * + * @return the eyeLeftInner value + */ + public Coordinate eyeLeftInner() { + return this.eyeLeftInner; + } + + /** + * Set the eyeLeftInner value. + * + * @param eyeLeftInner the eyeLeftInner value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeLeftInner(Coordinate eyeLeftInner) { + this.eyeLeftInner = eyeLeftInner; + return this; + } + + /** + * Get the eyebrowRightInner value. + * + * @return the eyebrowRightInner value + */ + public Coordinate eyebrowRightInner() { + return this.eyebrowRightInner; + } + + /** + * Set the eyebrowRightInner value. + * + * @param eyebrowRightInner the eyebrowRightInner value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyebrowRightInner(Coordinate eyebrowRightInner) { + this.eyebrowRightInner = eyebrowRightInner; + return this; + } + + /** + * Get the eyebrowRightOuter value. + * + * @return the eyebrowRightOuter value + */ + public Coordinate eyebrowRightOuter() { + return this.eyebrowRightOuter; + } + + /** + * Set the eyebrowRightOuter value. + * + * @param eyebrowRightOuter the eyebrowRightOuter value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyebrowRightOuter(Coordinate eyebrowRightOuter) { + this.eyebrowRightOuter = eyebrowRightOuter; + return this; + } + + /** + * Get the eyeRightInner value. + * + * @return the eyeRightInner value + */ + public Coordinate eyeRightInner() { + return this.eyeRightInner; + } + + /** + * Set the eyeRightInner value. + * + * @param eyeRightInner the eyeRightInner value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeRightInner(Coordinate eyeRightInner) { + this.eyeRightInner = eyeRightInner; + return this; + } + + /** + * Get the eyeRightTop value. + * + * @return the eyeRightTop value + */ + public Coordinate eyeRightTop() { + return this.eyeRightTop; + } + + /** + * Set the eyeRightTop value. + * + * @param eyeRightTop the eyeRightTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeRightTop(Coordinate eyeRightTop) { + this.eyeRightTop = eyeRightTop; + return this; + } + + /** + * Get the eyeRightBottom value. + * + * @return the eyeRightBottom value + */ + public Coordinate eyeRightBottom() { + return this.eyeRightBottom; + } + + /** + * Set the eyeRightBottom value. + * + * @param eyeRightBottom the eyeRightBottom value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeRightBottom(Coordinate eyeRightBottom) { + this.eyeRightBottom = eyeRightBottom; + return this; + } + + /** + * Get the eyeRightOuter value. + * + * @return the eyeRightOuter value + */ + public Coordinate eyeRightOuter() { + return this.eyeRightOuter; + } + + /** + * Set the eyeRightOuter value. + * + * @param eyeRightOuter the eyeRightOuter value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withEyeRightOuter(Coordinate eyeRightOuter) { + this.eyeRightOuter = eyeRightOuter; + return this; + } + + /** + * Get the noseRootLeft value. + * + * @return the noseRootLeft value + */ + public Coordinate noseRootLeft() { + return this.noseRootLeft; + } + + /** + * Set the noseRootLeft value. + * + * @param noseRootLeft the noseRootLeft value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseRootLeft(Coordinate noseRootLeft) { + this.noseRootLeft = noseRootLeft; + return this; + } + + /** + * Get the noseRootRight value. + * + * @return the noseRootRight value + */ + public Coordinate noseRootRight() { + return this.noseRootRight; + } + + /** + * Set the noseRootRight value. + * + * @param noseRootRight the noseRootRight value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseRootRight(Coordinate noseRootRight) { + this.noseRootRight = noseRootRight; + return this; + } + + /** + * Get the noseLeftAlarTop value. + * + * @return the noseLeftAlarTop value + */ + public Coordinate noseLeftAlarTop() { + return this.noseLeftAlarTop; + } + + /** + * Set the noseLeftAlarTop value. + * + * @param noseLeftAlarTop the noseLeftAlarTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseLeftAlarTop(Coordinate noseLeftAlarTop) { + this.noseLeftAlarTop = noseLeftAlarTop; + return this; + } + + /** + * Get the noseRightAlarTop value. + * + * @return the noseRightAlarTop value + */ + public Coordinate noseRightAlarTop() { + return this.noseRightAlarTop; + } + + /** + * Set the noseRightAlarTop value. + * + * @param noseRightAlarTop the noseRightAlarTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseRightAlarTop(Coordinate noseRightAlarTop) { + this.noseRightAlarTop = noseRightAlarTop; + return this; + } + + /** + * Get the noseLeftAlarOutTip value. + * + * @return the noseLeftAlarOutTip value + */ + public Coordinate noseLeftAlarOutTip() { + return this.noseLeftAlarOutTip; + } + + /** + * Set the noseLeftAlarOutTip value. + * + * @param noseLeftAlarOutTip the noseLeftAlarOutTip value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseLeftAlarOutTip(Coordinate noseLeftAlarOutTip) { + this.noseLeftAlarOutTip = noseLeftAlarOutTip; + return this; + } + + /** + * Get the noseRightAlarOutTip value. + * + * @return the noseRightAlarOutTip value + */ + public Coordinate noseRightAlarOutTip() { + return this.noseRightAlarOutTip; + } + + /** + * Set the noseRightAlarOutTip value. + * + * @param noseRightAlarOutTip the noseRightAlarOutTip value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withNoseRightAlarOutTip(Coordinate noseRightAlarOutTip) { + this.noseRightAlarOutTip = noseRightAlarOutTip; + return this; + } + + /** + * Get the upperLipTop value. + * + * @return the upperLipTop value + */ + public Coordinate upperLipTop() { + return this.upperLipTop; + } + + /** + * Set the upperLipTop value. + * + * @param upperLipTop the upperLipTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withUpperLipTop(Coordinate upperLipTop) { + this.upperLipTop = upperLipTop; + return this; + } + + /** + * Get the upperLipBottom value. + * + * @return the upperLipBottom value + */ + public Coordinate upperLipBottom() { + return this.upperLipBottom; + } + + /** + * Set the upperLipBottom value. + * + * @param upperLipBottom the upperLipBottom value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withUpperLipBottom(Coordinate upperLipBottom) { + this.upperLipBottom = upperLipBottom; + return this; + } + + /** + * Get the underLipTop value. + * + * @return the underLipTop value + */ + public Coordinate underLipTop() { + return this.underLipTop; + } + + /** + * Set the underLipTop value. + * + * @param underLipTop the underLipTop value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withUnderLipTop(Coordinate underLipTop) { + this.underLipTop = underLipTop; + return this; + } + + /** + * Get the underLipBottom value. + * + * @return the underLipBottom value + */ + public Coordinate underLipBottom() { + return this.underLipBottom; + } + + /** + * Set the underLipBottom value. + * + * @param underLipBottom the underLipBottom value to set + * @return the FaceLandmarks object itself. + */ + public FaceLandmarks withUnderLipBottom(Coordinate underLipBottom) { + this.underLipBottom = underLipBottom; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java new file mode 100644 index 0000000000000..c01d43f4437cb --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Face list object. + */ +public class FaceList extends NameAndUserDataContract { + /** + * FaceListId of the target face list. + */ + @JsonProperty(value = "faceListId", required = true) + private String faceListId; + + /** + * Persisted faces within the face list. + */ + @JsonProperty(value = "persistedFaces") + private List persistedFaces; + + /** + * Get faceListId of the target face list. + * + * @return the faceListId value + */ + public String faceListId() { + return this.faceListId; + } + + /** + * Set faceListId of the target face list. + * + * @param faceListId the faceListId value to set + * @return the FaceList object itself. + */ + public FaceList withFaceListId(String faceListId) { + this.faceListId = faceListId; + return this; + } + + /** + * Get persisted faces within the face list. + * + * @return the persistedFaces value + */ + public List persistedFaces() { + return this.persistedFaces; + } + + /** + * Set persisted faces within the face list. + * + * @param persistedFaces the persistedFaces value to set + * @return the FaceList object itself. + */ + public FaceList withPersistedFaces(List persistedFaces) { + this.persistedFaces = persistedFaces; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java new file mode 100644 index 0000000000000..e56a9e633bbe0 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java @@ -0,0 +1,123 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A rectangle within which a face can be found. + */ +public class FaceRectangle { + /** + * The width of the rectangle, in pixels. + */ + @JsonProperty(value = "width", required = true) + private int width; + + /** + * The height of the rectangle, in pixels. + */ + @JsonProperty(value = "height", required = true) + private int height; + + /** + * The distance from the left edge if the image to the left edge of the + * rectangle, in pixels. + */ + @JsonProperty(value = "left", required = true) + private int left; + + /** + * The distance from the top edge if the image to the top edge of the + * rectangle, in pixels. + */ + @JsonProperty(value = "top", required = true) + private int top; + + /** + * Get the width of the rectangle, in pixels. + * + * @return the width value + */ + public int width() { + return this.width; + } + + /** + * Set the width of the rectangle, in pixels. + * + * @param width the width value to set + * @return the FaceRectangle object itself. + */ + public FaceRectangle withWidth(int width) { + this.width = width; + return this; + } + + /** + * Get the height of the rectangle, in pixels. + * + * @return the height value + */ + public int height() { + return this.height; + } + + /** + * Set the height of the rectangle, in pixels. + * + * @param height the height value to set + * @return the FaceRectangle object itself. + */ + public FaceRectangle withHeight(int height) { + this.height = height; + return this; + } + + /** + * Get the distance from the left edge if the image to the left edge of the rectangle, in pixels. + * + * @return the left value + */ + public int left() { + return this.left; + } + + /** + * Set the distance from the left edge if the image to the left edge of the rectangle, in pixels. + * + * @param left the left value to set + * @return the FaceRectangle object itself. + */ + public FaceRectangle withLeft(int left) { + this.left = left; + return this; + } + + /** + * Get the distance from the top edge if the image to the top edge of the rectangle, in pixels. + * + * @return the top value + */ + public int top() { + return this.top; + } + + /** + * Set the distance from the top edge if the image to the top edge of the rectangle, in pixels. + * + * @param top the top value to set + * @return the FaceRectangle object itself. + */ + public FaceRectangle withTop(int top) { + this.top = top; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FacialHair.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FacialHair.java new file mode 100644 index 0000000000000..b0af112d2d5a5 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FacialHair.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing facial hair attributes. + */ +public class FacialHair { + /** + * The moustache property. + */ + @JsonProperty(value = "moustache") + private double moustache; + + /** + * The beard property. + */ + @JsonProperty(value = "beard") + private double beard; + + /** + * The sideburns property. + */ + @JsonProperty(value = "sideburns") + private double sideburns; + + /** + * Get the moustache value. + * + * @return the moustache value + */ + public double moustache() { + return this.moustache; + } + + /** + * Set the moustache value. + * + * @param moustache the moustache value to set + * @return the FacialHair object itself. + */ + public FacialHair withMoustache(double moustache) { + this.moustache = moustache; + return this; + } + + /** + * Get the beard value. + * + * @return the beard value + */ + public double beard() { + return this.beard; + } + + /** + * Set the beard value. + * + * @param beard the beard value to set + * @return the FacialHair object itself. + */ + public FacialHair withBeard(double beard) { + this.beard = beard; + return this; + } + + /** + * Get the sideburns value. + * + * @return the sideburns value + */ + public double sideburns() { + return this.sideburns; + } + + /** + * Set the sideburns value. + * + * @param sideburns the sideburns value to set + * @return the FacialHair object itself. + */ + public FacialHair withSideburns(double sideburns) { + this.sideburns = sideburns; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarMatchMode.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarMatchMode.java new file mode 100644 index 0000000000000..859c94033dbc8 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarMatchMode.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for FindSimilarMatchMode. + */ +public enum FindSimilarMatchMode { + /** Enum value matchPerson. */ + MATCH_PERSON("matchPerson"), + + /** Enum value matchFace. */ + MATCH_FACE("matchFace"); + + /** The actual serialized value for a FindSimilarMatchMode instance. */ + private String value; + + FindSimilarMatchMode(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a FindSimilarMatchMode instance. + * + * @param value the serialized value to parse. + * @return the parsed FindSimilarMatchMode object, or null if unable to parse. + */ + @JsonCreator + public static FindSimilarMatchMode fromString(String value) { + FindSimilarMatchMode[] items = FindSimilarMatchMode.values(); + for (FindSimilarMatchMode item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java new file mode 100644 index 0000000000000..d8fa63517085b --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java @@ -0,0 +1,156 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for find similar operation. + */ +public class FindSimilarRequest { + /** + * FaceId of the query face. User needs to call Face - Detect first to get + * a valid faceId. Note that this faceId is not persisted and will expire + * 24 hours after the detection call. + */ + @JsonProperty(value = "faceId", required = true) + private UUID faceId; + + /** + * An existing user-specified unique candidate face list, created in Face + * List - Create a Face List. Face list contains a set of persistedFaceIds + * which are persisted and will never expire. Parameter faceListId and + * faceIds should not be provided at the same time. + */ + @JsonProperty(value = "faceListId") + private String faceListId; + + /** + * An array of candidate faceIds. All of them are created by Face - Detect + * and the faceIds will expire 24 hours after the detection call. + */ + @JsonProperty(value = "faceIds") + private List faceIds; + + /** + * The number of top similar faces returned. The valid range is [1, 1000]. + */ + @JsonProperty(value = "maxNumOfCandidatesReturned") + private Integer maxNumOfCandidatesReturned; + + /** + * Similar face searching mode. It can be "matchPerson" or "matchFace". + * Possible values include: 'matchPerson', 'matchFace'. + */ + @JsonProperty(value = "mode") + private FindSimilarMatchMode mode; + + /** + * Get faceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call. + * + * @return the faceId value + */ + public UUID faceId() { + return this.faceId; + } + + /** + * Set faceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call. + * + * @param faceId the faceId value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withFaceId(UUID faceId) { + this.faceId = faceId; + return this; + } + + /** + * Get an existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time. + * + * @return the faceListId value + */ + public String faceListId() { + return this.faceListId; + } + + /** + * Set an existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time. + * + * @param faceListId the faceListId value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withFaceListId(String faceListId) { + this.faceListId = faceListId; + return this; + } + + /** + * Get an array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * + * @return the faceIds value + */ + public List faceIds() { + return this.faceIds; + } + + /** + * Set an array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * + * @param faceIds the faceIds value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withFaceIds(List faceIds) { + this.faceIds = faceIds; + return this; + } + + /** + * Get the number of top similar faces returned. The valid range is [1, 1000]. + * + * @return the maxNumOfCandidatesReturned value + */ + public Integer maxNumOfCandidatesReturned() { + return this.maxNumOfCandidatesReturned; + } + + /** + * Set the number of top similar faces returned. The valid range is [1, 1000]. + * + * @param maxNumOfCandidatesReturned the maxNumOfCandidatesReturned value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned) { + this.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; + return this; + } + + /** + * Get similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace'. + * + * @return the mode value + */ + public FindSimilarMatchMode mode() { + return this.mode; + } + + /** + * Set similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace'. + * + * @param mode the mode value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withMode(FindSimilarMatchMode mode) { + this.mode = mode; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Gender.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Gender.java new file mode 100644 index 0000000000000..811b4e5ebc356 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Gender.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for Gender. + */ +public enum Gender { + /** Enum value male. */ + MALE("male"), + + /** Enum value female. */ + FEMALE("female"), + + /** Enum value genderless. */ + GENDERLESS("genderless"); + + /** The actual serialized value for a Gender instance. */ + private String value; + + Gender(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Gender instance. + * + * @param value the serialized value to parse. + * @return the parsed Gender object, or null if unable to parse. + */ + @JsonCreator + public static Gender fromString(String value) { + Gender[] items = Gender.values(); + for (Gender item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GlassesType.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GlassesType.java new file mode 100644 index 0000000000000..0422e7421bfce --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GlassesType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for GlassesType. + */ +public enum GlassesType { + /** Enum value noGlasses. */ + NO_GLASSES("noGlasses"), + + /** Enum value readingGlasses. */ + READING_GLASSES("readingGlasses"), + + /** Enum value sunglasses. */ + SUNGLASSES("sunglasses"), + + /** Enum value swimmingGoggles. */ + SWIMMING_GOGGLES("swimmingGoggles"); + + /** The actual serialized value for a GlassesType instance. */ + private String value; + + GlassesType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a GlassesType instance. + * + * @param value the serialized value to parse. + * @return the parsed GlassesType object, or null if unable to parse. + */ + @JsonCreator + public static GlassesType fromString(String value) { + GlassesType[] items = GlassesType.values(); + for (GlassesType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java new file mode 100644 index 0000000000000..c44ee8495a569 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for group request. + */ +public class GroupRequest { + /** + * Array of candidate faceId created by Face - Detect. The maximum is 1000 + * faces. + */ + @JsonProperty(value = "faceIds", required = true) + private List faceIds; + + /** + * Get array of candidate faceId created by Face - Detect. The maximum is 1000 faces. + * + * @return the faceIds value + */ + public List faceIds() { + return this.faceIds; + } + + /** + * Set array of candidate faceId created by Face - Detect. The maximum is 1000 faces. + * + * @param faceIds the faceIds value to set + * @return the GroupRequest object itself. + */ + public GroupRequest withFaceIds(List faceIds) { + this.faceIds = faceIds; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java new file mode 100644 index 0000000000000..c2440f2b8c52c --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An array of face groups based on face similarity. + */ +public class GroupResult { + /** + * A partition of the original faces based on face similarity. Groups are + * ranked by number of faces. + */ + @JsonProperty(value = "groups", required = true) + private List> groups; + + /** + * Face ids array of faces that cannot find any similar faces from original + * faces. + */ + @JsonProperty(value = "messyGroup") + private List messyGroup; + + /** + * Get a partition of the original faces based on face similarity. Groups are ranked by number of faces. + * + * @return the groups value + */ + public List> groups() { + return this.groups; + } + + /** + * Set a partition of the original faces based on face similarity. Groups are ranked by number of faces. + * + * @param groups the groups value to set + * @return the GroupResult object itself. + */ + public GroupResult withGroups(List> groups) { + this.groups = groups; + return this; + } + + /** + * Get face ids array of faces that cannot find any similar faces from original faces. + * + * @return the messyGroup value + */ + public List messyGroup() { + return this.messyGroup; + } + + /** + * Set face ids array of faces that cannot find any similar faces from original faces. + * + * @param messyGroup the messyGroup value to set + * @return the GroupResult object itself. + */ + public GroupResult withMessyGroup(List messyGroup) { + this.messyGroup = messyGroup; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java new file mode 100644 index 0000000000000..49abb7342db8c --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing hair attributes. + */ +public class Hair { + /** + * A number describing confidence level of whether the person is bald. + */ + @JsonProperty(value = "bald") + private double bald; + + /** + * A boolean value describing whether the hair is visible in the image. + */ + @JsonProperty(value = "invisible") + private boolean invisible; + + /** + * An array of candidate colors and confidence level in the presence of + * each. + */ + @JsonProperty(value = "hairColor") + private List hairColor; + + /** + * Get a number describing confidence level of whether the person is bald. + * + * @return the bald value + */ + public double bald() { + return this.bald; + } + + /** + * Set a number describing confidence level of whether the person is bald. + * + * @param bald the bald value to set + * @return the Hair object itself. + */ + public Hair withBald(double bald) { + this.bald = bald; + return this; + } + + /** + * Get a boolean value describing whether the hair is visible in the image. + * + * @return the invisible value + */ + public boolean invisible() { + return this.invisible; + } + + /** + * Set a boolean value describing whether the hair is visible in the image. + * + * @param invisible the invisible value to set + * @return the Hair object itself. + */ + public Hair withInvisible(boolean invisible) { + this.invisible = invisible; + return this; + } + + /** + * Get an array of candidate colors and confidence level in the presence of each. + * + * @return the hairColor value + */ + public List hairColor() { + return this.hairColor; + } + + /** + * Set an array of candidate colors and confidence level in the presence of each. + * + * @param hairColor the hairColor value to set + * @return the Hair object itself. + */ + public Hair withHairColor(List hairColor) { + this.hairColor = hairColor; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java new file mode 100644 index 0000000000000..9e65e237ce903 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Hair color and associated confidence. + */ +public class HairColor { + /** + * Name of the hair color. Possible values include: 'unknown', 'white', + * 'gray', 'blond', 'brown', 'red', 'black', 'other'. + */ + @JsonProperty(value = "color") + private HairColorType color; + + /** + * Confidence level of the color. + */ + @JsonProperty(value = "confidence") + private double confidence; + + /** + * Get name of the hair color. Possible values include: 'unknown', 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other'. + * + * @return the color value + */ + public HairColorType color() { + return this.color; + } + + /** + * Set name of the hair color. Possible values include: 'unknown', 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other'. + * + * @param color the color value to set + * @return the HairColor object itself. + */ + public HairColor withColor(HairColorType color) { + this.color = color; + return this; + } + + /** + * Get confidence level of the color. + * + * @return the confidence value + */ + public double confidence() { + return this.confidence; + } + + /** + * Set confidence level of the color. + * + * @param confidence the confidence value to set + * @return the HairColor object itself. + */ + public HairColor withConfidence(double confidence) { + this.confidence = confidence; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColorType.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColorType.java new file mode 100644 index 0000000000000..573d651d71f97 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColorType.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for HairColorType. + */ +public enum HairColorType { + /** Enum value unknown. */ + UNKNOWN("unknown"), + + /** Enum value white. */ + WHITE("white"), + + /** Enum value gray. */ + GRAY("gray"), + + /** Enum value blond. */ + BLOND("blond"), + + /** Enum value brown. */ + BROWN("brown"), + + /** Enum value red. */ + RED("red"), + + /** Enum value black. */ + BLACK("black"), + + /** Enum value other. */ + OTHER("other"); + + /** The actual serialized value for a HairColorType instance. */ + private String value; + + HairColorType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a HairColorType instance. + * + * @param value the serialized value to parse. + * @return the parsed HairColorType object, or null if unable to parse. + */ + @JsonCreator + public static HairColorType fromString(String value) { + HairColorType[] items = HairColorType.values(); + for (HairColorType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HeadPose.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HeadPose.java new file mode 100644 index 0000000000000..2c8ea818bd2b0 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HeadPose.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties indicating head pose of the face. + */ +public class HeadPose { + /** + * The roll property. + */ + @JsonProperty(value = "roll") + private double roll; + + /** + * The yaw property. + */ + @JsonProperty(value = "yaw") + private double yaw; + + /** + * The pitch property. + */ + @JsonProperty(value = "pitch") + private double pitch; + + /** + * Get the roll value. + * + * @return the roll value + */ + public double roll() { + return this.roll; + } + + /** + * Set the roll value. + * + * @param roll the roll value to set + * @return the HeadPose object itself. + */ + public HeadPose withRoll(double roll) { + this.roll = roll; + return this; + } + + /** + * Get the yaw value. + * + * @return the yaw value + */ + public double yaw() { + return this.yaw; + } + + /** + * Set the yaw value. + * + * @param yaw the yaw value to set + * @return the HeadPose object itself. + */ + public HeadPose withYaw(double yaw) { + this.yaw = yaw; + return this; + } + + /** + * Get the pitch value. + * + * @return the pitch value + */ + public double pitch() { + return this.pitch; + } + + /** + * Set the pitch value. + * + * @param pitch the pitch value to set + * @return the HeadPose object itself. + */ + public HeadPose withPitch(double pitch) { + this.pitch = pitch; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java new file mode 100644 index 0000000000000..b0e9218869f1f --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * All possible faces that may qualify. + */ +public class IdentifyCandidate { + /** + * Id of candidate. + */ + @JsonProperty(value = "personId", required = true) + private UUID personId; + + /** + * Confidence threshold of identification, used to judge whether one face + * belong to one person. The range of confidenceThreshold is [0, 1] + * (default specified by algorithm). + */ + @JsonProperty(value = "confidence", required = true) + private double confidence; + + /** + * Get id of candidate. + * + * @return the personId value + */ + public UUID personId() { + return this.personId; + } + + /** + * Set id of candidate. + * + * @param personId the personId value to set + * @return the IdentifyCandidate object itself. + */ + public IdentifyCandidate withPersonId(UUID personId) { + this.personId = personId; + return this; + } + + /** + * Get confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * + * @return the confidence value + */ + public double confidence() { + return this.confidence; + } + + /** + * Set confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * + * @param confidence the confidence value to set + * @return the IdentifyCandidate object itself. + */ + public IdentifyCandidate withConfidence(double confidence) { + this.confidence = confidence; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java new file mode 100644 index 0000000000000..f7dbccf94643e --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java @@ -0,0 +1,129 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for identify face operation. + */ +public class IdentifyRequest { + /** + * PersonGroupId of the target person group, created by + * PersonGroups.Create. + */ + @JsonProperty(value = "personGroupId", required = true) + private String personGroupId; + + /** + * Array of query faces faceIds, created by the Face - Detect. Each of the + * faces are identified independently. The valid number of faceIds is + * between [1, 10]. + */ + @JsonProperty(value = "faceIds", required = true) + private List faceIds; + + /** + * The range of maxNumOfCandidatesReturned is between 1 and 5 (default is + * 1). + */ + @JsonProperty(value = "maxNumOfCandidatesReturned") + private Integer maxNumOfCandidatesReturned; + + /** + * Confidence threshold of identification, used to judge whether one face + * belong to one person. The range of confidenceThreshold is [0, 1] + * (default specified by algorithm). + */ + @JsonProperty(value = "confidenceThreshold") + private Double confidenceThreshold; + + /** + * Get personGroupId of the target person group, created by PersonGroups.Create. + * + * @return the personGroupId value + */ + public String personGroupId() { + return this.personGroupId; + } + + /** + * Set personGroupId of the target person group, created by PersonGroups.Create. + * + * @param personGroupId the personGroupId value to set + * @return the IdentifyRequest object itself. + */ + public IdentifyRequest withPersonGroupId(String personGroupId) { + this.personGroupId = personGroupId; + return this; + } + + /** + * Get array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * + * @return the faceIds value + */ + public List faceIds() { + return this.faceIds; + } + + /** + * Set array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * + * @param faceIds the faceIds value to set + * @return the IdentifyRequest object itself. + */ + public IdentifyRequest withFaceIds(List faceIds) { + this.faceIds = faceIds; + return this; + } + + /** + * Get the range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * + * @return the maxNumOfCandidatesReturned value + */ + public Integer maxNumOfCandidatesReturned() { + return this.maxNumOfCandidatesReturned; + } + + /** + * Set the range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * + * @param maxNumOfCandidatesReturned the maxNumOfCandidatesReturned value to set + * @return the IdentifyRequest object itself. + */ + public IdentifyRequest withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned) { + this.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; + return this; + } + + /** + * Get confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * + * @return the confidenceThreshold value + */ + public Double confidenceThreshold() { + return this.confidenceThreshold; + } + + /** + * Set confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * + * @param confidenceThreshold the confidenceThreshold value to set + * @return the IdentifyRequest object itself. + */ + public IdentifyRequest withConfidenceThreshold(Double confidenceThreshold) { + this.confidenceThreshold = confidenceThreshold; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java new file mode 100644 index 0000000000000..554bab530306b --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response body for identify face operation. + */ +public class IdentifyResult { + /** + * FaceId of the query face. + */ + @JsonProperty(value = "faceId", required = true) + private UUID faceId; + + /** + * Identified person candidates for that face (ranked by confidence). Array + * size should be no larger than input maxNumOfCandidatesReturned. If no + * person is identified, will return an empty array. + */ + @JsonProperty(value = "candidates", required = true) + private List candidates; + + /** + * Get faceId of the query face. + * + * @return the faceId value + */ + public UUID faceId() { + return this.faceId; + } + + /** + * Set faceId of the query face. + * + * @param faceId the faceId value to set + * @return the IdentifyResult object itself. + */ + public IdentifyResult withFaceId(UUID faceId) { + this.faceId = faceId; + return this; + } + + /** + * Get identified person candidates for that face (ranked by confidence). Array size should be no larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty array. + * + * @return the candidates value + */ + public List candidates() { + return this.candidates; + } + + /** + * Set identified person candidates for that face (ranked by confidence). Array size should be no larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty array. + * + * @param candidates the candidates value to set + * @return the IdentifyResult object itself. + */ + public IdentifyResult withCandidates(List candidates) { + this.candidates = candidates; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java new file mode 100644 index 0000000000000..b5a41095a3248 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ImageUrl model. + */ +public class ImageUrl { + /** + * Publicly reachable URL of an image. + */ + @JsonProperty(value = "url", required = true) + private String url; + + /** + * Get publicly reachable URL of an image. + * + * @return the url value + */ + public String url() { + return this.url; + } + + /** + * Set publicly reachable URL of an image. + * + * @param url the url value to set + * @return the ImageUrl object itself. + */ + public ImageUrl withUrl(String url) { + this.url = url; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java new file mode 100644 index 0000000000000..0f9923c6e30d5 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing present makeups on a given face. + */ +public class Makeup { + /** + * A boolean value describing whether eye makeup is present on a face. + */ + @JsonProperty(value = "eyeMakeup") + private boolean eyeMakeup; + + /** + * A boolean value describing whether lip makeup is present on a face. + */ + @JsonProperty(value = "lipMakeup") + private boolean lipMakeup; + + /** + * Get a boolean value describing whether eye makeup is present on a face. + * + * @return the eyeMakeup value + */ + public boolean eyeMakeup() { + return this.eyeMakeup; + } + + /** + * Set a boolean value describing whether eye makeup is present on a face. + * + * @param eyeMakeup the eyeMakeup value to set + * @return the Makeup object itself. + */ + public Makeup withEyeMakeup(boolean eyeMakeup) { + this.eyeMakeup = eyeMakeup; + return this; + } + + /** + * Get a boolean value describing whether lip makeup is present on a face. + * + * @return the lipMakeup value + */ + public boolean lipMakeup() { + return this.lipMakeup; + } + + /** + * Set a boolean value describing whether lip makeup is present on a face. + * + * @param lipMakeup the lipMakeup value to set + * @return the Makeup object itself. + */ + public Makeup withLipMakeup(boolean lipMakeup) { + this.lipMakeup = lipMakeup; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java new file mode 100644 index 0000000000000..fe757e8e831bd --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A combination of user defined name and user specified data for the person, + * personGroup, and faceList. + */ +public class NameAndUserDataContract { + /** + * User defined name, maximum length is 128. + */ + @JsonProperty(value = "name") + private String name; + + /** + * User specified data. Length should not exceed 16KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get user defined name, maximum length is 128. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set user defined name, maximum length is 128. + * + * @param name the name value to set + * @return the NameAndUserDataContract object itself. + */ + public NameAndUserDataContract withName(String name) { + this.name = name; + return this; + } + + /** + * Get user specified data. Length should not exceed 16KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user specified data. Length should not exceed 16KB. + * + * @param userData the userData value to set + * @return the NameAndUserDataContract object itself. + */ + public NameAndUserDataContract withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java new file mode 100644 index 0000000000000..946f9e70f347e --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing noise level of the image. + */ +public class Noise { + /** + * An enum value indicating level of noise. Possible values include: 'Low', + * 'Medium', 'High'. + */ + @JsonProperty(value = "noiseLevel") + private NoiseLevel noiseLevel; + + /** + * A number indicating level of noise level ranging from 0 to 1. [0, 0.25) + * is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over + * exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. + * [0.7, 1] is high noise level. + */ + @JsonProperty(value = "value") + private double value; + + /** + * Get an enum value indicating level of noise. Possible values include: 'Low', 'Medium', 'High'. + * + * @return the noiseLevel value + */ + public NoiseLevel noiseLevel() { + return this.noiseLevel; + } + + /** + * Set an enum value indicating level of noise. Possible values include: 'Low', 'Medium', 'High'. + * + * @param noiseLevel the noiseLevel value to set + * @return the Noise object itself. + */ + public Noise withNoiseLevel(NoiseLevel noiseLevel) { + this.noiseLevel = noiseLevel; + return this; + } + + /** + * Get a number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. + * + * @return the value value + */ + public double value() { + return this.value; + } + + /** + * Set a number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. + * + * @param value the value value to set + * @return the Noise object itself. + */ + public Noise withValue(double value) { + this.value = value; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NoiseLevel.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NoiseLevel.java new file mode 100644 index 0000000000000..0431b29ea62ab --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NoiseLevel.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for NoiseLevel. + */ +public enum NoiseLevel { + /** Enum value Low. */ + LOW("Low"), + + /** Enum value Medium. */ + MEDIUM("Medium"), + + /** Enum value High. */ + HIGH("High"); + + /** The actual serialized value for a NoiseLevel instance. */ + private String value; + + NoiseLevel(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a NoiseLevel instance. + * + * @param value the serialized value to parse. + * @return the parsed NoiseLevel object, or null if unable to parse. + */ + @JsonCreator + public static NoiseLevel fromString(String value) { + NoiseLevel[] items = NoiseLevel.values(); + for (NoiseLevel item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java new file mode 100644 index 0000000000000..7a75a5659f5d2 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Properties describing occlusions on a given face. + */ +public class Occlusion { + /** + * A boolean value indicating whether forehead is occluded. + */ + @JsonProperty(value = "foreheadOccluded") + private boolean foreheadOccluded; + + /** + * A boolean value indicating whether eyes are occluded. + */ + @JsonProperty(value = "eyeOccluded") + private boolean eyeOccluded; + + /** + * A boolean value indicating whether the mouth is occluded. + */ + @JsonProperty(value = "mouthOccluded") + private boolean mouthOccluded; + + /** + * Get a boolean value indicating whether forehead is occluded. + * + * @return the foreheadOccluded value + */ + public boolean foreheadOccluded() { + return this.foreheadOccluded; + } + + /** + * Set a boolean value indicating whether forehead is occluded. + * + * @param foreheadOccluded the foreheadOccluded value to set + * @return the Occlusion object itself. + */ + public Occlusion withForeheadOccluded(boolean foreheadOccluded) { + this.foreheadOccluded = foreheadOccluded; + return this; + } + + /** + * Get a boolean value indicating whether eyes are occluded. + * + * @return the eyeOccluded value + */ + public boolean eyeOccluded() { + return this.eyeOccluded; + } + + /** + * Set a boolean value indicating whether eyes are occluded. + * + * @param eyeOccluded the eyeOccluded value to set + * @return the Occlusion object itself. + */ + public Occlusion withEyeOccluded(boolean eyeOccluded) { + this.eyeOccluded = eyeOccluded; + return this; + } + + /** + * Get a boolean value indicating whether the mouth is occluded. + * + * @return the mouthOccluded value + */ + public boolean mouthOccluded() { + return this.mouthOccluded; + } + + /** + * Set a boolean value indicating whether the mouth is occluded. + * + * @param mouthOccluded the mouthOccluded value to set + * @return the Occlusion object itself. + */ + public Occlusion withMouthOccluded(boolean mouthOccluded) { + this.mouthOccluded = mouthOccluded; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java new file mode 100644 index 0000000000000..d62e83ec4c37d --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * PersonFace object. + */ +public class PersistedFace { + /** + * The persistedFaceId of the target face, which is persisted and will not + * expire. Different from faceId created by Face - Detect and will expire + * in 24 hours after the detection call. + */ + @JsonProperty(value = "persistedFaceId", required = true) + private UUID persistedFaceId; + + /** + * User-provided data attached to the face. The size limit is 1KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get the persistedFaceId of the target face, which is persisted and will not expire. Different from faceId created by Face - Detect and will expire in 24 hours after the detection call. + * + * @return the persistedFaceId value + */ + public UUID persistedFaceId() { + return this.persistedFaceId; + } + + /** + * Set the persistedFaceId of the target face, which is persisted and will not expire. Different from faceId created by Face - Detect and will expire in 24 hours after the detection call. + * + * @param persistedFaceId the persistedFaceId value to set + * @return the PersistedFace object itself. + */ + public PersistedFace withPersistedFaceId(UUID persistedFaceId) { + this.persistedFaceId = persistedFaceId; + return this; + } + + /** + * Get user-provided data attached to the face. The size limit is 1KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user-provided data attached to the face. The size limit is 1KB. + * + * @param userData the userData value to set + * @return the PersistedFace object itself. + */ + public PersistedFace withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java new file mode 100644 index 0000000000000..c2ee71712aa9e --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Person object. + */ +public class Person extends NameAndUserDataContract { + /** + * PersonId of the target face list. + */ + @JsonProperty(value = "personId", required = true) + private UUID personId; + + /** + * PersistedFaceIds of registered faces in the person. These + * persistedFaceIds are returned from Person - Add a Person Face, and will + * not expire. + */ + @JsonProperty(value = "persistedFaceIds") + private List persistedFaceIds; + + /** + * Get personId of the target face list. + * + * @return the personId value + */ + public UUID personId() { + return this.personId; + } + + /** + * Set personId of the target face list. + * + * @param personId the personId value to set + * @return the Person object itself. + */ + public Person withPersonId(UUID personId) { + this.personId = personId; + return this; + } + + /** + * Get persistedFaceIds of registered faces in the person. These persistedFaceIds are returned from Person - Add a Person Face, and will not expire. + * + * @return the persistedFaceIds value + */ + public List persistedFaceIds() { + return this.persistedFaceIds; + } + + /** + * Set persistedFaceIds of registered faces in the person. These persistedFaceIds are returned from Person - Add a Person Face, and will not expire. + * + * @param persistedFaceIds the persistedFaceIds value to set + * @return the Person object itself. + */ + public Person withPersistedFaceIds(List persistedFaceIds) { + this.persistedFaceIds = persistedFaceIds; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java new file mode 100644 index 0000000000000..c69251a7bb600 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Person group object. + */ +public class PersonGroup extends NameAndUserDataContract { + /** + * PersonGroupId of the existing person groups. + */ + @JsonProperty(value = "personGroupId", required = true) + private String personGroupId; + + /** + * Get personGroupId of the existing person groups. + * + * @return the personGroupId value + */ + public String personGroupId() { + return this.personGroupId; + } + + /** + * Set personGroupId of the existing person groups. + * + * @param personGroupId the personGroupId value to set + * @return the PersonGroup object itself. + */ + public PersonGroup withPersonGroupId(String personGroupId) { + this.personGroupId = personGroupId; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java new file mode 100644 index 0000000000000..9939e4a518af0 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java @@ -0,0 +1,100 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Response body for find similar face operation. + */ +public class SimilarFace { + /** + * FaceId of candidate face when find by faceIds. faceId is created by Face + * - Detect and will expire 24 hours after the detection call. + */ + @JsonProperty(value = "faceId") + private UUID faceId; + + /** + * PersistedFaceId of candidate face when find by faceListId. + * persistedFaceId in face list is persisted and will not expire. As showed + * in below response. + */ + @JsonProperty(value = "persistedFaceId") + private UUID persistedFaceId; + + /** + * Similarity confidence of the candidate face. The higher confidence, the + * more similar. Range between [0,1]. + */ + @JsonProperty(value = "confidence", required = true) + private double confidence; + + /** + * Get faceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire 24 hours after the detection call. + * + * @return the faceId value + */ + public UUID faceId() { + return this.faceId; + } + + /** + * Set faceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire 24 hours after the detection call. + * + * @param faceId the faceId value to set + * @return the SimilarFace object itself. + */ + public SimilarFace withFaceId(UUID faceId) { + this.faceId = faceId; + return this; + } + + /** + * Get persistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response. + * + * @return the persistedFaceId value + */ + public UUID persistedFaceId() { + return this.persistedFaceId; + } + + /** + * Set persistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response. + * + * @param persistedFaceId the persistedFaceId value to set + * @return the SimilarFace object itself. + */ + public SimilarFace withPersistedFaceId(UUID persistedFaceId) { + this.persistedFaceId = persistedFaceId; + return this; + } + + /** + * Get similarity confidence of the candidate face. The higher confidence, the more similar. Range between [0,1]. + * + * @return the confidence value + */ + public double confidence() { + return this.confidence; + } + + /** + * Set similarity confidence of the candidate face. The higher confidence, the more similar. Range between [0,1]. + * + * @param confidence the confidence value to set + * @return the SimilarFace object itself. + */ + public SimilarFace withConfidence(double confidence) { + this.confidence = confidence; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java new file mode 100644 index 0000000000000..1df0d9167c8cf --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java @@ -0,0 +1,130 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Training status object. + */ +public class TrainingStatus { + /** + * Training status: notstarted, running, succeeded, failed. If the training + * process is waiting to perform, the status is notstarted. If the training + * is ongoing, the status is running. Status succeed means this person + * group is ready for Face - Identify. Status failed is often caused by no + * person or no persisted face exist in the person group. Possible values + * include: 'nonstarted', 'running', 'succeeded', 'failed'. + */ + @JsonProperty(value = "status", required = true) + private TrainingStatusType status; + + /** + * A combined UTC date and time string that describes person group created + * time. + */ + @JsonProperty(value = "createdDateTime", required = true) + private DateTime created; + + /** + * Person group last modify time in the UTC, could be null value when the + * person group is not successfully trained. + */ + @JsonProperty(value = "lastActionDateTime") + private DateTime lastAction; + + /** + * Show failure message when training failed (omitted when training + * succeed). + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get training status: notstarted, running, succeeded, failed. If the training process is waiting to perform, the status is notstarted. If the training is ongoing, the status is running. Status succeed means this person group is ready for Face - Identify. Status failed is often caused by no person or no persisted face exist in the person group. Possible values include: 'nonstarted', 'running', 'succeeded', 'failed'. + * + * @return the status value + */ + public TrainingStatusType status() { + return this.status; + } + + /** + * Set training status: notstarted, running, succeeded, failed. If the training process is waiting to perform, the status is notstarted. If the training is ongoing, the status is running. Status succeed means this person group is ready for Face - Identify. Status failed is often caused by no person or no persisted face exist in the person group. Possible values include: 'nonstarted', 'running', 'succeeded', 'failed'. + * + * @param status the status value to set + * @return the TrainingStatus object itself. + */ + public TrainingStatus withStatus(TrainingStatusType status) { + this.status = status; + return this; + } + + /** + * Get a combined UTC date and time string that describes person group created time. + * + * @return the created value + */ + public DateTime created() { + return this.created; + } + + /** + * Set a combined UTC date and time string that describes person group created time. + * + * @param created the created value to set + * @return the TrainingStatus object itself. + */ + public TrainingStatus withCreated(DateTime created) { + this.created = created; + return this; + } + + /** + * Get person group last modify time in the UTC, could be null value when the person group is not successfully trained. + * + * @return the lastAction value + */ + public DateTime lastAction() { + return this.lastAction; + } + + /** + * Set person group last modify time in the UTC, could be null value when the person group is not successfully trained. + * + * @param lastAction the lastAction value to set + * @return the TrainingStatus object itself. + */ + public TrainingStatus withLastAction(DateTime lastAction) { + this.lastAction = lastAction; + return this; + } + + /** + * Get show failure message when training failed (omitted when training succeed). + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set show failure message when training failed (omitted when training succeed). + * + * @param message the message value to set + * @return the TrainingStatus object itself. + */ + public TrainingStatus withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatusType.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatusType.java new file mode 100644 index 0000000000000..13f5c6e5c9069 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatusType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for TrainingStatusType. + */ +public enum TrainingStatusType { + /** Enum value nonstarted. */ + NONSTARTED("nonstarted"), + + /** Enum value running. */ + RUNNING("running"), + + /** Enum value succeeded. */ + SUCCEEDED("succeeded"), + + /** Enum value failed. */ + FAILED("failed"); + + /** The actual serialized value for a TrainingStatusType instance. */ + private String value; + + TrainingStatusType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a TrainingStatusType instance. + * + * @param value the serialized value to parse. + * @return the parsed TrainingStatusType object, or null if unable to parse. + */ + @JsonCreator + public static TrainingStatusType fromString(String value) { + TrainingStatusType[] items = TrainingStatusType.values(); + for (TrainingStatusType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java new file mode 100644 index 0000000000000..4a5a1a0a74691 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request to update person face data. + */ +public class UpdatePersonFaceRequest { + /** + * User-provided data attached to the face. The size limit is 1KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get user-provided data attached to the face. The size limit is 1KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user-provided data attached to the face. The size limit is 1KB. + * + * @param userData the userData value to set + * @return the UpdatePersonFaceRequest object itself. + */ + public UpdatePersonFaceRequest withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java new file mode 100644 index 0000000000000..3bf44626a0d0d --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for verify operation. + */ +public class VerifyFaceToFaceRequest { + /** + * FaceId of the first face, comes from Face - Detect. + */ + @JsonProperty(value = "faceId1", required = true) + private UUID faceId1; + + /** + * FaceId of the second face, comes from Face - Detect. + */ + @JsonProperty(value = "faceId2", required = true) + private UUID faceId2; + + /** + * Get faceId of the first face, comes from Face - Detect. + * + * @return the faceId1 value + */ + public UUID faceId1() { + return this.faceId1; + } + + /** + * Set faceId of the first face, comes from Face - Detect. + * + * @param faceId1 the faceId1 value to set + * @return the VerifyFaceToFaceRequest object itself. + */ + public VerifyFaceToFaceRequest withFaceId1(UUID faceId1) { + this.faceId1 = faceId1; + return this; + } + + /** + * Get faceId of the second face, comes from Face - Detect. + * + * @return the faceId2 value + */ + public UUID faceId2() { + return this.faceId2; + } + + /** + * Set faceId of the second face, comes from Face - Detect. + * + * @param faceId2 the faceId2 value to set + * @return the VerifyFaceToFaceRequest object itself. + */ + public VerifyFaceToFaceRequest withFaceId2(UUID faceId2) { + this.faceId2 = faceId2; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java new file mode 100644 index 0000000000000..064c67e118ac3 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for verify operation. + */ +public class VerifyFaceToPersonRequest { + /** + * FaceId the face, comes from Face - Detect. + */ + @JsonProperty(value = "faceId", required = true) + private UUID faceId; + + /** + * Using existing personGroupId and personId for fast loading a specified + * person. personGroupId is created in Person Groups.Create. + */ + @JsonProperty(value = "personGroupId", required = true) + private String personGroupId; + + /** + * Specify a certain person in a person group. personId is created in + * Persons.Create. + */ + @JsonProperty(value = "personId", required = true) + private UUID personId; + + /** + * Get faceId the face, comes from Face - Detect. + * + * @return the faceId value + */ + public UUID faceId() { + return this.faceId; + } + + /** + * Set faceId the face, comes from Face - Detect. + * + * @param faceId the faceId value to set + * @return the VerifyFaceToPersonRequest object itself. + */ + public VerifyFaceToPersonRequest withFaceId(UUID faceId) { + this.faceId = faceId; + return this; + } + + /** + * Get using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * + * @return the personGroupId value + */ + public String personGroupId() { + return this.personGroupId; + } + + /** + * Set using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. + * + * @param personGroupId the personGroupId value to set + * @return the VerifyFaceToPersonRequest object itself. + */ + public VerifyFaceToPersonRequest withPersonGroupId(String personGroupId) { + this.personGroupId = personGroupId; + return this; + } + + /** + * Get specify a certain person in a person group. personId is created in Persons.Create. + * + * @return the personId value + */ + public UUID personId() { + return this.personId; + } + + /** + * Set specify a certain person in a person group. personId is created in Persons.Create. + * + * @param personId the personId value to set + * @return the VerifyFaceToPersonRequest object itself. + */ + public VerifyFaceToPersonRequest withPersonId(UUID personId) { + this.personId = personId; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java new file mode 100644 index 0000000000000..01b2167c81106 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Result of the verify operation. + */ +public class VerifyResult { + /** + * True if the two faces belong to the same person or the face belongs to + * the person, otherwise false. + */ + @JsonProperty(value = "isIdentical", required = true) + private boolean isIdentical; + + /** + * A number indicates the similarity confidence of whether two faces belong + * to the same person, or whether the face belongs to the person. By + * default, isIdentical is set to True if similarity confidence is greater + * than or equal to 0.5. This is useful for advanced users to override + * "isIdentical" and fine-tune the result on their own data. + */ + @JsonProperty(value = "confidence", required = true) + private double confidence; + + /** + * Get true if the two faces belong to the same person or the face belongs to the person, otherwise false. + * + * @return the isIdentical value + */ + public boolean isIdentical() { + return this.isIdentical; + } + + /** + * Set true if the two faces belong to the same person or the face belongs to the person, otherwise false. + * + * @param isIdentical the isIdentical value to set + * @return the VerifyResult object itself. + */ + public VerifyResult withIsIdentical(boolean isIdentical) { + this.isIdentical = isIdentical; + return this; + } + + /** + * Get a number indicates the similarity confidence of whether two faces belong to the same person, or whether the face belongs to the person. By default, isIdentical is set to True if similarity confidence is greater than or equal to 0.5. This is useful for advanced users to override "isIdentical" and fine-tune the result on their own data. + * + * @return the confidence value + */ + public double confidence() { + return this.confidence; + } + + /** + * Set a number indicates the similarity confidence of whether two faces belong to the same person, or whether the face belongs to the person. By default, isIdentical is set to True if similarity confidence is greater than or equal to 0.5. This is useful for advanced users to override "isIdentical" and fine-tune the result on their own data. + * + * @param confidence the confidence value to set + * @return the VerifyResult object itself. + */ + public VerifyResult withConfidence(double confidence) { + this.confidence = confidence; + return this; + } + +} diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java new file mode 100644 index 0000000000000..2e540da664843 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the models classes for FaceClient. + * An API for face detection, verification, and identification. + */ +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; diff --git a/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java new file mode 100644 index 0000000000000..6a7b6a2a05a47 --- /dev/null +++ b/azure-cognitiveservices/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for FaceClient. + * An API for face detection, verification, and identification. + */ +package com.microsoft.azure.cognitiveservices.vision.faceapi; diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java new file mode 100644 index 0000000000000..af54d6ee0c9f7 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceClient.java @@ -0,0 +1,146 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.AzureClient; +import com.microsoft.rest.RestClient; + +/** + * The interface for FaceClient class. + */ +public interface FaceClient { + /** + * Gets the REST client. + * + * @return the {@link RestClient} object. + */ + RestClient restClient(); + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + AzureClient getAzureClient(); + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + String userAgent(); + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * + * @return the endpoint value. + */ + String endpoint(); + + /** + * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).. + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + FaceClient withEndpoint(String endpoint); + + /** + * Gets Gets or sets the preferred language for the response.. + * + * @return the acceptLanguage value. + */ + String acceptLanguage(); + + /** + * Sets Gets or sets the preferred language for the response.. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + FaceClient withAcceptLanguage(String acceptLanguage); + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @return the longRunningOperationRetryTimeout value. + */ + int longRunningOperationRetryTimeout(); + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + FaceClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @return the generateClientRequestId value. + */ + boolean generateClientRequestId(); + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + FaceClient withGenerateClientRequestId(boolean generateClientRequestId); + + /** + * Gets the Faces object to access its operations. + * @return the Faces object. + */ + Faces faces(); + + /** + * Gets the PersonGroupPersons object to access its operations. + * @return the PersonGroupPersons object. + */ + PersonGroupPersons personGroupPersons(); + + /** + * Gets the PersonGroups object to access its operations. + * @return the PersonGroups object. + */ + PersonGroups personGroups(); + + /** + * Gets the FaceLists object to access its operations. + * @return the FaceLists object. + */ + FaceLists faceLists(); + + /** + * Gets the LargePersonGroupPersons object to access its operations. + * @return the LargePersonGroupPersons object. + */ + LargePersonGroupPersons largePersonGroupPersons(); + + /** + * Gets the LargePersonGroups object to access its operations. + * @return the LargePersonGroups object. + */ + LargePersonGroups largePersonGroups(); + + /** + * Gets the LargeFaceLists object to access its operations. + * @return the LargeFaceLists object. + */ + LargeFaceLists largeFaceLists(); + + /** + * Gets the Snapshots object to access its operations. + * @return the Snapshots object. + */ + Snapshots snapshots(); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java index 4c81ca14a1301..4c8ba40f1b050 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/FaceLists.java @@ -8,13 +8,13 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreateFaceListsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceListsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddFaceFromUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddFaceFromStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceList; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; import java.util.List; import java.util.UUID; import rx.Observable; @@ -28,95 +28,84 @@ public interface FaceLists { * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void create(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter); + void create(String faceListId); /** * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - - Observable createAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter); + ServiceFuture createAsync(String faceListId, final ServiceCallback serviceCallback); /** * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * - * @return the first stage of the create call - */ - FaceListsCreateDefinitionStages.WithFaceListId create(); - - /** - * Grouping of create definition stages. - */ - interface FaceListsCreateDefinitionStages { - /** - * The stage of the definition to be specify faceListId. - */ - interface WithFaceListId { - /** - * Id referencing a particular face list. - * - * @return next definition stage - */ - FaceListsCreateDefinitionStages.WithExecute withFaceListId(String faceListId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - FaceListsCreateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - FaceListsCreateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FaceListsCreateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); - - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } - - /** - * The entirety of create definition. - */ - interface FaceListsCreateDefinition extends - FaceListsCreateDefinitionStages.WithFaceListId, - FaceListsCreateDefinitionStages.WithExecute { - } + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String faceListId); + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String faceListId); + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String faceListId, String name, String userData); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String faceListId, String name, String userData); + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String faceListId, String name, String userData); /** * Retrieve a face list's information. @@ -129,6 +118,16 @@ interface FaceListsCreateDefinition extends */ FaceList get(String faceListId); + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String faceListId, final ServiceCallback serviceCallback); + /** * Retrieve a face list's information. * @@ -138,104 +137,100 @@ interface FaceListsCreateDefinition extends */ Observable getAsync(String faceListId); + /** + * Retrieve a face list's information. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the FaceList object + */ + Observable> getWithServiceResponseAsync(String faceListId); /** * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void update(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter); + void update(String faceListId); /** * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - - Observable updateAsync(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter); + ServiceFuture updateAsync(String faceListId, final ServiceCallback serviceCallback); /** * Update information of a face list. * - * @return the first stage of the update call + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - FaceListsUpdateDefinitionStages.WithFaceListId update(); + Observable updateAsync(String faceListId); /** - * Grouping of update definition stages. + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface FaceListsUpdateDefinitionStages { - /** - * The stage of the definition to be specify faceListId. - */ - interface WithFaceListId { - /** - * Id referencing a particular face list. - * - * @return next definition stage - */ - FaceListsUpdateDefinitionStages.WithExecute withFaceListId(String faceListId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - FaceListsUpdateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - FaceListsUpdateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FaceListsUpdateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); + Observable> updateWithServiceResponseAsync(String faceListId); + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String faceListId, String name, String userData); - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback); /** - * The entirety of update definition. + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface FaceListsUpdateDefinition extends - FaceListsUpdateDefinitionStages.WithFaceListId, - FaceListsUpdateDefinitionStages.WithExecute { - } + Observable updateAsync(String faceListId, String name, String userData); + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String faceListId, String name, String userData); /** - * Delete an existing face list according to faceListId. Persisted face images in the face list will - * also be deleted. + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. * * @param faceListId Id referencing a particular face list. * @throws IllegalArgumentException thrown if parameters fail the validation @@ -245,20 +240,35 @@ interface FaceListsUpdateDefinition extends void delete(String faceListId); /** - * Delete an existing face list according to faceListId. Persisted face images in the face list will - * also be deleted. + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. * * @param faceListId Id referencing a particular face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - Observable deleteAsync(String faceListId); + ServiceFuture deleteAsync(String faceListId, final ServiceCallback serviceCallback); + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String faceListId); + /** + * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String faceListId); /** - * Retrieve information about all existing face lists. Only faceListId, name and userData will be - * returned. + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. * * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server @@ -268,19 +278,32 @@ interface FaceListsUpdateDefinition extends List list(); /** - * Retrieve information about all existing face lists. Only faceListId, name and userData will be - * returned. + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. * * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<FaceList> object */ Observable> listAsync(); - + /** + * Retrieve information about all existing face lists. Only faceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<FaceList> object + */ + Observable>> listWithServiceResponseAsync(); /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted - * image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. @@ -291,245 +314,220 @@ interface FaceListsUpdateDefinition extends void deleteFace(String faceListId, UUID persistedFaceId); /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted - * image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteFaceAsync(String faceListId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceResponse} object if successful. */ Observable deleteFaceAsync(String faceListId, UUID persistedFaceId); + /** + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * + * @param faceListId Id referencing a particular face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String faceListId, UUID persistedFaceId); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String faceListId, String url); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String faceListId, String url, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String faceListId, String url); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String faceListId, String url, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace); /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. - * @param url Publicly reachable URL of an image. - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - - PersistedFace addFaceFromUrl(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter); + PersistedFace addFaceFromStream(String faceListId, byte[] image); /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. - * @param url Publicly reachable URL of an image. - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - - Observable addFaceFromUrlAsync(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter); - - /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. - * - * @return the first stage of the addFaceFromUrl call - */ - FaceListsAddFaceFromUrlDefinitionStages.WithFaceListId addFaceFromUrl(); - - /** - * Grouping of addFaceFromUrl definition stages. - */ - interface FaceListsAddFaceFromUrlDefinitionStages { - /** - * The stage of the definition to be specify faceListId. - */ - interface WithFaceListId { - /** - * Id referencing a particular face list. - * - * @return next definition stage - */ - WithUrl withFaceListId(String faceListId); - } - /** - * The stage of the definition to be specify url. - */ - interface WithUrl { - /** - * Publicly reachable URL of an image. - * - * @return next definition stage - */ - FaceListsAddFaceFromUrlDefinitionStages.WithExecute withUrl(String url); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User-specified data about the face for any purpose. The maximum length is 1KB. - * - * @return next definition stage - */ - FaceListsAddFaceFromUrlDefinitionStages.WithExecute withUserData(String userData); - - /** - * A face rectangle to specify the target face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the - * image, targetFace is required to specify which face to add. No targetFace means there is only one face - * detected in the entire image. - * - * @return next definition stage - */ - FaceListsAddFaceFromUrlDefinitionStages.WithExecute withTargetFace(List targetFace); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FaceListsAddFaceFromUrlDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the PersistedFace object if successful. - */ - PersistedFace execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the PersistedFace object - */ - Observable executeAsync(); - } - } - - /** - * The entirety of addFaceFromUrl definition. - */ - interface FaceListsAddFaceFromUrlDefinition extends - FaceListsAddFaceFromUrlDefinitionStages.WithFaceListId, - FaceListsAddFaceFromUrlDefinitionStages.WithUrl, - FaceListsAddFaceFromUrlDefinitionStages.WithExecute { - } - - /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. + Observable addFaceFromStreamAsync(String faceListId, byte[] image); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - - PersistedFace addFaceFromStream(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter); + PersistedFace addFaceFromStream(String faceListId, byte[] image, String userData, List targetFace); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace); /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - - Observable addFaceFromStreamAsync(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter); - - /** - * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a - * persistedFaceId representing the added face, and persistedFaceId will not expire. - * - * @return the first stage of the addFaceFromStream call - */ - FaceListsAddFaceFromStreamDefinitionStages.WithFaceListId addFaceFromStream(); - - /** - * Grouping of addFaceFromStream definition stages. - */ - interface FaceListsAddFaceFromStreamDefinitionStages { - /** - * The stage of the definition to be specify faceListId. - */ - interface WithFaceListId { - /** - * Id referencing a particular face list. - * - * @return next definition stage - */ - WithImage withFaceListId(String faceListId); - } - /** - * The stage of the definition to be specify image. - */ - interface WithImage { - /** - * An image stream. - * - * @return next definition stage - */ - FaceListsAddFaceFromStreamDefinitionStages.WithExecute withImage(byte[] image); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User-specified data about the face for any purpose. The maximum length is 1KB. - * - * @return next definition stage - */ - FaceListsAddFaceFromStreamDefinitionStages.WithExecute withUserData(String userData); - - /** - * A face rectangle to specify the target face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the - * image, targetFace is required to specify which face to add. No targetFace means there is only one face - * detected in the entire image. - * - * @return next definition stage - */ - FaceListsAddFaceFromStreamDefinitionStages.WithExecute withTargetFace(List targetFace); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FaceListsAddFaceFromStreamDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the PersistedFace object if successful. - */ - PersistedFace execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the PersistedFace object - */ - Observable executeAsync(); - } - } - - /** - * The entirety of addFaceFromStream definition. - */ - interface FaceListsAddFaceFromStreamDefinition extends - FaceListsAddFaceFromStreamDefinitionStages.WithFaceListId, - FaceListsAddFaceFromStreamDefinitionStages.WithImage, - FaceListsAddFaceFromStreamDefinitionStages.WithExecute { - } + Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image, String userData, List targetFace); } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java index 99629847497d7..d42c636eccef2 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Faces.java @@ -8,10 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FindSimilarOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectWithUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectWithStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectedFace; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FaceAttributeType; @@ -20,6 +16,10 @@ import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyResult; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SimilarFace; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.VerifyResult; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; import java.util.List; import java.util.UUID; import rx.Observable; @@ -30,126 +30,106 @@ */ public interface Faces { /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * - * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this - * faceId is not persisted and will expire 24 hours after the detection call. - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<SimilarFace> object if successful. */ - - List findSimilar(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter); + List findSimilar(UUID faceId); /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * - * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this - * faceId is not persisted and will expire 24 hours after the detection call. - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> findSimilarAsync(UUID faceId, final ServiceCallback> serviceCallback); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable> findSimilarAsync(UUID faceId); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable>> findSimilarWithServiceResponseAsync(UUID faceId); + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + List findSimilar(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> findSimilarAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode, final ServiceCallback> serviceCallback); + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<SimilarFace> object */ - - Observable> findSimilarAsync(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter); - - /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. - * - * @return the first stage of the findSimilar call - */ - FacesFindSimilarDefinitionStages.WithFaceId findSimilar(); - - /** - * Grouping of findSimilar definition stages. - */ - interface FacesFindSimilarDefinitionStages { - /** - * The stage of the definition to be specify faceId. - */ - interface WithFaceId { - /** - * FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this - * faceId is not persisted and will expire 24 hours after the detection call. - * - * @return next definition stage - */ - FacesFindSimilarDefinitionStages.WithExecute withFaceId(UUID faceId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list - * contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and - * faceIds should not be provided at the same time. - * - * @return next definition stage - */ - FacesFindSimilarDefinitionStages.WithExecute withFaceListId(String faceListId); - - /** - * An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours - * after the detection call. - * - * @return next definition stage - */ - FacesFindSimilarDefinitionStages.WithExecute withFaceIds(List faceIds); - - /** - * The number of top similar faces returned. The valid range is [1, 1000]. - * - * @return next definition stage - */ - FacesFindSimilarDefinitionStages.WithExecute withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned); - - /** - * Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', - * 'matchFace'. - * - * @return next definition stage - */ - FacesFindSimilarDefinitionStages.WithExecute withMode(FindSimilarMatchMode mode); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FacesFindSimilarDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<SimilarFace> object if successful. - */ - List execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the List<SimilarFace> object - */ - Observable> executeAsync(); - } - } - - /** - * The entirety of findSimilar definition. - */ - interface FacesFindSimilarDefinition extends - FacesFindSimilarDefinitionStages.WithFaceId, - FacesFindSimilarDefinitionStages.WithExecute { - } + Observable> findSimilarAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + Observable>> findSimilarWithServiceResponseAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode); /** * Divide candidate faces into groups based on face similarity. * - * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces. + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @@ -160,132 +140,129 @@ interface FacesFindSimilarDefinition extends /** * Divide candidate faces into groups based on face similarity. * - * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces. + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture groupAsync(List faceIds, final ServiceCallback serviceCallback); + + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the GroupResult object */ Observable groupAsync(List faceIds); + /** + * Divide candidate faces into groups based on face similarity. + * + * @param faceIds Array of candidate faceId created by Face - Detect. The maximum is 1000 faces + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the GroupResult object + */ + Observable> groupWithServiceResponseAsync(List faceIds); + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + List identify(List faceIds); + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> identifyAsync(List faceIds, final ServiceCallback> serviceCallback); + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable> identifyAsync(List faceIds); /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create. - * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. - * The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable>> identifyWithServiceResponseAsync(List faceIds); + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<IdentifyResult> object if successful. */ - - List identify(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter); + List identify(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create. - * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. - * The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> identifyAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold, final ServiceCallback> serviceCallback); + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<IdentifyResult> object */ - - Observable> identifyAsync(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter); - - /** - * Identify unknown faces from a person group. - * - * @return the first stage of the identify call - */ - FacesIdentifyDefinitionStages.WithPersonGroupId identify(); - - /** - * Grouping of identify definition stages. - */ - interface FacesIdentifyDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * PersonGroupId of the target person group, created by PersonGroups.Create. - * - * @return next definition stage - */ - WithFaceIds withPersonGroupId(String personGroupId); - } - /** - * The stage of the definition to be specify faceIds. - */ - interface WithFaceIds { - /** - * Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. - * The valid number of faceIds is between [1, 10]. - * - * @return next definition stage - */ - FacesIdentifyDefinitionStages.WithExecute withFaceIds(List faceIds); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). - * - * @return next definition stage - */ - FacesIdentifyDefinitionStages.WithExecute withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned); - - /** - * Confidence threshold of identification, used to judge whether one face belong to one person. The range of - * confidenceThreshold is [0, 1] (default specified by algorithm). - * - * @return next definition stage - */ - FacesIdentifyDefinitionStages.WithExecute withConfidenceThreshold(Double confidenceThreshold); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FacesIdentifyDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<IdentifyResult> object if successful. - */ - List execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the List<IdentifyResult> object - */ - Observable> executeAsync(); - } - } - - /** - * The entirety of identify definition. - */ - interface FacesIdentifyDefinition extends - FacesIdentifyDefinitionStages.WithPersonGroupId, - FacesIdentifyDefinitionStages.WithFaceIds, - FacesIdentifyDefinitionStages.WithExecute { - } + Observable> identifyAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + Observable>> identifyWithServiceResponseAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold); /** * Verify whether two faces belong to a same person or whether one face belongs to a person. * - * @param faceId1 FaceId of the first face, comes from Face - Detect. - * @param faceId2 FaceId of the second face, comes from Face - Detect. + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent @@ -296,256 +273,303 @@ interface FacesIdentifyDefinition extends /** * Verify whether two faces belong to a same person or whether one face belongs to a person. * - * @param faceId1 FaceId of the first face, comes from Face - Detect. - * @param faceId2 FaceId of the second face, comes from Face - Detect. + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture verifyFaceToFaceAsync(UUID faceId1, UUID faceId2, final ServiceCallback serviceCallback); + + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the VerifyResult object */ Observable verifyFaceToFaceAsync(UUID faceId1, UUID faceId2); + /** + * Verify whether two faces belong to a same person or whether one face belongs to a person. + * + * @param faceId1 FaceId of the first face, comes from Face - Detect + * @param faceId2 FaceId of the second face, comes from Face - Detect + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable> verifyFaceToFaceWithServiceResponseAsync(UUID faceId1, UUID faceId2); /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * - * @param url Publicly reachable URL of an image. - * @param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param url Publicly reachable URL of an image * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<DetectedFace> object if successful. */ - - List detectWithUrl(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter); + List detectWithUrl(String url); /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * - * @param url Publicly reachable URL of an image. - * @param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithUrlAsync(String url, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - - Observable> detectWithUrlAsync(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter); - - /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. - * - * @return the first stage of the detectWithUrl call - */ - FacesDetectWithUrlDefinitionStages.WithUrl detectWithUrl(); - - /** - * Grouping of detectWithUrl definition stages. - */ - interface FacesDetectWithUrlDefinitionStages { - /** - * The stage of the definition to be specify url. - */ - interface WithUrl { - /** - * Publicly reachable URL of an image. - * - * @return next definition stage - */ - FacesDetectWithUrlDefinitionStages.WithExecute withUrl(String url); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * A value indicating whether the operation should return faceIds of detected faces. - * - * @return next definition stage - */ - FacesDetectWithUrlDefinitionStages.WithExecute withReturnFaceId(Boolean returnFaceId); - - /** - * A value indicating whether the operation should return landmarks of the detected faces. - * - * @return next definition stage - */ - FacesDetectWithUrlDefinitionStages.WithExecute withReturnFaceLandmarks(Boolean returnFaceLandmarks); - - /** - * Analyze and return the one or more specified face attributes in the comma-separated string like - * "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, - * facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and - * time cost. - * - * @return next definition stage - */ - FacesDetectWithUrlDefinitionStages.WithExecute withReturnFaceAttributes(List returnFaceAttributes); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FacesDetectWithUrlDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<DetectedFace> object if successful. - */ - List execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the List<DetectedFace> object - */ - Observable> executeAsync(); - } - } - - /** - * The entirety of detectWithUrl definition. - */ - interface FacesDetectWithUrlDefinition extends - FacesDetectWithUrlDefinitionStages.WithUrl, - FacesDetectWithUrlDefinitionStages.WithExecute { - } + Observable> detectWithUrlAsync(String url); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithUrlWithServiceResponseAsync(String url); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithUrl(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithUrlWithServiceResponseAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect. - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is - * created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the VerifyResult object if successful. */ - VerifyResult verifyFaceToPerson(UUID faceId, String personGroupId, UUID personId); + VerifyResult verifyFaceToPerson(UUID faceId, UUID personId); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture verifyFaceToPersonAsync(UUID faceId, UUID personId, final ServiceCallback serviceCallback); /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect. - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is - * created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the VerifyResult object */ - Observable verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId); + Observable verifyFaceToPersonAsync(UUID faceId, UUID personId); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, UUID personId); + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the VerifyResult object if successful. + */ + VerifyResult verifyFaceToPerson(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId); + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture verifyFaceToPersonAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId, final ServiceCallback serviceCallback); /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable verifyFaceToPersonAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId); + + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param image An image stream. - * @param detectWithStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<DetectedFace> object if successful. */ - - List detectWithStream(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter); + List detectWithStream(byte[] image); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithStreamAsync(byte[] image, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithStreamAsync(byte[] image); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable>> detectWithStreamWithServiceResponseAsync(byte[] image); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + List detectWithStream(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback); + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + Observable> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param image An image stream. - * @param detectWithStreamOptionalParameter the object representing the optional parameters to be set before calling this API + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - - Observable> detectWithStreamAsync(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter); - - /** - * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and - * attributes. - * - * @return the first stage of the detectWithStream call - */ - FacesDetectWithStreamDefinitionStages.WithImage detectWithStream(); - - /** - * Grouping of detectWithStream definition stages. - */ - interface FacesDetectWithStreamDefinitionStages { - /** - * The stage of the definition to be specify image. - */ - interface WithImage { - /** - * An image stream. - * - * @return next definition stage - */ - FacesDetectWithStreamDefinitionStages.WithExecute withImage(byte[] image); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * A value indicating whether the operation should return faceIds of detected faces. - * - * @return next definition stage - */ - FacesDetectWithStreamDefinitionStages.WithExecute withReturnFaceId(Boolean returnFaceId); - - /** - * A value indicating whether the operation should return landmarks of the detected faces. - * - * @return next definition stage - */ - FacesDetectWithStreamDefinitionStages.WithExecute withReturnFaceLandmarks(Boolean returnFaceLandmarks); - - /** - * Analyze and return the one or more specified face attributes in the comma-separated string like - * "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, - * facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and - * time cost. - * - * @return next definition stage - */ - FacesDetectWithStreamDefinitionStages.WithExecute withReturnFaceAttributes(List returnFaceAttributes); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends FacesDetectWithStreamDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<DetectedFace> object if successful. - */ - List execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the List<DetectedFace> object - */ - Observable> executeAsync(); - } - } - - /** - * The entirety of detectWithStream definition. - */ - interface FacesDetectWithStreamDefinition extends - FacesDetectWithStreamDefinitionStages.WithImage, - FacesDetectWithStreamDefinitionStages.WithExecute { - } + Observable>> detectWithStreamWithServiceResponseAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes); } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceListFaces.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceListFaces.java new file mode 100644 index 0000000000000..2e518ca0a5d89 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceListFaces.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargeFaceListFaces. + */ +public interface LargeFaceListFaces { + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + List list(String largeFaceListId); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String largeFaceListId, final ServiceCallback> serviceCallback); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable> listAsync(String largeFaceListId); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable>> listWithServiceResponseAsync(String largeFaceListId); + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + List list(String largeFaceListId, String start, Integer top); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String largeFaceListId, String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable> listAsync(String largeFaceListId, String start, Integer top); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable>> listWithServiceResponseAsync(String largeFaceListId, String start, Integer top); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceLists.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceLists.java new file mode 100644 index 0000000000000..05e86da4c65cd --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargeFaceLists.java @@ -0,0 +1,826 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.LargeFaceList; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargeFaceLists. + */ +public interface LargeFaceLists { + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String largeFaceListId); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String largeFaceListId); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String largeFaceListId); + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String largeFaceListId, String name, String userData); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largeFaceListId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String largeFaceListId, String name, String userData); + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String largeFaceListId, String name, String userData); + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LargeFaceList object if successful. + */ + LargeFaceList get(String largeFaceListId); + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargeFaceList object + */ + Observable getAsync(String largeFaceListId); + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargeFaceList object + */ + Observable> getWithServiceResponseAsync(String largeFaceListId); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largeFaceListId); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largeFaceListId); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largeFaceListId); + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largeFaceListId, String name, String userData); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largeFaceListId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largeFaceListId, String name, String userData); + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largeFaceListId, String name, String userData); + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String largeFaceListId); + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String largeFaceListId); + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String largeFaceListId); + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + TrainingStatus getTrainingStatus(String largeFaceListId); + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getTrainingStatusAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable getTrainingStatusAsync(String largeFaceListId); + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable> getTrainingStatusWithServiceResponseAsync(String largeFaceListId); + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargeFaceList> object if successful. + */ + List list(); + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargeFaceList> object + */ + Observable> listAsync(); + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargeFaceList> object + */ + Observable>> listWithServiceResponseAsync(); + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void train(String largeFaceListId); + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture trainAsync(String largeFaceListId, final ServiceCallback serviceCallback); + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable trainAsync(String largeFaceListId); + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> trainWithServiceResponseAsync(String largeFaceListId); + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void deleteFace(String largeFaceListId, UUID persistedFaceId); + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteFaceAsync(String largeFaceListId, UUID persistedFaceId); + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace getFace(String largeFaceListId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable getFaceAsync(String largeFaceListId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> getFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String largeFaceListId, UUID persistedFaceId); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String largeFaceListId, UUID persistedFaceId); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId); + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String largeFaceListId, UUID persistedFaceId, String userData); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String largeFaceListId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String largeFaceListId, UUID persistedFaceId, String userData); + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId, String userData); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String largeFaceListId, String url); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String largeFaceListId, String url, final ServiceCallback serviceCallback); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String largeFaceListId, String url); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String largeFaceListId, String url); + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String largeFaceListId, String url, String userData, List targetFace); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String largeFaceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String largeFaceListId, String url, String userData, List targetFace); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String largeFaceListId, String url, String userData, List targetFace); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + List listFaces(String largeFaceListId); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listFacesAsync(String largeFaceListId, final ServiceCallback> serviceCallback); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable> listFacesAsync(String largeFaceListId); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable>> listFacesWithServiceResponseAsync(String largeFaceListId); + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + List listFaces(String largeFaceListId, String start, Integer top); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listFacesAsync(String largeFaceListId, String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable> listFacesAsync(String largeFaceListId, String start, Integer top); + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + Observable>> listFacesWithServiceResponseAsync(String largeFaceListId, String start, Integer top); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String largeFaceListId, byte[] image); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String largeFaceListId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String largeFaceListId, byte[] image); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String largeFaceListId, byte[] image); + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String largeFaceListId, byte[] image, String userData, List targetFace); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String largeFaceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String largeFaceListId, byte[] image, String userData, List targetFace); + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String largeFaceListId, byte[] image, String userData, List targetFace); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroupPersons.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroupPersons.java new file mode 100644 index 0000000000000..42c58b38b6284 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroupPersons.java @@ -0,0 +1,763 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargePersonGroupPersons. + */ +public interface LargePersonGroupPersons { + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person create(String largePersonGroupId); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable createAsync(String largePersonGroupId); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> createWithServiceResponseAsync(String largePersonGroupId); + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person create(String largePersonGroupId, String name, String userData); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable createAsync(String largePersonGroupId, String name, String userData); + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> createWithServiceResponseAsync(String largePersonGroupId, String name, String userData); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String largePersonGroupId); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String largePersonGroupId, final ServiceCallback> serviceCallback); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable> listAsync(String largePersonGroupId); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String largePersonGroupId); + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String largePersonGroupId, String start, Integer top); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String largePersonGroupId, String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable> listAsync(String largePersonGroupId, String start, Integer top); + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String largePersonGroupId, String start, Integer top); + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String largePersonGroupId, UUID personId); + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String largePersonGroupId, UUID personId); + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String largePersonGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + Person get(String largePersonGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable getAsync(String largePersonGroupId, UUID personId); + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> getWithServiceResponseAsync(String largePersonGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largePersonGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largePersonGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largePersonGroupId, UUID personId); + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largePersonGroupId, UUID personId, String name, String userData); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largePersonGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largePersonGroupId, UUID personId, String name, String userData); + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largePersonGroupId, UUID personId, String name, String userData); + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void deleteFace(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace getFace(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable getFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> getFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId); + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String largePersonGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String largePersonGroupId, UUID personId, String url); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String largePersonGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String largePersonGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String largePersonGroupId, UUID personId, byte[] image); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroups.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroups.java new file mode 100644 index 0000000000000..aff5d58905561 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/LargePersonGroups.java @@ -0,0 +1,423 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.LargePersonGroup; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargePersonGroups. + */ +public interface LargePersonGroups { + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String largePersonGroupId); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String largePersonGroupId); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String largePersonGroupId); + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String largePersonGroupId, String name, String userData); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable createAsync(String largePersonGroupId, String name, String userData); + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String largePersonGroupId, String name, String userData); + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(String largePersonGroupId); + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String largePersonGroupId); + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String largePersonGroupId); + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LargePersonGroup object if successful. + */ + LargePersonGroup get(String largePersonGroupId); + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargePersonGroup object + */ + Observable getAsync(String largePersonGroupId); + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargePersonGroup object + */ + Observable> getWithServiceResponseAsync(String largePersonGroupId); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largePersonGroupId); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largePersonGroupId); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largePersonGroupId); + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String largePersonGroupId, String name, String userData); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String largePersonGroupId, String name, String userData); + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String largePersonGroupId, String name, String userData); + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + TrainingStatus getTrainingStatus(String largePersonGroupId); + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getTrainingStatusAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable getTrainingStatusAsync(String largePersonGroupId); + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable> getTrainingStatusWithServiceResponseAsync(String largePersonGroupId); + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargePersonGroup> object if successful. + */ + List list(); + + /** + * List large person groups and their information. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + Observable> listAsync(); + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + Observable>> listWithServiceResponseAsync(); + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargePersonGroup> object if successful. + */ + List list(String start, Integer top); + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback); + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + Observable> listAsync(String start, Integer top); + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + Observable>> listWithServiceResponseAsync(String start, Integer top); + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void train(String largePersonGroupId); + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture trainAsync(String largePersonGroupId, final ServiceCallback serviceCallback); + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable trainAsync(String largePersonGroupId); + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> trainWithServiceResponseAsync(String largePersonGroupId); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java index 851f772de3c48..22ab0c2391e0b 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroupPersons.java @@ -8,15 +8,13 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreatePersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ListPersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddPersonFaceFromUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddPersonFaceFromStreamOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; import java.util.List; import java.util.UUID; import rx.Observable; @@ -30,199 +28,174 @@ public interface PersonGroupPersons { * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the Person object if successful. */ - - Person create(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter); + Person create(String personGroupId); + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback); /** * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the Person object */ - - Observable createAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter); + Observable createAsync(String personGroupId); /** * Create a new person in a specified person group. * - * @return the first stage of the create call - */ - PersonGroupPersonsCreateDefinitionStages.WithPersonGroupId create(); - - /** - * Grouping of create definition stages. - */ - interface PersonGroupPersonsCreateDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - PersonGroupPersonsCreateDefinitionStages.WithExecute withPersonGroupId(String personGroupId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - PersonGroupPersonsCreateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - PersonGroupPersonsCreateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsCreateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the Person object if successful. - */ - Person execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the Person object - */ - Observable executeAsync(); - } - } - - /** - * The entirety of create definition. - */ - interface PersonGroupPersonsCreateDefinition extends - PersonGroupPersonsCreateDefinitionStages.WithPersonGroupId, - PersonGroupPersonsCreateDefinitionStages.WithExecute { - } - - /** - * List all persons in a person group, and retrieve person information (including personId, name, userData and - * persistedFaceIds of registered faces of the person). - * - * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> createWithServiceResponseAsync(String personGroupId); + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent - * @return the List<Person> object if successful. + * @return the Person object if successful. */ - - List list(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter); + Person create(String personGroupId, String name, String userData); /** - * List all persons in a person group, and retrieve person information (including personId, name, userData and - * persistedFaceIds of registered faces of the person). + * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<Person> object + * @return the {@link ServiceFuture} object */ - - Observable> listAsync(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter); + ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); /** - * List all persons in a person group, and retrieve person information (including personId, name, userData and - * persistedFaceIds of registered faces of the person). + * Create a new person in a specified person group. * - * @return the first stage of the list call + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object */ - PersonGroupPersonsListDefinitionStages.WithPersonGroupId list(); + Observable createAsync(String personGroupId, String name, String userData); /** - * Grouping of list definition stages. + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object */ - interface PersonGroupPersonsListDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - PersonGroupPersonsListDefinitionStages.WithExecute withPersonGroupId(String personGroupId); - } + Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData); - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * Starting person id to return (used to list a range of persons). - * - * @return next definition stage - */ - PersonGroupPersonsListDefinitionStages.WithExecute withStart(String start); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String personGroupId); - /** - * Number of persons to return starting with the person id indicated by the 'start' parameter. - * - * @return next definition stage - */ - PersonGroupPersonsListDefinitionStages.WithExecute withTop(Integer top); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String personGroupId, final ServiceCallback> serviceCallback); - } + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable> listAsync(String personGroupId); - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsListDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<Person> object if successful. - */ - List execute(); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String personGroupId); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + List list(String personGroupId, String start, Integer top); - /** - * Execute the request asynchronously. - * - * @return the observable to the List<Person> object - */ - Observable> executeAsync(); - } - } + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String personGroupId, String start, Integer top, final ServiceCallback> serviceCallback); /** - * The entirety of list definition. + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object */ - interface PersonGroupPersonsListDefinition extends - PersonGroupPersonsListDefinitionStages.WithPersonGroupId, - PersonGroupPersonsListDefinitionStages.WithExecute { - } + Observable> listAsync(String personGroupId, String start, Integer top); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + Observable>> listWithServiceResponseAsync(String personGroupId, String start, Integer top); /** - * Delete an existing person from a person group. Persisted face images of the person will also be - * deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -233,17 +206,35 @@ interface PersonGroupPersonsListDefinition extends void delete(String personGroupId, UUID personId); /** - * Delete an existing person from a person group. Persisted face images of the person will also be - * deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - Observable deleteAsync(String personGroupId, UUID personId); + ServiceFuture deleteAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + /** + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String personGroupId, UUID personId); + /** + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String personGroupId, UUID personId); /** * Retrieve a person's information, including registered persisted faces, name and userData. @@ -257,6 +248,17 @@ interface PersonGroupPersonsListDefinition extends */ Person get(String personGroupId, UUID personId); + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + /** * Retrieve a person's information, including registered persisted faces, name and userData. * @@ -267,117 +269,109 @@ interface PersonGroupPersonsListDefinition extends */ Observable getAsync(String personGroupId, UUID personId); + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + Observable> getWithServiceResponseAsync(String personGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId, UUID personId); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId, UUID personId); /** * Update name or userData of a person. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId); + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void update(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter); + void update(String personGroupId, UUID personId, String name, String userData); /** * Update name or userData of a person. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - - Observable updateAsync(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter); + ServiceFuture updateAsync(String personGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback); /** * Update name or userData of a person. * - * @return the first stage of the update call - */ - PersonGroupPersonsUpdateDefinitionStages.WithPersonGroupId update(); - - /** - * Grouping of update definition stages. - */ - interface PersonGroupPersonsUpdateDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - WithPersonId withPersonGroupId(String personGroupId); - } - /** - * The stage of the definition to be specify personId. - */ - interface WithPersonId { - /** - * Id referencing a particular person. - * - * @return next definition stage - */ - PersonGroupPersonsUpdateDefinitionStages.WithExecute withPersonId(UUID personId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - PersonGroupPersonsUpdateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - PersonGroupPersonsUpdateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsUpdateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); - - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } - - /** - * The entirety of update definition. - */ - interface PersonGroupPersonsUpdateDefinition extends - PersonGroupPersonsUpdateDefinitionStages.WithPersonGroupId, - PersonGroupPersonsUpdateDefinitionStages.WithPersonId, - PersonGroupPersonsUpdateDefinitionStages.WithExecute { - } - - - /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(String personGroupId, UUID personId, String name, String userData); + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId, String name, String userData); + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -389,21 +383,41 @@ interface PersonGroupPersonsUpdateDefinition extends void deleteFace(String personGroupId, UUID personId, UUID persistedFaceId); /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - Observable deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + ServiceFuture deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); /** - * Retrieve information about a persisted face (specified by persistedFaceId, personId and its - * belonging personGroupId). + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -416,8 +430,19 @@ interface PersonGroupPersonsUpdateDefinition extends PersistedFace getFace(String personGroupId, UUID personId, UUID persistedFaceId); /** - * Retrieve information about a persisted face (specified by persistedFaceId, personId and its - * belonging personGroupId). + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -427,6 +452,16 @@ interface PersonGroupPersonsUpdateDefinition extends */ Observable getFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId). + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> getFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); /** * Update a person persisted face's userData field. @@ -434,13 +469,70 @@ interface PersonGroupPersonsUpdateDefinition extends * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter); + void updateFace(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId); + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback); /** * Update a person persisted face's userData field. @@ -448,356 +540,224 @@ interface PersonGroupPersonsUpdateDefinition extends * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API + * @param userData User-provided data attached to the face. The size limit is 1KB. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceResponse} object if successful. */ - - Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter); + Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData); /** * Update a person persisted face's userData field. * - * @return the first stage of the updateFace call - */ - PersonGroupPersonsUpdateFaceDefinitionStages.WithPersonGroupId updateFace(); - - /** - * Grouping of updateFace definition stages. - */ - interface PersonGroupPersonsUpdateFaceDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - WithPersonId withPersonGroupId(String personGroupId); - } - /** - * The stage of the definition to be specify personId. - */ - interface WithPersonId { - /** - * Id referencing a particular person. - * - * @return next definition stage - */ - WithPersistedFaceId withPersonId(UUID personId); - } - /** - * The stage of the definition to be specify persistedFaceId. - */ - interface WithPersistedFaceId { - /** - * Id referencing a particular persistedFaceId of an existing face. - * - * @return next definition stage - */ - PersonGroupPersonsUpdateFaceDefinitionStages.WithExecute withPersistedFaceId(UUID persistedFaceId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User-provided data attached to the face. The size limit is 1KB. - * - * @return next definition stage - */ - PersonGroupPersonsUpdateFaceDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsUpdateFaceDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); - - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } - - /** - * The entirety of updateFace definition. - */ - interface PersonGroupPersonsUpdateFaceDefinition extends - PersonGroupPersonsUpdateFaceDefinitionStages.WithPersonGroupId, - PersonGroupPersonsUpdateFaceDefinitionStages.WithPersonId, - PersonGroupPersonsUpdateFaceDefinitionStages.WithPersistedFaceId, - PersonGroupPersonsUpdateFaceDefinitionStages.WithExecute { - } - - /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. - * - * @param personGroupId Id referencing a particular person group. - * @param personId Id referencing a particular person. - * @param url Publicly reachable URL of an image. - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - - PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter); + PersistedFace addFaceFromUrl(String personGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String personGroupId, UUID personId, String url, final ServiceCallback serviceCallback); /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param url Publicly reachable URL of an image. - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API + * @param url Publicly reachable URL of an image * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - - Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter); - - /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. - * - * @return the first stage of the addPersonFaceFromUrl call - */ - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithPersonGroupId addPersonFaceFromUrl(); - - /** - * Grouping of addPersonFaceFromUrl definition stages. - */ - interface PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - WithPersonId withPersonGroupId(String personGroupId); - } - /** - * The stage of the definition to be specify personId. - */ - interface WithPersonId { - /** - * Id referencing a particular person. - * - * @return next definition stage - */ - WithUrl withPersonId(UUID personId); - } - /** - * The stage of the definition to be specify url. - */ - interface WithUrl { - /** - * Publicly reachable URL of an image. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithExecute withUrl(String url); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User-specified data about the face for any purpose. The maximum length is 1KB. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithExecute withUserData(String userData); - - /** - * A face rectangle to specify the target face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the - * image, targetFace is required to specify which face to add. No targetFace means there is only one face - * detected in the entire image. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithExecute withTargetFace(List targetFace); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the PersistedFace object if successful. - */ - PersistedFace execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the PersistedFace object - */ - Observable executeAsync(); - } - } - - /** - * The entirety of addPersonFaceFromUrl definition. - */ - interface PersonGroupPersonsAddPersonFaceFromUrlDefinition extends - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithPersonGroupId, - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithPersonId, - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithUrl, - PersonGroupPersonsAddPersonFaceFromUrlDefinitionStages.WithExecute { - } - - /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. + Observable addFaceFromUrlAsync(String personGroupId, UUID personId, String url); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromUrl(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - - PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter); + PersistedFace addFaceFromStream(String personGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable> addFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + PersistedFace addFaceFromStream(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback); + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + Observable addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - - Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter); - - /** - * Add a representative face to a person for identification. The input face is specified as an image with a - * targetFace rectangle. - * - * @return the first stage of the addPersonFaceFromStream call - */ - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithPersonGroupId addPersonFaceFromStream(); - - /** - * Grouping of addPersonFaceFromStream definition stages. - */ - interface PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - WithPersonId withPersonGroupId(String personGroupId); - } - /** - * The stage of the definition to be specify personId. - */ - interface WithPersonId { - /** - * Id referencing a particular person. - * - * @return next definition stage - */ - WithImage withPersonId(UUID personId); - } - /** - * The stage of the definition to be specify image. - */ - interface WithImage { - /** - * An image stream. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithExecute withImage(byte[] image); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User-specified data about the face for any purpose. The maximum length is 1KB. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithExecute withUserData(String userData); - - /** - * A face rectangle to specify the target face to be added to a person in the format of - * "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the - * image, targetFace is required to specify which face to add. No targetFace means there is only one face - * detected in the entire image. - * - * @return next definition stage - */ - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithExecute withTargetFace(List targetFace); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the PersistedFace object if successful. - */ - PersistedFace execute(); - - /** - * Execute the request asynchronously. - * - * @return the observable to the PersistedFace object - */ - Observable executeAsync(); - } - } - - /** - * The entirety of addPersonFaceFromStream definition. - */ - interface PersonGroupPersonsAddPersonFaceFromStreamDefinition extends - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithPersonGroupId, - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithPersonId, - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithImage, - PersonGroupPersonsAddPersonFaceFromStreamDefinitionStages.WithExecute { - } + Observable> addFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace); } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java index 59496a6f4ca82..d6464459900d1 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/PersonGroups.java @@ -8,12 +8,13 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreatePersonGroupsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonGroupsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ListPersonGroupsOptionalParameter; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersonGroup; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; import java.util.List; import rx.Observable; @@ -26,99 +27,87 @@ public interface PersonGroups { * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void create(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter); + void create(String personGroupId); /** * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - - Observable createAsync(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter); + ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback); /** * Create a new person group with specified personGroupId, name and user-provided userData. * - * @return the first stage of the create call + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - PersonGroupsCreateDefinitionStages.WithPersonGroupId create(); + Observable createAsync(String personGroupId); /** - * Grouping of create definition stages. + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface PersonGroupsCreateDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - PersonGroupsCreateDefinitionStages.WithExecute withPersonGroupId(String personGroupId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - PersonGroupsCreateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - PersonGroupsCreateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupsCreateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); + Observable> createWithServiceResponseAsync(String personGroupId); + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void create(String personGroupId, String name, String userData); - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); /** - * The entirety of create definition. + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface PersonGroupsCreateDefinition extends - PersonGroupsCreateDefinitionStages.WithPersonGroupId, - PersonGroupsCreateDefinitionStages.WithExecute { - } + Observable createAsync(String personGroupId, String name, String userData); + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData); /** - * Delete an existing person group. Persisted face images of all people in the person group will also - * be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. * @throws IllegalArgumentException thrown if parameters fail the validation @@ -128,16 +117,32 @@ interface PersonGroupsCreateDefinition extends void delete(String personGroupId); /** - * Delete an existing person group. Persisted face images of all people in the person group will also - * be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - Observable deleteAsync(String personGroupId); + ServiceFuture deleteAsync(String personGroupId, final ServiceCallback serviceCallback); + /** + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(String personGroupId); + /** + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(String personGroupId); /** * Retrieve the information of a person group, including its name and userData. @@ -150,6 +155,16 @@ interface PersonGroupsCreateDefinition extends */ PersonGroup get(String personGroupId); + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(String personGroupId, final ServiceCallback serviceCallback); + /** * Retrieve the information of a person group, including its name and userData. * @@ -159,103 +174,97 @@ interface PersonGroupsCreateDefinition extends */ Observable getAsync(String personGroupId); + /** + * Retrieve the information of a person group, including its name and userData. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersonGroup object + */ + Observable> getWithServiceResponseAsync(String personGroupId); /** - * Update an existing person group's display name and userData. The properties which does not appear in request - * body will not be updated. + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - - void update(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter); + void update(String personGroupId); /** - * Update an existing person group's display name and userData. The properties which does not appear in request - * body will not be updated. + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceFuture} object */ - - Observable updateAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter); + ServiceFuture updateAsync(String personGroupId, final ServiceCallback serviceCallback); /** - * Update an existing person group's display name and userData. The properties which does not appear in request - * body will not be updated. + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * - * @return the first stage of the update call + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - PersonGroupsUpdateDefinitionStages.WithPersonGroupId update(); + Observable updateAsync(String personGroupId); /** - * Grouping of update definition stages. + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface PersonGroupsUpdateDefinitionStages { - /** - * The stage of the definition to be specify personGroupId. - */ - interface WithPersonGroupId { - /** - * Id referencing a particular person group. - * - * @return next definition stage - */ - PersonGroupsUpdateDefinitionStages.WithExecute withPersonGroupId(String personGroupId); - } - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * User defined name, maximum length is 128. - * - * @return next definition stage - */ - PersonGroupsUpdateDefinitionStages.WithExecute withName(String name); - - /** - * User specified data. Length should not exceed 16KB. - * - * @return next definition stage - */ - PersonGroupsUpdateDefinitionStages.WithExecute withUserData(String userData); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupsUpdateDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - */ - void execute(); + Observable> updateWithServiceResponseAsync(String personGroupId); + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(String personGroupId, String name, String userData); - /** - * Execute the request asynchronously. - * - * @return a representation of the deferred computation of this call if successful. - */ - Observable executeAsync(); - } - } + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback); /** - * The entirety of update definition. + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. */ - interface PersonGroupsUpdateDefinition extends - PersonGroupsUpdateDefinitionStages.WithPersonGroupId, - PersonGroupsUpdateDefinitionStages.WithExecute { - } + Observable updateAsync(String personGroupId, String name, String userData); + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(String personGroupId, String name, String userData); /** * Retrieve the training status of a person group (completed or ongoing). @@ -268,6 +277,16 @@ interface PersonGroupsUpdateDefinition extends */ TrainingStatus getTrainingStatus(String personGroupId); + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getTrainingStatusAsync(String personGroupId, final ServiceCallback serviceCallback); + /** * Retrieve the training status of a person group (completed or ongoing). * @@ -277,88 +296,91 @@ interface PersonGroupsUpdateDefinition extends */ Observable getTrainingStatusAsync(String personGroupId); + /** + * Retrieve the training status of a person group (completed or ongoing). + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + Observable> getTrainingStatusWithServiceResponseAsync(String personGroupId); /** * List person groups and their information. * - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<PersonGroup> object if successful. */ - - List list(ListPersonGroupsOptionalParameter listOptionalParameter); + List list(); /** * List person groups and their information. * - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return the observable to the List<PersonGroup> object + * @return the {@link ServiceFuture} object */ - - Observable> listAsync(ListPersonGroupsOptionalParameter listOptionalParameter); + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); /** * List person groups and their information. * - * @return the first stage of the list call + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object */ - PersonGroupsListDefinitionStages.WithExecute list(); + Observable> listAsync(); /** - * Grouping of list definition stages. + * List person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object */ - interface PersonGroupsListDefinitionStages { - - /** - * The stage of the definition which allows for any other optional settings to be specified. - */ - interface WithAllOptions { - /** - * List person groups from the least personGroupId greater than the "start". - * - * @return next definition stage - */ - PersonGroupsListDefinitionStages.WithExecute withStart(String start); - - /** - * The number of person groups to list. - * - * @return next definition stage - */ - PersonGroupsListDefinitionStages.WithExecute withTop(Integer top); - - } - - /** - * The last stage of the definition which will make the operation call. - */ - interface WithExecute extends PersonGroupsListDefinitionStages.WithAllOptions { - /** - * Execute the request. - * - * @return the List<PersonGroup> object if successful. - */ - List execute(); + Observable>> listWithServiceResponseAsync(); + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + List list(String start, Integer top); - /** - * Execute the request asynchronously. - * - * @return the observable to the List<PersonGroup> object - */ - Observable> executeAsync(); - } - } + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback); /** - * The entirety of list definition. + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object */ - interface PersonGroupsListDefinition extends - PersonGroupsListDefinitionStages.WithExecute { - } + Observable> listAsync(String start, Integer top); + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + Observable>> listWithServiceResponseAsync(String start, Integer top); /** * Queue a person group training task, the training task may not be started immediately. @@ -370,14 +392,32 @@ interface PersonGroupsListDefinition extends */ void train(String personGroupId); + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture trainAsync(String personGroupId, final ServiceCallback serviceCallback); + /** * Queue a person group training task, the training task may not be started immediately. * * @param personGroupId Id referencing a particular person group. * @throws IllegalArgumentException thrown if parameters fail the validation - * @return a representation of the deferred computation of this call if successful. + * @return the {@link ServiceResponse} object if successful. */ Observable trainAsync(String personGroupId); + /** + * Queue a person group training task, the training task may not be started immediately. + * + * @param personGroupId Id referencing a particular person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> trainWithServiceResponseAsync(String personGroupId); } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Snapshots.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Snapshots.java new file mode 100644 index 0000000000000..a059629555bac --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Snapshots.java @@ -0,0 +1,610 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi; + +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.OperationStatus; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Snapshot; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotApplyHeaders; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotApplyMode; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotObjectType; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotTakeHeaders; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseWithHeaders; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Snapshots. + */ +public interface Snapshots { + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void take(SnapshotObjectType type, String objectId, List applyScope); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture takeAsync(SnapshotObjectType type, String objectId, List applyScope, final ServiceCallback serviceCallback); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable takeAsync(SnapshotObjectType type, String objectId, List applyScope); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable> takeWithServiceResponseAsync(SnapshotObjectType type, String objectId, List applyScope); + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void take(SnapshotObjectType type, String objectId, List applyScope, String userData); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture takeAsync(SnapshotObjectType type, String objectId, List applyScope, String userData, final ServiceCallback serviceCallback); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable takeAsync(SnapshotObjectType type, String objectId, List applyScope, String userData); + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable> takeWithServiceResponseAsync(SnapshotObjectType type, String objectId, List applyScope, String userData); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Snapshot> object if successful. + */ + List list(); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(final ServiceCallback> serviceCallback); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + Observable> listAsync(); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + Observable>> listWithServiceResponseAsync(); + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Snapshot> object if successful. + */ + List list(SnapshotObjectType type, List applyScope); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture> listAsync(SnapshotObjectType type, List applyScope, final ServiceCallback> serviceCallback); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + Observable> listAsync(SnapshotObjectType type, List applyScope); + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + Observable>> listWithServiceResponseAsync(SnapshotObjectType type, List applyScope); + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Snapshot object if successful. + */ + Snapshot get(UUID snapshotId); + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getAsync(UUID snapshotId, final ServiceCallback serviceCallback); + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Snapshot object + */ + Observable getAsync(UUID snapshotId); + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Snapshot object + */ + Observable> getWithServiceResponseAsync(UUID snapshotId); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(UUID snapshotId); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(UUID snapshotId, final ServiceCallback serviceCallback); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(UUID snapshotId); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(UUID snapshotId); + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void update(UUID snapshotId, List applyScope, String userData); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture updateAsync(UUID snapshotId, List applyScope, String userData, final ServiceCallback serviceCallback); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable updateAsync(UUID snapshotId, List applyScope, String userData); + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> updateWithServiceResponseAsync(UUID snapshotId, List applyScope, String userData); + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void delete(UUID snapshotId); + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture deleteAsync(UUID snapshotId, final ServiceCallback serviceCallback); + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable deleteAsync(UUID snapshotId); + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + Observable> deleteWithServiceResponseAsync(UUID snapshotId); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void apply(UUID snapshotId, String objectId); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture applyAsync(UUID snapshotId, String objectId, final ServiceCallback serviceCallback); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable applyAsync(UUID snapshotId, String objectId); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable> applyWithServiceResponseAsync(UUID snapshotId, String objectId); + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + void apply(UUID snapshotId, String objectId, SnapshotApplyMode mode); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture applyAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode, final ServiceCallback serviceCallback); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable applyAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode); + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + Observable> applyWithServiceResponseAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode); + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the OperationStatus object if successful. + */ + OperationStatus getOperationStatus(UUID operationId); + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture getOperationStatusAsync(UUID operationId, final ServiceCallback serviceCallback); + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the OperationStatus object + */ + Observable getOperationStatusAsync(UUID operationId); + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the OperationStatus object + */ + Observable> getOperationStatusWithServiceResponseAsync(UUID operationId); + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java new file mode 100644 index 0000000000000..8561ce2e91212 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceClientImpl.java @@ -0,0 +1,290 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceClient; +import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists; +import com.microsoft.azure.cognitiveservices.vision.faceapi.Faces; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons; +import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups; +import com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the FaceClientImpl class. + */ +public class FaceClientImpl extends AzureServiceClient implements FaceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). */ + private String endpoint; + + /** + * Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * + * @return the endpoint value. + */ + public String endpoint() { + return this.endpoint; + } + + /** + * Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com). + * + * @param endpoint the endpoint value. + * @return the service client itself + */ + public FaceClientImpl withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public FaceClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public FaceClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public FaceClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The Faces object to access its operations. + */ + private Faces faces; + + /** + * Gets the Faces object to access its operations. + * @return the Faces object. + */ + public Faces faces() { + return this.faces; + } + + /** + * The PersonGroupPersons object to access its operations. + */ + private PersonGroupPersons personGroupPersons; + + /** + * Gets the PersonGroupPersons object to access its operations. + * @return the PersonGroupPersons object. + */ + public PersonGroupPersons personGroupPersons() { + return this.personGroupPersons; + } + + /** + * The PersonGroups object to access its operations. + */ + private PersonGroups personGroups; + + /** + * Gets the PersonGroups object to access its operations. + * @return the PersonGroups object. + */ + public PersonGroups personGroups() { + return this.personGroups; + } + + /** + * The FaceLists object to access its operations. + */ + private FaceLists faceLists; + + /** + * Gets the FaceLists object to access its operations. + * @return the FaceLists object. + */ + public FaceLists faceLists() { + return this.faceLists; + } + + /** + * The LargePersonGroupPersons object to access its operations. + */ + private LargePersonGroupPersons largePersonGroupPersons; + + /** + * Gets the LargePersonGroupPersons object to access its operations. + * @return the LargePersonGroupPersons object. + */ + public LargePersonGroupPersons largePersonGroupPersons() { + return this.largePersonGroupPersons; + } + + /** + * The LargePersonGroups object to access its operations. + */ + private LargePersonGroups largePersonGroups; + + /** + * Gets the LargePersonGroups object to access its operations. + * @return the LargePersonGroups object. + */ + public LargePersonGroups largePersonGroups() { + return this.largePersonGroups; + } + + /** + * The LargeFaceLists object to access its operations. + */ + private LargeFaceLists largeFaceLists; + + /** + * Gets the LargeFaceLists object to access its operations. + * @return the LargeFaceLists object. + */ + public LargeFaceLists largeFaceLists() { + return this.largeFaceLists; + } + + /** + * The Snapshots object to access its operations. + */ + private Snapshots snapshots; + + /** + * Gets the Snapshots object to access its operations. + * @return the Snapshots object. + */ + public Snapshots snapshots() { + return this.snapshots; + } + + /** + * Initializes an instance of FaceClient client. + * + * @param credentials the management credentials for Azure + */ + public FaceClientImpl(ServiceClientCredentials credentials) { + this("https://{Endpoint}/face/v1.0", credentials); + } + + /** + * Initializes an instance of FaceClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + private FaceClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of FaceClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public FaceClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.faces = new FacesImpl(restClient().retrofit(), this); + this.personGroupPersons = new PersonGroupPersonsImpl(restClient().retrofit(), this); + this.personGroups = new PersonGroupsImpl(restClient().retrofit(), this); + this.faceLists = new FaceListsImpl(restClient().retrofit(), this); + this.largePersonGroupPersons = new LargePersonGroupPersonsImpl(restClient().retrofit(), this); + this.largePersonGroups = new LargePersonGroupsImpl(restClient().retrofit(), this); + this.largeFaceLists = new LargeFaceListsImpl(restClient().retrofit(), this); + this.snapshots = new SnapshotsImpl(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "FaceClient", "1.0"); + } +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java index 9090fdb56ee00..be0ec1afa6fe1 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FaceListsImpl.java @@ -8,10 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreateFaceListsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceListsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddFaceFromUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddFaceFromStreamOptionalParameter; import retrofit2.Retrofit; import com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists; import com.google.common.base.Joiner; @@ -26,6 +22,7 @@ import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; +import java.io.InputStream; import java.io.IOException; import java.util.List; import java.util.UUID; @@ -54,7 +51,7 @@ public class FaceListsImpl implements FaceLists { /** The Retrofit service to perform REST calls. */ private FaceListsService service; /** The service client containing this operation class. */ - private FaceAPIImpl client; + private FaceClientImpl client; /** * Initializes an instance of FaceListsImpl. @@ -62,7 +59,7 @@ public class FaceListsImpl implements FaceLists { * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public FaceListsImpl(Retrofit retrofit, FaceAPIImpl client) { + public FaceListsImpl(Retrofit retrofit, FaceClientImpl client) { this.service = retrofit.create(FaceListsService.class); this.client = client; } @@ -74,7 +71,7 @@ public FaceListsImpl(Retrofit retrofit, FaceAPIImpl client) { interface FaceListsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists create" }) @PUT("facelists/{faceListId}") - Observable> create(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> create(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists get" }) @GET("facelists/{faceListId}") @@ -82,7 +79,7 @@ interface FaceListsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists update" }) @PATCH("facelists/{faceListId}") - Observable> update(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> update(@Path("faceListId") String faceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists delete" }) @HTTP(path = "facelists/{faceListId}", method = "DELETE", hasBody = true) @@ -93,56 +90,52 @@ interface FaceListsService { Observable> list(@Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists deleteFace" }) - @HTTP(path = "facelists/{faceListId}/persistedFaces/{persistedFaceId}", method = "DELETE", hasBody = true) + @HTTP(path = "facelists/{faceListId}/persistedfaces/{persistedFaceId}", method = "DELETE", hasBody = true) Observable> deleteFace(@Path("faceListId") String faceListId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists addFaceFromUrl" }) - @POST("facelists/{faceListId}/persistedFaces") + @POST("facelists/{faceListId}/persistedfaces") Observable> addFaceFromUrl(@Path("faceListId") String faceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.FaceLists addFaceFromStream" }) - @POST("facelists/{faceListId}/persistedFaces") + @POST("facelists/{faceListId}/persistedfaces") Observable> addFaceFromStream(@Path("faceListId") String faceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } - /** * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void create(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter) { - createWithServiceResponseAsync(faceListId, createOptionalParameter).toBlocking().single().body(); + public void create(String faceListId) { + createWithServiceResponseAsync(faceListId).toBlocking().single().body(); } /** * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture createAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(faceListId, createOptionalParameter), serviceCallback); + public ServiceFuture createAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(faceListId), serviceCallback); } /** * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable createAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter) { - return createWithServiceResponseAsync(faceListId, createOptionalParameter).map(new Func1, Void>() { + public Observable createAsync(String faceListId) { + return createWithServiceResponseAsync(faceListId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -154,21 +147,80 @@ public Void call(ServiceResponse response) { * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. * * @param faceListId Id referencing a particular face list. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> createWithServiceResponseAsync(String faceListId, CreateFaceListsOptionalParameter createOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> createWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - final String name = createOptionalParameter != null ? createOptionalParameter.name() : null; - final String userData = createOptionalParameter != null ? createOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return createWithServiceResponseAsync(faceListId, name, userData); + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String faceListId, String name, String userData) { + createWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(faceListId, name, userData), serviceCallback); + } + + /** + * Create an empty face list. Up to 64 face lists are allowed to exist in one subscription. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String faceListId, String name, String userData) { + return createWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -181,17 +233,17 @@ public Observable> createWithServiceResponseAsync(String f * @return the {@link ServiceResponse} object if successful. */ public Observable> createWithServiceResponseAsync(String faceListId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.create(faceListId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -212,62 +264,6 @@ private ServiceResponse createDelegate(Response response) th .build(response); } - @Override - public FaceListsCreateParameters create() { - return new FaceListsCreateParameters(this); - } - - /** - * Internal class implementing FaceListsCreateDefinition. - */ - class FaceListsCreateParameters implements FaceListsCreateDefinition { - private FaceListsImpl parent; - private String faceListId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - FaceListsCreateParameters(FaceListsImpl parent) { - this.parent = parent; - } - - @Override - public FaceListsCreateParameters withFaceListId(String faceListId) { - this.faceListId = faceListId; - return this; - } - - @Override - public FaceListsCreateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public FaceListsCreateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - createWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return createWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - /** * Retrieve a face list's information. * @@ -317,13 +313,13 @@ public FaceList call(ServiceResponse response) { * @return the observable to the FaceList object */ public Observable> getWithServiceResponseAsync(String faceListId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.get(faceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -345,43 +341,39 @@ private ServiceResponse getDelegate(Response response) t .build(response); } - /** * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void update(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter) { - updateWithServiceResponseAsync(faceListId, updateOptionalParameter).toBlocking().single().body(); + public void update(String faceListId) { + updateWithServiceResponseAsync(faceListId).toBlocking().single().body(); } /** * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture updateAsync(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(faceListId, updateOptionalParameter), serviceCallback); + public ServiceFuture updateAsync(String faceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(faceListId), serviceCallback); } /** * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable updateAsync(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter) { - return updateWithServiceResponseAsync(faceListId, updateOptionalParameter).map(new Func1, Void>() { + public Observable updateAsync(String faceListId) { + return updateWithServiceResponseAsync(faceListId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -393,21 +385,80 @@ public Void call(ServiceResponse response) { * Update information of a face list. * * @param faceListId Id referencing a particular face list. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateWithServiceResponseAsync(String faceListId, UpdateFaceListsOptionalParameter updateOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> updateWithServiceResponseAsync(String faceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - final String name = updateOptionalParameter != null ? updateOptionalParameter.name() : null; - final String userData = updateOptionalParameter != null ? updateOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return updateWithServiceResponseAsync(faceListId, name, userData); + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String faceListId, String name, String userData) { + updateWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String faceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(faceListId, name, userData), serviceCallback); + } + + /** + * Update information of a face list. + * + * @param faceListId Id referencing a particular face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String faceListId, String name, String userData) { + return updateWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -420,17 +471,17 @@ public Observable> updateWithServiceResponseAsync(String f * @return the {@link ServiceResponse} object if successful. */ public Observable> updateWithServiceResponseAsync(String faceListId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.update(faceListId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(faceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -451,62 +502,6 @@ private ServiceResponse updateDelegate(Response response) th .build(response); } - @Override - public FaceListsUpdateParameters update() { - return new FaceListsUpdateParameters(this); - } - - /** - * Internal class implementing FaceListsUpdateDefinition. - */ - class FaceListsUpdateParameters implements FaceListsUpdateDefinition { - private FaceListsImpl parent; - private String faceListId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - FaceListsUpdateParameters(FaceListsImpl parent) { - this.parent = parent; - } - - @Override - public FaceListsUpdateParameters withFaceListId(String faceListId) { - this.faceListId = faceListId; - return this; - } - - @Override - public FaceListsUpdateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public FaceListsUpdateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - updateWithServiceResponseAsync(faceListId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return updateWithServiceResponseAsync(faceListId, name, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - /** * Delete an existing face list according to faceListId. Persisted face images in the face list will also be deleted. * @@ -555,13 +550,13 @@ public Void call(ServiceResponse response) { * @return the {@link ServiceResponse} object if successful. */ public Observable> deleteWithServiceResponseAsync(String faceListId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.delete(faceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -628,10 +623,10 @@ public List call(ServiceResponse> response) { * @return the observable to the List<FaceList> object */ public Observable>> listWithServiceResponseAsync() { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.list(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override @@ -654,7 +649,7 @@ private ServiceResponse> listDelegate(Response resp } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. @@ -667,7 +662,7 @@ public void deleteFace(String faceListId, UUID persistedFaceId) { } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. @@ -680,7 +675,7 @@ public ServiceFuture deleteFaceAsync(String faceListId, UUID persistedFace } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. @@ -697,7 +692,7 @@ public Void call(ServiceResponse response) { } /** - * Delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image related to the face will also be deleted. + * Delete an existing face from a face list (given by a persistedFaceId and a faceListId). Persisted image related to the face will also be deleted. * * @param faceListId Id referencing a particular face list. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. @@ -705,8 +700,8 @@ public Void call(ServiceResponse response) { * @return the {@link ServiceResponse} object if successful. */ public Observable> deleteFaceWithServiceResponseAsync(String faceListId, UUID persistedFaceId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); @@ -714,7 +709,7 @@ public Observable> deleteFaceWithServiceResponseAsync(Stri if (persistedFaceId == null) { throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.deleteFace(faceListId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -736,20 +731,18 @@ private ServiceResponse deleteFaceDelegate(Response response .build(response); } - /** * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. * @param url Publicly reachable URL of an image - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - public PersistedFace addFaceFromUrl(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter) { - return addFaceFromUrlWithServiceResponseAsync(faceListId, url, addFaceFromUrlOptionalParameter).toBlocking().single().body(); + public PersistedFace addFaceFromUrl(String faceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url).toBlocking().single().body(); } /** @@ -757,13 +750,12 @@ public PersistedFace addFaceFromUrl(String faceListId, String url, AddFaceFromUr * * @param faceListId Id referencing a particular face list. * @param url Publicly reachable URL of an image - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture addFaceFromUrlAsync(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(faceListId, url, addFaceFromUrlOptionalParameter), serviceCallback); + public ServiceFuture addFaceFromUrlAsync(String faceListId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(faceListId, url), serviceCallback); } /** @@ -771,12 +763,11 @@ public ServiceFuture addFaceFromUrlAsync(String faceListId, Strin * * @param faceListId Id referencing a particular face list. * @param url Publicly reachable URL of an image - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable addFaceFromUrlAsync(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter) { - return addFaceFromUrlWithServiceResponseAsync(faceListId, url, addFaceFromUrlOptionalParameter).map(new Func1, PersistedFace>() { + public Observable addFaceFromUrlAsync(String faceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url).map(new Func1, PersistedFace>() { @Override public PersistedFace call(ServiceResponse response) { return response.body(); @@ -789,13 +780,12 @@ public PersistedFace call(ServiceResponse response) { * * @param faceListId Id referencing a particular face list. * @param url Publicly reachable URL of an image - * @param addFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url, AddFaceFromUrlOptionalParameter addFaceFromUrlOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); @@ -803,10 +793,74 @@ public Observable> addFaceFromUrlWithServiceRespo if (url == null) { throw new IllegalArgumentException("Parameter url is required and cannot be null."); } - final String userData = addFaceFromUrlOptionalParameter != null ? addFaceFromUrlOptionalParameter.userData() : null; - final List targetFace = addFaceFromUrlOptionalParameter != null ? addFaceFromUrlOptionalParameter.targetFace() : null; + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(faceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String faceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String faceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -820,8 +874,8 @@ public Observable> addFaceFromUrlWithServiceRespo * @return the observable to the PersistedFace object */ public Observable> addFaceFromUrlWithServiceResponseAsync(String faceListId, String url, String userData, List targetFace) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); @@ -832,7 +886,7 @@ public Observable> addFaceFromUrlWithServiceRespo Validator.validate(targetFace); ImageUrl imageUrl = new ImageUrl(); imageUrl.withUrl(url); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); return service.addFaceFromUrl(faceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @@ -855,83 +909,18 @@ private ServiceResponse addFaceFromUrlDelegate(Response targetFace; - - /** - * Constructor. - * @param parent the parent object. - */ - FaceListsAddFaceFromUrlParameters(FaceListsImpl parent) { - this.parent = parent; - } - - @Override - public FaceListsAddFaceFromUrlParameters withFaceListId(String faceListId) { - this.faceListId = faceListId; - return this; - } - - @Override - public FaceListsAddFaceFromUrlParameters withUrl(String url) { - this.url = url; - return this; - } - - @Override - public FaceListsAddFaceFromUrlParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public FaceListsAddFaceFromUrlParameters withTargetFace(List targetFace) { - this.targetFace = targetFace; - return this; - } - - @Override - public PersistedFace execute() { - return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return addFaceFromUrlWithServiceResponseAsync(faceListId, url, userData, targetFace).map(new Func1, PersistedFace>() { - @Override - public PersistedFace call(ServiceResponse response) { - return response.body(); - } - }); - } - } - - /** * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - public PersistedFace addFaceFromStream(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter) { - return addFaceFromStreamWithServiceResponseAsync(faceListId, image, addFaceFromStreamOptionalParameter).toBlocking().single().body(); + public PersistedFace addFaceFromStream(String faceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image).toBlocking().single().body(); } /** @@ -939,13 +928,12 @@ public PersistedFace addFaceFromStream(String faceListId, byte[] image, AddFaceF * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(faceListId, image, addFaceFromStreamOptionalParameter), serviceCallback); + public ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(faceListId, image), serviceCallback); } /** @@ -953,12 +941,11 @@ public ServiceFuture addFaceFromStreamAsync(String faceListId, by * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable addFaceFromStreamAsync(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter) { - return addFaceFromStreamWithServiceResponseAsync(faceListId, image, addFaceFromStreamOptionalParameter).map(new Func1, PersistedFace>() { + public Observable addFaceFromStreamAsync(String faceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image).map(new Func1, PersistedFace>() { @Override public PersistedFace call(ServiceResponse response) { return response.body(); @@ -971,13 +958,12 @@ public PersistedFace call(ServiceResponse response) { * * @param faceListId Id referencing a particular face list. * @param image An image stream. - * @param addFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image, AddFaceFromStreamOptionalParameter addFaceFromStreamOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); @@ -985,10 +971,72 @@ public Observable> addFaceFromStreamWithServiceRe if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } - final String userData = addFaceFromStreamOptionalParameter != null ? addFaceFromStreamOptionalParameter.userData() : null; - final List targetFace = addFaceFromStreamOptionalParameter != null ? addFaceFromStreamOptionalParameter.targetFace() : null; + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(faceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace); + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String faceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param faceListId Id referencing a particular face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String faceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -1002,8 +1050,8 @@ public Observable> addFaceFromStreamWithServiceRe * @return the observable to the PersistedFace object */ public Observable> addFaceFromStreamWithServiceResponseAsync(String faceListId, byte[] image, String userData, List targetFace) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceListId == null) { throw new IllegalArgumentException("Parameter faceListId is required and cannot be null."); @@ -1012,9 +1060,8 @@ public Observable> addFaceFromStreamWithServiceRe throw new IllegalArgumentException("Parameter image is required and cannot be null."); } Validator.validate(targetFace); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); - RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); return service.addFaceFromStream(faceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -1036,67 +1083,4 @@ private ServiceResponse addFaceFromStreamDelegate(Response targetFace; - - /** - * Constructor. - * @param parent the parent object. - */ - FaceListsAddFaceFromStreamParameters(FaceListsImpl parent) { - this.parent = parent; - } - - @Override - public FaceListsAddFaceFromStreamParameters withFaceListId(String faceListId) { - this.faceListId = faceListId; - return this; - } - - @Override - public FaceListsAddFaceFromStreamParameters withImage(byte[] image) { - this.image = image; - return this; - } - - @Override - public FaceListsAddFaceFromStreamParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public FaceListsAddFaceFromStreamParameters withTargetFace(List targetFace) { - this.targetFace = targetFace; - return this; - } - - @Override - public PersistedFace execute() { - return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return addFaceFromStreamWithServiceResponseAsync(faceListId, image, userData, targetFace).map(new Func1, PersistedFace>() { - @Override - public PersistedFace call(ServiceResponse response) { - return response.body(); - } - }); - } - } - } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java index 15f568d59a332..61917a95fb4ae 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java @@ -8,10 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.FindSimilarOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.IdentifyOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectWithUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.DetectWithStreamOptionalParameter; import retrofit2.Retrofit; import com.microsoft.azure.cognitiveservices.vision.faceapi.Faces; import com.google.common.base.Joiner; @@ -35,6 +31,7 @@ import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; +import java.io.InputStream; import java.io.IOException; import java.util.List; import java.util.UUID; @@ -58,7 +55,7 @@ public class FacesImpl implements Faces { /** The Retrofit service to perform REST calls. */ private FacesService service; /** The service client containing this operation class. */ - private FaceAPIImpl client; + private FaceClientImpl client; /** * Initializes an instance of FacesImpl. @@ -66,7 +63,7 @@ public class FacesImpl implements Faces { * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public FacesImpl(Retrofit retrofit, FaceAPIImpl client) { + public FacesImpl(Retrofit retrofit, FaceClientImpl client) { this.service = retrofit.create(FacesService.class); this.client = client; } @@ -78,19 +75,19 @@ public FacesImpl(Retrofit retrofit, FaceAPIImpl client) { interface FacesService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces findSimilar" }) @POST("findsimilars") - Observable> findSimilar(@Header("accept-language") String acceptLanguage, @Body FindSimilarRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> findSimilar(@Header("accept-language") String acceptLanguage, @Body FindSimilarRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces group" }) @POST("group") - Observable> group(@Header("accept-language") String acceptLanguage, @Body GroupRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> group(@Header("accept-language") String acceptLanguage, @Body GroupRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces identify" }) @POST("identify") - Observable> identify(@Header("accept-language") String acceptLanguage, @Body IdentifyRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> identify(@Header("accept-language") String acceptLanguage, @Body IdentifyRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces verifyFaceToFace" }) @POST("verify") - Observable> verifyFaceToFace(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToFaceRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> verifyFaceToFace(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces detectWithUrl" }) @POST("detect") @@ -98,7 +95,7 @@ interface FacesService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces verifyFaceToPerson" }) @POST("verify") - Observable> verifyFaceToPerson(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToPersonRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> verifyFaceToPerson(@Header("accept-language") String acceptLanguage, @Body VerifyFaceToPersonRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Faces detectWithStream" }) @POST("detect") @@ -106,44 +103,40 @@ interface FacesService { } - /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<SimilarFace> object if successful. */ - public List findSimilar(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter) { - return findSimilarWithServiceResponseAsync(faceId, findSimilarOptionalParameter).toBlocking().single().body(); + public List findSimilar(UUID faceId) { + return findSimilarWithServiceResponseAsync(faceId).toBlocking().single().body(); } /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> findSimilarAsync(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(findSimilarWithServiceResponseAsync(faceId, findSimilarOptionalParameter), serviceCallback); + public ServiceFuture> findSimilarAsync(UUID faceId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(findSimilarWithServiceResponseAsync(faceId), serviceCallback); } /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<SimilarFace> object */ - public Observable> findSimilarAsync(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter) { - return findSimilarWithServiceResponseAsync(faceId, findSimilarOptionalParameter).map(new Func1>, List>() { + public Observable> findSimilarAsync(UUID faceId) { + return findSimilarWithServiceResponseAsync(faceId).map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -152,55 +145,131 @@ public List call(ServiceResponse> response) { } /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call - * @param findSimilarOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<SimilarFace> object */ - public Observable>> findSimilarWithServiceResponseAsync(UUID faceId, FindSimilarOptionalParameter findSimilarOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> findSimilarWithServiceResponseAsync(UUID faceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceId == null) { throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); } - final String faceListId = findSimilarOptionalParameter != null ? findSimilarOptionalParameter.faceListId() : null; - final List faceIds = findSimilarOptionalParameter != null ? findSimilarOptionalParameter.faceIds() : null; - final Integer maxNumOfCandidatesReturned = findSimilarOptionalParameter != null ? findSimilarOptionalParameter.maxNumOfCandidatesReturned() : null; - final FindSimilarMatchMode mode = findSimilarOptionalParameter != null ? findSimilarOptionalParameter.mode() : null; + final String faceListId = null; + final String largeFaceListId = null; + final List faceIds = null; + final Integer maxNumOfCandidatesReturned = null; + final FindSimilarMatchMode mode = null; + FindSimilarRequest body = new FindSimilarRequest(); + body.withFaceId(faceId); + body.withFaceListId(null); + body.withLargeFaceListId(null); + body.withFaceIds(null); + body.withMaxNumOfCandidatesReturned(null); + body.withMode(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.findSimilar(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = findSimilarDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode); + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<SimilarFace> object if successful. + */ + public List findSimilar(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + return findSimilarWithServiceResponseAsync(faceId, faceListId, largeFaceListId, faceIds, maxNumOfCandidatesReturned, mode).toBlocking().single().body(); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> findSimilarAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(findSimilarWithServiceResponseAsync(faceId, faceListId, largeFaceListId, faceIds, maxNumOfCandidatesReturned, mode), serviceCallback); + } + + /** + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. + * + * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. + * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<SimilarFace> object + */ + public Observable> findSimilarAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + return findSimilarWithServiceResponseAsync(faceId, faceListId, largeFaceListId, faceIds, maxNumOfCandidatesReturned, mode).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); } /** - * Given query face's faceId, find the similar-looking faces from a faceId array or a faceListId. + * Given query face's faceId, find the similar-looking faces from a faceId array, a face list or a large face list. * * @param faceId FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call - * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId and faceIds should not be provided at the same time - * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. + * @param faceListId An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param largeFaceListId An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * @param faceIds An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. * @param maxNumOfCandidatesReturned The number of top similar faces returned. The valid range is [1, 1000]. * @param mode Similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace' * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<SimilarFace> object */ - public Observable>> findSimilarWithServiceResponseAsync(UUID faceId, String faceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> findSimilarWithServiceResponseAsync(UUID faceId, String faceListId, String largeFaceListId, List faceIds, Integer maxNumOfCandidatesReturned, FindSimilarMatchMode mode) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceId == null) { throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); } Validator.validate(faceIds); - FindSimilarRequest bodyParameter = new FindSimilarRequest(); - bodyParameter.withFaceId(faceId); - bodyParameter.withFaceListId(faceListId); - bodyParameter.withFaceIds(faceIds); - bodyParameter.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); - bodyParameter.withMode(mode); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.findSimilar(this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + FindSimilarRequest body = new FindSimilarRequest(); + body.withFaceId(faceId); + body.withFaceListId(faceListId); + body.withLargeFaceListId(largeFaceListId); + body.withFaceIds(faceIds); + body.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); + body.withMode(mode); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.findSimilar(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { @@ -221,76 +290,6 @@ private ServiceResponse> findSimilarDelegate(Response faceIds; - private Integer maxNumOfCandidatesReturned; - private FindSimilarMatchMode mode; - - /** - * Constructor. - * @param parent the parent object. - */ - FacesFindSimilarParameters(FacesImpl parent) { - this.parent = parent; - } - - @Override - public FacesFindSimilarParameters withFaceId(UUID faceId) { - this.faceId = faceId; - return this; - } - - @Override - public FacesFindSimilarParameters withFaceListId(String faceListId) { - this.faceListId = faceListId; - return this; - } - - @Override - public FacesFindSimilarParameters withFaceIds(List faceIds) { - this.faceIds = faceIds; - return this; - } - - @Override - public FacesFindSimilarParameters withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned) { - this.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; - return this; - } - - @Override - public FacesFindSimilarParameters withMode(FindSimilarMatchMode mode) { - this.mode = mode; - return this; - } - - @Override - public List execute() { - return findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return findSimilarWithServiceResponseAsync(faceId, faceListId, faceIds, maxNumOfCandidatesReturned, mode).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - } - /** * Divide candidate faces into groups based on face similarity. * @@ -340,17 +339,17 @@ public GroupResult call(ServiceResponse response) { * @return the observable to the GroupResult object */ public Observable> groupWithServiceResponseAsync(List faceIds) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceIds == null) { throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); } Validator.validate(faceIds); - GroupRequest bodyParameter = new GroupRequest(); - bodyParameter.withFaceIds(faceIds); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.group(this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + GroupRequest body = new GroupRequest(); + body.withFaceIds(faceIds); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.group(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -371,47 +370,40 @@ private ServiceResponse groupDelegate(Response respon .build(response); } - /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<IdentifyResult> object if successful. */ - public List identify(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter) { - return identifyWithServiceResponseAsync(personGroupId, faceIds, identifyOptionalParameter).toBlocking().single().body(); + public List identify(List faceIds) { + return identifyWithServiceResponseAsync(faceIds).toBlocking().single().body(); } /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> identifyAsync(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(identifyWithServiceResponseAsync(personGroupId, faceIds, identifyOptionalParameter), serviceCallback); + public ServiceFuture> identifyAsync(List faceIds, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(identifyWithServiceResponseAsync(faceIds), serviceCallback); } /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<IdentifyResult> object */ - public Observable> identifyAsync(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter) { - return identifyWithServiceResponseAsync(personGroupId, faceIds, identifyOptionalParameter).map(new Func1>, List>() { + public Observable> identifyAsync(List faceIds) { + return identifyWithServiceResponseAsync(faceIds).map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -420,59 +412,125 @@ public List call(ServiceResponse> response) } /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. - * @param identifyOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<IdentifyResult> object */ - public Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds, IdentifyOptionalParameter identifyOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); - } - if (personGroupId == null) { - throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + public Observable>> identifyWithServiceResponseAsync(List faceIds) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceIds == null) { throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); } Validator.validate(faceIds); - final Integer maxNumOfCandidatesReturned = identifyOptionalParameter != null ? identifyOptionalParameter.maxNumOfCandidatesReturned() : null; - final Double confidenceThreshold = identifyOptionalParameter != null ? identifyOptionalParameter.confidenceThreshold() : null; + final String personGroupId = null; + final String largePersonGroupId = null; + final Integer maxNumOfCandidatesReturned = null; + final Double confidenceThreshold = null; + IdentifyRequest body = new IdentifyRequest(); + body.withFaceIds(faceIds); + body.withPersonGroupId(null); + body.withLargePersonGroupId(null); + body.withMaxNumOfCandidatesReturned(null); + body.withConfidenceThreshold(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.identify(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = identifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<IdentifyResult> object if successful. + */ + public List identify(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + return identifyWithServiceResponseAsync(faceIds, personGroupId, largePersonGroupId, maxNumOfCandidatesReturned, confidenceThreshold).toBlocking().single().body(); + } - return identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold); + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> identifyAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(identifyWithServiceResponseAsync(faceIds, personGroupId, largePersonGroupId, maxNumOfCandidatesReturned, confidenceThreshold), serviceCallback); } /** - * Identify unknown faces from a person group. + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. * - * @param personGroupId PersonGroupId of the target person group, created by PersonGroups.Create * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<IdentifyResult> object */ - public Observable>> identifyWithServiceResponseAsync(String personGroupId, List faceIds, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); - } - if (personGroupId == null) { - throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); + public Observable> identifyAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + return identifyWithServiceResponseAsync(faceIds, personGroupId, largePersonGroupId, maxNumOfCandidatesReturned, confidenceThreshold).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * 1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. + * + * @param faceIds Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * @param personGroupId PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param maxNumOfCandidatesReturned The range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). + * @param confidenceThreshold Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<IdentifyResult> object + */ + public Observable>> identifyWithServiceResponseAsync(List faceIds, String personGroupId, String largePersonGroupId, Integer maxNumOfCandidatesReturned, Double confidenceThreshold) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceIds == null) { throw new IllegalArgumentException("Parameter faceIds is required and cannot be null."); } Validator.validate(faceIds); - IdentifyRequest bodyParameter = new IdentifyRequest(); - bodyParameter.withPersonGroupId(personGroupId); - bodyParameter.withFaceIds(faceIds); - bodyParameter.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); - bodyParameter.withConfidenceThreshold(confidenceThreshold); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.identify(this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + IdentifyRequest body = new IdentifyRequest(); + body.withFaceIds(faceIds); + body.withPersonGroupId(personGroupId); + body.withLargePersonGroupId(largePersonGroupId); + body.withMaxNumOfCandidatesReturned(maxNumOfCandidatesReturned); + body.withConfidenceThreshold(confidenceThreshold); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.identify(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { @@ -493,69 +551,6 @@ private ServiceResponse> identifyDelegate(Response faceIds; - private Integer maxNumOfCandidatesReturned; - private Double confidenceThreshold; - - /** - * Constructor. - * @param parent the parent object. - */ - FacesIdentifyParameters(FacesImpl parent) { - this.parent = parent; - } - - @Override - public FacesIdentifyParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public FacesIdentifyParameters withFaceIds(List faceIds) { - this.faceIds = faceIds; - return this; - } - - @Override - public FacesIdentifyParameters withMaxNumOfCandidatesReturned(Integer maxNumOfCandidatesReturned) { - this.maxNumOfCandidatesReturned = maxNumOfCandidatesReturned; - return this; - } - - @Override - public FacesIdentifyParameters withConfidenceThreshold(Double confidenceThreshold) { - this.confidenceThreshold = confidenceThreshold; - return this; - } - - @Override - public List execute() { - return identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return identifyWithServiceResponseAsync(personGroupId, faceIds, maxNumOfCandidatesReturned, confidenceThreshold).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - } - /** * Verify whether two faces belong to a same person or whether one face belongs to a person. * @@ -609,8 +604,8 @@ public VerifyResult call(ServiceResponse response) { * @return the observable to the VerifyResult object */ public Observable> verifyFaceToFaceWithServiceResponseAsync(UUID faceId1, UUID faceId2) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceId1 == null) { throw new IllegalArgumentException("Parameter faceId1 is required and cannot be null."); @@ -618,11 +613,11 @@ public Observable> verifyFaceToFaceWithServiceResp if (faceId2 == null) { throw new IllegalArgumentException("Parameter faceId2 is required and cannot be null."); } - VerifyFaceToFaceRequest bodyParameter = new VerifyFaceToFaceRequest(); - bodyParameter.withFaceId1(faceId1); - bodyParameter.withFaceId2(faceId2); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.verifyFaceToFace(this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + VerifyFaceToFaceRequest body = new VerifyFaceToFaceRequest(); + body.withFaceId1(faceId1); + body.withFaceId2(faceId2); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.verifyFaceToFace(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -643,44 +638,40 @@ private ServiceResponse verifyFaceToFaceDelegate(Response detectWithUrl(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter) { - return detectWithUrlWithServiceResponseAsync(url, detectWithUrlOptionalParameter).toBlocking().single().body(); + public List detectWithUrl(String url) { + return detectWithUrlWithServiceResponseAsync(url).toBlocking().single().body(); } /** * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param url Publicly reachable URL of an image - * @param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> detectWithUrlAsync(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(detectWithUrlWithServiceResponseAsync(url, detectWithUrlOptionalParameter), serviceCallback); + public ServiceFuture> detectWithUrlAsync(String url, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithUrlWithServiceResponseAsync(url), serviceCallback); } /** * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param url Publicly reachable URL of an image - * @param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - public Observable> detectWithUrlAsync(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter) { - return detectWithUrlWithServiceResponseAsync(url, detectWithUrlOptionalParameter).map(new Func1>, List>() { + public Observable> detectWithUrlAsync(String url) { + return detectWithUrlWithServiceResponseAsync(url).map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -692,22 +683,85 @@ public List call(ServiceResponse> response) { * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param url Publicly reachable URL of an image - * @param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - public Observable>> detectWithUrlWithServiceResponseAsync(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> detectWithUrlWithServiceResponseAsync(String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (url == null) { throw new IllegalArgumentException("Parameter url is required and cannot be null."); } - final Boolean returnFaceId = detectWithUrlOptionalParameter != null ? detectWithUrlOptionalParameter.returnFaceId() : null; - final Boolean returnFaceLandmarks = detectWithUrlOptionalParameter != null ? detectWithUrlOptionalParameter.returnFaceLandmarks() : null; - final List returnFaceAttributes = detectWithUrlOptionalParameter != null ? detectWithUrlOptionalParameter.returnFaceAttributes() : null; + final Boolean returnFaceId = null; + final Boolean returnFaceLandmarks = null; + final List returnFaceAttributes = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV); + return service.detectWithUrl(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithUrl(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param url Publicly reachable URL of an image + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithUrlAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); } /** @@ -721,8 +775,8 @@ public Observable>> detectWithUrlWithServiceR * @return the observable to the List<DetectedFace> object */ public Observable>> detectWithUrlWithServiceResponseAsync(String url, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (url == null) { throw new IllegalArgumentException("Parameter url is required and cannot be null."); @@ -730,7 +784,7 @@ public Observable>> detectWithUrlWithServiceR Validator.validate(returnFaceAttributes); ImageUrl imageUrl = new ImageUrl(); imageUrl.withUrl(url); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV); return service.detectWithUrl(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @@ -753,109 +807,133 @@ private ServiceResponse> detectWithUrlDelegate(Response returnFaceAttributes; - - /** - * Constructor. - * @param parent the parent object. - */ - FacesDetectWithUrlParameters(FacesImpl parent) { - this.parent = parent; - } + public ServiceFuture verifyFaceToPersonAsync(UUID faceId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(verifyFaceToPersonWithServiceResponseAsync(faceId, personId), serviceCallback); + } - @Override - public FacesDetectWithUrlParameters withUrl(String url) { - this.url = url; - return this; - } + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable verifyFaceToPersonAsync(UUID faceId, UUID personId) { + return verifyFaceToPersonWithServiceResponseAsync(faceId, personId).map(new Func1, VerifyResult>() { + @Override + public VerifyResult call(ServiceResponse response) { + return response.body(); + } + }); + } - @Override - public FacesDetectWithUrlParameters withReturnFaceId(Boolean returnFaceId) { - this.returnFaceId = returnFaceId; - return this; + /** + * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. + * + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the VerifyResult object + */ + public Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } - - @Override - public FacesDetectWithUrlParameters withReturnFaceLandmarks(Boolean returnFaceLandmarks) { - this.returnFaceLandmarks = returnFaceLandmarks; - return this; + if (faceId == null) { + throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); } - - @Override - public FacesDetectWithUrlParameters withReturnFaceAttributes(List returnFaceAttributes) { - this.returnFaceAttributes = returnFaceAttributes; - return this; + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - - @Override - public List execute() { - return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return detectWithUrlWithServiceResponseAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { + final String personGroupId = null; + final String largePersonGroupId = null; + VerifyFaceToPersonRequest body = new VerifyFaceToPersonRequest(); + body.withFaceId(faceId); + body.withPersonGroupId(null); + body.withLargePersonGroupId(null); + body.withPersonId(personId); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.verifyFaceToPerson(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { @Override - public List call(ServiceResponse> response) { - return response.body(); + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyFaceToPersonDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } } }); - } } /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the VerifyResult object if successful. */ - public VerifyResult verifyFaceToPerson(UUID faceId, String personGroupId, UUID personId) { - return verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId).toBlocking().single().body(); + public VerifyResult verifyFaceToPerson(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId) { + return verifyFaceToPersonWithServiceResponseAsync(faceId, personId, personGroupId, largePersonGroupId).toBlocking().single().body(); } /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId), serviceCallback); + public ServiceFuture verifyFaceToPersonAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(verifyFaceToPersonWithServiceResponseAsync(faceId, personId, personGroupId, largePersonGroupId), serviceCallback); } /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the VerifyResult object */ - public Observable verifyFaceToPersonAsync(UUID faceId, String personGroupId, UUID personId) { - return verifyFaceToPersonWithServiceResponseAsync(faceId, personGroupId, personId).map(new Func1, VerifyResult>() { + public Observable verifyFaceToPersonAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId) { + return verifyFaceToPersonWithServiceResponseAsync(faceId, personId, personGroupId, largePersonGroupId).map(new Func1, VerifyResult>() { @Override public VerifyResult call(ServiceResponse response) { return response.body(); @@ -866,31 +944,30 @@ public VerifyResult call(ServiceResponse response) { /** * Verify whether two faces belong to a same person. Compares a face Id with a Person Id. * - * @param faceId FaceId the face, comes from Face - Detect - * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in Person Groups.Create. - * @param personId Specify a certain person in a person group. personId is created in Persons.Create. + * @param faceId FaceId of the face, comes from Face - Detect + * @param personId Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. + * @param personGroupId Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * @param largePersonGroupId Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the VerifyResult object */ - public Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, String personGroupId, UUID personId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> verifyFaceToPersonWithServiceResponseAsync(UUID faceId, UUID personId, String personGroupId, String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (faceId == null) { throw new IllegalArgumentException("Parameter faceId is required and cannot be null."); } - if (personGroupId == null) { - throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); - } if (personId == null) { throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - VerifyFaceToPersonRequest bodyParameter = new VerifyFaceToPersonRequest(); - bodyParameter.withFaceId(faceId); - bodyParameter.withPersonGroupId(personGroupId); - bodyParameter.withPersonId(personId); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.verifyFaceToPerson(this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + VerifyFaceToPersonRequest body = new VerifyFaceToPersonRequest(); + body.withFaceId(faceId); + body.withPersonGroupId(personGroupId); + body.withLargePersonGroupId(largePersonGroupId); + body.withPersonId(personId); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.verifyFaceToPerson(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -911,44 +988,40 @@ private ServiceResponse verifyFaceToPersonDelegate(Response detectWithStream(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter) { - return detectWithStreamWithServiceResponseAsync(image, detectWithStreamOptionalParameter).toBlocking().single().body(); + public List detectWithStream(byte[] image) { + return detectWithStreamWithServiceResponseAsync(image).toBlocking().single().body(); } /** * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param image An image stream. - * @param detectWithStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> detectWithStreamAsync(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(detectWithStreamWithServiceResponseAsync(image, detectWithStreamOptionalParameter), serviceCallback); + public ServiceFuture> detectWithStreamAsync(byte[] image, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithStreamWithServiceResponseAsync(image), serviceCallback); } /** * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param image An image stream. - * @param detectWithStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - public Observable> detectWithStreamAsync(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter) { - return detectWithStreamWithServiceResponseAsync(image, detectWithStreamOptionalParameter).map(new Func1>, List>() { + public Observable> detectWithStreamAsync(byte[] image) { + return detectWithStreamWithServiceResponseAsync(image).map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -960,22 +1033,83 @@ public List call(ServiceResponse> response) { * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. * * @param image An image stream. - * @param detectWithStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<DetectedFace> object */ - public Observable>> detectWithStreamWithServiceResponseAsync(byte[] image, DetectWithStreamOptionalParameter detectWithStreamOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> detectWithStreamWithServiceResponseAsync(byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } - final Boolean returnFaceId = detectWithStreamOptionalParameter != null ? detectWithStreamOptionalParameter.returnFaceId() : null; - final Boolean returnFaceLandmarks = detectWithStreamOptionalParameter != null ? detectWithStreamOptionalParameter.returnFaceLandmarks() : null; - final List returnFaceAttributes = detectWithStreamOptionalParameter != null ? detectWithStreamOptionalParameter.returnFaceAttributes() : null; + final Boolean returnFaceId = null; + final Boolean returnFaceLandmarks = null; + final List returnFaceAttributes = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.detectWithStream(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = detectWithStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes); + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<DetectedFace> object if successful. + */ + public List detectWithStream(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes), serviceCallback); + } + + /** + * Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes. + * + * @param image An image stream. + * @param returnFaceId A value indicating whether the operation should return faceIds of detected faces. + * @param returnFaceLandmarks A value indicating whether the operation should return landmarks of the detected faces. + * @param returnFaceAttributes Analyze and return the one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional computational and time cost. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<DetectedFace> object + */ + public Observable> detectWithStreamAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { + return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); } /** @@ -989,16 +1123,15 @@ public Observable>> detectWithStreamWithServi * @return the observable to the List<DetectedFace> object */ public Observable>> detectWithStreamWithServiceResponseAsync(byte[] image, Boolean returnFaceId, Boolean returnFaceLandmarks, List returnFaceAttributes) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } Validator.validate(returnFaceAttributes); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV); - RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String returnFaceAttributesConverted = this.client.serializerAdapter().serializeList(returnFaceAttributes, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); return service.detectWithStream(returnFaceId, returnFaceLandmarks, returnFaceAttributesConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override @@ -1020,67 +1153,4 @@ private ServiceResponse> detectWithStreamDelegate(Response returnFaceAttributes; - - /** - * Constructor. - * @param parent the parent object. - */ - FacesDetectWithStreamParameters(FacesImpl parent) { - this.parent = parent; - } - - @Override - public FacesDetectWithStreamParameters withImage(byte[] image) { - this.image = image; - return this; - } - - @Override - public FacesDetectWithStreamParameters withReturnFaceId(Boolean returnFaceId) { - this.returnFaceId = returnFaceId; - return this; - } - - @Override - public FacesDetectWithStreamParameters withReturnFaceLandmarks(Boolean returnFaceLandmarks) { - this.returnFaceLandmarks = returnFaceLandmarks; - return this; - } - - @Override - public FacesDetectWithStreamParameters withReturnFaceAttributes(List returnFaceAttributes) { - this.returnFaceAttributes = returnFaceAttributes; - return this; - } - - @Override - public List execute() { - return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return detectWithStreamWithServiceResponseAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - } - } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListFacesImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListFacesImpl.java new file mode 100644 index 0000000000000..bf89b10ca0476 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListFacesImpl.java @@ -0,0 +1,221 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceListFaces; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargeFaceListFaces. + */ +public class LargeFaceListFacesImpl implements LargeFaceListFaces { + /** The Retrofit service to perform REST calls. */ + private LargeFaceListFacesService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of LargeFaceListFacesImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public LargeFaceListFacesImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(LargeFaceListFacesService.class); + this.client = client; + } + + /** + * The interface defining all the services for LargeFaceListFaces to be + * used by Retrofit to perform actually REST calls. + */ + interface LargeFaceListFacesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceListFaces list" }) + @GET("largefacelists/{largeFaceListId}/persistedfaces") + Observable> list(@Path("largeFaceListId") String largeFaceListId, @Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + public List list(String largeFaceListId) { + return listWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String largeFaceListId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable> listAsync(String largeFaceListId) { + return listWithServiceResponseAsync(largeFaceListId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable>> listWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(largeFaceListId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + public List list(String largeFaceListId, String start, Integer top) { + return listWithServiceResponseAsync(largeFaceListId, start, top).toBlocking().single().body(); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String largeFaceListId, String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(largeFaceListId, start, top), serviceCallback); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable> listAsync(String largeFaceListId, String start, Integer top) { + return listWithServiceResponseAsync(largeFaceListId, start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable>> listWithServiceResponseAsync(String largeFaceListId, String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(largeFaceListId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListsImpl.java new file mode 100644 index 0000000000000..f53882f5e3d51 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargeFaceListsImpl.java @@ -0,0 +1,1670 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ImageUrl; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.LargeFaceList; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceRequest; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargeFaceLists. + */ +public class LargeFaceListsImpl implements LargeFaceLists { + /** The Retrofit service to perform REST calls. */ + private LargeFaceListsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of LargeFaceListsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public LargeFaceListsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(LargeFaceListsService.class); + this.client = client; + } + + /** + * The interface defining all the services for LargeFaceLists to be + * used by Retrofit to perform actually REST calls. + */ + interface LargeFaceListsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists create" }) + @PUT("largefacelists/{largeFaceListId}") + Observable> create(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists get" }) + @GET("largefacelists/{largeFaceListId}") + Observable> get(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists update" }) + @PATCH("largefacelists/{largeFaceListId}") + Observable> update(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists delete" }) + @HTTP(path = "largefacelists/{largeFaceListId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists getTrainingStatus" }) + @GET("largefacelists/{largeFaceListId}/training") + Observable> getTrainingStatus(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists list" }) + @GET("largefacelists") + Observable> list(@Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists train" }) + @POST("largefacelists/{largeFaceListId}/train") + Observable> train(@Path("largeFaceListId") String largeFaceListId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists deleteFace" }) + @HTTP(path = "largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}", method = "DELETE", hasBody = true) + Observable> deleteFace(@Path("largeFaceListId") String largeFaceListId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists getFace" }) + @GET("largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}") + Observable> getFace(@Path("largeFaceListId") String largeFaceListId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists updateFace" }) + @PATCH("largefacelists/{largeFaceListId}/persistedfaces/{persistedFaceId}") + Observable> updateFace(@Path("largeFaceListId") String largeFaceListId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Body UpdateFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists addFaceFromUrl" }) + @POST("largefacelists/{largeFaceListId}/persistedfaces") + Observable> addFaceFromUrl(@Path("largeFaceListId") String largeFaceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists listFaces" }) + @GET("largefacelists/{largeFaceListId}/persistedfaces") + Observable> listFaces(@Path("largeFaceListId") String largeFaceListId, @Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargeFaceLists addFaceFromStream" }) + @POST("largefacelists/{largeFaceListId}/persistedfaces") + Observable> addFaceFromStream(@Path("largeFaceListId") String largeFaceListId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String largeFaceListId) { + createWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String largeFaceListId) { + return createWithServiceResponseAsync(largeFaceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largeFaceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String largeFaceListId, String name, String userData) { + createWithServiceResponseAsync(largeFaceListId, name, userData).toBlocking().single().body(); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largeFaceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largeFaceListId, name, userData), serviceCallback); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String largeFaceListId, String name, String userData) { + return createWithServiceResponseAsync(largeFaceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create an empty large face list. Up to 64 large face lists are allowed to exist in one subscription. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String largeFaceListId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largeFaceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LargeFaceList object if successful. + */ + public LargeFaceList get(String largeFaceListId) { + return getWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargeFaceList object + */ + public Observable getAsync(String largeFaceListId) { + return getWithServiceResponseAsync(largeFaceListId).map(new Func1, LargeFaceList>() { + @Override + public LargeFaceList call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve a large face list's information. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargeFaceList object + */ + public Observable> getWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(largeFaceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largeFaceListId) { + updateWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largeFaceListId) { + return updateWithServiceResponseAsync(largeFaceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largeFaceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largeFaceListId, String name, String userData) { + updateWithServiceResponseAsync(largeFaceListId, name, userData).toBlocking().single().body(); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largeFaceListId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largeFaceListId, name, userData), serviceCallback); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largeFaceListId, String name, String userData) { + return updateWithServiceResponseAsync(largeFaceListId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update information of a large face list. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largeFaceListId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largeFaceListId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String largeFaceListId) { + deleteWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String largeFaceListId) { + return deleteWithServiceResponseAsync(largeFaceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing large face list according to faceListId. Persisted face images in the large face list will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(largeFaceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + public TrainingStatus getTrainingStatus(String largeFaceListId) { + return getTrainingStatusWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getTrainingStatusAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getTrainingStatusWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable getTrainingStatusAsync(String largeFaceListId) { + return getTrainingStatusWithServiceResponseAsync(largeFaceListId).map(new Func1, TrainingStatus>() { + @Override + public TrainingStatus call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the training status of a large face list (completed or ongoing). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable> getTrainingStatusWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getTrainingStatus(largeFaceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getTrainingStatusDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getTrainingStatusDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargeFaceList> object if successful. + */ + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargeFaceList> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about all existing large face lists. Only largeFaceListId, name and userData will be returned. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargeFaceList> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void train(String largeFaceListId) { + trainWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture trainAsync(String largeFaceListId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(trainWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable trainAsync(String largeFaceListId) { + return trainWithServiceResponseAsync(largeFaceListId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Queue a large face list training task, the training task may not be started immediately. + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> trainWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.train(largeFaceListId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = trainDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse trainDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteFace(String largeFaceListId, UUID persistedFaceId) { + deleteFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId), serviceCallback); + } + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteFaceAsync(String largeFaceListId, UUID persistedFaceId) { + return deleteFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing face from a large face list (given by a persistedFaceId and a largeFaceListId). Persisted image related to the face will also be deleted. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.deleteFace(largeFaceListId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace getFace(String largeFaceListId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId), serviceCallback); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable getFaceAsync(String largeFaceListId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> getFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getFace(largeFaceListId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String largeFaceListId, UUID persistedFaceId) { + updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String largeFaceListId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId), serviceCallback); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String largeFaceListId, UUID persistedFaceId) { + return updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + final String userData = null; + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(largeFaceListId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String largeFaceListId, UUID persistedFaceId, String userData) { + updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId, userData).toBlocking().single().body(); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String largeFaceListId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId, userData), serviceCallback); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String largeFaceListId, UUID persistedFaceId, String userData) { + return updateFaceWithServiceResponseAsync(largeFaceListId, persistedFaceId, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a persisted face's userData field. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String largeFaceListId, UUID persistedFaceId, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(largeFaceListId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String largeFaceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url).toBlocking().single().body(); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String largeFaceListId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url), serviceCallback); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String largeFaceListId, String url) { + return addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String largeFaceListId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(largeFaceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String largeFaceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String largeFaceListId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String largeFaceListId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(largeFaceListId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String largeFaceListId, String url, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + Validator.validate(targetFace); + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(largeFaceListId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + public List listFaces(String largeFaceListId) { + return listFacesWithServiceResponseAsync(largeFaceListId).toBlocking().single().body(); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listFacesAsync(String largeFaceListId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listFacesWithServiceResponseAsync(largeFaceListId), serviceCallback); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable> listFacesAsync(String largeFaceListId) { + return listFacesWithServiceResponseAsync(largeFaceListId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable>> listFacesWithServiceResponseAsync(String largeFaceListId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.listFaces(largeFaceListId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listFacesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersistedFace> object if successful. + */ + public List listFaces(String largeFaceListId, String start, Integer top) { + return listFacesWithServiceResponseAsync(largeFaceListId, start, top).toBlocking().single().body(); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listFacesAsync(String largeFaceListId, String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listFacesWithServiceResponseAsync(largeFaceListId, start, top), serviceCallback); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable> listFacesAsync(String largeFaceListId, String start, Integer top) { + return listFacesWithServiceResponseAsync(largeFaceListId, start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face). + * + * @param largeFaceListId Id referencing a particular large face list. + * @param start Starting face id to return (used to list a range of faces). + * @param top Number of faces to return starting with the face id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersistedFace> object + */ + public Observable>> listFacesWithServiceResponseAsync(String largeFaceListId, String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.listFaces(largeFaceListId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listFacesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listFacesDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String largeFaceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image).toBlocking().single().body(); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String largeFaceListId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image), serviceCallback); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String largeFaceListId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String largeFaceListId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(largeFaceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String largeFaceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String largeFaceListId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image, userData, targetFace), serviceCallback); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String largeFaceListId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(largeFaceListId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a face to a large face list. The input face is specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face, and persistedFaceId will not expire. + * + * @param largeFaceListId Id referencing a particular large face list. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String largeFaceListId, byte[] image, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largeFaceListId == null) { + throw new IllegalArgumentException("Parameter largeFaceListId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + Validator.validate(targetFace); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(largeFaceListId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupPersonsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupPersonsImpl.java new file mode 100644 index 0000000000000..b0eeb13a2c9cf --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupPersonsImpl.java @@ -0,0 +1,1519 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ImageUrl; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceRequest; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.InputStream; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargePersonGroupPersons. + */ +public class LargePersonGroupPersonsImpl implements LargePersonGroupPersons { + /** The Retrofit service to perform REST calls. */ + private LargePersonGroupPersonsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of LargePersonGroupPersonsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public LargePersonGroupPersonsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(LargePersonGroupPersonsService.class); + this.client = client; + } + + /** + * The interface defining all the services for LargePersonGroupPersons to be + * used by Retrofit to perform actually REST calls. + */ + interface LargePersonGroupPersonsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons create" }) + @POST("largepersongroups/{largePersonGroupId}/persons") + Observable> create(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons list" }) + @GET("largepersongroups/{largePersonGroupId}/persons") + Observable> list(@Path("largePersonGroupId") String largePersonGroupId, @Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons delete" }) + @HTTP(path = "largepersongroups/{largePersonGroupId}/persons/{personId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons get" }) + @GET("largepersongroups/{largePersonGroupId}/persons/{personId}") + Observable> get(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons update" }) + @PATCH("largepersongroups/{largePersonGroupId}/persons/{personId}") + Observable> update(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons deleteFace" }) + @HTTP(path = "largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", method = "DELETE", hasBody = true) + Observable> deleteFace(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons getFace" }) + @GET("largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}") + Observable> getFace(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons updateFace" }) + @PATCH("largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}") + Observable> updateFace(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Body UpdateFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons addFaceFromUrl" }) + @POST("largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces") + Observable> addFaceFromUrl(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroupPersons addFaceFromStream" }) + @POST("largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces") + Observable> addFaceFromStream(@Path("largePersonGroupId") String largePersonGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person create(String largePersonGroupId) { + return createWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable createAsync(String largePersonGroupId) { + return createWithServiceResponseAsync(largePersonGroupId).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> createWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person create(String largePersonGroupId, String name, String userData) { + return createWithServiceResponseAsync(largePersonGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largePersonGroupId, name, userData), serviceCallback); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable createAsync(String largePersonGroupId, String name, String userData) { + return createWithServiceResponseAsync(largePersonGroupId, name, userData).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new person in a specified large person group. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> createWithServiceResponseAsync(String largePersonGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + public List list(String largePersonGroupId) { + return listWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String largePersonGroupId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable> listAsync(String largePersonGroupId) { + return listWithServiceResponseAsync(largePersonGroupId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable>> listWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(largePersonGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + public List list(String largePersonGroupId, String start, Integer top) { + return listWithServiceResponseAsync(largePersonGroupId, start, top).toBlocking().single().body(); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String largePersonGroupId, String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(largePersonGroupId, start, top), serviceCallback); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable> listAsync(String largePersonGroupId, String start, Integer top) { + return listWithServiceResponseAsync(largePersonGroupId, start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable>> listWithServiceResponseAsync(String largePersonGroupId, String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(largePersonGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String largePersonGroupId, UUID personId) { + deleteWithServiceResponseAsync(largePersonGroupId, personId).toBlocking().single().body(); + } + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(largePersonGroupId, personId), serviceCallback); + } + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String largePersonGroupId, UUID personId) { + return deleteWithServiceResponseAsync(largePersonGroupId, personId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing person from a large person group. All stored person data, and face features in the person entry will be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String largePersonGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(largePersonGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person get(String largePersonGroupId, UUID personId) { + return getWithServiceResponseAsync(largePersonGroupId, personId).toBlocking().single().body(); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(largePersonGroupId, personId), serviceCallback); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable getAsync(String largePersonGroupId, UUID personId) { + return getWithServiceResponseAsync(largePersonGroupId, personId).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve a person's information, including registered persisted faces, name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable> getWithServiceResponseAsync(String largePersonGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(largePersonGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largePersonGroupId, UUID personId) { + updateWithServiceResponseAsync(largePersonGroupId, personId).toBlocking().single().body(); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largePersonGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largePersonGroupId, personId), serviceCallback); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largePersonGroupId, UUID personId) { + return updateWithServiceResponseAsync(largePersonGroupId, personId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largePersonGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largePersonGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largePersonGroupId, UUID personId, String name, String userData) { + updateWithServiceResponseAsync(largePersonGroupId, personId, name, userData).toBlocking().single().body(); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largePersonGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largePersonGroupId, personId, name, userData), serviceCallback); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largePersonGroupId, UUID personId, String name, String userData) { + return updateWithServiceResponseAsync(largePersonGroupId, personId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update name or userData of a person. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largePersonGroupId, UUID personId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largePersonGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void deleteFace(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + deleteFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + return deleteFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete a face from a person. Relative feature for the persisted face will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.deleteFace(largePersonGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace getFace(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable getFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + return getFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> getFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getFace(largePersonGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).toBlocking().single().body(); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId), serviceCallback); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + return updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + final String userData = null; + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(largePersonGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData) { + updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId, userData).toBlocking().single().body(); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId, userData), serviceCallback); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData) { + return updateFaceWithServiceResponseAsync(largePersonGroupId, personId, persistedFaceId, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateFaceWithServiceResponseAsync(String largePersonGroupId, UUID personId, UUID persistedFaceId, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (persistedFaceId == null) { + throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); + } + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(largePersonGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateFaceDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String largePersonGroupId, UUID personId, String url) { + return addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url) { + return addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String largePersonGroupId, UUID personId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(largePersonGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String largePersonGroupId, UUID personId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(largePersonGroupId, personId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromUrlWithServiceResponseAsync(String largePersonGroupId, UUID personId, String url, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (url == null) { + throw new IllegalArgumentException("Parameter url is required and cannot be null."); + } + Validator.validate(targetFace); + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(largePersonGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String largePersonGroupId, UUID personId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String largePersonGroupId, UUID personId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(largePersonGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image, userData, targetFace), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromStreamAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(largePersonGroupId, personId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String largePersonGroupId, UUID personId, byte[] image, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + if (personId == null) { + throw new IllegalArgumentException("Parameter personId is required and cannot be null."); + } + if (image == null) { + throw new IllegalArgumentException("Parameter image is required and cannot be null."); + } + Validator.validate(targetFace); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(largePersonGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse addFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupsImpl.java new file mode 100644 index 0000000000000..d58352d8e80cf --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/LargePersonGroupsImpl.java @@ -0,0 +1,866 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.LargePersonGroup; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TrainingStatus; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in LargePersonGroups. + */ +public class LargePersonGroupsImpl implements LargePersonGroups { + /** The Retrofit service to perform REST calls. */ + private LargePersonGroupsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of LargePersonGroupsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public LargePersonGroupsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(LargePersonGroupsService.class); + this.client = client; + } + + /** + * The interface defining all the services for LargePersonGroups to be + * used by Retrofit to perform actually REST calls. + */ + interface LargePersonGroupsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups create" }) + @PUT("largepersongroups/{largePersonGroupId}") + Observable> create(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups delete" }) + @HTTP(path = "largepersongroups/{largePersonGroupId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups get" }) + @GET("largepersongroups/{largePersonGroupId}") + Observable> get(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups update" }) + @PATCH("largepersongroups/{largePersonGroupId}") + Observable> update(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups getTrainingStatus" }) + @GET("largepersongroups/{largePersonGroupId}/training") + Observable> getTrainingStatus(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups list" }) + @GET("largepersongroups") + Observable> list(@Query("start") String start, @Query("top") Integer top, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.LargePersonGroups train" }) + @POST("largepersongroups/{largePersonGroupId}/train") + Observable> train(@Path("largePersonGroupId") String largePersonGroupId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String largePersonGroupId) { + createWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String largePersonGroupId) { + return createWithServiceResponseAsync(largePersonGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String largePersonGroupId, String name, String userData) { + createWithServiceResponseAsync(largePersonGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(largePersonGroupId, name, userData), serviceCallback); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String largePersonGroupId, String name, String userData) { + return createWithServiceResponseAsync(largePersonGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create a new large person group with specified largePersonGroupId, name and user-provided userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> createWithServiceResponseAsync(String largePersonGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String largePersonGroupId) { + deleteWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String largePersonGroupId) { + return deleteWithServiceResponseAsync(largePersonGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(largePersonGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LargePersonGroup object if successful. + */ + public LargePersonGroup get(String largePersonGroupId) { + return getWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargePersonGroup object + */ + public Observable getAsync(String largePersonGroupId) { + return getWithServiceResponseAsync(largePersonGroupId).map(new Func1, LargePersonGroup>() { + @Override + public LargePersonGroup call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the information of a large person group, including its name and userData. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LargePersonGroup object + */ + public Observable> getWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(largePersonGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largePersonGroupId) { + updateWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largePersonGroupId) { + return updateWithServiceResponseAsync(largePersonGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String largePersonGroupId, String name, String userData) { + updateWithServiceResponseAsync(largePersonGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String largePersonGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(largePersonGroupId, name, userData), serviceCallback); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String largePersonGroupId, String name, String userData) { + return updateWithServiceResponseAsync(largePersonGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update an existing large person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(String largePersonGroupId, String name, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(largePersonGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the TrainingStatus object if successful. + */ + public TrainingStatus getTrainingStatus(String largePersonGroupId) { + return getTrainingStatusWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getTrainingStatusAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getTrainingStatusWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable getTrainingStatusAsync(String largePersonGroupId) { + return getTrainingStatusWithServiceResponseAsync(largePersonGroupId).map(new Func1, TrainingStatus>() { + @Override + public TrainingStatus call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the training status of a large person group (completed or ongoing). + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the TrainingStatus object + */ + public Observable> getTrainingStatusWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getTrainingStatus(largePersonGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getTrainingStatusDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getTrainingStatusDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargePersonGroup> object if successful. + */ + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * List large person groups and their information. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List large person groups and their information. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<LargePersonGroup> object if successful. + */ + public List list(String start, Integer top) { + return listWithServiceResponseAsync(start, top).toBlocking().single().body(); + } + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(start, top), serviceCallback); + } + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + public Observable> listAsync(String start, Integer top) { + return listWithServiceResponseAsync(start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List large person groups and their information. + * + * @param start List large person groups from the least largePersonGroupId greater than the "start". + * @param top The number of large person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<LargePersonGroup> object + */ + public Observable>> listWithServiceResponseAsync(String start, Integer top) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void train(String largePersonGroupId) { + trainWithServiceResponseAsync(largePersonGroupId).toBlocking().single().body(); + } + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture trainAsync(String largePersonGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(trainWithServiceResponseAsync(largePersonGroupId), serviceCallback); + } + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable trainAsync(String largePersonGroupId) { + return trainWithServiceResponseAsync(largePersonGroupId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Queue a large person group training task, the training task may not be started immediately. + * + * @param largePersonGroupId Id referencing a particular large person group. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> trainWithServiceResponseAsync(String largePersonGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (largePersonGroupId == null) { + throw new IllegalArgumentException("Parameter largePersonGroupId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.train(largePersonGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = trainDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse trainDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java index cf06d839bd97a..a811c75958313 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupPersonsImpl.java @@ -8,12 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreatePersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ListPersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonGroupPersonsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddPersonFaceFromUrlOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.AddPersonFaceFromStreamOptionalParameter; import retrofit2.Retrofit; import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons; import com.google.common.base.Joiner; @@ -23,12 +17,13 @@ import com.microsoft.azure.cognitiveservices.vision.faceapi.models.NameAndUserDataContract; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.PersistedFace; import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Person; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonFaceRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateFaceRequest; import com.microsoft.rest.CollectionFormat; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; +import java.io.InputStream; import java.io.IOException; import java.util.List; import java.util.UUID; @@ -56,7 +51,7 @@ public class PersonGroupPersonsImpl implements PersonGroupPersons { /** The Retrofit service to perform REST calls. */ private PersonGroupPersonsService service; /** The service client containing this operation class. */ - private FaceAPIImpl client; + private FaceClientImpl client; /** * Initializes an instance of PersonGroupPersonsImpl. @@ -64,7 +59,7 @@ public class PersonGroupPersonsImpl implements PersonGroupPersons { * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public PersonGroupPersonsImpl(Retrofit retrofit, FaceAPIImpl client) { + public PersonGroupPersonsImpl(Retrofit retrofit, FaceClientImpl client) { this.service = retrofit.create(PersonGroupPersonsService.class); this.client = client; } @@ -76,7 +71,7 @@ public PersonGroupPersonsImpl(Retrofit retrofit, FaceAPIImpl client) { interface PersonGroupPersonsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons create" }) @POST("persongroups/{personGroupId}/persons") - Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons list" }) @GET("persongroups/{personGroupId}/persons") @@ -92,68 +87,64 @@ interface PersonGroupPersonsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons update" }) @PATCH("persongroups/{personGroupId}/persons/{personId}") - Observable> update(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> update(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons deleteFace" }) - @HTTP(path = "persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", method = "DELETE", hasBody = true) + @HTTP(path = "persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}", method = "DELETE", hasBody = true) Observable> deleteFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons getFace" }) - @GET("persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}") + @GET("persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}") Observable> getFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons updateFace" }) - @PATCH("persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}") - Observable> updateFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Body UpdatePersonFaceRequest bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @PATCH("persongroups/{personGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}") + Observable> updateFace(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Path("persistedFaceId") UUID persistedFaceId, @Header("accept-language") String acceptLanguage, @Body UpdateFaceRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addPersonFaceFromUrl" }) - @POST("persongroups/{personGroupId}/persons/{personId}/persistedFaces") - Observable> addPersonFaceFromUrl(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addFaceFromUrl" }) + @POST("persongroups/{personGroupId}/persons/{personId}/persistedfaces") + Observable> addFaceFromUrl(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Header("accept-language") String acceptLanguage, @Body ImageUrl imageUrl, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addPersonFaceFromStream" }) - @POST("persongroups/{personGroupId}/persons/{personId}/persistedFaces") - Observable> addPersonFaceFromStream(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/octet-stream", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroupPersons addFaceFromStream" }) + @POST("persongroups/{personGroupId}/persons/{personId}/persistedfaces") + Observable> addFaceFromStream(@Path("personGroupId") String personGroupId, @Path("personId") UUID personId, @Query("userData") String userData, @Query("targetFace") String targetFace, @Body RequestBody image, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } - /** * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the Person object if successful. */ - public Person create(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter) { - return createWithServiceResponseAsync(personGroupId, createOptionalParameter).toBlocking().single().body(); + public Person create(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).toBlocking().single().body(); } /** * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture createAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, createOptionalParameter), serviceCallback); + public ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId), serviceCallback); } /** * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the Person object */ - public Observable createAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter) { - return createWithServiceResponseAsync(personGroupId, createOptionalParameter).map(new Func1, Person>() { + public Observable createAsync(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).map(new Func1, Person>() { @Override public Person call(ServiceResponse response) { return response.body(); @@ -165,21 +156,81 @@ public Person call(ServiceResponse response) { * Create a new person in a specified person group. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the Person object */ - public Observable> createWithServiceResponseAsync(String personGroupId, CreatePersonGroupPersonsOptionalParameter createOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> createWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - final String name = createOptionalParameter != null ? createOptionalParameter.name() : null; - final String userData = createOptionalParameter != null ? createOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Person object if successful. + */ + public Person create(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } - return createWithServiceResponseAsync(personGroupId, name, userData); + /** + * Create a new person in a specified person group. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Person object + */ + public Observable createAsync(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Person>() { + @Override + public Person call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -192,17 +243,17 @@ public Observable> createWithServiceResponseAsync(String * @return the observable to the Person object */ public Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.create(personGroupId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -223,100 +274,40 @@ private ServiceResponse createDelegate(Response response) .build(response); } - @Override - public PersonGroupPersonsCreateParameters create() { - return new PersonGroupPersonsCreateParameters(this); - } - - /** - * Internal class implementing PersonGroupPersonsCreateDefinition. - */ - class PersonGroupPersonsCreateParameters implements PersonGroupPersonsCreateDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsCreateParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsCreateParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsCreateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public PersonGroupPersonsCreateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public Person execute() { - return createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Person>() { - @Override - public Person call(ServiceResponse response) { - return response.body(); - } - }); - } - } - - /** * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). * * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the List<Person> object if successful. */ - public List list(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter) { - return listWithServiceResponseAsync(personGroupId, listOptionalParameter).toBlocking().single().body(); + public List list(String personGroupId) { + return listWithServiceResponseAsync(personGroupId).toBlocking().single().body(); } /** * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). * * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> listAsync(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(personGroupId, listOptionalParameter), serviceCallback); + public ServiceFuture> listAsync(String personGroupId, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(personGroupId), serviceCallback); } /** * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). * * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<Person> object */ - public Observable> listAsync(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter) { - return listWithServiceResponseAsync(personGroupId, listOptionalParameter).map(new Func1>, List>() { + public Observable> listAsync(String personGroupId) { + return listWithServiceResponseAsync(personGroupId).map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -328,21 +319,78 @@ public List call(ServiceResponse> response) { * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). * * @param personGroupId Id referencing a particular person group. - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<Person> object */ - public Observable>> listWithServiceResponseAsync(String personGroupId, ListPersonGroupPersonsOptionalParameter listOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> listWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - final String start = listOptionalParameter != null ? listOptionalParameter.start() : null; - final Integer top = listOptionalParameter != null ? listOptionalParameter.top() : null; + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(personGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Person> object if successful. + */ + public List list(String personGroupId, String start, Integer top) { + return listWithServiceResponseAsync(personGroupId, start, top).toBlocking().single().body(); + } - return listWithServiceResponseAsync(personGroupId, start, top); + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String personGroupId, String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(personGroupId, start, top), serviceCallback); + } + + /** + * List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person). + * + * @param personGroupId Id referencing a particular person group. + * @param start Starting person id to return (used to list a range of persons). + * @param top Number of persons to return starting with the person id indicated by the 'start' parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Person> object + */ + public Observable> listAsync(String personGroupId, String start, Integer top) { + return listWithServiceResponseAsync(personGroupId, start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); } /** @@ -355,13 +403,13 @@ public Observable>> listWithServiceResponseAsync(St * @return the observable to the List<Person> object */ public Observable>> listWithServiceResponseAsync(String personGroupId, String start, Integer top) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.list(personGroupId, start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override @@ -383,64 +431,8 @@ private ServiceResponse> listDelegate(Response respon .build(response); } - @Override - public PersonGroupPersonsListParameters list() { - return new PersonGroupPersonsListParameters(this); - } - - /** - * Internal class implementing PersonGroupPersonsListDefinition. - */ - class PersonGroupPersonsListParameters implements PersonGroupPersonsListDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private String start; - private Integer top; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsListParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsListParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsListParameters withStart(String start) { - this.start = start; - return this; - } - - @Override - public PersonGroupPersonsListParameters withTop(Integer top) { - this.top = top; - return this; - } - - @Override - public List execute() { - return listWithServiceResponseAsync(personGroupId, start, top).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return listWithServiceResponseAsync(personGroupId, start, top).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - } - /** - * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -453,7 +445,7 @@ public void delete(String personGroupId, UUID personId) { } /** - * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -466,7 +458,7 @@ public ServiceFuture deleteAsync(String personGroupId, UUID personId, fina } /** - * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -483,7 +475,7 @@ public Void call(ServiceResponse response) { } /** - * Delete an existing person from a person group. Persisted face images of the person will also be deleted. + * Delete an existing person from a person group. All stored person data, and face features in the person entry will be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -491,8 +483,8 @@ public Void call(ServiceResponse response) { * @return the {@link ServiceResponse} object if successful. */ public Observable> deleteWithServiceResponseAsync(String personGroupId, UUID personId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -500,7 +492,7 @@ public Observable> deleteWithServiceResponseAsync(String p if (personId == null) { throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.delete(personGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -575,8 +567,8 @@ public Person call(ServiceResponse response) { * @return the observable to the Person object */ public Observable> getWithServiceResponseAsync(String personGroupId, UUID personId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -584,7 +576,7 @@ public Observable> getWithServiceResponseAsync(String pe if (personId == null) { throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.get(personGroupId, personId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -606,19 +598,17 @@ private ServiceResponse getDelegate(Response response) thr .build(response); } - /** * Update name or userData of a person. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void update(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter) { - updateWithServiceResponseAsync(personGroupId, personId, updateOptionalParameter).toBlocking().single().body(); + public void update(String personGroupId, UUID personId) { + updateWithServiceResponseAsync(personGroupId, personId).toBlocking().single().body(); } /** @@ -626,13 +616,12 @@ public void update(String personGroupId, UUID personId, UpdatePersonGroupPersons * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture updateAsync(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, personId, updateOptionalParameter), serviceCallback); + public ServiceFuture updateAsync(String personGroupId, UUID personId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, personId), serviceCallback); } /** @@ -640,12 +629,11 @@ public ServiceFuture updateAsync(String personGroupId, UUID personId, Upda * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable updateAsync(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter) { - return updateWithServiceResponseAsync(personGroupId, personId, updateOptionalParameter).map(new Func1, Void>() { + public Observable updateAsync(String personGroupId, UUID personId) { + return updateWithServiceResponseAsync(personGroupId, personId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -658,13 +646,12 @@ public Void call(ServiceResponse response) { * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId, UpdatePersonGroupPersonsOptionalParameter updateOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -672,10 +659,73 @@ public Observable> updateWithServiceResponseAsync(String p if (personId == null) { throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - final String name = updateOptionalParameter != null ? updateOptionalParameter.name() : null; - final String userData = updateOptionalParameter != null ? updateOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return updateWithServiceResponseAsync(personGroupId, personId, name, userData); + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId, UUID personId, String name, String userData) { + updateWithServiceResponseAsync(personGroupId, personId, name, userData).toBlocking().single().body(); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, UUID personId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, personId, name, userData), serviceCallback); + } + + /** + * Update name or userData of a person. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId, UUID personId, String name, String userData) { + return updateWithServiceResponseAsync(personGroupId, personId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -689,8 +739,8 @@ public Observable> updateWithServiceResponseAsync(String p * @return the {@link ServiceResponse} object if successful. */ public Observable> updateWithServiceResponseAsync(String personGroupId, UUID personId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -698,11 +748,11 @@ public Observable> updateWithServiceResponseAsync(String p if (personId == null) { throw new IllegalArgumentException("Parameter personId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.update(personGroupId, personId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, personId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -723,71 +773,8 @@ private ServiceResponse updateDelegate(Response response) th .build(response); } - @Override - public PersonGroupPersonsUpdateParameters update() { - return new PersonGroupPersonsUpdateParameters(this); - } - /** - * Internal class implementing PersonGroupPersonsUpdateDefinition. - */ - class PersonGroupPersonsUpdateParameters implements PersonGroupPersonsUpdateDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private UUID personId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsUpdateParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsUpdateParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsUpdateParameters withPersonId(UUID personId) { - this.personId = personId; - return this; - } - - @Override - public PersonGroupPersonsUpdateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public PersonGroupPersonsUpdateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - updateWithServiceResponseAsync(personGroupId, personId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return updateWithServiceResponseAsync(personGroupId, personId, name, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - - /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -801,7 +788,7 @@ public void deleteFace(String personGroupId, UUID personId, UUID persistedFaceId } /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -815,7 +802,7 @@ public ServiceFuture deleteFaceAsync(String personGroupId, UUID personId, } /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -833,7 +820,7 @@ public Void call(ServiceResponse response) { } /** - * Delete a face from a person. Relative image for the persisted face will also be deleted. + * Delete a face from a person. Relative feature for the persisted face will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. @@ -842,8 +829,8 @@ public Void call(ServiceResponse response) { * @return the {@link ServiceResponse} object if successful. */ public Observable> deleteFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -854,7 +841,7 @@ public Observable> deleteFaceWithServiceResponseAsync(Stri if (persistedFaceId == null) { throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.deleteFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -933,8 +920,8 @@ public PersistedFace call(ServiceResponse response) { * @return the observable to the PersistedFace object */ public Observable> getFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -945,7 +932,7 @@ public Observable> getFaceWithServiceResponseAsyn if (persistedFaceId == null) { throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.getFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -967,20 +954,18 @@ private ServiceResponse getFaceDelegate(Response re .build(response); } - /** * Update a person persisted face's userData field. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter) { - updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, updateFaceOptionalParameter).toBlocking().single().body(); + public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId) { + updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).toBlocking().single().body(); } /** @@ -989,13 +974,12 @@ public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, updateFaceOptionalParameter), serviceCallback); + public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId), serviceCallback); } /** @@ -1004,12 +988,11 @@ public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter) { - return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, updateFaceOptionalParameter).map(new Func1, Void>() { + public Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -1023,13 +1006,12 @@ public Void call(ServiceResponse response) { * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. - * @param updateFaceOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId, UpdateFaceOptionalParameter updateFaceOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1040,9 +1022,71 @@ public Observable> updateFaceWithServiceResponseAsync(Stri if (persistedFaceId == null) { throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); } - final String userData = updateFaceOptionalParameter != null ? updateFaceOptionalParameter.userData() : null; + final String userData = null; + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateFaceDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void updateFace(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { + updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).toBlocking().single().body(); + } + + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData), serviceCallback); + } - return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData); + /** + * Update a person persisted face's userData field. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param persistedFaceId Id referencing a particular persistedFaceId of an existing face. + * @param userData User-provided data attached to the face. The size limit is 1KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateFaceAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { + return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -1056,8 +1100,8 @@ public Observable> updateFaceWithServiceResponseAsync(Stri * @return the {@link ServiceResponse} object if successful. */ public Observable> updateFaceWithServiceResponseAsync(String personGroupId, UUID personId, UUID persistedFaceId, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1068,10 +1112,10 @@ public Observable> updateFaceWithServiceResponseAsync(Stri if (persistedFaceId == null) { throw new IllegalArgumentException("Parameter persistedFaceId is required and cannot be null."); } - UpdatePersonFaceRequest bodyParameter = new UpdatePersonFaceRequest(); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.updateFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + UpdateFaceRequest body = new UpdateFaceRequest(); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateFace(personGroupId, personId, persistedFaceId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -1092,84 +1136,19 @@ private ServiceResponse updateFaceDelegate(Response response .build(response); } - @Override - public PersonGroupPersonsUpdateFaceParameters updateFace() { - return new PersonGroupPersonsUpdateFaceParameters(this); - } - - /** - * Internal class implementing PersonGroupPersonsUpdateFaceDefinition. - */ - class PersonGroupPersonsUpdateFaceParameters implements PersonGroupPersonsUpdateFaceDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private UUID personId; - private UUID persistedFaceId; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsUpdateFaceParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsUpdateFaceParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsUpdateFaceParameters withPersonId(UUID personId) { - this.personId = personId; - return this; - } - - @Override - public PersonGroupPersonsUpdateFaceParameters withPersistedFaceId(UUID persistedFaceId) { - this.persistedFaceId = persistedFaceId; - return this; - } - - @Override - public PersonGroupPersonsUpdateFaceParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return updateFaceWithServiceResponseAsync(personGroupId, personId, persistedFaceId, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - - /** * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param url Publicly reachable URL of an image - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - public PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter) { - return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, addPersonFaceFromUrlOptionalParameter).toBlocking().single().body(); + public PersistedFace addFaceFromUrl(String personGroupId, UUID personId, String url) { + return addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url).toBlocking().single().body(); } /** @@ -1178,13 +1157,12 @@ public PersistedFace addPersonFaceFromUrl(String personGroupId, UUID personId, S * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param url Publicly reachable URL of an image - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, addPersonFaceFromUrlOptionalParameter), serviceCallback); + public ServiceFuture addFaceFromUrlAsync(String personGroupId, UUID personId, String url, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url), serviceCallback); } /** @@ -1193,12 +1171,11 @@ public ServiceFuture addPersonFaceFromUrlAsync(String personGroup * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param url Publicly reachable URL of an image - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable addPersonFaceFromUrlAsync(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter) { - return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, addPersonFaceFromUrlOptionalParameter).map(new Func1, PersistedFace>() { + public Observable addFaceFromUrlAsync(String personGroupId, UUID personId, String url) { + return addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url).map(new Func1, PersistedFace>() { @Override public PersistedFace call(ServiceResponse response) { return response.body(); @@ -1212,13 +1189,12 @@ public PersistedFace call(ServiceResponse response) { * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param url Publicly reachable URL of an image - * @param addPersonFaceFromUrlOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, AddPersonFaceFromUrlOptionalParameter addPersonFaceFromUrlOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> addFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1229,10 +1205,77 @@ public Observable> addPersonFaceFromUrlWithServic if (url == null) { throw new IllegalArgumentException("Parameter url is required and cannot be null."); } - final String userData = addPersonFaceFromUrlOptionalParameter != null ? addPersonFaceFromUrlOptionalParameter.userData() : null; - final List targetFace = addPersonFaceFromUrlOptionalParameter != null ? addPersonFaceFromUrlOptionalParameter.targetFace() : null; + final String userData = null; + final List targetFace = null; + ImageUrl imageUrl = new ImageUrl(); + imageUrl.withUrl(url); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); + return service.addFaceFromUrl(personGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromUrl(String personGroupId, UUID personId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace), serviceCallback); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param url Publicly reachable URL of an image + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable addFaceFromUrlAsync(String personGroupId, UUID personId, String url, String userData, List targetFace) { + return addFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -1246,9 +1289,9 @@ public Observable> addPersonFaceFromUrlWithServic * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addPersonFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, String userData, List targetFace) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> addFaceFromUrlWithServiceResponseAsync(String personGroupId, UUID personId, String url, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1262,14 +1305,14 @@ public Observable> addPersonFaceFromUrlWithServic Validator.validate(targetFace); ImageUrl imageUrl = new ImageUrl(); imageUrl.withUrl(url); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); - return service.addPersonFaceFromUrl(personGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) + return service.addFaceFromUrl(personGroupId, personId, userData, targetFaceConverted, this.client.acceptLanguage(), imageUrl, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = addPersonFaceFromUrlDelegate(response); + ServiceResponse clientResponse = addFaceFromUrlDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -1278,98 +1321,26 @@ public Observable> call(Response re }); } - private ServiceResponse addPersonFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + private ServiceResponse addFaceFromUrlDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(APIErrorException.class) .build(response); } - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters addPersonFaceFromUrl() { - return new PersonGroupPersonsAddPersonFaceFromUrlParameters(this); - } - - /** - * Internal class implementing PersonGroupPersonsAddPersonFaceFromUrlDefinition. - */ - class PersonGroupPersonsAddPersonFaceFromUrlParameters implements PersonGroupPersonsAddPersonFaceFromUrlDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private UUID personId; - private String url; - private String userData; - private List targetFace; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsAddPersonFaceFromUrlParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters withPersonId(UUID personId) { - this.personId = personId; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters withUrl(String url) { - this.url = url; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromUrlParameters withTargetFace(List targetFace) { - this.targetFace = targetFace; - return this; - } - - @Override - public PersistedFace execute() { - return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return addPersonFaceFromUrlWithServiceResponseAsync(personGroupId, personId, url, userData, targetFace).map(new Func1, PersistedFace>() { - @Override - public PersistedFace call(ServiceResponse response) { - return response.body(); - } - }); - } - } - - /** * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. * * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent * @return the PersistedFace object if successful. */ - public PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter) { - return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, addPersonFaceFromStreamOptionalParameter).toBlocking().single().body(); + public PersistedFace addFaceFromStream(String personGroupId, UUID personId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image).toBlocking().single().body(); } /** @@ -1378,13 +1349,12 @@ public PersistedFace addPersonFaceFromStream(String personGroupId, UUID personId * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, addPersonFaceFromStreamOptionalParameter), serviceCallback); + public ServiceFuture addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image), serviceCallback); } /** @@ -1393,12 +1363,11 @@ public ServiceFuture addPersonFaceFromStreamAsync(String personGr * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable addPersonFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter) { - return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, addPersonFaceFromStreamOptionalParameter).map(new Func1, PersistedFace>() { + public Observable addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image) { + return addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image).map(new Func1, PersistedFace>() { @Override public PersistedFace call(ServiceResponse response) { return response.body(); @@ -1412,13 +1381,12 @@ public PersistedFace call(ServiceResponse response) { * @param personGroupId Id referencing a particular person group. * @param personId Id referencing a particular person. * @param image An image stream. - * @param addPersonFaceFromStreamOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, AddPersonFaceFromStreamOptionalParameter addPersonFaceFromStreamOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> addFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1429,10 +1397,55 @@ public Observable> addPersonFaceFromStreamWithSer if (image == null) { throw new IllegalArgumentException("Parameter image is required and cannot be null."); } - final String userData = addPersonFaceFromStreamOptionalParameter != null ? addPersonFaceFromStreamOptionalParameter.userData() : null; - final List targetFace = addPersonFaceFromStreamOptionalParameter != null ? addPersonFaceFromStreamOptionalParameter.targetFace() : null; + final String userData = null; + final List targetFace = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(personGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace); + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the PersistedFace object if successful. + */ + public PersistedFace addFaceFromStream(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).toBlocking().single().body(); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace), serviceCallback); } /** @@ -1446,9 +1459,29 @@ public Observable> addPersonFaceFromStreamWithSer * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the PersistedFace object */ - public Observable> addPersonFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable addFaceFromStreamAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + return addFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).map(new Func1, PersistedFace>() { + @Override + public PersistedFace call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Add a representative face to a person for identification. The input face is specified as an image with a targetFace rectangle. + * + * @param personGroupId Id referencing a particular person group. + * @param personId Id referencing a particular person. + * @param image An image stream. + * @param userData User-specified data about the face for any purpose. The maximum length is 1KB. + * @param targetFace A face rectangle to specify the target face to be added to a person in the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the PersistedFace object + */ + public Observable> addFaceFromStreamWithServiceResponseAsync(String personGroupId, UUID personId, byte[] image, String userData, List targetFace) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); @@ -1460,15 +1493,14 @@ public Observable> addPersonFaceFromStreamWithSer throw new IllegalArgumentException("Parameter image is required and cannot be null."); } Validator.validate(targetFace); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV); - RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); - return service.addPersonFaceFromStream(personGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String targetFaceConverted = this.client.serializerAdapter().serializeList(targetFace, CollectionFormat.CSV);RequestBody imageConverted = RequestBody.create(MediaType.parse("application/octet-stream"), image); + return service.addFaceFromStream(personGroupId, personId, userData, targetFaceConverted, imageConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = addPersonFaceFromStreamDelegate(response); + ServiceResponse clientResponse = addFaceFromStreamDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); @@ -1477,81 +1509,11 @@ public Observable> call(Response re }); } - private ServiceResponse addPersonFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + private ServiceResponse addFaceFromStreamDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(APIErrorException.class) .build(response); } - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters addPersonFaceFromStream() { - return new PersonGroupPersonsAddPersonFaceFromStreamParameters(this); - } - - /** - * Internal class implementing PersonGroupPersonsAddPersonFaceFromStreamDefinition. - */ - class PersonGroupPersonsAddPersonFaceFromStreamParameters implements PersonGroupPersonsAddPersonFaceFromStreamDefinition { - private PersonGroupPersonsImpl parent; - private String personGroupId; - private UUID personId; - private byte[] image; - private String userData; - private List targetFace; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupPersonsAddPersonFaceFromStreamParameters(PersonGroupPersonsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters withPersonId(UUID personId) { - this.personId = personId; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters withImage(byte[] image) { - this.image = image; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public PersonGroupPersonsAddPersonFaceFromStreamParameters withTargetFace(List targetFace) { - this.targetFace = targetFace; - return this; - } - - @Override - public PersistedFace execute() { - return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return addPersonFaceFromStreamWithServiceResponseAsync(personGroupId, personId, image, userData, targetFace).map(new Func1, PersistedFace>() { - @Override - public PersistedFace call(ServiceResponse response) { - return response.body(); - } - }); - } - } - } diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java index fe1eac104a0b4..b19b05797bec6 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/PersonGroupsImpl.java @@ -8,9 +8,6 @@ package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.CreatePersonGroupsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdatePersonGroupsOptionalParameter; -import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ListPersonGroupsOptionalParameter; import retrofit2.Retrofit; import com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups; import com.google.common.base.Joiner; @@ -47,7 +44,7 @@ public class PersonGroupsImpl implements PersonGroups { /** The Retrofit service to perform REST calls. */ private PersonGroupsService service; /** The service client containing this operation class. */ - private FaceAPIImpl client; + private FaceClientImpl client; /** * Initializes an instance of PersonGroupsImpl. @@ -55,7 +52,7 @@ public class PersonGroupsImpl implements PersonGroups { * @param retrofit the Retrofit instance built from a Retrofit Builder. * @param client the instance of the service client containing this operation class. */ - public PersonGroupsImpl(Retrofit retrofit, FaceAPIImpl client) { + public PersonGroupsImpl(Retrofit retrofit, FaceClientImpl client) { this.service = retrofit.create(PersonGroupsService.class); this.client = client; } @@ -67,7 +64,7 @@ public PersonGroupsImpl(Retrofit retrofit, FaceAPIImpl client) { interface PersonGroupsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups create" }) @PUT("persongroups/{personGroupId}") - Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> create(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups delete" }) @HTTP(path = "persongroups/{personGroupId}", method = "DELETE", hasBody = true) @@ -79,7 +76,7 @@ interface PersonGroupsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups update" }) @PATCH("persongroups/{personGroupId}") - Observable> update(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract bodyParameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> update(@Path("personGroupId") String personGroupId, @Header("accept-language") String acceptLanguage, @Body NameAndUserDataContract body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.PersonGroups getTrainingStatus" }) @GET("persongroups/{personGroupId}/training") @@ -95,43 +92,39 @@ interface PersonGroupsService { } - /** * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void create(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter) { - createWithServiceResponseAsync(personGroupId, createOptionalParameter).toBlocking().single().body(); + public void create(String personGroupId) { + createWithServiceResponseAsync(personGroupId).toBlocking().single().body(); } /** * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture createAsync(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, createOptionalParameter), serviceCallback); + public ServiceFuture createAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId), serviceCallback); } /** * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable createAsync(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter) { - return createWithServiceResponseAsync(personGroupId, createOptionalParameter).map(new Func1, Void>() { + public Observable createAsync(String personGroupId) { + return createWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -143,21 +136,80 @@ public Void call(ServiceResponse response) { * Create a new person group with specified personGroupId, name and user-provided userData. * * @param personGroupId Id referencing a particular person group. - * @param createOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> createWithServiceResponseAsync(String personGroupId, CreatePersonGroupsOptionalParameter createOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> createWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - final String name = createOptionalParameter != null ? createOptionalParameter.name() : null; - final String userData = createOptionalParameter != null ? createOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return createWithServiceResponseAsync(personGroupId, name, userData); + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void create(String personGroupId, String name, String userData) { + createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } + + /** + * Create a new person group with specified personGroupId, name and user-provided userData. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable createAsync(String personGroupId, String name, String userData) { + return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -170,17 +222,17 @@ public Observable> createWithServiceResponseAsync(String p * @return the {@link ServiceResponse} object if successful. */ public Observable> createWithServiceResponseAsync(String personGroupId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.create(personGroupId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.create(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -201,64 +253,8 @@ private ServiceResponse createDelegate(Response response) th .build(response); } - @Override - public PersonGroupsCreateParameters create() { - return new PersonGroupsCreateParameters(this); - } - - /** - * Internal class implementing PersonGroupsCreateDefinition. - */ - class PersonGroupsCreateParameters implements PersonGroupsCreateDefinition { - private PersonGroupsImpl parent; - private String personGroupId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupsCreateParameters(PersonGroupsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupsCreateParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupsCreateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public PersonGroupsCreateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - createWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return createWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - /** - * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. * @throws IllegalArgumentException thrown if parameters fail the validation @@ -270,7 +266,7 @@ public void delete(String personGroupId) { } /** - * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -282,7 +278,7 @@ public ServiceFuture deleteAsync(String personGroupId, final ServiceCallba } /** - * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. * @throws IllegalArgumentException thrown if parameters fail the validation @@ -298,20 +294,20 @@ public Void call(ServiceResponse response) { } /** - * Delete an existing person group. Persisted face images of all people in the person group will also be deleted. + * Delete an existing person group. Persisted face features of all people in the person group will also be deleted. * * @param personGroupId Id referencing a particular person group. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ public Observable> deleteWithServiceResponseAsync(String personGroupId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.delete(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -382,13 +378,13 @@ public PersonGroup call(ServiceResponse response) { * @return the observable to the PersonGroup object */ public Observable> getWithServiceResponseAsync(String personGroupId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.get(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -410,43 +406,39 @@ private ServiceResponse getDelegate(Response response .build(response); } - /** * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @throws APIErrorException thrown if the request is rejected by server * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent */ - public void update(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter) { - updateWithServiceResponseAsync(personGroupId, updateOptionalParameter).toBlocking().single().body(); + public void update(String personGroupId) { + updateWithServiceResponseAsync(personGroupId).toBlocking().single().body(); } /** * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture updateAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter, final ServiceCallback serviceCallback) { - return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, updateOptionalParameter), serviceCallback); + public ServiceFuture updateAsync(String personGroupId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId), serviceCallback); } /** * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable updateAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter) { - return updateWithServiceResponseAsync(personGroupId, updateOptionalParameter).map(new Func1, Void>() { + public Observable updateAsync(String personGroupId) { + return updateWithServiceResponseAsync(personGroupId).map(new Func1, Void>() { @Override public Void call(ServiceResponse response) { return response.body(); @@ -458,21 +450,80 @@ public Void call(ServiceResponse response) { * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. * * @param personGroupId Id referencing a particular person group. - * @param updateOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceResponse} object if successful. */ - public Observable> updateWithServiceResponseAsync(String personGroupId, UpdatePersonGroupsOptionalParameter updateOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable> updateWithServiceResponseAsync(String personGroupId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - final String name = updateOptionalParameter != null ? updateOptionalParameter.name() : null; - final String userData = updateOptionalParameter != null ? updateOptionalParameter.userData() : null; + final String name = null; + final String userData = null; + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return updateWithServiceResponseAsync(personGroupId, name, userData); + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(String personGroupId, String name, String userData) { + updateWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String personGroupId, String name, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(personGroupId, name, userData), serviceCallback); + } + + /** + * Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated. + * + * @param personGroupId Id referencing a particular person group. + * @param name User defined name, maximum length is 128. + * @param userData User specified data. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(String personGroupId, String name, String userData) { + return updateWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); } /** @@ -485,17 +536,17 @@ public Observable> updateWithServiceResponseAsync(String p * @return the {@link ServiceResponse} object if successful. */ public Observable> updateWithServiceResponseAsync(String personGroupId, String name, String userData) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - NameAndUserDataContract bodyParameter = new NameAndUserDataContract(); - bodyParameter.withName(name); - bodyParameter.withUserData(userData); - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); - return service.update(personGroupId, this.client.acceptLanguage(), bodyParameter, parameterizedHost, this.client.userAgent()) + NameAndUserDataContract body = new NameAndUserDataContract(); + body.withName(name); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(personGroupId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override public Observable> call(Response response) { @@ -516,62 +567,6 @@ private ServiceResponse updateDelegate(Response response) th .build(response); } - @Override - public PersonGroupsUpdateParameters update() { - return new PersonGroupsUpdateParameters(this); - } - - /** - * Internal class implementing PersonGroupsUpdateDefinition. - */ - class PersonGroupsUpdateParameters implements PersonGroupsUpdateDefinition { - private PersonGroupsImpl parent; - private String personGroupId; - private String name; - private String userData; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupsUpdateParameters(PersonGroupsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupsUpdateParameters withPersonGroupId(String personGroupId) { - this.personGroupId = personGroupId; - return this; - } - - @Override - public PersonGroupsUpdateParameters withName(String name) { - this.name = name; - return this; - } - - @Override - public PersonGroupsUpdateParameters withUserData(String userData) { - this.userData = userData; - return this; - } - - @Override - public void execute() { - updateWithServiceResponseAsync(personGroupId, name, userData).toBlocking().single().body(); - } - - @Override - public Observable executeAsync() { - return updateWithServiceResponseAsync(personGroupId, name, userData).map(new Func1, Void>() { - @Override - public Void call(ServiceResponse response) { - return response.body(); - } - }); - } - } - /** * Retrieve the training status of a person group (completed or ongoing). * @@ -621,13 +616,13 @@ public TrainingStatus call(ServiceResponse response) { * @return the observable to the TrainingStatus object */ public Observable> getTrainingStatusWithServiceResponseAsync(String personGroupId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.getTrainingStatus(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override @@ -649,41 +644,37 @@ private ServiceResponse getTrainingStatusDelegate(Response list(ListPersonGroupsOptionalParameter listOptionalParameter) { - return listWithServiceResponseAsync(listOptionalParameter).toBlocking().single().body(); + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); } /** * List person groups and their information. * - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if parameters fail the validation * @return the {@link ServiceFuture} object */ - public ServiceFuture> listAsync(ListPersonGroupsOptionalParameter listOptionalParameter, final ServiceCallback> serviceCallback) { - return ServiceFuture.fromResponse(listWithServiceResponseAsync(listOptionalParameter), serviceCallback); + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); } /** * List person groups and their information. * - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<PersonGroup> object */ - public Observable> listAsync(ListPersonGroupsOptionalParameter listOptionalParameter) { - return listWithServiceResponseAsync(listOptionalParameter).map(new Func1>, List>() { + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { @Override public List call(ServiceResponse> response) { return response.body(); @@ -694,18 +685,72 @@ public List call(ServiceResponse> response) { /** * List person groups and their information. * - * @param listOptionalParameter the object representing the optional parameters to be set before calling this API * @throws IllegalArgumentException thrown if parameters fail the validation * @return the observable to the List<PersonGroup> object */ - public Observable>> listWithServiceResponseAsync(ListPersonGroupsOptionalParameter listOptionalParameter) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } - final String start = listOptionalParameter != null ? listOptionalParameter.start() : null; - final Integer top = listOptionalParameter != null ? listOptionalParameter.top() : null; + final String start = null; + final Integer top = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } - return listWithServiceResponseAsync(start, top); + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<PersonGroup> object if successful. + */ + public List list(String start, Integer top) { + return listWithServiceResponseAsync(start, top).toBlocking().single().body(); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(String start, Integer top, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(start, top), serviceCallback); + } + + /** + * List person groups and their information. + * + * @param start List person groups from the least personGroupId greater than the "start". + * @param top The number of person groups to list. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<PersonGroup> object + */ + public Observable> listAsync(String start, Integer top) { + return listWithServiceResponseAsync(start, top).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); } /** @@ -717,10 +762,10 @@ public Observable>> listWithServiceResponseAsy * @return the observable to the List<PersonGroup> object */ public Observable>> listWithServiceResponseAsync(String start, Integer top) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.list(start, top, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>>() { @Override @@ -742,55 +787,6 @@ private ServiceResponse> listDelegate(Response r .build(response); } - @Override - public PersonGroupsListParameters list() { - return new PersonGroupsListParameters(this); - } - - /** - * Internal class implementing PersonGroupsListDefinition. - */ - class PersonGroupsListParameters implements PersonGroupsListDefinition { - private PersonGroupsImpl parent; - private String start; - private Integer top; - - /** - * Constructor. - * @param parent the parent object. - */ - PersonGroupsListParameters(PersonGroupsImpl parent) { - this.parent = parent; - } - - @Override - public PersonGroupsListParameters withStart(String start) { - this.start = start; - return this; - } - - @Override - public PersonGroupsListParameters withTop(Integer top) { - this.top = top; - return this; - } - - @Override - public List execute() { - return listWithServiceResponseAsync(start, top).toBlocking().single().body(); - } - - @Override - public Observable> executeAsync() { - return listWithServiceResponseAsync(start, top).map(new Func1>, List>() { - @Override - public List call(ServiceResponse> response) { - return response.body(); - } - }); - } - } - /** * Queue a person group training task, the training task may not be started immediately. * @@ -839,13 +835,13 @@ public Void call(ServiceResponse response) { * @return the {@link ServiceResponse} object if successful. */ public Observable> trainWithServiceResponseAsync(String personGroupId) { - if (this.client.azureRegion() == null) { - throw new IllegalArgumentException("Parameter this.client.azureRegion() is required and cannot be null."); + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); } if (personGroupId == null) { throw new IllegalArgumentException("Parameter personGroupId is required and cannot be null."); } - String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.client.azureRegion()); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); return service.train(personGroupId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) .flatMap(new Func1, Observable>>() { @Override diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/SnapshotsImpl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/SnapshotsImpl.java new file mode 100644 index 0000000000000..29c06d6c4088d --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/SnapshotsImpl.java @@ -0,0 +1,1122 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.APIErrorException; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.ApplySnapshotRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.OperationStatus; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.Snapshot; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotApplyHeaders; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotApplyMode; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotObjectType; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.SnapshotTakeHeaders; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.TakeSnapshotRequest; +import com.microsoft.azure.cognitiveservices.vision.faceapi.models.UpdateSnapshotRequest; +import com.microsoft.rest.CollectionFormat; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseWithHeaders; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Snapshots. + */ +public class SnapshotsImpl implements Snapshots { + /** The Retrofit service to perform REST calls. */ + private SnapshotsService service; + /** The service client containing this operation class. */ + private FaceClientImpl client; + + /** + * Initializes an instance of SnapshotsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public SnapshotsImpl(Retrofit retrofit, FaceClientImpl client) { + this.service = retrofit.create(SnapshotsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Snapshots to be + * used by Retrofit to perform actually REST calls. + */ + interface SnapshotsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots take" }) + @POST("snapshots") + Observable> take(@Header("accept-language") String acceptLanguage, @Body TakeSnapshotRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots list" }) + @GET("snapshots") + Observable> list(@Query("type") SnapshotObjectType type, @Query("applyScope") String applyScope, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots get" }) + @GET("snapshots/{snapshotId}") + Observable> get(@Path("snapshotId") UUID snapshotId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots update" }) + @PATCH("snapshots/{snapshotId}") + Observable> update(@Path("snapshotId") UUID snapshotId, @Header("accept-language") String acceptLanguage, @Body UpdateSnapshotRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots delete" }) + @HTTP(path = "snapshots/{snapshotId}", method = "DELETE", hasBody = true) + Observable> delete(@Path("snapshotId") UUID snapshotId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots apply" }) + @POST("snapshots/{snapshotId}/apply") + Observable> apply(@Path("snapshotId") UUID snapshotId, @Header("accept-language") String acceptLanguage, @Body ApplySnapshotRequest body, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.vision.faceapi.Snapshots getOperationStatus" }) + @GET("operations/{operationId}") + Observable> getOperationStatus(@Path("operationId") UUID operationId, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void take(SnapshotObjectType type, String objectId, List applyScope) { + takeWithServiceResponseAsync(type, objectId, applyScope).toBlocking().single().body(); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture takeAsync(SnapshotObjectType type, String objectId, List applyScope, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(takeWithServiceResponseAsync(type, objectId, applyScope), serviceCallback); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable takeAsync(SnapshotObjectType type, String objectId, List applyScope) { + return takeWithServiceResponseAsync(type, objectId, applyScope).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> takeWithServiceResponseAsync(SnapshotObjectType type, String objectId, List applyScope) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (type == null) { + throw new IllegalArgumentException("Parameter type is required and cannot be null."); + } + if (objectId == null) { + throw new IllegalArgumentException("Parameter objectId is required and cannot be null."); + } + if (applyScope == null) { + throw new IllegalArgumentException("Parameter applyScope is required and cannot be null."); + } + Validator.validate(applyScope); + final String userData = null; + TakeSnapshotRequest body = new TakeSnapshotRequest(); + body.withType(type); + body.withObjectId(objectId); + body.withApplyScope(applyScope); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.take(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = takeDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void take(SnapshotObjectType type, String objectId, List applyScope, String userData) { + takeWithServiceResponseAsync(type, objectId, applyScope, userData).toBlocking().single().body(); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture takeAsync(SnapshotObjectType type, String objectId, List applyScope, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(takeWithServiceResponseAsync(type, objectId, applyScope, userData), serviceCallback); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable takeAsync(SnapshotObjectType type, String objectId, List applyScope, String userData) { + return takeWithServiceResponseAsync(type, objectId, applyScope, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Taking snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> + Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + * Free-tier subscription quota: 100 take operations per month. + * S0-tier subscription quota: 100 take operations per day. + * + * @param type User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param objectId User specified source object id to take snapshot from. + * @param applyScope User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> takeWithServiceResponseAsync(SnapshotObjectType type, String objectId, List applyScope, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (type == null) { + throw new IllegalArgumentException("Parameter type is required and cannot be null."); + } + if (objectId == null) { + throw new IllegalArgumentException("Parameter objectId is required and cannot be null."); + } + if (applyScope == null) { + throw new IllegalArgumentException("Parameter applyScope is required and cannot be null."); + } + Validator.validate(applyScope); + TakeSnapshotRequest body = new TakeSnapshotRequest(); + body.withType(type); + body.withObjectId(objectId); + body.withApplyScope(applyScope); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.take(this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = takeDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponseWithHeaders takeDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .buildWithHeaders(response, SnapshotTakeHeaders.class); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Snapshot> object if successful. + */ + public List list() { + return listWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + final SnapshotObjectType type = null; + final List applyScope = null; + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String applyScopeConverted = this.client.serializerAdapter().serializeList(applyScope, CollectionFormat.CSV); + return service.list(type, applyScopeConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<Snapshot> object if successful. + */ + public List list(SnapshotObjectType type, List applyScope) { + return listWithServiceResponseAsync(type, applyScope).toBlocking().single().body(); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(SnapshotObjectType type, List applyScope, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(type, applyScope), serviceCallback); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + public Observable> listAsync(SnapshotObjectType type, List applyScope) { + return listWithServiceResponseAsync(type, applyScope).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take). + * + * @param type User specified object type as a search filter. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' + * @param applyScope User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<Snapshot> object + */ + public Observable>> listWithServiceResponseAsync(SnapshotObjectType type, List applyScope) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + Validator.validate(applyScope); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + String applyScopeConverted = this.client.serializerAdapter().serializeList(applyScope, CollectionFormat.CSV); + return service.list(type, applyScopeConverted, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., APIErrorException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the Snapshot object if successful. + */ + public Snapshot get(UUID snapshotId) { + return getWithServiceResponseAsync(snapshotId).toBlocking().single().body(); + } + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getAsync(UUID snapshotId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(snapshotId), serviceCallback); + } + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Snapshot object + */ + public Observable getAsync(UUID snapshotId) { + return getWithServiceResponseAsync(snapshotId).map(new Func1, Snapshot>() { + @Override + public Snapshot call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the Snapshot object + */ + public Observable> getWithServiceResponseAsync(UUID snapshotId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.get(snapshotId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(UUID snapshotId) { + updateWithServiceResponseAsync(snapshotId).toBlocking().single().body(); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(UUID snapshotId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(snapshotId), serviceCallback); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(UUID snapshotId) { + return updateWithServiceResponseAsync(snapshotId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(UUID snapshotId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + final List applyScope = null; + final String userData = null; + UpdateSnapshotRequest body = new UpdateSnapshotRequest(); + body.withApplyScope(null); + body.withUserData(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(snapshotId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void update(UUID snapshotId, List applyScope, String userData) { + updateWithServiceResponseAsync(snapshotId, applyScope, userData).toBlocking().single().body(); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(UUID snapshotId, List applyScope, String userData, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(snapshotId, applyScope, userData), serviceCallback); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable updateAsync(UUID snapshotId, List applyScope, String userData) { + return updateWithServiceResponseAsync(snapshotId, applyScope, userData).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot. + * + * @param snapshotId Id referencing a particular snapshot. + * @param applyScope Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * @param userData User specified data about the snapshot for any purpose. Length should not exceed 16KB. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> updateWithServiceResponseAsync(UUID snapshotId, List applyScope, String userData) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + Validator.validate(applyScope); + UpdateSnapshotRequest body = new UpdateSnapshotRequest(); + body.withApplyScope(applyScope); + body.withUserData(userData); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.update(snapshotId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(UUID snapshotId) { + deleteWithServiceResponseAsync(snapshotId).toBlocking().single().body(); + } + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(UUID snapshotId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(snapshotId), serviceCallback); + } + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(UUID snapshotId) { + return deleteWithServiceResponseAsync(snapshotId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation. + * + * @param snapshotId Id referencing a particular snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(UUID snapshotId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.delete(snapshotId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void apply(UUID snapshotId, String objectId) { + applyWithServiceResponseAsync(snapshotId, objectId).toBlocking().single().body(); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture applyAsync(UUID snapshotId, String objectId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(applyWithServiceResponseAsync(snapshotId, objectId), serviceCallback); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable applyAsync(UUID snapshotId, String objectId) { + return applyWithServiceResponseAsync(snapshotId, objectId).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> applyWithServiceResponseAsync(UUID snapshotId, String objectId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + if (objectId == null) { + throw new IllegalArgumentException("Parameter objectId is required and cannot be null."); + } + final SnapshotApplyMode mode = null; + ApplySnapshotRequest body = new ApplySnapshotRequest(); + body.withObjectId(objectId); + body.withMode(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.apply(snapshotId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = applyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void apply(UUID snapshotId, String objectId, SnapshotApplyMode mode) { + applyWithServiceResponseAsync(snapshotId, objectId, mode).toBlocking().single().body(); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture applyAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode, final ServiceCallback serviceCallback) { + return ServiceFuture.fromHeaderResponse(applyWithServiceResponseAsync(snapshotId, objectId, mode), serviceCallback); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable applyAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode) { + return applyWithServiceResponseAsync(snapshotId, objectId, mode).map(new Func1, Void>() { + @Override + public Void call(ServiceResponseWithHeaders response) { + return response.body(); + } + }); + } + + /** + * Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> + The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> + Applying snapshot is an asynchronous operation. An operation id can be obtained from the "Operation-Location" field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the "resourceLocation" field in OperationStatus - Get response when the operation status is "succeeded".<br /> + Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> + Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> + Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> + One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts.<br /> + * Free-tier subscription quota: 100 apply operations per month. + * S0-tier subscription quota: 100 apply operations per day. + * + * @param snapshotId Id referencing a particular snapshot. + * @param objectId User specified target object id to be created from the snapshot. + * @param mode Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponseWithHeaders} object if successful. + */ + public Observable> applyWithServiceResponseAsync(UUID snapshotId, String objectId, SnapshotApplyMode mode) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (snapshotId == null) { + throw new IllegalArgumentException("Parameter snapshotId is required and cannot be null."); + } + if (objectId == null) { + throw new IllegalArgumentException("Parameter objectId is required and cannot be null."); + } + ApplySnapshotRequest body = new ApplySnapshotRequest(); + body.withObjectId(objectId); + body.withMode(mode); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.apply(snapshotId, this.client.acceptLanguage(), body, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponseWithHeaders clientResponse = applyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponseWithHeaders applyDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .buildWithHeaders(response, SnapshotApplyHeaders.class); + } + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws APIErrorException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the OperationStatus object if successful. + */ + public OperationStatus getOperationStatus(UUID operationId) { + return getOperationStatusWithServiceResponseAsync(operationId).toBlocking().single().body(); + } + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getOperationStatusAsync(UUID operationId, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getOperationStatusWithServiceResponseAsync(operationId), serviceCallback); + } + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the OperationStatus object + */ + public Observable getOperationStatusAsync(UUID operationId) { + return getOperationStatusWithServiceResponseAsync(operationId).map(new Func1, OperationStatus>() { + @Override + public OperationStatus call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve the status of a take/apply snapshot operation. + * + * @param operationId Id referencing a particular take/apply snapshot operation. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the OperationStatus object + */ + public Observable> getOperationStatusWithServiceResponseAsync(UUID operationId) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + if (operationId == null) { + throw new IllegalArgumentException("Parameter operationId is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getOperationStatus(operationId, this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getOperationStatusDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getOperationStatusDelegate(Response response) throws APIErrorException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(APIErrorException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java index 5890cb1a5db8f..34c335c4ef0d8 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the implementation classes for FaceAPI. + * This package contains the implementation classes for FaceClient. * An API for face detection, verification, and identification. */ package com.microsoft.azure.cognitiveservices.vision.faceapi.implementation; diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java index db1dd7ec68180..f09314a9ce903 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Accessory.java @@ -28,7 +28,7 @@ public class Accessory { private double confidence; /** - * Get the type value. + * Get type of an accessory. Possible values include: 'headWear', 'glasses', 'mask'. * * @return the type value */ @@ -37,7 +37,7 @@ public AccessoryType type() { } /** - * Set the type value. + * Set type of an accessory. Possible values include: 'headWear', 'glasses', 'mask'. * * @param type the type value to set * @return the Accessory object itself. @@ -48,7 +48,7 @@ public Accessory withType(AccessoryType type) { } /** - * Get the confidence value. + * Get confidence level of an accessory. * * @return the confidence value */ @@ -57,7 +57,7 @@ public double confidence() { } /** - * Set the confidence value. + * Set confidence level of an accessory. * * @param confidence the confidence value to set * @return the Accessory object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ApplySnapshotRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ApplySnapshotRequest.java new file mode 100644 index 0000000000000..268e1111109c3 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ApplySnapshotRequest.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for applying snapshot operation. + */ +public class ApplySnapshotRequest { + /** + * User specified target object id to be created from the snapshot. + */ + @JsonProperty(value = "objectId", required = true) + private String objectId; + + /** + * Snapshot applying mode. Currently only CreateNew is supported, which + * means the apply operation will fail if target subscription already + * contains an object of same type and using the same objectId. Users can + * specify the "objectId" in request body to avoid such conflicts. Possible + * values include: 'CreateNew'. + */ + @JsonProperty(value = "mode") + private SnapshotApplyMode mode; + + /** + * Get user specified target object id to be created from the snapshot. + * + * @return the objectId value + */ + public String objectId() { + return this.objectId; + } + + /** + * Set user specified target object id to be created from the snapshot. + * + * @param objectId the objectId value to set + * @return the ApplySnapshotRequest object itself. + */ + public ApplySnapshotRequest withObjectId(String objectId) { + this.objectId = objectId; + return this; + } + + /** + * Get snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew'. + * + * @return the mode value + */ + public SnapshotApplyMode mode() { + return this.mode; + } + + /** + * Set snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the "objectId" in request body to avoid such conflicts. Possible values include: 'CreateNew'. + * + * @param mode the mode value to set + * @return the ApplySnapshotRequest object itself. + */ + public ApplySnapshotRequest withMode(SnapshotApplyMode mode) { + this.mode = mode; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java index 6600c2679ec39..24fa48618f9b4 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Blur.java @@ -28,7 +28,7 @@ public class Blur { private double value; /** - * Get the blurLevel value. + * Get an enum value indicating level of blurriness. Possible values include: 'Low', 'Medium', 'High'. * * @return the blurLevel value */ @@ -37,7 +37,7 @@ public BlurLevel blurLevel() { } /** - * Set the blurLevel value. + * Set an enum value indicating level of blurriness. Possible values include: 'Low', 'Medium', 'High'. * * @param blurLevel the blurLevel value to set * @return the Blur object itself. @@ -48,7 +48,7 @@ public Blur withBlurLevel(BlurLevel blurLevel) { } /** - * Get the value value. + * Get a number indicating level of blurriness ranging from 0 to 1. * * @return the value value */ @@ -57,7 +57,7 @@ public double value() { } /** - * Set the value value. + * Set a number indicating level of blurriness ranging from 0 to 1. * * @param value the value value to set * @return the Blur object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java index 6490f235c048c..9615465ef3126 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Coordinate.java @@ -27,7 +27,7 @@ public class Coordinate { private double y; /** - * Get the x value. + * Get the horizontal component, in pixels. * * @return the x value */ @@ -36,7 +36,7 @@ public double x() { } /** - * Set the x value. + * Set the horizontal component, in pixels. * * @param x the x value to set * @return the Coordinate object itself. @@ -47,7 +47,7 @@ public Coordinate withX(double x) { } /** - * Get the y value. + * Get the vertical component, in pixels. * * @return the y value */ @@ -56,7 +56,7 @@ public double y() { } /** - * Set the y value. + * Set the vertical component, in pixels. * * @param y the y value to set * @return the Coordinate object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java index 15ddf53fc2aec..822f1888ace82 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Exposure.java @@ -30,7 +30,7 @@ public class Exposure { private double value; /** - * Get the exposureLevel value. + * Get an enum value indicating level of exposure. Possible values include: 'UnderExposure', 'GoodExposure', 'OverExposure'. * * @return the exposureLevel value */ @@ -39,7 +39,7 @@ public ExposureLevel exposureLevel() { } /** - * Set the exposureLevel value. + * Set an enum value indicating level of exposure. Possible values include: 'UnderExposure', 'GoodExposure', 'OverExposure'. * * @param exposureLevel the exposureLevel value to set * @return the Exposure object itself. @@ -50,7 +50,7 @@ public Exposure withExposureLevel(ExposureLevel exposureLevel) { } /** - * Get the value value. + * Get a number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. * * @return the value value */ @@ -59,7 +59,7 @@ public double value() { } /** - * Set the value value. + * Set a number indicating level of exposure level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. * * @param value the value value to set * @return the Exposure object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java index a0e8bd76f3a0b..dee079c669257 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceAttributes.java @@ -103,7 +103,7 @@ public class FaceAttributes { private Noise noise; /** - * Get the age value. + * Get age in years. * * @return the age value */ @@ -112,7 +112,7 @@ public Double age() { } /** - * Set the age value. + * Set age in years. * * @param age the age value to set * @return the FaceAttributes object itself. @@ -123,7 +123,7 @@ public FaceAttributes withAge(Double age) { } /** - * Get the gender value. + * Get possible gender of the face. Possible values include: 'male', 'female', 'genderless'. * * @return the gender value */ @@ -132,7 +132,7 @@ public Gender gender() { } /** - * Set the gender value. + * Set possible gender of the face. Possible values include: 'male', 'female', 'genderless'. * * @param gender the gender value to set * @return the FaceAttributes object itself. @@ -143,7 +143,7 @@ public FaceAttributes withGender(Gender gender) { } /** - * Get the smile value. + * Get smile intensity, a number between [0,1]. * * @return the smile value */ @@ -152,7 +152,7 @@ public Double smile() { } /** - * Set the smile value. + * Set smile intensity, a number between [0,1]. * * @param smile the smile value to set * @return the FaceAttributes object itself. @@ -163,7 +163,7 @@ public FaceAttributes withSmile(Double smile) { } /** - * Get the facialHair value. + * Get properties describing facial hair attributes. * * @return the facialHair value */ @@ -172,7 +172,7 @@ public FacialHair facialHair() { } /** - * Set the facialHair value. + * Set properties describing facial hair attributes. * * @param facialHair the facialHair value to set * @return the FaceAttributes object itself. @@ -183,7 +183,7 @@ public FaceAttributes withFacialHair(FacialHair facialHair) { } /** - * Get the glasses value. + * Get glasses type if any of the face. Possible values include: 'noGlasses', 'readingGlasses', 'sunglasses', 'swimmingGoggles'. * * @return the glasses value */ @@ -192,7 +192,7 @@ public GlassesType glasses() { } /** - * Set the glasses value. + * Set glasses type if any of the face. Possible values include: 'noGlasses', 'readingGlasses', 'sunglasses', 'swimmingGoggles'. * * @param glasses the glasses value to set * @return the FaceAttributes object itself. @@ -203,7 +203,7 @@ public FaceAttributes withGlasses(GlassesType glasses) { } /** - * Get the headPose value. + * Get properties indicating head pose of the face. * * @return the headPose value */ @@ -212,7 +212,7 @@ public HeadPose headPose() { } /** - * Set the headPose value. + * Set properties indicating head pose of the face. * * @param headPose the headPose value to set * @return the FaceAttributes object itself. @@ -223,7 +223,7 @@ public FaceAttributes withHeadPose(HeadPose headPose) { } /** - * Get the emotion value. + * Get properties describing facial emotion in form of confidence ranging from 0 to 1. * * @return the emotion value */ @@ -232,7 +232,7 @@ public Emotion emotion() { } /** - * Set the emotion value. + * Set properties describing facial emotion in form of confidence ranging from 0 to 1. * * @param emotion the emotion value to set * @return the FaceAttributes object itself. @@ -243,7 +243,7 @@ public FaceAttributes withEmotion(Emotion emotion) { } /** - * Get the hair value. + * Get properties describing hair attributes. * * @return the hair value */ @@ -252,7 +252,7 @@ public Hair hair() { } /** - * Set the hair value. + * Set properties describing hair attributes. * * @param hair the hair value to set * @return the FaceAttributes object itself. @@ -263,7 +263,7 @@ public FaceAttributes withHair(Hair hair) { } /** - * Get the makeup value. + * Get properties describing present makeups on a given face. * * @return the makeup value */ @@ -272,7 +272,7 @@ public Makeup makeup() { } /** - * Set the makeup value. + * Set properties describing present makeups on a given face. * * @param makeup the makeup value to set * @return the FaceAttributes object itself. @@ -283,7 +283,7 @@ public FaceAttributes withMakeup(Makeup makeup) { } /** - * Get the occlusion value. + * Get properties describing occlusions on a given face. * * @return the occlusion value */ @@ -292,7 +292,7 @@ public Occlusion occlusion() { } /** - * Set the occlusion value. + * Set properties describing occlusions on a given face. * * @param occlusion the occlusion value to set * @return the FaceAttributes object itself. @@ -303,7 +303,7 @@ public FaceAttributes withOcclusion(Occlusion occlusion) { } /** - * Get the accessories value. + * Get properties describing any accessories on a given face. * * @return the accessories value */ @@ -312,7 +312,7 @@ public List accessories() { } /** - * Set the accessories value. + * Set properties describing any accessories on a given face. * * @param accessories the accessories value to set * @return the FaceAttributes object itself. @@ -323,7 +323,7 @@ public FaceAttributes withAccessories(List accessories) { } /** - * Get the blur value. + * Get properties describing any presence of blur within the image. * * @return the blur value */ @@ -332,7 +332,7 @@ public Blur blur() { } /** - * Set the blur value. + * Set properties describing any presence of blur within the image. * * @param blur the blur value to set * @return the FaceAttributes object itself. @@ -343,7 +343,7 @@ public FaceAttributes withBlur(Blur blur) { } /** - * Get the exposure value. + * Get properties describing exposure level of the image. * * @return the exposure value */ @@ -352,7 +352,7 @@ public Exposure exposure() { } /** - * Set the exposure value. + * Set properties describing exposure level of the image. * * @param exposure the exposure value to set * @return the FaceAttributes object itself. @@ -363,7 +363,7 @@ public FaceAttributes withExposure(Exposure exposure) { } /** - * Get the noise value. + * Get properties describing noise level of the image. * * @return the noise value */ @@ -372,7 +372,7 @@ public Noise noise() { } /** - * Set the noise value. + * Set properties describing noise level of the image. * * @param noise the noise value to set * @return the FaceAttributes object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java index d31c2e886266e..c01d43f4437cb 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceList.java @@ -28,7 +28,7 @@ public class FaceList extends NameAndUserDataContract { private List persistedFaces; /** - * Get the faceListId value. + * Get faceListId of the target face list. * * @return the faceListId value */ @@ -37,7 +37,7 @@ public String faceListId() { } /** - * Set the faceListId value. + * Set faceListId of the target face list. * * @param faceListId the faceListId value to set * @return the FaceList object itself. @@ -48,7 +48,7 @@ public FaceList withFaceListId(String faceListId) { } /** - * Get the persistedFaces value. + * Get persisted faces within the face list. * * @return the persistedFaces value */ @@ -57,7 +57,7 @@ public List persistedFaces() { } /** - * Set the persistedFaces value. + * Set persisted faces within the face list. * * @param persistedFaces the persistedFaces value to set * @return the FaceList object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java index a3c64c9d73c75..e56a9e633bbe0 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FaceRectangle.java @@ -41,7 +41,7 @@ public class FaceRectangle { private int top; /** - * Get the width value. + * Get the width of the rectangle, in pixels. * * @return the width value */ @@ -50,7 +50,7 @@ public int width() { } /** - * Set the width value. + * Set the width of the rectangle, in pixels. * * @param width the width value to set * @return the FaceRectangle object itself. @@ -61,7 +61,7 @@ public FaceRectangle withWidth(int width) { } /** - * Get the height value. + * Get the height of the rectangle, in pixels. * * @return the height value */ @@ -70,7 +70,7 @@ public int height() { } /** - * Set the height value. + * Set the height of the rectangle, in pixels. * * @param height the height value to set * @return the FaceRectangle object itself. @@ -81,7 +81,7 @@ public FaceRectangle withHeight(int height) { } /** - * Get the left value. + * Get the distance from the left edge if the image to the left edge of the rectangle, in pixels. * * @return the left value */ @@ -90,7 +90,7 @@ public int left() { } /** - * Set the left value. + * Set the distance from the left edge if the image to the left edge of the rectangle, in pixels. * * @param left the left value to set * @return the FaceRectangle object itself. @@ -101,7 +101,7 @@ public FaceRectangle withLeft(int left) { } /** - * Get the top value. + * Get the distance from the top edge if the image to the top edge of the rectangle, in pixels. * * @return the top value */ @@ -110,7 +110,7 @@ public int top() { } /** - * Set the top value. + * Set the distance from the top edge if the image to the top edge of the rectangle, in pixels. * * @param top the top value to set * @return the FaceRectangle object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java index 109bfbb56460a..4b210b15164ae 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/FindSimilarRequest.java @@ -27,15 +27,27 @@ public class FindSimilarRequest { /** * An existing user-specified unique candidate face list, created in Face * List - Create a Face List. Face list contains a set of persistedFaceIds - * which are persisted and will never expire. Parameter faceListId and - * faceIds should not be provided at the same time. + * which are persisted and will never expire. Parameter faceListId, + * largeFaceListId and faceIds should not be provided at the same time. */ @JsonProperty(value = "faceListId") private String faceListId; + /** + * An existing user-specified unique candidate large face list, created in + * LargeFaceList - Create. Large face list contains a set of + * persistedFaceIds which are persisted and will never expire. Parameter + * faceListId, largeFaceListId and faceIds should not be provided at the + * same time. + */ + @JsonProperty(value = "largeFaceListId") + private String largeFaceListId; + /** * An array of candidate faceIds. All of them are created by Face - Detect - * and the faceIds will expire 24 hours after the detection call. + * and the faceIds will expire 24 hours after the detection call. The + * number of faceIds is limited to 1000. Parameter faceListId, + * largeFaceListId and faceIds should not be provided at the same time. */ @JsonProperty(value = "faceIds") private List faceIds; @@ -54,7 +66,7 @@ public class FindSimilarRequest { private FindSimilarMatchMode mode; /** - * Get the faceId value. + * Get faceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call. * * @return the faceId value */ @@ -63,7 +75,7 @@ public UUID faceId() { } /** - * Set the faceId value. + * Set faceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire 24 hours after the detection call. * * @param faceId the faceId value to set * @return the FindSimilarRequest object itself. @@ -74,7 +86,7 @@ public FindSimilarRequest withFaceId(UUID faceId) { } /** - * Get the faceListId value. + * Get an existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. * * @return the faceListId value */ @@ -83,7 +95,7 @@ public String faceListId() { } /** - * Set the faceListId value. + * Set an existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. * * @param faceListId the faceListId value to set * @return the FindSimilarRequest object itself. @@ -94,7 +106,27 @@ public FindSimilarRequest withFaceListId(String faceListId) { } /** - * Get the faceIds value. + * Get an existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * + * @return the largeFaceListId value + */ + public String largeFaceListId() { + return this.largeFaceListId; + } + + /** + * Set an existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. + * + * @param largeFaceListId the largeFaceListId value to set + * @return the FindSimilarRequest object itself. + */ + public FindSimilarRequest withLargeFaceListId(String largeFaceListId) { + this.largeFaceListId = largeFaceListId; + return this; + } + + /** + * Get an array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. * * @return the faceIds value */ @@ -103,7 +135,7 @@ public List faceIds() { } /** - * Set the faceIds value. + * Set an array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time. * * @param faceIds the faceIds value to set * @return the FindSimilarRequest object itself. @@ -114,7 +146,7 @@ public FindSimilarRequest withFaceIds(List faceIds) { } /** - * Get the maxNumOfCandidatesReturned value. + * Get the number of top similar faces returned. The valid range is [1, 1000]. * * @return the maxNumOfCandidatesReturned value */ @@ -123,7 +155,7 @@ public Integer maxNumOfCandidatesReturned() { } /** - * Set the maxNumOfCandidatesReturned value. + * Set the number of top similar faces returned. The valid range is [1, 1000]. * * @param maxNumOfCandidatesReturned the maxNumOfCandidatesReturned value to set * @return the FindSimilarRequest object itself. @@ -134,7 +166,7 @@ public FindSimilarRequest withMaxNumOfCandidatesReturned(Integer maxNumOfCandida } /** - * Get the mode value. + * Get similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace'. * * @return the mode value */ @@ -143,7 +175,7 @@ public FindSimilarMatchMode mode() { } /** - * Set the mode value. + * Set similar face searching mode. It can be "matchPerson" or "matchFace". Possible values include: 'matchPerson', 'matchFace'. * * @param mode the mode value to set * @return the FindSimilarRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java index e2c8c8dcf2817..c44ee8495a569 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupRequest.java @@ -24,7 +24,7 @@ public class GroupRequest { private List faceIds; /** - * Get the faceIds value. + * Get array of candidate faceId created by Face - Detect. The maximum is 1000 faces. * * @return the faceIds value */ @@ -33,7 +33,7 @@ public List faceIds() { } /** - * Set the faceIds value. + * Set array of candidate faceId created by Face - Detect. The maximum is 1000 faces. * * @param faceIds the faceIds value to set * @return the GroupRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java index 86e0fdbfd4483..c2440f2b8c52c 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/GroupResult.java @@ -31,7 +31,7 @@ public class GroupResult { private List messyGroup; /** - * Get the groups value. + * Get a partition of the original faces based on face similarity. Groups are ranked by number of faces. * * @return the groups value */ @@ -40,7 +40,7 @@ public List> groups() { } /** - * Set the groups value. + * Set a partition of the original faces based on face similarity. Groups are ranked by number of faces. * * @param groups the groups value to set * @return the GroupResult object itself. @@ -51,7 +51,7 @@ public GroupResult withGroups(List> groups) { } /** - * Get the messyGroup value. + * Get face ids array of faces that cannot find any similar faces from original faces. * * @return the messyGroup value */ @@ -60,7 +60,7 @@ public List messyGroup() { } /** - * Set the messyGroup value. + * Set face ids array of faces that cannot find any similar faces from original faces. * * @param messyGroup the messyGroup value to set * @return the GroupResult object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java index 074ae217a0c49..49abb7342db8c 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Hair.java @@ -35,7 +35,7 @@ public class Hair { private List hairColor; /** - * Get the bald value. + * Get a number describing confidence level of whether the person is bald. * * @return the bald value */ @@ -44,7 +44,7 @@ public double bald() { } /** - * Set the bald value. + * Set a number describing confidence level of whether the person is bald. * * @param bald the bald value to set * @return the Hair object itself. @@ -55,7 +55,7 @@ public Hair withBald(double bald) { } /** - * Get the invisible value. + * Get a boolean value describing whether the hair is visible in the image. * * @return the invisible value */ @@ -64,7 +64,7 @@ public boolean invisible() { } /** - * Set the invisible value. + * Set a boolean value describing whether the hair is visible in the image. * * @param invisible the invisible value to set * @return the Hair object itself. @@ -75,7 +75,7 @@ public Hair withInvisible(boolean invisible) { } /** - * Get the hairColor value. + * Get an array of candidate colors and confidence level in the presence of each. * * @return the hairColor value */ @@ -84,7 +84,7 @@ public List hairColor() { } /** - * Set the hairColor value. + * Set an array of candidate colors and confidence level in the presence of each. * * @param hairColor the hairColor value to set * @return the Hair object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java index 923a82973dbe7..9e65e237ce903 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/HairColor.java @@ -28,7 +28,7 @@ public class HairColor { private double confidence; /** - * Get the color value. + * Get name of the hair color. Possible values include: 'unknown', 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other'. * * @return the color value */ @@ -37,7 +37,7 @@ public HairColorType color() { } /** - * Set the color value. + * Set name of the hair color. Possible values include: 'unknown', 'white', 'gray', 'blond', 'brown', 'red', 'black', 'other'. * * @param color the color value to set * @return the HairColor object itself. @@ -48,7 +48,7 @@ public HairColor withColor(HairColorType color) { } /** - * Get the confidence value. + * Get confidence level of the color. * * @return the confidence value */ @@ -57,7 +57,7 @@ public double confidence() { } /** - * Set the confidence value. + * Set confidence level of the color. * * @param confidence the confidence value to set * @return the HairColor object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java index 3f2f00a03d793..b0e9218869f1f 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyCandidate.java @@ -30,7 +30,7 @@ public class IdentifyCandidate { private double confidence; /** - * Get the personId value. + * Get id of candidate. * * @return the personId value */ @@ -39,7 +39,7 @@ public UUID personId() { } /** - * Set the personId value. + * Set id of candidate. * * @param personId the personId value to set * @return the IdentifyCandidate object itself. @@ -50,7 +50,7 @@ public IdentifyCandidate withPersonId(UUID personId) { } /** - * Get the confidence value. + * Get confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * * @return the confidence value */ @@ -59,7 +59,7 @@ public double confidence() { } /** - * Set the confidence value. + * Set confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * * @param confidence the confidence value to set * @return the IdentifyCandidate object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java index de63a2dd45960..ea62ca005dc7f 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyRequest.java @@ -16,13 +16,6 @@ * Request body for identify face operation. */ public class IdentifyRequest { - /** - * PersonGroupId of the target person group, created by - * PersonGroups.Create. - */ - @JsonProperty(value = "personGroupId", required = true) - private String personGroupId; - /** * Array of query faces faceIds, created by the Face - Detect. Each of the * faces are identified independently. The valid number of faceIds is @@ -31,6 +24,22 @@ public class IdentifyRequest { @JsonProperty(value = "faceIds", required = true) private List faceIds; + /** + * PersonGroupId of the target person group, created by PersonGroup - + * Create. Parameter personGroupId and largePersonGroupId should not be + * provided at the same time. + */ + @JsonProperty(value = "personGroupId") + private String personGroupId; + + /** + * LargePersonGroupId of the target large person group, created by + * LargePersonGroup - Create. Parameter personGroupId and + * largePersonGroupId should not be provided at the same time. + */ + @JsonProperty(value = "largePersonGroupId") + private String largePersonGroupId; + /** * The range of maxNumOfCandidatesReturned is between 1 and 5 (default is * 1). @@ -47,7 +56,27 @@ public class IdentifyRequest { private Double confidenceThreshold; /** - * Get the personGroupId value. + * Get array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * + * @return the faceIds value + */ + public List faceIds() { + return this.faceIds; + } + + /** + * Set array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10]. + * + * @param faceIds the faceIds value to set + * @return the IdentifyRequest object itself. + */ + public IdentifyRequest withFaceIds(List faceIds) { + this.faceIds = faceIds; + return this; + } + + /** + * Get personGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * * @return the personGroupId value */ @@ -56,7 +85,7 @@ public String personGroupId() { } /** - * Set the personGroupId value. + * Set personGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * * @param personGroupId the personGroupId value to set * @return the IdentifyRequest object itself. @@ -67,27 +96,27 @@ public IdentifyRequest withPersonGroupId(String personGroupId) { } /** - * Get the faceIds value. + * Get largePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * - * @return the faceIds value + * @return the largePersonGroupId value */ - public List faceIds() { - return this.faceIds; + public String largePersonGroupId() { + return this.largePersonGroupId; } /** - * Set the faceIds value. + * Set largePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * - * @param faceIds the faceIds value to set + * @param largePersonGroupId the largePersonGroupId value to set * @return the IdentifyRequest object itself. */ - public IdentifyRequest withFaceIds(List faceIds) { - this.faceIds = faceIds; + public IdentifyRequest withLargePersonGroupId(String largePersonGroupId) { + this.largePersonGroupId = largePersonGroupId; return this; } /** - * Get the maxNumOfCandidatesReturned value. + * Get the range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * * @return the maxNumOfCandidatesReturned value */ @@ -96,7 +125,7 @@ public Integer maxNumOfCandidatesReturned() { } /** - * Set the maxNumOfCandidatesReturned value. + * Set the range of maxNumOfCandidatesReturned is between 1 and 5 (default is 1). * * @param maxNumOfCandidatesReturned the maxNumOfCandidatesReturned value to set * @return the IdentifyRequest object itself. @@ -107,7 +136,7 @@ public IdentifyRequest withMaxNumOfCandidatesReturned(Integer maxNumOfCandidates } /** - * Get the confidenceThreshold value. + * Get confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * * @return the confidenceThreshold value */ @@ -116,7 +145,7 @@ public Double confidenceThreshold() { } /** - * Set the confidenceThreshold value. + * Set confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm). * * @param confidenceThreshold the confidenceThreshold value to set * @return the IdentifyRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java index 282a35ae6c4d7..554bab530306b 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/IdentifyResult.java @@ -31,7 +31,7 @@ public class IdentifyResult { private List candidates; /** - * Get the faceId value. + * Get faceId of the query face. * * @return the faceId value */ @@ -40,7 +40,7 @@ public UUID faceId() { } /** - * Set the faceId value. + * Set faceId of the query face. * * @param faceId the faceId value to set * @return the IdentifyResult object itself. @@ -51,7 +51,7 @@ public IdentifyResult withFaceId(UUID faceId) { } /** - * Get the candidates value. + * Get identified person candidates for that face (ranked by confidence). Array size should be no larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty array. * * @return the candidates value */ @@ -60,7 +60,7 @@ public List candidates() { } /** - * Set the candidates value. + * Set identified person candidates for that face (ranked by confidence). Array size should be no larger than input maxNumOfCandidatesReturned. If no person is identified, will return an empty array. * * @param candidates the candidates value to set * @return the IdentifyResult object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java index 3372efa615a05..b5a41095a3248 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/ImageUrl.java @@ -21,7 +21,7 @@ public class ImageUrl { private String url; /** - * Get the url value. + * Get publicly reachable URL of an image. * * @return the url value */ @@ -30,7 +30,7 @@ public String url() { } /** - * Set the url value. + * Set publicly reachable URL of an image. * * @param url the url value to set * @return the ImageUrl object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargeFaceList.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargeFaceList.java new file mode 100644 index 0000000000000..9ec1098cc50fc --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargeFaceList.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Large face list object. + */ +public class LargeFaceList extends NameAndUserDataContract { + /** + * LargeFaceListId of the target large face list. + */ + @JsonProperty(value = "largeFaceListId", required = true) + private String largeFaceListId; + + /** + * Get largeFaceListId of the target large face list. + * + * @return the largeFaceListId value + */ + public String largeFaceListId() { + return this.largeFaceListId; + } + + /** + * Set largeFaceListId of the target large face list. + * + * @param largeFaceListId the largeFaceListId value to set + * @return the LargeFaceList object itself. + */ + public LargeFaceList withLargeFaceListId(String largeFaceListId) { + this.largeFaceListId = largeFaceListId; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargePersonGroup.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargePersonGroup.java new file mode 100644 index 0000000000000..972a8bcd79111 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/LargePersonGroup.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Large person group object. + */ +public class LargePersonGroup extends NameAndUserDataContract { + /** + * LargePersonGroupId of the target large person groups. + */ + @JsonProperty(value = "largePersonGroupId", required = true) + private String largePersonGroupId; + + /** + * Get largePersonGroupId of the target large person groups. + * + * @return the largePersonGroupId value + */ + public String largePersonGroupId() { + return this.largePersonGroupId; + } + + /** + * Set largePersonGroupId of the target large person groups. + * + * @param largePersonGroupId the largePersonGroupId value to set + * @return the LargePersonGroup object itself. + */ + public LargePersonGroup withLargePersonGroupId(String largePersonGroupId) { + this.largePersonGroupId = largePersonGroupId; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java index d0ae91e1294aa..0f9923c6e30d5 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Makeup.java @@ -27,7 +27,7 @@ public class Makeup { private boolean lipMakeup; /** - * Get the eyeMakeup value. + * Get a boolean value describing whether eye makeup is present on a face. * * @return the eyeMakeup value */ @@ -36,7 +36,7 @@ public boolean eyeMakeup() { } /** - * Set the eyeMakeup value. + * Set a boolean value describing whether eye makeup is present on a face. * * @param eyeMakeup the eyeMakeup value to set * @return the Makeup object itself. @@ -47,7 +47,7 @@ public Makeup withEyeMakeup(boolean eyeMakeup) { } /** - * Get the lipMakeup value. + * Get a boolean value describing whether lip makeup is present on a face. * * @return the lipMakeup value */ @@ -56,7 +56,7 @@ public boolean lipMakeup() { } /** - * Set the lipMakeup value. + * Set a boolean value describing whether lip makeup is present on a face. * * @param lipMakeup the lipMakeup value to set * @return the Makeup object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java index f91ac6b65e982..f6c31c6e1f359 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/NameAndUserDataContract.java @@ -12,7 +12,7 @@ /** * A combination of user defined name and user specified data for the person, - * personGroup, and faceList. + * largePersonGroup/personGroup, and largeFaceList/faceList. */ public class NameAndUserDataContract { /** @@ -28,7 +28,7 @@ public class NameAndUserDataContract { private String userData; /** - * Get the name value. + * Get user defined name, maximum length is 128. * * @return the name value */ @@ -37,7 +37,7 @@ public String name() { } /** - * Set the name value. + * Set user defined name, maximum length is 128. * * @param name the name value to set * @return the NameAndUserDataContract object itself. @@ -48,7 +48,7 @@ public NameAndUserDataContract withName(String name) { } /** - * Get the userData value. + * Get user specified data. Length should not exceed 16KB. * * @return the userData value */ @@ -57,7 +57,7 @@ public String userData() { } /** - * Set the userData value. + * Set user specified data. Length should not exceed 16KB. * * @param userData the userData value to set * @return the NameAndUserDataContract object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java index 6d347f644dc4f..946f9e70f347e 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Noise.java @@ -31,7 +31,7 @@ public class Noise { private double value; /** - * Get the noiseLevel value. + * Get an enum value indicating level of noise. Possible values include: 'Low', 'Medium', 'High'. * * @return the noiseLevel value */ @@ -40,7 +40,7 @@ public NoiseLevel noiseLevel() { } /** - * Set the noiseLevel value. + * Set an enum value indicating level of noise. Possible values include: 'Low', 'Medium', 'High'. * * @param noiseLevel the noiseLevel value to set * @return the Noise object itself. @@ -51,7 +51,7 @@ public Noise withNoiseLevel(NoiseLevel noiseLevel) { } /** - * Get the value value. + * Get a number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. * * @return the value value */ @@ -60,7 +60,7 @@ public double value() { } /** - * Set the value value. + * Set a number indicating level of noise level ranging from 0 to 1. [0, 0.25) is under exposure. [0.25, 0.75) is good exposure. [0.75, 1] is over exposure. [0, 0.3) is low noise level. [0.3, 0.7) is medium noise level. [0.7, 1] is high noise level. * * @param value the value value to set * @return the Noise object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java index c7fd8df4522b0..7a75a5659f5d2 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Occlusion.java @@ -33,7 +33,7 @@ public class Occlusion { private boolean mouthOccluded; /** - * Get the foreheadOccluded value. + * Get a boolean value indicating whether forehead is occluded. * * @return the foreheadOccluded value */ @@ -42,7 +42,7 @@ public boolean foreheadOccluded() { } /** - * Set the foreheadOccluded value. + * Set a boolean value indicating whether forehead is occluded. * * @param foreheadOccluded the foreheadOccluded value to set * @return the Occlusion object itself. @@ -53,7 +53,7 @@ public Occlusion withForeheadOccluded(boolean foreheadOccluded) { } /** - * Get the eyeOccluded value. + * Get a boolean value indicating whether eyes are occluded. * * @return the eyeOccluded value */ @@ -62,7 +62,7 @@ public boolean eyeOccluded() { } /** - * Set the eyeOccluded value. + * Set a boolean value indicating whether eyes are occluded. * * @param eyeOccluded the eyeOccluded value to set * @return the Occlusion object itself. @@ -73,7 +73,7 @@ public Occlusion withEyeOccluded(boolean eyeOccluded) { } /** - * Get the mouthOccluded value. + * Get a boolean value indicating whether the mouth is occluded. * * @return the mouthOccluded value */ @@ -82,7 +82,7 @@ public boolean mouthOccluded() { } /** - * Set the mouthOccluded value. + * Set a boolean value indicating whether the mouth is occluded. * * @param mouthOccluded the mouthOccluded value to set * @return the Occlusion object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatus.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatus.java new file mode 100644 index 0000000000000..c6a3c9cc0ab71 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatus.java @@ -0,0 +1,169 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Operation status object. Operation refers to the asynchronous backend task + * including taking a snapshot and applying a snapshot. + */ +public class OperationStatus { + /** + * Operation status: notstarted, running, succeeded, failed. If the + * operation is requested and waiting to perform, the status is notstarted. + * If the operation is ongoing in backend, the status is running. Status + * succeeded means the operation is completed successfully, specifically + * for snapshot taking operation, it illustrates the snapshot is well taken + * and ready to apply, and for snapshot applying operation, it presents the + * target object has finished creating by the snapshot and ready to be + * used. Status failed is often caused by editing the source object while + * taking the snapshot or editing the target object while applying the + * snapshot before completion, see the field "message" to check the failure + * reason. Possible values include: 'notstarted', 'running', 'succeeded', + * 'failed'. + */ + @JsonProperty(value = "status", required = true) + private OperationStatusType status; + + /** + * A combined UTC date and time string that describes the time when the + * operation (take or apply a snapshot) is requested. E.g. + * 2018-12-25T11:41:02.2331413Z. + */ + @JsonProperty(value = "createdTime", required = true) + private DateTime createdTime; + + /** + * A combined UTC date and time string that describes the last time the + * operation (take or apply a snapshot) is actively migrating data. The + * lastActionTime will keep increasing until the operation finishes. E.g. + * 2018-12-25T11:51:27.8705696Z. + */ + @JsonProperty(value = "lastActionTime") + private DateTime lastActionTime; + + /** + * When the operation succeeds successfully, for snapshot taking operation + * the snapshot id will be included in this field, and for snapshot + * applying operation, the path to get the target object will be returned + * in this field. + */ + @JsonProperty(value = "resourceLocation") + private String resourceLocation; + + /** + * Show failure message when operation fails (omitted when operation + * succeeds). + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get operation status: notstarted, running, succeeded, failed. If the operation is requested and waiting to perform, the status is notstarted. If the operation is ongoing in backend, the status is running. Status succeeded means the operation is completed successfully, specifically for snapshot taking operation, it illustrates the snapshot is well taken and ready to apply, and for snapshot applying operation, it presents the target object has finished creating by the snapshot and ready to be used. Status failed is often caused by editing the source object while taking the snapshot or editing the target object while applying the snapshot before completion, see the field "message" to check the failure reason. Possible values include: 'notstarted', 'running', 'succeeded', 'failed'. + * + * @return the status value + */ + public OperationStatusType status() { + return this.status; + } + + /** + * Set operation status: notstarted, running, succeeded, failed. If the operation is requested and waiting to perform, the status is notstarted. If the operation is ongoing in backend, the status is running. Status succeeded means the operation is completed successfully, specifically for snapshot taking operation, it illustrates the snapshot is well taken and ready to apply, and for snapshot applying operation, it presents the target object has finished creating by the snapshot and ready to be used. Status failed is often caused by editing the source object while taking the snapshot or editing the target object while applying the snapshot before completion, see the field "message" to check the failure reason. Possible values include: 'notstarted', 'running', 'succeeded', 'failed'. + * + * @param status the status value to set + * @return the OperationStatus object itself. + */ + public OperationStatus withStatus(OperationStatusType status) { + this.status = status; + return this; + } + + /** + * Get a combined UTC date and time string that describes the time when the operation (take or apply a snapshot) is requested. E.g. 2018-12-25T11:41:02.2331413Z. + * + * @return the createdTime value + */ + public DateTime createdTime() { + return this.createdTime; + } + + /** + * Set a combined UTC date and time string that describes the time when the operation (take or apply a snapshot) is requested. E.g. 2018-12-25T11:41:02.2331413Z. + * + * @param createdTime the createdTime value to set + * @return the OperationStatus object itself. + */ + public OperationStatus withCreatedTime(DateTime createdTime) { + this.createdTime = createdTime; + return this; + } + + /** + * Get a combined UTC date and time string that describes the last time the operation (take or apply a snapshot) is actively migrating data. The lastActionTime will keep increasing until the operation finishes. E.g. 2018-12-25T11:51:27.8705696Z. + * + * @return the lastActionTime value + */ + public DateTime lastActionTime() { + return this.lastActionTime; + } + + /** + * Set a combined UTC date and time string that describes the last time the operation (take or apply a snapshot) is actively migrating data. The lastActionTime will keep increasing until the operation finishes. E.g. 2018-12-25T11:51:27.8705696Z. + * + * @param lastActionTime the lastActionTime value to set + * @return the OperationStatus object itself. + */ + public OperationStatus withLastActionTime(DateTime lastActionTime) { + this.lastActionTime = lastActionTime; + return this; + } + + /** + * Get when the operation succeeds successfully, for snapshot taking operation the snapshot id will be included in this field, and for snapshot applying operation, the path to get the target object will be returned in this field. + * + * @return the resourceLocation value + */ + public String resourceLocation() { + return this.resourceLocation; + } + + /** + * Set when the operation succeeds successfully, for snapshot taking operation the snapshot id will be included in this field, and for snapshot applying operation, the path to get the target object will be returned in this field. + * + * @param resourceLocation the resourceLocation value to set + * @return the OperationStatus object itself. + */ + public OperationStatus withResourceLocation(String resourceLocation) { + this.resourceLocation = resourceLocation; + return this; + } + + /** + * Get show failure message when operation fails (omitted when operation succeeds). + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set show failure message when operation fails (omitted when operation succeeds). + * + * @param message the message value to set + * @return the OperationStatus object itself. + */ + public OperationStatus withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatusType.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatusType.java new file mode 100644 index 0000000000000..fc12ee2535461 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/OperationStatusType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for OperationStatusType. + */ +public enum OperationStatusType { + /** Enum value notstarted. */ + NOTSTARTED("notstarted"), + + /** Enum value running. */ + RUNNING("running"), + + /** Enum value succeeded. */ + SUCCEEDED("succeeded"), + + /** Enum value failed. */ + FAILED("failed"); + + /** The actual serialized value for a OperationStatusType instance. */ + private String value; + + OperationStatusType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a OperationStatusType instance. + * + * @param value the serialized value to parse. + * @return the parsed OperationStatusType object, or null if unable to parse. + */ + @JsonCreator + public static OperationStatusType fromString(String value) { + OperationStatusType[] items = OperationStatusType.values(); + for (OperationStatusType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java index afff640ba4f3d..d62e83ec4c37d 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersistedFace.java @@ -30,7 +30,7 @@ public class PersistedFace { private String userData; /** - * Get the persistedFaceId value. + * Get the persistedFaceId of the target face, which is persisted and will not expire. Different from faceId created by Face - Detect and will expire in 24 hours after the detection call. * * @return the persistedFaceId value */ @@ -39,7 +39,7 @@ public UUID persistedFaceId() { } /** - * Set the persistedFaceId value. + * Set the persistedFaceId of the target face, which is persisted and will not expire. Different from faceId created by Face - Detect and will expire in 24 hours after the detection call. * * @param persistedFaceId the persistedFaceId value to set * @return the PersistedFace object itself. @@ -50,7 +50,7 @@ public PersistedFace withPersistedFaceId(UUID persistedFaceId) { } /** - * Get the userData value. + * Get user-provided data attached to the face. The size limit is 1KB. * * @return the userData value */ @@ -59,7 +59,7 @@ public String userData() { } /** - * Set the userData value. + * Set user-provided data attached to the face. The size limit is 1KB. * * @param userData the userData value to set * @return the PersistedFace object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java index b98667abb2620..c2ee71712aa9e 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Person.java @@ -31,7 +31,7 @@ public class Person extends NameAndUserDataContract { private List persistedFaceIds; /** - * Get the personId value. + * Get personId of the target face list. * * @return the personId value */ @@ -40,7 +40,7 @@ public UUID personId() { } /** - * Set the personId value. + * Set personId of the target face list. * * @param personId the personId value to set * @return the Person object itself. @@ -51,7 +51,7 @@ public Person withPersonId(UUID personId) { } /** - * Get the persistedFaceIds value. + * Get persistedFaceIds of registered faces in the person. These persistedFaceIds are returned from Person - Add a Person Face, and will not expire. * * @return the persistedFaceIds value */ @@ -60,7 +60,7 @@ public List persistedFaceIds() { } /** - * Set the persistedFaceIds value. + * Set persistedFaceIds of registered faces in the person. These persistedFaceIds are returned from Person - Add a Person Face, and will not expire. * * @param persistedFaceIds the persistedFaceIds value to set * @return the Person object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java index 561e6ceb78385..4d54a0106cfd7 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/PersonGroup.java @@ -15,13 +15,13 @@ */ public class PersonGroup extends NameAndUserDataContract { /** - * PersonGroupId of the existing person groups. + * PersonGroupId of the target person group. */ @JsonProperty(value = "personGroupId", required = true) private String personGroupId; /** - * Get the personGroupId value. + * Get personGroupId of the target person group. * * @return the personGroupId value */ @@ -30,7 +30,7 @@ public String personGroupId() { } /** - * Set the personGroupId value. + * Set personGroupId of the target person group. * * @param personGroupId the personGroupId value to set * @return the PersonGroup object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java index 9fb409c689a3a..9939e4a518af0 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SimilarFace.java @@ -38,7 +38,7 @@ public class SimilarFace { private double confidence; /** - * Get the faceId value. + * Get faceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire 24 hours after the detection call. * * @return the faceId value */ @@ -47,7 +47,7 @@ public UUID faceId() { } /** - * Set the faceId value. + * Set faceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire 24 hours after the detection call. * * @param faceId the faceId value to set * @return the SimilarFace object itself. @@ -58,7 +58,7 @@ public SimilarFace withFaceId(UUID faceId) { } /** - * Get the persistedFaceId value. + * Get persistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response. * * @return the persistedFaceId value */ @@ -67,7 +67,7 @@ public UUID persistedFaceId() { } /** - * Set the persistedFaceId value. + * Set persistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response. * * @param persistedFaceId the persistedFaceId value to set * @return the SimilarFace object itself. @@ -78,7 +78,7 @@ public SimilarFace withPersistedFaceId(UUID persistedFaceId) { } /** - * Get the confidence value. + * Get similarity confidence of the candidate face. The higher confidence, the more similar. Range between [0,1]. * * @return the confidence value */ @@ -87,7 +87,7 @@ public double confidence() { } /** - * Set the confidence value. + * Set similarity confidence of the candidate face. The higher confidence, the more similar. Range between [0,1]. * * @param confidence the confidence value to set * @return the SimilarFace object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Snapshot.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Snapshot.java new file mode 100644 index 0000000000000..f44c454146e8a --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/Snapshot.java @@ -0,0 +1,214 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.UUID; +import java.util.List; +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Snapshot object. + */ +public class Snapshot { + /** + * Snapshot id. + */ + @JsonProperty(value = "id", required = true) + private UUID id; + + /** + * Azure Cognitive Service Face account id of the subscriber who created + * the snapshot by Snapshot - Take. + */ + @JsonProperty(value = "account", required = true) + private String account; + + /** + * Type of the source object in the snapshot, specified by the subscriber + * who created the snapshot when calling Snapshot - Take. Currently + * FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. + * Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup'. + */ + @JsonProperty(value = "type", required = true) + private SnapshotObjectType type; + + /** + * Array of the target Face subscription ids for the snapshot, specified by + * the user who created the snapshot when calling Snapshot - Take. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - + * Take can apply it. + */ + @JsonProperty(value = "applyScope", required = true) + private List applyScope; + + /** + * User specified data about the snapshot for any purpose. Length should + * not exceed 16KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * A combined UTC date and time string that describes the created time of + * the snapshot. E.g. 2018-12-25T11:41:02.2331413Z. + */ + @JsonProperty(value = "createdTime", required = true) + private DateTime createdTime; + + /** + * A combined UTC date and time string that describes the last time when + * the snapshot was created or updated by Snapshot - Update. E.g. + * 2018-12-25T11:51:27.8705696Z. + */ + @JsonProperty(value = "lastUpdateTime", required = true) + private DateTime lastUpdateTime; + + /** + * Get snapshot id. + * + * @return the id value + */ + public UUID id() { + return this.id; + } + + /** + * Set snapshot id. + * + * @param id the id value to set + * @return the Snapshot object itself. + */ + public Snapshot withId(UUID id) { + this.id = id; + return this; + } + + /** + * Get azure Cognitive Service Face account id of the subscriber who created the snapshot by Snapshot - Take. + * + * @return the account value + */ + public String account() { + return this.account; + } + + /** + * Set azure Cognitive Service Face account id of the subscriber who created the snapshot by Snapshot - Take. + * + * @param account the account value to set + * @return the Snapshot object itself. + */ + public Snapshot withAccount(String account) { + this.account = account; + return this; + } + + /** + * Get type of the source object in the snapshot, specified by the subscriber who created the snapshot when calling Snapshot - Take. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup'. + * + * @return the type value + */ + public SnapshotObjectType type() { + return this.type; + } + + /** + * Set type of the source object in the snapshot, specified by the subscriber who created the snapshot when calling Snapshot - Take. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup'. + * + * @param type the type value to set + * @return the Snapshot object itself. + */ + public Snapshot withType(SnapshotObjectType type) { + this.type = type; + return this; + } + + /** + * Get array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @return the applyScope value + */ + public List applyScope() { + return this.applyScope; + } + + /** + * Set array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @param applyScope the applyScope value to set + * @return the Snapshot object itself. + */ + public Snapshot withApplyScope(List applyScope) { + this.applyScope = applyScope; + return this; + } + + /** + * Get user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @param userData the userData value to set + * @return the Snapshot object itself. + */ + public Snapshot withUserData(String userData) { + this.userData = userData; + return this; + } + + /** + * Get a combined UTC date and time string that describes the created time of the snapshot. E.g. 2018-12-25T11:41:02.2331413Z. + * + * @return the createdTime value + */ + public DateTime createdTime() { + return this.createdTime; + } + + /** + * Set a combined UTC date and time string that describes the created time of the snapshot. E.g. 2018-12-25T11:41:02.2331413Z. + * + * @param createdTime the createdTime value to set + * @return the Snapshot object itself. + */ + public Snapshot withCreatedTime(DateTime createdTime) { + this.createdTime = createdTime; + return this; + } + + /** + * Get a combined UTC date and time string that describes the last time when the snapshot was created or updated by Snapshot - Update. E.g. 2018-12-25T11:51:27.8705696Z. + * + * @return the lastUpdateTime value + */ + public DateTime lastUpdateTime() { + return this.lastUpdateTime; + } + + /** + * Set a combined UTC date and time string that describes the last time when the snapshot was created or updated by Snapshot - Update. E.g. 2018-12-25T11:51:27.8705696Z. + * + * @param lastUpdateTime the lastUpdateTime value to set + * @return the Snapshot object itself. + */ + public Snapshot withLastUpdateTime(DateTime lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyHeaders.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyHeaders.java new file mode 100644 index 0000000000000..08b9f045873cf --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyHeaders.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines headers for Apply operation. + */ +public class SnapshotApplyHeaders { + /** + * Operation location with an operation id used to track the progress of + * applying the snapshot by OperationStatus - Get. + */ + @JsonProperty(value = "Operation-Location") + private String operationLocation; + + /** + * Get operation location with an operation id used to track the progress of applying the snapshot by OperationStatus - Get. + * + * @return the operationLocation value + */ + public String operationLocation() { + return this.operationLocation; + } + + /** + * Set operation location with an operation id used to track the progress of applying the snapshot by OperationStatus - Get. + * + * @param operationLocation the operationLocation value to set + * @return the SnapshotApplyHeaders object itself. + */ + public SnapshotApplyHeaders withOperationLocation(String operationLocation) { + this.operationLocation = operationLocation; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyMode.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyMode.java new file mode 100644 index 0000000000000..cf6885e07ce7d --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotApplyMode.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for SnapshotApplyMode. + */ +public enum SnapshotApplyMode { + /** Enum value CreateNew. */ + CREATE_NEW("CreateNew"); + + /** The actual serialized value for a SnapshotApplyMode instance. */ + private String value; + + SnapshotApplyMode(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SnapshotApplyMode instance. + * + * @param value the serialized value to parse. + * @return the parsed SnapshotApplyMode object, or null if unable to parse. + */ + @JsonCreator + public static SnapshotApplyMode fromString(String value) { + SnapshotApplyMode[] items = SnapshotApplyMode.values(); + for (SnapshotApplyMode item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotObjectType.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotObjectType.java new file mode 100644 index 0000000000000..b487afccad041 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotObjectType.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for SnapshotObjectType. + */ +public enum SnapshotObjectType { + /** Enum value FaceList. */ + FACE_LIST("FaceList"), + + /** Enum value LargeFaceList. */ + LARGE_FACE_LIST("LargeFaceList"), + + /** Enum value LargePersonGroup. */ + LARGE_PERSON_GROUP("LargePersonGroup"), + + /** Enum value PersonGroup. */ + PERSON_GROUP("PersonGroup"); + + /** The actual serialized value for a SnapshotObjectType instance. */ + private String value; + + SnapshotObjectType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SnapshotObjectType instance. + * + * @param value the serialized value to parse. + * @return the parsed SnapshotObjectType object, or null if unable to parse. + */ + @JsonCreator + public static SnapshotObjectType fromString(String value) { + SnapshotObjectType[] items = SnapshotObjectType.values(); + for (SnapshotObjectType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotTakeHeaders.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotTakeHeaders.java new file mode 100644 index 0000000000000..6a7f95c051998 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/SnapshotTakeHeaders.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines headers for Take operation. + */ +public class SnapshotTakeHeaders { + /** + * Operation location with an operation id used to track the progress of + * taking snapshot. The returned id is the operation id, rather than + * snapshot id. Snapshot id can be obtained only when the operation status + * becomes "succeeded" in OperationStatus - Get. + */ + @JsonProperty(value = "Operation-Location") + private String operationLocation; + + /** + * Get operation location with an operation id used to track the progress of taking snapshot. The returned id is the operation id, rather than snapshot id. Snapshot id can be obtained only when the operation status becomes "succeeded" in OperationStatus - Get. + * + * @return the operationLocation value + */ + public String operationLocation() { + return this.operationLocation; + } + + /** + * Set operation location with an operation id used to track the progress of taking snapshot. The returned id is the operation id, rather than snapshot id. Snapshot id can be obtained only when the operation status becomes "succeeded" in OperationStatus - Get. + * + * @param operationLocation the operationLocation value to set + * @return the SnapshotTakeHeaders object itself. + */ + public SnapshotTakeHeaders withOperationLocation(String operationLocation) { + this.operationLocation = operationLocation; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TakeSnapshotRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TakeSnapshotRequest.java new file mode 100644 index 0000000000000..0fcb328904f00 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TakeSnapshotRequest.java @@ -0,0 +1,129 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for taking snapshot operation. + */ +public class TakeSnapshotRequest { + /** + * User specified type for the source object to take snapshot from. + * Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are + * supported. Possible values include: 'FaceList', 'LargeFaceList', + * 'LargePersonGroup', 'PersonGroup'. + */ + @JsonProperty(value = "type", required = true) + private SnapshotObjectType type; + + /** + * User specified source object id to take snapshot from. + */ + @JsonProperty(value = "objectId", required = true) + private String objectId; + + /** + * User specified array of target Face subscription ids for the snapshot. + * For each snapshot, only subscriptions included in the applyScope of + * Snapshot - Take can apply it. + */ + @JsonProperty(value = "applyScope", required = true) + private List applyScope; + + /** + * User specified data about the snapshot for any purpose. Length should + * not exceed 16KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get user specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup'. + * + * @return the type value + */ + public SnapshotObjectType type() { + return this.type; + } + + /** + * Set user specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup'. + * + * @param type the type value to set + * @return the TakeSnapshotRequest object itself. + */ + public TakeSnapshotRequest withType(SnapshotObjectType type) { + this.type = type; + return this; + } + + /** + * Get user specified source object id to take snapshot from. + * + * @return the objectId value + */ + public String objectId() { + return this.objectId; + } + + /** + * Set user specified source object id to take snapshot from. + * + * @param objectId the objectId value to set + * @return the TakeSnapshotRequest object itself. + */ + public TakeSnapshotRequest withObjectId(String objectId) { + this.objectId = objectId; + return this; + } + + /** + * Get user specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @return the applyScope value + */ + public List applyScope() { + return this.applyScope; + } + + /** + * Set user specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @param applyScope the applyScope value to set + * @return the TakeSnapshotRequest object itself. + */ + public TakeSnapshotRequest withApplyScope(List applyScope) { + this.applyScope = applyScope; + return this; + } + + /** + * Get user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @param userData the userData value to set + * @return the TakeSnapshotRequest object itself. + */ + public TakeSnapshotRequest withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java index c80730f3617d3..9c0ff492b7a01 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/TrainingStatus.java @@ -19,27 +19,38 @@ public class TrainingStatus { * Training status: notstarted, running, succeeded, failed. If the training * process is waiting to perform, the status is notstarted. If the training * is ongoing, the status is running. Status succeed means this person - * group is ready for Face - Identify. Status failed is often caused by no - * person or no persisted face exist in the person group. Possible values - * include: 'nonstarted', 'running', 'succeeded', 'failed'. + * group or large person group is ready for Face - Identify, or this large + * face list is ready for Face - Find Similar. Status failed is often + * caused by no person or no persisted face exist in the person group or + * large person group, or no persisted face exist in the large face list. + * Possible values include: 'nonstarted', 'running', 'succeeded', 'failed'. */ @JsonProperty(value = "status", required = true) private TrainingStatusType status; /** - * A combined UTC date and time string that describes person group created - * time. + * A combined UTC date and time string that describes the created time of + * the person group, large person group or large face list. */ @JsonProperty(value = "createdDateTime", required = true) private DateTime created; /** - * Person group last modify time in the UTC, could be null value when the - * person group is not successfully trained. + * A combined UTC date and time string that describes the last modify time + * of the person group, large person group or large face list, could be + * null value when the group is not successfully trained. */ @JsonProperty(value = "lastActionDateTime") private DateTime lastAction; + /** + * A combined UTC date and time string that describes the last successful + * training time of the person group, large person group or large face + * list. + */ + @JsonProperty(value = "lastSuccessfulTrainingDateTime") + private DateTime lastSuccessfulTraining; + /** * Show failure message when training failed (omitted when training * succeed). @@ -48,7 +59,7 @@ public class TrainingStatus { private String message; /** - * Get the status value. + * Get training status: notstarted, running, succeeded, failed. If the training process is waiting to perform, the status is notstarted. If the training is ongoing, the status is running. Status succeed means this person group or large person group is ready for Face - Identify, or this large face list is ready for Face - Find Similar. Status failed is often caused by no person or no persisted face exist in the person group or large person group, or no persisted face exist in the large face list. Possible values include: 'nonstarted', 'running', 'succeeded', 'failed'. * * @return the status value */ @@ -57,7 +68,7 @@ public TrainingStatusType status() { } /** - * Set the status value. + * Set training status: notstarted, running, succeeded, failed. If the training process is waiting to perform, the status is notstarted. If the training is ongoing, the status is running. Status succeed means this person group or large person group is ready for Face - Identify, or this large face list is ready for Face - Find Similar. Status failed is often caused by no person or no persisted face exist in the person group or large person group, or no persisted face exist in the large face list. Possible values include: 'nonstarted', 'running', 'succeeded', 'failed'. * * @param status the status value to set * @return the TrainingStatus object itself. @@ -68,7 +79,7 @@ public TrainingStatus withStatus(TrainingStatusType status) { } /** - * Get the created value. + * Get a combined UTC date and time string that describes the created time of the person group, large person group or large face list. * * @return the created value */ @@ -77,7 +88,7 @@ public DateTime created() { } /** - * Set the created value. + * Set a combined UTC date and time string that describes the created time of the person group, large person group or large face list. * * @param created the created value to set * @return the TrainingStatus object itself. @@ -88,7 +99,7 @@ public TrainingStatus withCreated(DateTime created) { } /** - * Get the lastAction value. + * Get a combined UTC date and time string that describes the last modify time of the person group, large person group or large face list, could be null value when the group is not successfully trained. * * @return the lastAction value */ @@ -97,7 +108,7 @@ public DateTime lastAction() { } /** - * Set the lastAction value. + * Set a combined UTC date and time string that describes the last modify time of the person group, large person group or large face list, could be null value when the group is not successfully trained. * * @param lastAction the lastAction value to set * @return the TrainingStatus object itself. @@ -108,7 +119,27 @@ public TrainingStatus withLastAction(DateTime lastAction) { } /** - * Get the message value. + * Get a combined UTC date and time string that describes the last successful training time of the person group, large person group or large face list. + * + * @return the lastSuccessfulTraining value + */ + public DateTime lastSuccessfulTraining() { + return this.lastSuccessfulTraining; + } + + /** + * Set a combined UTC date and time string that describes the last successful training time of the person group, large person group or large face list. + * + * @param lastSuccessfulTraining the lastSuccessfulTraining value to set + * @return the TrainingStatus object itself. + */ + public TrainingStatus withLastSuccessfulTraining(DateTime lastSuccessfulTraining) { + this.lastSuccessfulTraining = lastSuccessfulTraining; + return this; + } + + /** + * Get show failure message when training failed (omitted when training succeed). * * @return the message value */ @@ -117,7 +148,7 @@ public String message() { } /** - * Set the message value. + * Set show failure message when training failed (omitted when training succeed). * * @param message the message value to set * @return the TrainingStatus object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateFaceRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateFaceRequest.java new file mode 100644 index 0000000000000..94b1020f33b95 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateFaceRequest.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request to update face data. + */ +public class UpdateFaceRequest { + /** + * User-provided data attached to the face. The size limit is 1KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get user-provided data attached to the face. The size limit is 1KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user-provided data attached to the face. The size limit is 1KB. + * + * @param userData the userData value to set + * @return the UpdateFaceRequest object itself. + */ + public UpdateFaceRequest withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java index d2568b3c044ad..4a5a1a0a74691 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdatePersonFaceRequest.java @@ -21,7 +21,7 @@ public class UpdatePersonFaceRequest { private String userData; /** - * Get the userData value. + * Get user-provided data attached to the face. The size limit is 1KB. * * @return the userData value */ @@ -30,7 +30,7 @@ public String userData() { } /** - * Set the userData value. + * Set user-provided data attached to the face. The size limit is 1KB. * * @param userData the userData value to set * @return the UpdatePersonFaceRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateSnapshotRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateSnapshotRequest.java new file mode 100644 index 0000000000000..cc23208d61a6f --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/UpdateSnapshotRequest.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.vision.faceapi.models; + +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request body for updating a snapshot, with a combination of user defined + * apply scope and user specified data. + */ +public class UpdateSnapshotRequest { + /** + * Array of the target Face subscription ids for the snapshot, specified by + * the user who created the snapshot when calling Snapshot - Take. For each + * snapshot, only subscriptions included in the applyScope of Snapshot - + * Take can apply it. + */ + @JsonProperty(value = "applyScope") + private List applyScope; + + /** + * User specified data about the snapshot for any purpose. Length should + * not exceed 16KB. + */ + @JsonProperty(value = "userData") + private String userData; + + /** + * Get array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @return the applyScope value + */ + public List applyScope() { + return this.applyScope; + } + + /** + * Set array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it. + * + * @param applyScope the applyScope value to set + * @return the UpdateSnapshotRequest object itself. + */ + public UpdateSnapshotRequest withApplyScope(List applyScope) { + this.applyScope = applyScope; + return this; + } + + /** + * Get user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @return the userData value + */ + public String userData() { + return this.userData; + } + + /** + * Set user specified data about the snapshot for any purpose. Length should not exceed 16KB. + * + * @param userData the userData value to set + * @return the UpdateSnapshotRequest object itself. + */ + public UpdateSnapshotRequest withUserData(String userData) { + this.userData = userData; + return this; + } + +} diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java index c38465fcc0fc1..5696325adf75c 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToFaceRequest.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Request body for verify operation. + * Request body for face to face verification. */ public class VerifyFaceToFaceRequest { /** @@ -28,7 +28,7 @@ public class VerifyFaceToFaceRequest { private UUID faceId2; /** - * Get the faceId1 value. + * Get faceId of the first face, comes from Face - Detect. * * @return the faceId1 value */ @@ -37,7 +37,7 @@ public UUID faceId1() { } /** - * Set the faceId1 value. + * Set faceId of the first face, comes from Face - Detect. * * @param faceId1 the faceId1 value to set * @return the VerifyFaceToFaceRequest object itself. @@ -48,7 +48,7 @@ public VerifyFaceToFaceRequest withFaceId1(UUID faceId1) { } /** - * Get the faceId2 value. + * Get faceId of the second face, comes from Face - Detect. * * @return the faceId2 value */ @@ -57,7 +57,7 @@ public UUID faceId2() { } /** - * Set the faceId2 value. + * Set faceId of the second face, comes from Face - Detect. * * @param faceId2 the faceId2 value to set * @return the VerifyFaceToFaceRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java index 69cfa7b70ccdc..5758d82d4a93a 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyFaceToPersonRequest.java @@ -12,31 +12,43 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Request body for verify operation. + * Request body for face to person verification. */ public class VerifyFaceToPersonRequest { /** - * FaceId the face, comes from Face - Detect. + * FaceId of the face, comes from Face - Detect. */ @JsonProperty(value = "faceId", required = true) private UUID faceId; /** * Using existing personGroupId and personId for fast loading a specified - * person. personGroupId is created in Person Groups.Create. + * person. personGroupId is created in PersonGroup - Create. Parameter + * personGroupId and largePersonGroupId should not be provided at the same + * time. */ - @JsonProperty(value = "personGroupId", required = true) + @JsonProperty(value = "personGroupId") private String personGroupId; /** - * Specify a certain person in a person group. personId is created in - * Persons.Create. + * Using existing largePersonGroupId and personId for fast loading a + * specified person. largePersonGroupId is created in LargePersonGroup - + * Create. Parameter personGroupId and largePersonGroupId should not be + * provided at the same time. + */ + @JsonProperty(value = "largePersonGroupId") + private String largePersonGroupId; + + /** + * Specify a certain person in a person group or a large person group. + * personId is created in PersonGroup Person - Create or LargePersonGroup + * Person - Create. */ @JsonProperty(value = "personId", required = true) private UUID personId; /** - * Get the faceId value. + * Get faceId of the face, comes from Face - Detect. * * @return the faceId value */ @@ -45,7 +57,7 @@ public UUID faceId() { } /** - * Set the faceId value. + * Set faceId of the face, comes from Face - Detect. * * @param faceId the faceId value to set * @return the VerifyFaceToPersonRequest object itself. @@ -56,7 +68,7 @@ public VerifyFaceToPersonRequest withFaceId(UUID faceId) { } /** - * Get the personGroupId value. + * Get using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * * @return the personGroupId value */ @@ -65,7 +77,7 @@ public String personGroupId() { } /** - * Set the personGroupId value. + * Set using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. * * @param personGroupId the personGroupId value to set * @return the VerifyFaceToPersonRequest object itself. @@ -76,7 +88,27 @@ public VerifyFaceToPersonRequest withPersonGroupId(String personGroupId) { } /** - * Get the personId value. + * Get using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * + * @return the largePersonGroupId value + */ + public String largePersonGroupId() { + return this.largePersonGroupId; + } + + /** + * Set using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time. + * + * @param largePersonGroupId the largePersonGroupId value to set + * @return the VerifyFaceToPersonRequest object itself. + */ + public VerifyFaceToPersonRequest withLargePersonGroupId(String largePersonGroupId) { + this.largePersonGroupId = largePersonGroupId; + return this; + } + + /** + * Get specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. * * @return the personId value */ @@ -85,7 +117,7 @@ public UUID personId() { } /** - * Set the personId value. + * Set specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create. * * @param personId the personId value to set * @return the VerifyFaceToPersonRequest object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java index df17ae94bc5de..01b2167c81106 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/VerifyResult.java @@ -32,7 +32,7 @@ public class VerifyResult { private double confidence; /** - * Get the isIdentical value. + * Get true if the two faces belong to the same person or the face belongs to the person, otherwise false. * * @return the isIdentical value */ @@ -41,7 +41,7 @@ public boolean isIdentical() { } /** - * Set the isIdentical value. + * Set true if the two faces belong to the same person or the face belongs to the person, otherwise false. * * @param isIdentical the isIdentical value to set * @return the VerifyResult object itself. @@ -52,7 +52,7 @@ public VerifyResult withIsIdentical(boolean isIdentical) { } /** - * Get the confidence value. + * Get a number indicates the similarity confidence of whether two faces belong to the same person, or whether the face belongs to the person. By default, isIdentical is set to True if similarity confidence is greater than or equal to 0.5. This is useful for advanced users to override "isIdentical" and fine-tune the result on their own data. * * @return the confidence value */ @@ -61,7 +61,7 @@ public double confidence() { } /** - * Set the confidence value. + * Set a number indicates the similarity confidence of whether two faces belong to the same person, or whether the face belongs to the person. By default, isIdentical is set to True if similarity confidence is greater than or equal to 0.5. This is useful for advanced users to override "isIdentical" and fine-tune the result on their own data. * * @param confidence the confidence value to set * @return the VerifyResult object itself. diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java index acb4d1e307afc..2e540da664843 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/models/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the models classes for FaceAPI. + * This package contains the models classes for FaceClient. * An API for face detection, verification, and identification. */ package com.microsoft.azure.cognitiveservices.vision.faceapi.models; diff --git a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java index 9266ae52be91c..6a7b6a2a05a47 100644 --- a/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the classes for FaceAPI. + * This package contains the classes for FaceClient. * An API for face detection, verification, and identification. */ package com.microsoft.azure.cognitiveservices.vision.faceapi;