Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
codegen
  • Loading branch information
Han-msft committed Oct 9, 2024
commit e8f18da8295ca7b2e70d6048e61d42c5540763c8
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var sessionClient = new FaceSessionClient(endpoint, credential);
Before you can detect liveness in a face, you need to create a liveness detection session with Azure AI Face Service. The service creates a liveness-session and responds back with a session-authorization-token.

```C# Snippet:CreateLivenessWithVerifySession
var parameters = new CreateLivenessSessionContent(LivenessOperationMode.Passive) {
var parameters = new CreateLivenessWithVerifySessionJsonContent(LivenessOperationMode.Passive) {
SendResultsToClient = true,
DeviceCorrelationId = Guid.NewGuid().ToString(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var sessionClient = new FaceSessionClient(endpoint, credential);
Before you can detect liveness in a face, you need to create a liveness detection session with Azure AI Face Service. The service creates a liveness-session and responds back with a session-authorization-token.

```C# Snippet:CreateLivenessWithVerifySessionAsync
var parameters = new CreateLivenessSessionContent(LivenessOperationMode.Passive) {
var parameters = new CreateLivenessWithVerifySessionJsonContent(LivenessOperationMode.Passive) {
SendResultsToClient = true,
DeviceCorrelationId = Guid.NewGuid().ToString(),
};
Expand Down
79 changes: 79 additions & 0 deletions sdk/face/Azure.AI.Vision.Face/src/Custom/FaceListClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core;
using Azure.Core.Pipeline;

namespace Azure.AI.Vision.Face
{
// Data plane generated sub-client.
/// <summary> The FaceList sub-client. </summary>
[CodeGenClient("FaceListClientImpl")]
public partial class FaceListClient
{
/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public FaceListClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureAIVisionFaceClientOptions())
{
}

/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public FaceListClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureAIVisionFaceClientOptions())
{
}

/// <summary> Initializes a new instance of FaceListClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public FaceListClient(Uri endpoint, AzureKeyCredential credential, AzureAIVisionFaceClientOptions options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new AzureAIVisionFaceClientOptions();

ClientDiagnostics = new ClientDiagnostics(options, true);
_keyCredential = credential;
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier());
_endpoint = endpoint;
_apiVersion = options.Version;
}

