Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update purview scanning samples #18154

Merged
merged 6 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sdk/purview/purview-scanning-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,27 @@ The following section shows you how to initialize and authenticate your client,
### List All Data Sources

```typescript
import PurviewScanning from "@azure-rest/purview-scanning";
import PurviewScanning, { paginate } from "@azure-rest/purview-scanning";
import { DefaultAzureCredential } from "@azure/identity";

async function main() {
console.log("== List dataSources ==");
const client = PurviewScanning(
"https://<my-account-name>.purview.azure.com",
"https://<my-account-name>.scan.purview.azure.com",
new DefaultAzureCredential()
);

const dataSources = await client.path("/datasources").get();

const iter = paginate(client, dataSources)
if (dataSources.status !== "200") {
throw dataSources.body.error;
}
const items: any[] = [];

console.log(dataSources.body.value?.map((ds) => ds.name).join("\n"));
for await (const item of iter) {
items.push(item);
}
console.log(items?.map((ds) => ds.name).join("\n"));
}

main().catch(console.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @azsdk-weight 40
*/

import PurviewScanning from "@azure-rest/purview-scanning";
import PurviewScanning, { paginate } from "@azure-rest/purview-scanning";
import { DefaultAzureCredential } from "@azure/identity";
import dotenv from "dotenv";

Expand All @@ -17,16 +17,21 @@ dotenv.config();
const endpoint = process.env["ENDPOINT"] || "";

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

const dataSources = await client.path("/datasources").get();

const iter = paginate(client, dataSources);
if (dataSources.status !== "200") {
throw dataSources.body.error;
throw dataSources;
}
const items: any[] = [];

console.log(dataSources.body.value?.map((ds) => ds.name).join("\n"));
for await (const item of iter) {
// console.log(item);
items.push(item);
}
console.log(items?.map((ds) => ds?.name).join("\n"));
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @summary gets a list of datasources
*/

const PurviewScanning = require("@azure-rest/purview-scanning");
const PurviewScanning, { paginate } = require("@azure-rest/purview-scanning");
const { DefaultAzureCredential } = require("@azure/identity");
const dotenv = require("dotenv");

Expand All @@ -21,11 +21,17 @@ async function main() {

const dataSources = await client.path("/datasources").get();

const iter = paginate(client, dataSources)
if (dataSources.status !== "200") {
throw dataSources.body.error;
throw dataSources;
}
const items = [];

console.log(dataSources.body.value?.map((ds) => ds.name).join("\n"));
for await (const item of iter) {
// console.log(item);
items.push(item);
}
console.log(items?.map((ds) => ds?.name).join("\n"));
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@
* @summary gets a list of datasources
*/

import PurviewScanning from "@azure-rest/purview-scanning";
import PurviewScanning, { paginate } from "@azure-rest/purview-scanning";
import { DefaultAzureCredential } from "@azure/identity";
import dotenv from "dotenv";

dotenv.config();

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

async function main() {
console.log("== List dataSources sample ==");
const client = PurviewScanning(endpoint, new DefaultAzureCredential());
console.log("== List dataSources ==");
const client = PurviewScanning(
"https://<purview-account-name>.scan.purview.azure.com",
new DefaultAzureCredential()
);

const dataSources = await client.path("/datasources").get();

const iter = paginate(client, dataSources)
if (dataSources.status !== "200") {
throw dataSources.body.error;
throw dataSources;
}
const items: any[] = [];

console.log(dataSources.body.value?.map((ds) => ds.name).join("\n"));
for await (const item of iter) {
// console.log(item);
items.push(item);
}
console.log(items?.map((ds) => ds.name).join("\n"));
}

main().catch(console.error);