| | 1 | | // <auto-generated> |
| | 2 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 3 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 4 | | // license information. |
| | 5 | | // |
| | 6 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 7 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 8 | | // regenerated. |
| | 9 | | // </auto-generated> |
| | 10 | |
|
| | 11 | | namespace Microsoft.Azure.CognitiveServices.Vision.Face |
| | 12 | | { |
| | 13 | | using Models; |
| | 14 | | using System.Collections; |
| | 15 | | using System.Collections.Generic; |
| | 16 | | using System.Threading; |
| | 17 | | using System.Threading.Tasks; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Extension methods for SnapshotOperations. |
| | 21 | | /// </summary> |
| | 22 | | public static partial class SnapshotOperationsExtensions |
| | 23 | | { |
| | 24 | | /// <summary> |
| | 25 | | /// Submit an operation to take a snapshot of face list, large face list, |
| | 26 | | /// person group or large person group, with user-specified snapshot type, |
| | 27 | | /// source object id, apply scope and an optional user data.<br /> |
| | 28 | | /// The snapshot interfaces are for users to backup and restore their face data |
| | 29 | | /// from one face subscription to another, inside same region or across |
| | 30 | | /// regions. The workflow contains two phases, user first calls Snapshot - Take |
| | 31 | | /// to create a copy of the source object and store it as a snapshot, then |
| | 32 | | /// calls Snapshot - Apply to paste the snapshot to target subscription. The |
| | 33 | | /// snapshots are stored in a centralized location (per Azure instance), so |
| | 34 | | /// that they can be applied cross accounts and regions.<br /> |
| | 35 | | /// Taking snapshot is an asynchronous operation. An operation id can be |
| | 36 | | /// obtained from the "Operation-Location" field in response header, to be used |
| | 37 | | /// in OperationStatus - Get for tracking the progress of creating the |
| | 38 | | /// snapshot. The snapshot id will be included in the "resourceLocation" field |
| | 39 | | /// in OperationStatus - Get response when the operation status is |
| | 40 | | /// "succeeded".<br /> |
| | 41 | | /// Snapshot taking time depends on the number of person and face entries in |
| | 42 | | /// the source object. It could be in seconds, or up to several hours for |
| | 43 | | /// 1,000,000 persons with multiple faces.<br /> |
| | 44 | | /// Snapshots will be automatically expired and cleaned in 48 hours after it is |
| | 45 | | /// created by Snapshot - Take. User can delete the snapshot using Snapshot - |
| | 46 | | /// Delete by themselves any time before expiration.<br /> |
| | 47 | | /// Taking snapshot for a certain object will not block any other operations |
| | 48 | | /// against the object. All read-only operations (Get/List and |
| | 49 | | /// Identify/FindSimilar/Verify) can be conducted as usual. For all writable |
| | 50 | | /// operations, including Add/Update/Delete the source object or its |
| | 51 | | /// persons/faces and Train, they are not blocked but not recommended because |
| | 52 | | /// writable updates may not be reflected on the snapshot during its taking. |
| | 53 | | /// After snapshot taking is completed, all readable and writable operations |
| | 54 | | /// can work as normal. Snapshot will also include the training results of the |
| | 55 | | /// source object, which means target subscription the snapshot applied to does |
| | 56 | | /// not need re-train the target object before calling |
| | 57 | | /// Identify/FindSimilar.<br /> |
| | 58 | | /// * Free-tier subscription quota: 100 take operations per month. |
| | 59 | | /// * S0-tier subscription quota: 100 take operations per day. |
| | 60 | | /// </summary> |
| | 61 | | /// <param name='operations'> |
| | 62 | | /// The operations group for this extension method. |
| | 63 | | /// </param> |
| | 64 | | /// <param name='type'> |
| | 65 | | /// User specified type for the source object to take snapshot from. Currently |
| | 66 | | /// FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. |
| | 67 | | /// Possible values include: 'FaceList', 'LargeFaceList', 'LargePersonGroup', |
| | 68 | | /// 'PersonGroup' |
| | 69 | | /// </param> |
| | 70 | | /// <param name='objectId'> |
| | 71 | | /// User specified source object id to take snapshot from. |
| | 72 | | /// </param> |
| | 73 | | /// <param name='applyScope'> |
| | 74 | | /// User specified array of target Face subscription ids for the snapshot. For |
| | 75 | | /// each snapshot, only subscriptions included in the applyScope of Snapshot - |
| | 76 | | /// Take can apply it. |
| | 77 | | /// </param> |
| | 78 | | /// <param name='userData'> |
| | 79 | | /// User specified data about the snapshot for any purpose. Length should not |
| | 80 | | /// exceed 16KB. |
| | 81 | | /// </param> |
| | 82 | | /// <param name='cancellationToken'> |
| | 83 | | /// The cancellation token. |
| | 84 | | /// </param> |
| | 85 | | public static async Task<SnapshotTakeHeaders> TakeAsync(this ISnapshotOperations operations, SnapshotObjectT |
| | 86 | | { |
| 8 | 87 | | using (var _result = await operations.TakeWithHttpMessagesAsync(type, objectId, applyScope, userData, nu |
| | 88 | | { |
| 8 | 89 | | return _result.Headers; |
| | 90 | | } |
| 8 | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// List all accessible snapshots with related information, including snapshots |
| | 95 | | /// that were taken by the user, or snapshots to be applied to the user |
| | 96 | | /// (subscription id was included in the applyScope in Snapshot - Take). |
| | 97 | | /// </summary> |
| | 98 | | /// <param name='operations'> |
| | 99 | | /// The operations group for this extension method. |
| | 100 | | /// </param> |
| | 101 | | /// <param name='type'> |
| | 102 | | /// User specified object type as a search filter. Possible values include: |
| | 103 | | /// 'FaceList', 'LargeFaceList', 'LargePersonGroup', 'PersonGroup' |
| | 104 | | /// </param> |
| | 105 | | /// <param name='applyScope'> |
| | 106 | | /// User specified snapshot apply scopes as a search filter. ApplyScope is an |
| | 107 | | /// array of the target Azure subscription ids for the snapshot, specified by |
| | 108 | | /// the user who created the snapshot by Snapshot - Take. |
| | 109 | | /// </param> |
| | 110 | | /// <param name='cancellationToken'> |
| | 111 | | /// The cancellation token. |
| | 112 | | /// </param> |
| | 113 | | public static async Task<IList<Snapshot>> ListAsync(this ISnapshotOperations operations, SnapshotObjectType? |
| | 114 | | { |
| 0 | 115 | | using (var _result = await operations.ListWithHttpMessagesAsync(type, applyScope, null, cancellationToke |
| | 116 | | { |
| 0 | 117 | | return _result.Body; |
| | 118 | | } |
| 0 | 119 | | } |
| | 120 | |
|
| | 121 | | /// <summary> |
| | 122 | | /// Retrieve information about a snapshot. Snapshot is only accessible to the |
| | 123 | | /// source subscription who took it, and target subscriptions included in the |
| | 124 | | /// applyScope in Snapshot - Take. |
| | 125 | | /// </summary> |
| | 126 | | /// <param name='operations'> |
| | 127 | | /// The operations group for this extension method. |
| | 128 | | /// </param> |
| | 129 | | /// <param name='snapshotId'> |
| | 130 | | /// Id referencing a particular snapshot. |
| | 131 | | /// </param> |
| | 132 | | /// <param name='cancellationToken'> |
| | 133 | | /// The cancellation token. |
| | 134 | | /// </param> |
| | 135 | | public static async Task<Snapshot> GetAsync(this ISnapshotOperations operations, System.Guid snapshotId, Can |
| | 136 | | { |
| 0 | 137 | | using (var _result = await operations.GetWithHttpMessagesAsync(snapshotId, null, cancellationToken).Conf |
| | 138 | | { |
| 0 | 139 | | return _result.Body; |
| | 140 | | } |
| 0 | 141 | | } |
| | 142 | |
|
| | 143 | | /// <summary> |
| | 144 | | /// Update the information of a snapshot. Only the source subscription who took |
| | 145 | | /// the snapshot can update the snapshot. |
| | 146 | | /// </summary> |
| | 147 | | /// <param name='operations'> |
| | 148 | | /// The operations group for this extension method. |
| | 149 | | /// </param> |
| | 150 | | /// <param name='snapshotId'> |
| | 151 | | /// Id referencing a particular snapshot. |
| | 152 | | /// </param> |
| | 153 | | /// <param name='applyScope'> |
| | 154 | | /// Array of the target Face subscription ids for the snapshot, specified by |
| | 155 | | /// the user who created the snapshot when calling Snapshot - Take. For each |
| | 156 | | /// snapshot, only subscriptions included in the applyScope of Snapshot - Take |
| | 157 | | /// can apply it. |
| | 158 | | /// </param> |
| | 159 | | /// <param name='userData'> |
| | 160 | | /// User specified data about the snapshot for any purpose. Length should not |
| | 161 | | /// exceed 16KB. |
| | 162 | | /// </param> |
| | 163 | | /// <param name='cancellationToken'> |
| | 164 | | /// The cancellation token. |
| | 165 | | /// </param> |
| | 166 | | public static async Task UpdateAsync(this ISnapshotOperations operations, System.Guid snapshotId, IList<Syst |
| | 167 | | { |
| 0 | 168 | | (await operations.UpdateWithHttpMessagesAsync(snapshotId, applyScope, userData, null, cancellationToken) |
| 0 | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> |
| | 172 | | /// Delete an existing snapshot according to the snapshotId. All object data |
| | 173 | | /// and information in the snapshot will also be deleted. Only the source |
| | 174 | | /// subscription who took the snapshot can delete the snapshot. If the user |
| | 175 | | /// does not delete a snapshot with this API, the snapshot will still be |
| | 176 | | /// automatically deleted in 48 hours after creation. |
| | 177 | | /// </summary> |
| | 178 | | /// <param name='operations'> |
| | 179 | | /// The operations group for this extension method. |
| | 180 | | /// </param> |
| | 181 | | /// <param name='snapshotId'> |
| | 182 | | /// Id referencing a particular snapshot. |
| | 183 | | /// </param> |
| | 184 | | /// <param name='cancellationToken'> |
| | 185 | | /// The cancellation token. |
| | 186 | | /// </param> |
| | 187 | | public static async Task DeleteAsync(this ISnapshotOperations operations, System.Guid snapshotId, Cancellati |
| | 188 | | { |
| 8 | 189 | | (await operations.DeleteWithHttpMessagesAsync(snapshotId, null, cancellationToken).ConfigureAwait(false) |
| 8 | 190 | | } |
| | 191 | |
|
| | 192 | | /// <summary> |
| | 193 | | /// Submit an operation to apply a snapshot to current subscription. For each |
| | 194 | | /// snapshot, only subscriptions included in the applyScope of Snapshot - Take |
| | 195 | | /// can apply it.<br /> |
| | 196 | | /// The snapshot interfaces are for users to backup and restore their face data |
| | 197 | | /// from one face subscription to another, inside same region or across |
| | 198 | | /// regions. The workflow contains two phases, user first calls Snapshot - Take |
| | 199 | | /// to create a copy of the source object and store it as a snapshot, then |
| | 200 | | /// calls Snapshot - Apply to paste the snapshot to target subscription. The |
| | 201 | | /// snapshots are stored in a centralized location (per Azure instance), so |
| | 202 | | /// that they can be applied cross accounts and regions.<br /> |
| | 203 | | /// Applying snapshot is an asynchronous operation. An operation id can be |
| | 204 | | /// obtained from the "Operation-Location" field in response header, to be used |
| | 205 | | /// in OperationStatus - Get for tracking the progress of applying the |
| | 206 | | /// snapshot. The target object id will be included in the "resourceLocation" |
| | 207 | | /// field in OperationStatus - Get response when the operation status is |
| | 208 | | /// "succeeded".<br /> |
| | 209 | | /// Snapshot applying time depends on the number of person and face entries in |
| | 210 | | /// the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 |
| | 211 | | /// persons with multiple faces.<br /> |
| | 212 | | /// Snapshots will be automatically expired and cleaned in 48 hours after it is |
| | 213 | | /// created by Snapshot - Take. So the target subscription is required to apply |
| | 214 | | /// the snapshot in 48 hours since its creation.<br /> |
| | 215 | | /// Applying a snapshot will not block any other operations against the target |
| | 216 | | /// object, however it is not recommended because the correctness cannot be |
| | 217 | | /// guaranteed during snapshot applying. After snapshot applying is completed, |
| | 218 | | /// all operations towards the target object can work as normal. Snapshot also |
| | 219 | | /// includes the training results of the source object, which means target |
| | 220 | | /// subscription the snapshot applied to does not need re-train the target |
| | 221 | | /// object before calling Identify/FindSimilar.<br /> |
| | 222 | | /// One snapshot can be applied multiple times in parallel, while currently |
| | 223 | | /// only CreateNew apply mode is supported, which means the apply operation |
| | 224 | | /// will fail if target subscription already contains an object of same type |
| | 225 | | /// and using the same objectId. Users can specify the "objectId" in request |
| | 226 | | /// body to avoid such conflicts.<br /> |
| | 227 | | /// * Free-tier subscription quota: 100 apply operations per month. |
| | 228 | | /// * S0-tier subscription quota: 100 apply operations per day. |
| | 229 | | /// </summary> |
| | 230 | | /// <param name='operations'> |
| | 231 | | /// The operations group for this extension method. |
| | 232 | | /// </param> |
| | 233 | | /// <param name='snapshotId'> |
| | 234 | | /// Id referencing a particular snapshot. |
| | 235 | | /// </param> |
| | 236 | | /// <param name='objectId'> |
| | 237 | | /// User specified target object id to be created from the snapshot. |
| | 238 | | /// </param> |
| | 239 | | /// <param name='mode'> |
| | 240 | | /// Snapshot applying mode. Currently only CreateNew is supported, which means |
| | 241 | | /// the apply operation will fail if target subscription already contains an |
| | 242 | | /// object of same type and using the same objectId. Users can specify the |
| | 243 | | /// "objectId" in request body to avoid such conflicts. Possible values |
| | 244 | | /// include: 'CreateNew' |
| | 245 | | /// </param> |
| | 246 | | /// <param name='cancellationToken'> |
| | 247 | | /// The cancellation token. |
| | 248 | | /// </param> |
| | 249 | | public static async Task<SnapshotApplyHeaders> ApplyAsync(this ISnapshotOperations operations, System.Guid s |
| | 250 | | { |
| 8 | 251 | | using (var _result = await operations.ApplyWithHttpMessagesAsync(snapshotId, objectId, mode, null, cance |
| | 252 | | { |
| 8 | 253 | | return _result.Headers; |
| | 254 | | } |
| 8 | 255 | | } |
| | 256 | |
|
| | 257 | | /// <summary> |
| | 258 | | /// Retrieve the status of a take/apply snapshot operation. |
| | 259 | | /// </summary> |
| | 260 | | /// <param name='operations'> |
| | 261 | | /// The operations group for this extension method. |
| | 262 | | /// </param> |
| | 263 | | /// <param name='operationId'> |
| | 264 | | /// Id referencing a particular take/apply snapshot operation. |
| | 265 | | /// </param> |
| | 266 | | /// <param name='cancellationToken'> |
| | 267 | | /// The cancellation token. |
| | 268 | | /// </param> |
| | 269 | | public static async Task<OperationStatus> GetOperationStatusAsync(this ISnapshotOperations operations, Syste |
| | 270 | | { |
| 32 | 271 | | using (var _result = await operations.GetOperationStatusWithHttpMessagesAsync(operationId, null, cancell |
| | 272 | | { |
| 32 | 273 | | return _result.Body; |
| | 274 | | } |
| 32 | 275 | | } |
| | 276 | |
|
| | 277 | | } |
| | 278 | | } |