/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public FaceListClient(Uri endpoint, TokenCredential credential, AzureAIVisionFaceClientOptions options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new AzureAIVisionFaceClientOptions();

ClientDiagnostics = new ClientDiagnostics(options, true);
_tokenCredential = credential;
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
_endpoint = endpoint;
_apiVersion = options.Version;
}
}
}
28 changes: 14 additions & 14 deletions sdk/face/Azure.AI.Vision.Face/src/Custom/FaceSessionClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ namespace Azure.AI.Vision.Face
public partial class FaceSessionClient
{
/// <summary> Create a new liveness session with verify. Provide the verify image during session creation. </summary>
/// <param name="createLivenessSessionContent"> Parameters for liveness with verify session creation. </param>
/// <param name="jsonContent"> Parameters for liveness with verify session creation. </param>
/// <param name="verifyImage"> Image binary data for verify image, can be provided as session creation time or during the /detectLivenessWithVerify/singleModal </param>///
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="createLivenessSessionContent"/> is null. </exception>
/// <exception cref="ArgumentNullException"> <paramref name="jsonContent"/> is null. </exception>
/// <remarks>
/// A session is best for client device scenarios where developers want to authorize a client device to perform only a liveness detection without granting full access to their resource. Created sessions have a limited life span and only authorize clients to perform the desired action before access is expired.
///
Expand All @@ -39,24 +39,24 @@ public partial class FaceSessionClient
/// &gt; Extra measures should be taken to validate that the client is sending the expected VerifyImage.
/// </remarks>
[ForwardsClientCalls]
public virtual async Task<Response<CreateLivenessWithVerifySessionResult>> CreateLivenessWithVerifySessionAsync(CreateLivenessSessionContent createLivenessSessionContent, Stream verifyImage, CancellationToken cancellationToken = default)
public virtual async Task<Response<CreateLivenessWithVerifySessionResult>> CreateLivenessWithVerifySessionAsync(CreateLivenessWithVerifySessionJsonContent jsonContent, Stream verifyImage, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(createLivenessSessionContent, nameof(createLivenessSessionContent));
Argument.AssertNotNull(jsonContent, nameof(jsonContent));

if (verifyImage == null)
{
return await CreateLivenessWithVerifySessionAsync(createLivenessSessionContent, cancellationToken).ConfigureAwait(false);
return await CreateLivenessWithVerifySessionAsync(jsonContent, cancellationToken).ConfigureAwait(false);
}

var createLivenessWithVerifySessionContent = new CreateLivenessWithVerifySessionContent(createLivenessSessionContent, verifyImage);
return await CreateLivenessWithVerifySessionWithVerifyImageAsync(createLivenessWithVerifySessionContent, cancellationToken).ConfigureAwait(false);
CreateLivenessWithVerifySessionMultipartContent multipartContent = new CreateLivenessWithVerifySessionMultipartContent(jsonContent, verifyImage);
return await CreateLivenessWithVerifySessionWithVerifyImageAsync(multipartContent, cancellationToken).ConfigureAwait(false);
}

/// <summary> Create a new liveness session with verify. Provide the verify image during session creation. </summary>
/// <param name="createLivenessSessionContent"> Parameters for liveness with verify session creation. </param>
/// <param name="jsonContent"> Parameters for liveness with verify session creation. </param>
/// <param name="verifyImage"> Image binary data for verify image, can be provided as session creation time or during the /detectLivenessWithVerify/singleModal </param>///
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="createLivenessSessionContent"/> is null. </exception>
/// <exception cref="ArgumentNullException"> <paramref name="jsonContent"/> is null. </exception>
/// <remarks>
/// A session is best for client device scenarios where developers want to authorize a client device to perform only a liveness detection without granting full access to their resource. Created sessions have a limited life span and only authorize clients to perform the desired action before access is expired.
///
Expand All @@ -79,17 +79,17 @@ public virtual async Task<Response<CreateLivenessWithVerifySessionResult>> Creat
/// &gt; Extra measures should be taken to validate that the client is sending the expected VerifyImage.
/// </remarks>
[ForwardsClientCalls]
public virtual Response<CreateLivenessWithVerifySessionResult> CreateLivenessWithVerifySession(CreateLivenessSessionContent createLivenessSessionContent, Stream verifyImage, CancellationToken cancellationToken = default)
public virtual Response<CreateLivenessWithVerifySessionResult> CreateLivenessWithVerifySession(CreateLivenessWithVerifySessionJsonContent jsonContent, Stream verifyImage, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(createLivenessSessionContent, nameof(createLivenessSessionContent));
Argument.AssertNotNull(jsonContent, nameof(jsonContent));

if (verifyImage == null)
{
return CreateLivenessWithVerifySession(createLivenessSessionContent, cancellationToken);
return CreateLivenessWithVerifySession(jsonContent, cancellationToken);
}

var createLivenessWithVerifySessionContent = new CreateLivenessWithVerifySessionContent(createLivenessSessionContent, verifyImage);
return CreateLivenessWithVerifySessionWithVerifyImage(createLivenessWithVerifySessionContent, cancellationToken);
CreateLivenessWithVerifySessionMultipartContent multipartContent = new CreateLivenessWithVerifySessionMultipartContent(jsonContent, verifyImage);
return CreateLivenessWithVerifySessionWithVerifyImage(multipartContent, cancellationToken);
}
}
}
79 changes: 79 additions & 0 deletions sdk/face/Azure.AI.Vision.Face/src/Custom/LargeFaceListClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using Azure.Core;
using Azure.Core.Pipeline;

namespace Azure.AI.Vision.Face
{
// Data plane generated sub-client.
/// <summary> The LargeFaceList sub-client. </summary>
[CodeGenClient("LargeFaceListClientImpl")]
public partial class LargeFaceListClient
{
/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LargeFaceListClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AzureAIVisionFaceClientOptions())
{
}

/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LargeFaceListClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureAIVisionFaceClientOptions())
{
}

/// <summary> Initializes a new instance of LargeFaceListClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LargeFaceListClient(Uri endpoint, AzureKeyCredential credential, AzureAIVisionFaceClientOptions options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new AzureAIVisionFaceClientOptions();

ClientDiagnostics = new ClientDiagnostics(options, true);
_keyCredential = credential;
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier());
_endpoint = endpoint;
_apiVersion = options.Version;
}

/// <summary> Initializes a new instance of FaceClient. </summary>
/// <param name="endpoint">
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://{resource-name}.cognitiveservices.azure.com).
/// </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="options"> The options for configuring the client. </param>
/// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="credential"/> is null. </exception>
public LargeFaceListClient(Uri endpoint, TokenCredential credential, AzureAIVisionFaceClientOptions options)
{
Argument.AssertNotNull(endpoint, nameof(endpoint));
Argument.AssertNotNull(credential, nameof(credential));
options ??= new AzureAIVisionFaceClientOptions();

ClientDiagnostics = new ClientDiagnostics(options, true);
_tokenCredential = credential;
_pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier());
_endpoint = endpoint;
_apiVersion = options.Version;
}
}
}
Loading