Skip to content

Commit

Permalink
CodeGen from PR 13030 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 3174e25489fbb9c3b38ab0cbb02b40fde7031118 into 4a02e7a998f4ec8aa6d8700545b93ad8830b3c2d
  • Loading branch information
SDKAuto committed Feb 18, 2021
1 parent de864dd commit 1d3c10e
Show file tree
Hide file tree
Showing 25 changed files with 268 additions and 455 deletions.
2 changes: 1 addition & 1 deletion sdk/cognitiveservices/cognitiveservices-face/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 Microsoft
Copyright (c) 2021 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
105 changes: 50 additions & 55 deletions sdk/cognitiveservices/cognitiveservices-face/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,86 +15,81 @@ npm install @azure/cognitiveservices-face

### How to use

#### nodejs - Authentication, client creation and list personGroupPerson as an example written in TypeScript.
#### nodejs - client creation and list personGroupPerson as an example written in TypeScript.

##### Install @azure/ms-rest-azure-js
##### Install @azure/ms-rest-nodeauth

- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
```bash
npm install @azure/ms-rest-azure-js
npm install @azure/ms-rest-nodeauth@"^3.0.0"
```

##### Sample code
The following sample detects the facial features on the given image. To know more, refer to the [Azure Documentation on Face APIs](https://docs.microsoft.com/azure/cognitive-services/face/overview)

```javascript
const { FaceClient, FaceModels } = require("@azure/cognitiveservices-face");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const faceKey = process.env["faceKey"] || "<faceKey>";
const faceEndPoint = process.env["faceEndPoint"] || "<faceEndPoint>";
const cognitiveServiceCredentials = new CognitiveServicesCredentials(faceKey);
const client = new FaceClient(cognitiveServiceCredentials, faceEndPoint);
const url =
"https://pbs.twimg.com/profile_images/3354326900/3a5168f2b45c07d0965098be1a4e3007.jpeg";
const options = {
returnFaceLandmarks: true
};
client.face
.detectWithUrl(url, options)
.then(result => {
console.log("The result is: ");
console.log(result);
})
.catch(err => {
console.log("An error occurred:");
console.error(err);
});
}

main();

While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package
```typescript
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const { FaceClient } = require("@azure/cognitiveservices-face");
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new FaceClient(creds, subscriptionId);
const personGroupId = "testpersonGroupId";
const start = "teststart";
const top = 1;
client.personGroupPerson.list(personGroupId, start, top).then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
```

#### browser - Authentication, client creation and list personGroupPerson as an example written in JavaScript.

##### Install @azure/ms-rest-browserauth

```bash
npm install @azure/ms-rest-browserauth
```

##### Sample code

See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

- index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>@azure/cognitiveservices-face sample</title>
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
<script src="node_modules/@azure/cognitiveservices-face/dist/cognitiveservices-face.js"></script>
<script type="text/javascript">
const faceKey = "<YOUR_FACE_KEY>";
const faceEndPoint = "<YOUR_FACE_ENDPOINT>";
const cognitiveServiceCredentials = new msRest.ApiKeyCredentials({
inHeader: {
"Ocp-Apim-Subscription-Key": faceKey
}
const subscriptionId = "<Subscription_Id>";
const authManager = new msAuth.AuthManager({
clientId: "<client id for your Azure AD app>",
tenant: "<optional tenant for your organization>"
});
const client = new Azure.CognitiveservicesFace.FaceClient(
cognitiveServiceCredentials,
faceEndPoint
);
const url =
"https://pbs.twimg.com/profile_images/3354326900/3a5168f2b45c07d0965098be1a4e3007.jpeg";
const options = {
returnFaceLandmarks: true
};
client.face
.detectWithUrl(url, options)
.then(result => {
console.log("The result is: ");
authManager.finalizeLogin().then((res) => {
if (!res.isLoggedIn) {
// may cause redirects
authManager.login();
}
const client = new Azure.CognitiveservicesFace.FaceClient(res.creds, subscriptionId);
const personGroupId = "testpersonGroupId";
const start = "teststart";
const top = 1;
client.personGroupPerson.list(personGroupId, start, top).then((result) => {
console.log("The result is:");
console.log(result);
})
.catch(err => {
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
<body></body>
Expand All @@ -105,4 +100,4 @@ main();

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-face%2FREADME.png)
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-face/README.png)
4 changes: 2 additions & 2 deletions sdk/cognitiveservices/cognitiveservices-face/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const config = {
"@azure/ms-rest-azure-js": "msRestAzure"
},
banner: `/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
56 changes: 35 additions & 21 deletions sdk/cognitiveservices/cognitiveservices-face/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down Expand Up @@ -334,7 +334,8 @@ export interface DetectedFace {
export interface FindSimilarRequest {
/**
* FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note
* that this faceId is not persisted and will expire 24 hours after the detection call
* that this faceId is not persisted and will expire at the time specified by faceIdTimeToLive
* after the detection call
*/
faceId: string;
/**
Expand All @@ -352,8 +353,9 @@ export interface FindSimilarRequest {
largeFaceListId?: string;
/**
* An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will
* expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter
* faceListId, largeFaceListId and faceIds should not be provided at the same time.
* expire at the time specified by faceIdTimeToLive after the detection call. The number of
* faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be
* provided at the same time.
*/
faceIds?: string[];
/**
Expand All @@ -373,7 +375,7 @@ export interface FindSimilarRequest {
export interface SimilarFace {
/**
* FaceId of candidate face when find by faceIds. faceId is created by Face - Detect and will
* expire 24 hours after the detection call
* expire at the time specified by faceIdTimeToLive after the detection call
*/
faceId?: string;
/**
Expand Down Expand Up @@ -539,7 +541,8 @@ export interface VerifyResult {
export interface PersistedFace {
/**
* The persistedFaceId of the target face, which is persisted and will not expire. Different from
* faceId created by Face - Detect and will expire in 24 hours after the detection call.
* faceId created by Face - Detect and will expire in at the time specified by faceIdTimeToLive
* after the detection call.
*/
persistedFaceId: string;
/**
Expand Down Expand Up @@ -850,8 +853,9 @@ export interface FaceFindSimilarOptionalParams extends msRest.RequestOptionsBase
largeFaceListId?: string;
/**
* An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will
* expire 24 hours after the detection call. The number of faceIds is limited to 1000. Parameter
* faceListId, largeFaceListId and faceIds should not be provided at the same time.
* expire at the time specified by faceIdTimeToLive after the detection call. The number of
* faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be
* provided at the same time.
*/
faceIds?: string[];
/**
Expand Down Expand Up @@ -930,9 +934,14 @@ export interface FaceDetectWithUrlOptionalParams extends msRest.RequestOptionsBa
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
/**
* The number of seconds for the faceId being cached. Supported range from 60 seconds up to 86400
* seconds. The default value is 86400 (24 hours). Default value: 86400.
*/
faceIdTimeToLive?: number;
}

/**
Expand Down Expand Up @@ -993,9 +1002,14 @@ export interface FaceDetectWithStreamOptionalParams extends msRest.RequestOption
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
/**
* The number of seconds for the faceId being cached. Supported range from 60 seconds up to 86400
* seconds. The default value is 86400 (24 hours). Default value: 86400.
*/
faceIdTimeToLive?: number;
}

/**
Expand Down Expand Up @@ -1070,7 +1084,7 @@ export interface PersonGroupPersonAddFaceFromUrlOptionalParams extends msRest.Re
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand All @@ -1095,7 +1109,7 @@ export interface PersonGroupPersonAddFaceFromStreamOptionalParams extends msRest
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand Down Expand Up @@ -1238,7 +1252,7 @@ export interface FaceListAddFaceFromUrlOptionalParams extends msRest.RequestOpti
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand All @@ -1263,7 +1277,7 @@ export interface FaceListAddFaceFromStreamOptionalParams extends msRest.RequestO
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand Down Expand Up @@ -1340,7 +1354,7 @@ export interface LargePersonGroupPersonAddFaceFromUrlOptionalParams extends msRe
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand All @@ -1365,7 +1379,7 @@ export interface LargePersonGroupPersonAddFaceFromStreamOptionalParams extends m
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand Down Expand Up @@ -1518,7 +1532,7 @@ export interface LargeFaceListAddFaceFromUrlOptionalParams extends msRest.Reques
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand Down Expand Up @@ -1557,7 +1571,7 @@ export interface LargeFaceListAddFaceFromStreamOptionalParams extends msRest.Req
* detection model name can be provided when performing Face - Detect or (Large)FaceList - Add
* Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model
* is needed, please explicitly specify it. Possible values include: 'detection_01',
* 'detection_02'. Default value: 'detection_01'.
* 'detection_02', 'detection_03'. Default value: 'detection_01'.
*/
detectionModel?: DetectionModel;
}
Expand Down Expand Up @@ -1756,11 +1770,11 @@ export type FaceAttributeType = 'age' | 'gender' | 'headPose' | 'smile' | 'facia

/**
* Defines values for DetectionModel.
* Possible values include: 'detection_01', 'detection_02'
* Possible values include: 'detection_01', 'detection_02', 'detection_03'
* @readonly
* @enum {string}
*/
export type DetectionModel = 'detection_01' | 'detection_02';
export type DetectionModel = 'detection_01' | 'detection_02' | 'detection_03';

/**
* Contains response data for the findSimilar operation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
Expand Down
Loading

0 comments on commit 1d3c10e

Please sign in to comment.