Skip to content

Commit

Permalink
[Rest Client] Purview administration (#17875)
Browse files Browse the repository at this point in the history
* Initial POC for multi client rest package

* Rush and lock

* Format and lint

* Update CI

* Use modules

* Update lock

* update links

* Address PR comments

* Remove locale from links

* Update recordings

* Update changelog and recordings

* Update lint rules

* FIx format
  • Loading branch information
joheredi authored Sep 30, 2021
1 parent 9dc6167 commit e219c0a
Show file tree
Hide file tree
Showing 55 changed files with 4,375 additions and 1 deletion.
48 changes: 48 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@
"projectFolder": "sdk/purview/purview-account-rest",
"versionPolicyName": "client"
},
{
"packageName": "@azure-rest/purview-administration",
"projectFolder": "sdk/purview/purview-administration-rest",
"versionPolicyName": "client"
},
{
"packageName": "@azure-rest/purview-catalog",
"projectFolder": "sdk/purview/purview-catalog-rest",
Expand Down Expand Up @@ -952,4 +957,4 @@
"versionPolicyName": "management"
}
]
}
}
2 changes: 2 additions & 0 deletions sdk/purview/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ extends:
safeName: azurerestpurviewscanning
- name: azure-rest-purview-account
safeName: azurerestpurviewaccount
- name: azure-rest-purview-administration
safeName: azurerestpurviewadministration
- name: azure-arm-purview
safeName: azurearmpurview
10 changes: 10 additions & 0 deletions sdk/purview/purview-administration-rest/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"@azure/azure-sdk/ts-package-json-engine-is-present": [
"error",
{ "nodeVersionOverride": ">=14.0.0" }
]
}
}
5 changes: 5 additions & 0 deletions sdk/purview/purview-administration-rest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0-beta.1 (UNRELEASED)

- First release of package, see README.md for details.
21 changes: 21 additions & 0 deletions sdk/purview/purview-administration-rest/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
147 changes: 147 additions & 0 deletions sdk/purview/purview-administration-rest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# 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][account_product_documentation] and our [REST client docs][rest_client] to use this library**

Key links:

- [Source code][source_code]
- [Package (NPM)][account_npm]
- [API reference documentation][account_ref_docs]
- [Product documentation][account_product_documentation]

## Getting started

### Currently supported environments

- Node.js version 14.x.x or higher

### Prerequisites

- You must have an [Azure subscription][azure_subscription] and a [Purview][purview_resource] to use this package.

#### Create a Purview Resource

Follow [these][purview_resource] instructions to create your Purview resource

### Install the `@azure-rest/purview-account` package

Install the Azure Purview Account client library for JavaScript with `npm`:

```bash
npm install @azure-rest/purview-account
```

### Create and authenticate a `PurviewAccount`

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

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

After setup, you can choose which type of [credential][azure_identity_credentials] from `@azure/identity` to use.
As an example, [DefaultAzureCredential][default_azure_credential]
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:

```typescript
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][rest_client].

## Examples

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

- [Get A List of Collections](#get-a-list-of-collections "Get A List of Collections")

```typescript
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`:

```javascript
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](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).

## Next steps

## Contributing

If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.

## Related projects

- [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%2Fpurview%2Fpurview-account-rest%2FREADME.png)

[account_product_documentation]: https://azure.microsoft.com/services/purview/
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/purview/purview-catalog-rest
[account_npm]: https://www.npmjs.com/org/azure-rest
[account_ref_docs]: https://azure.github.io/azure-sdk-for-js
[azure_subscription]: https://azure.microsoft.com/free/
[purview_resource]: https://docs.microsoft.com/azure/purview/create-catalog-portal
[authenticate_with_token]: https://docs.microsoft.com/azure/purview/tutorial-using-rest-apis#create-a-service-principal-application
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials
[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity
[enable_aad]: https://docs.microsoft.com/azure/purview/create-catalog-portal#add-a-security-principal-to-a-data-plane-role
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
31 changes: 31 additions & 0 deletions sdk/purview/purview-administration-rest/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/purview-administration-rest.d.ts"
},
"messages": {
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "none"
}
}
}
}
Loading

0 comments on commit e219c0a

Please sign in to comment.