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

[containerregistry] Update containerregistry projects to use snippets extraction #32679

Merged
merged 16 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 14 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
33 changes: 21 additions & 12 deletions sdk/containerregistry/arm-containerregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,28 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica

For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).

```javascript
const { ContainerRegistryManagementClient } = require("@azure/arm-containerregistry");
const { DefaultAzureCredential } = require("@azure/identity");
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client.

```ts snippet:ReadmeSampleCreateClient_Node
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerRegistryManagementClient(new DefaultAzureCredential(), subscriptionId);
```

For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate.

// For client-side applications running in the browser, use this code instead:
// const credential = new InteractiveBrowserCredential({
// tenantId: "<YOUR_TENANT_ID>",
// clientId: "<YOUR_CLIENT_ID>"
// });
// const client = new ContainerRegistryManagementClient(credential, subscriptionId);
```ts snippet:ReadmeSampleCreateClient_Browser
import { InteractiveBrowserCredential } from "@azure/identity";
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
tenantId: "<YOUR_TENANT_ID>",
clientId: "<YOUR_CLIENT_ID>",
});
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
```

### JavaScript Bundle
Expand All @@ -78,8 +86,9 @@ To use this client library in the browser, first you need to use a bundler. For

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
const { setLogLevel } = require("@azure/logger");
```ts snippet:SetLogLevel
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
```

Expand Down
2 changes: 1 addition & 1 deletion sdk/containerregistry/arm-containerregistry/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
"release_tool": "@azure-tools/[email protected]",
"use": "@autorest/[email protected]"
}
}
25 changes: 12 additions & 13 deletions sdk/containerregistry/arm-containerregistry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
"node": ">=18.0.0"
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-auth": "^1.3.0",
"@azure/core-client": "^1.7.0",
"@azure/abort-controller": "^2.1.2",
"@azure/core-auth": "^1.9.0",
"@azure/core-client": "^1.9.2",
"@azure/core-lro": "^2.5.4",
"@azure/core-paging": "^1.2.0",
"@azure/core-rest-pipeline": "^1.12.0",
"tslib": "^2.2.0"
"@azure/core-paging": "^1.6.2",
"@azure/core-rest-pipeline": "^1.18.2",
"tslib": "^2.8.1"
},
"keywords": [
"node",
"azure",
"typescript",
"browser",
"isomorphic"
"isomorphic",
"cloud"
],
"license": "MIT",
"main": "./dist/commonjs/index.js",
Expand All @@ -32,7 +33,8 @@
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/identity": "^4.0.1",
"@azure/identity": "^4.6.0",
"@azure/logger": "^1.1.4",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
Expand All @@ -41,10 +43,7 @@
"typescript": "~5.7.2",
"vitest": "^3.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
},
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
Expand Down Expand Up @@ -79,7 +78,7 @@
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "echo skipped",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
"update-snippets": "dev-tool run update-snippets"
},
"sideEffects": false,
"//metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
AgentPool} from "@azure/arm-containerregistry";
mpodwysocki marked this conversation as resolved.
Show resolved Hide resolved
import {
AgentPool,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -51,7 +52,7 @@ async function agentPoolsCreate(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsCreate();
await agentPoolsCreate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function agentPoolsDelete(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsDelete();
await agentPoolsDelete();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function agentPoolsGetQueueStatus(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsGetQueueStatus();
await agentPoolsGetQueueStatus();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function agentPoolsGet(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsGet();
await agentPoolsGet();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function agentPoolsList(): Promise<void> {
subscriptionId
);
const resArray = new Array();
for await (let item of client.agentPools.list(
for await (const item of client.agentPools.list(
resourceGroupName,
registryName
)) {
Expand All @@ -41,7 +41,7 @@ async function agentPoolsList(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsList();
await agentPoolsList();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
AgentPoolUpdateParameters} from "@azure/arm-containerregistry";
import {
AgentPoolUpdateParameters,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -45,7 +46,7 @@ async function agentPoolsUpdate(): Promise<void> {
}

async function main(): Promise<void> {
agentPoolsUpdate();
await agentPoolsUpdate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function archiveVersionCreate(): Promise<void> {
}

async function main(): Promise<void> {
archiveVersionCreate();
await archiveVersionCreate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function archiveVersionDelete(): Promise<void> {
}

async function main(): Promise<void> {
archiveVersionDelete();
await archiveVersionDelete();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function archiveVersionGet(): Promise<void> {
}

async function main(): Promise<void> {
archiveVersionGet();
await archiveVersionGet();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function archiveVersionList(): Promise<void> {
subscriptionId
);
const resArray = new Array();
for await (let item of client.archiveVersions.list(
for await (const item of client.archiveVersions.list(
resourceGroupName,
registryName,
packageType,
Expand All @@ -45,7 +45,7 @@ async function archiveVersionList(): Promise<void> {
}

async function main(): Promise<void> {
archiveVersionList();
await archiveVersionList();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
Archive} from "@azure/arm-containerregistry";
import {
Archive,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -51,7 +52,7 @@ async function archiveCreate(): Promise<void> {
}

async function main(): Promise<void> {
archiveCreate();
await archiveCreate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function archiveDelete(): Promise<void> {
}

async function main(): Promise<void> {
archiveDelete();
await archiveDelete();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function archiveGet(): Promise<void> {
}

async function main(): Promise<void> {
archiveGet();
await archiveGet();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function archiveList(): Promise<void> {
subscriptionId
);
const resArray = new Array();
for await (let item of client.archives.list(
for await (const item of client.archives.list(
resourceGroupName,
registryName,
packageType
Expand All @@ -43,7 +43,7 @@ async function archiveList(): Promise<void> {
}

async function main(): Promise<void> {
archiveList();
await archiveList();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
ArchiveUpdateParameters} from "@azure/arm-containerregistry";
import {
ArchiveUpdateParameters,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -49,7 +50,7 @@ async function archiveUpdate(): Promise<void> {
}

async function main(): Promise<void> {
archiveUpdate();
await archiveUpdate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
CacheRule} from "@azure/arm-containerregistry";
import {
CacheRule,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -50,7 +51,7 @@ async function cacheRuleCreate(): Promise<void> {
}

async function main(): Promise<void> {
cacheRuleCreate();
await cacheRuleCreate();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function cacheRuleDelete(): Promise<void> {
}

async function main(): Promise<void> {
cacheRuleDelete();
await cacheRuleDelete();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function cacheRuleGet(): Promise<void> {
}

async function main(): Promise<void> {
cacheRuleGet();
await cacheRuleGet();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function cacheRuleList(): Promise<void> {
subscriptionId
);
const resArray = new Array();
for await (let item of client.cacheRules.list(
for await (const item of client.cacheRules.list(
resourceGroupName,
registryName
)) {
Expand All @@ -41,7 +41,7 @@ async function cacheRuleList(): Promise<void> {
}

async function main(): Promise<void> {
cacheRuleList();
await cacheRuleList();
}

main().catch(console.error);
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import type {
CacheRuleUpdateParameters} from "@azure/arm-containerregistry";
import {
CacheRuleUpdateParameters,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
Expand Down Expand Up @@ -48,7 +49,7 @@ async function cacheRuleUpdate(): Promise<void> {
}

async function main(): Promise<void> {
cacheRuleUpdate();
await cacheRuleUpdate();
}

main().catch(console.error);
Loading
Loading