azure-sdk-for-js/sdk/purview/purview-administration-rest
Jeremy Meng 3a68e456b2 [Samples] update "src/**.ts" to "src/**/*.ts" in tsconfig.json
Previously dev-tool has been fixed to generate correct include path in samples
tsconfig.json but samples were not updated.

This PR fixes the samples tsconfig.json in one run; otherwise with the recent
branch protection policy changes, when individual packages re-publish samples,
js-core team would have to approve the tsconfig.json changes.

***NO_CI***
2024-07-24 13:53:00 +00:00
..
review [Rest Client] Purview administration (#17875) 2021-09-30 10:40:47 -05:00
samples/v1 [Samples] update "src/**.ts" to "src/**/*.ts" in tsconfig.json 2024-07-24 13:53:00 +00:00
samples-dev [Rest Client] Purview administration (#17875) 2021-09-30 10:40:47 -05:00
src [EngSys] upgrade to prettier v3 2024-01-10 18:45:01 -05:00
swagger Post release automated changes for purview releases (#18215) 2021-10-18 12:40:56 -07:00
test/public [EngSys] upgrade to prettier v3 2024-01-10 18:45:01 -05:00
.eslintrc.json [EngSys] Enable Rush build cache for for common packages (#27409) 2023-10-19 14:22:44 -07:00
CHANGELOG.md Post release automated changes for purview releases (#18215) 2021-10-18 12:40:56 -07:00
LICENSE [Rest Client] Purview administration (#17875) 2021-09-30 10:40:47 -05:00
README.md Increment minimum supported node version to 16 2023-10-09 21:09:54 +00:00
api-extractor.json [Rest Client] Purview administration (#17875) 2021-09-30 10:40:47 -05:00
assets.json rlc migrate (#26453) 2023-07-12 12:59:56 +08:00
karma.conf.js [engsys] remove karma ie and edge launcher 2023-03-06 17:08:15 -05:00
package.json [EngSys] upgrade dev dependency `typescript` version to `~5.5.3` 2024-07-03 22:24:35 +00:00
sample.env [Rest Client] Purview administration (#17875) 2021-09-30 10:40:47 -05:00
tsconfig.json [EngSys] remove tsconfig.package.json 2024-07-16 13:27:25 +00:00

README.md

Azure Purview Administration REST client library for JavaScript

Azure Purview data plane administration. It supports data plane operations. It can manage account, collections, keys, resource set rule, metadata policy, metadata roles.

Azure Purview Metadata Policies

Please rely heavily on the service's documentation and our REST client docs to use this library

Key links:

Getting started

Currently supported environments

Prerequisites

Create a Purview Resource

Follow these instructions to create your Purview resource

Install the @azure-rest/purview-administration package

Install the Azure Purview Administration client library for JavaScript with npm:

npm install @azure-rest/purview-administration

Create and authenticate a PurviewAccount

To use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the @azure/identity library.

To authenticate with AAD, you must first npm install @azure/identity and enable AAD authentication on your Purview resource

After setup, you can choose which type of credential from @azure/identity to use. As an example, DefaultAzureCredential can be used to authenticate the client:

Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

Use the returned token credential to authenticate the client:

import {
  PurviewAccountClient,
  PurviewMetadataPoliciesClient,
} from "@azure-rest/purview-administration";
import { DefaultAzureCredential } from "@azure/identity";
const accountClient = PurviewAccountClient(
  "https://<my-account-name>.purview.azure.com",
  new DefaultAzureCredential()
);

const metadataClient = PurviewAccountClient(
  "https://<my-account-name>.purview.azure.com",
  new DefaultAzureCredential()
);

Key concepts

REST Client

This client is one of our REST clients. We highly recommend you read how to use a REST client here.

Examples

The following section shows you how to initialize and authenticate your client, then get all of your type-defs.

import { PurviewAccountClient } from "@azure-rest/purview-administration";
import { DefaultAzureCredential } from "@azure/identity";
import dotenv from "dotenv";

dotenv.config();

const endpoint = process.env["ENDPOINT"] || "";

async function main() {
  console.log("== List collections sample ==");
  const client = PurviewAccountClient(endpoint, new DefaultAzureCredential());

  const response = await client.path("/collections").get();

  if (response.status !== "200") {
    console.log(`GET "/collections" failed with ${response.status}`);
  }

  console.log(response.body);
}

main().catch(console.error);

Troubleshooting

Logging

Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.

Next steps

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

Impressions