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 index 389c74a4585f..af54d6ee0c9f 100644 --- 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 @@ -137,4 +137,10 @@ public interface FaceClient { */ 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/Snapshots.java b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Snapshots.java new file mode 100644 index 000000000000..043e04b3555a --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/Snapshots.java @@ -0,0 +1,578 @@ +/** + * 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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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 index 8da3d678fc2b..8561ce2e9121 100644 --- 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 @@ -18,6 +18,7 @@ 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; @@ -219,6 +220,19 @@ 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. * @@ -260,6 +274,7 @@ protected void initialize() { 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); } 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 000000000000..7cde0e56f315 --- /dev/null +++ b/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/SnapshotsImpl.java @@ -0,0 +1,1090 @@ +/** + * 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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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. + 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. + 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". + 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. + 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. + 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. + 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. + * + * @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/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 000000000000..268e1111109c --- /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/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 000000000000..c6a3c9cc0ab7 --- /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 000000000000..fc12ee253546 --- /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/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 000000000000..f44c454146e8 --- /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 000000000000..08b9f045873c --- /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 000000000000..cf6885e07ce7 --- /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 000000000000..b487afccad04 --- /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 000000000000..6a7f95c05199 --- /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 000000000000..0fcb328904f0 --- /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/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 000000000000..cc23208d61a6 --- /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; + } + +}