mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
Overhauls tests and samples for Azure Cognitive Services for Language SDKs by implementing safe secret standards: - Updates `test-resources.bicep` to not output API keys nor SAS tokens - Updates the tests to retrieve API keys using the arm client - Updates the tests to create SAS tokens for Storage container access - Updates the samples and snippets to use Entra ID authentication - Fix live tests by enabling SAS access to the persistent storage account Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4694655&view=results
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample shows how to get the details of a custom classifier by its ID, including information about the document
|
|
* types that the classifier supports.
|
|
*
|
|
* @summary get information about a classifier by its ID
|
|
*/
|
|
|
|
const DocumentIntelligence = require("@azure-rest/ai-document-intelligence").default,
|
|
{ isUnexpected } = require("@azure-rest/ai-document-intelligence");
|
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
require("dotenv/config");
|
|
|
|
async function main() {
|
|
const client = DocumentIntelligence(
|
|
process.env["DOCUMENT_INTELLIGENCE_ENDPOINT"] || "<cognitive services endpoint>",
|
|
new DefaultAzureCredential(),
|
|
);
|
|
|
|
const classifierId = process.env.CUSTOM_CLASSIFIER_ID ?? "<classifier id>";
|
|
const classifier = await client.path("/documentClassifiers/{classifierId}", classifierId).get();
|
|
|
|
if (isUnexpected(classifier)) {
|
|
throw classifier.body.error;
|
|
}
|
|
console.log("ID", classifier.body.classifierId);
|
|
console.log("Created:", classifier.body.createdDateTime);
|
|
console.log("Description: ", classifier.body.description || "<none>");
|
|
|
|
console.log("Document Types:");
|
|
for (const [docType, details] of Object.entries(classifier.body.docTypes || {})) {
|
|
// We can also programmatically access a schema of the fields.
|
|
console.log(`- Name "${docType}", source: ${JSON.stringify(details, null, 2)}`);
|
|
}
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("An error occurred:", error);
|
|
process.exit(1);
|
|
});
|