-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[purview] Migrate purview REST projects to use snippets extraction (#…
…33174) ### Packages impacted by this PR - @azure-rest/purview-administration - @azure-rest/purview-catalog - @azure-rest/purview-datamap - @azure-rest/purview-scanning - @azure-rest/purview-sharing - @azure-rest/purview-workflow ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Updates all REST projects under `purview` to use snippets extraction. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
- Loading branch information
1 parent
a702a44
commit 7c81323
Showing
56 changed files
with
817 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
sdk/purview/purview-administration-rest/test/snippets.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { PurviewAccount, PurviewMetadataPolicies } from "../src/index.js"; | ||
import { DefaultAzureCredential } from "@azure/identity"; | ||
import { setLogLevel } from "@azure/logger"; | ||
import { describe, it } from "vitest"; | ||
|
||
describe("snippets", () => { | ||
it("ReadmeSampleCreateClient_Node", async () => { | ||
const accountClient = PurviewAccount.createClient( | ||
"https://<my-account-name>.purview.azure.com", | ||
new DefaultAzureCredential(), | ||
); | ||
// @ts-preserve-whitespace | ||
const metadataClient = PurviewMetadataPolicies.createClient( | ||
"https://<my-account-name>.purview.azure.com", | ||
new DefaultAzureCredential(), | ||
); | ||
}); | ||
|
||
it("ReadmeSampleGetCollections", async () => { | ||
const accountClient = PurviewAccount.createClient( | ||
"https://<my-account-name>.purview.azure.com", | ||
new DefaultAzureCredential(), | ||
); | ||
// @ts-preserve-whitespace | ||
const response = await accountClient.path("/collections").get(); | ||
// @ts-preserve-whitespace | ||
if (PurviewAccount.UnexpectedHelper.isUnexpected(response)) { | ||
throw response.body.error; | ||
} | ||
// @ts-preserve-whitespace | ||
const paginated = PurviewAccount.PaginateHelper.paginate(accountClient, response); | ||
for await (const collection of paginated) { | ||
console.log( | ||
`Collection name: ${collection.name}\tCollection description: ${collection.description}`, | ||
); | ||
} | ||
}); | ||
|
||
it("ReadmeSampleGetMetadataPolicies", async () => { | ||
const metadataClient = PurviewMetadataPolicies.createClient( | ||
"https://<my-account-name>.purview.azure.com", | ||
new DefaultAzureCredential(), | ||
); | ||
// @ts-preserve-whitespace | ||
const response = await metadataClient.path("/metadataPolicies").get(); | ||
// @ts-preserve-whitespace | ||
if (PurviewMetadataPolicies.UnexpectedHelper.isUnexpected(response)) { | ||
throw response.body.error; | ||
} | ||
// @ts-preserve-whitespace | ||
const policies = PurviewMetadataPolicies.PaginateHelper.paginate(metadataClient, response); | ||
// @ts-preserve-whitespace | ||
for await (const policy of policies) { | ||
if (Array.isArray(policy)) { | ||
console.error("Unexpected array:", policy); | ||
} else { | ||
console.log(`Policy name: ${policy.name}`); | ||
} | ||
} | ||
}); | ||
|
||
it("SetLogLevel", async () => { | ||
setLogLevel("info"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
{ | ||
"references": [ | ||
{ "path": "./tsconfig.src.json" }, | ||
{ "path": "./tsconfig.samples.json" }, | ||
{ "path": "./tsconfig.test.json" } | ||
{ | ||
"path": "./tsconfig.src.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.samples.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.test.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.