Skip to content

Commit

Permalink
[containerregistry] Update containerregistry projects to use snippets…
Browse files Browse the repository at this point in the history
… extraction (#32679)

### Packages impacted by this PR

- @azure/arm-containerregistry
- @azure/container-registry

### Issues associated with this PR

- #32416

### Describe the problem that is addressed by this PR

Updates all projects under `containerregistry` 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
mpodwysocki authored Jan 24, 2025
1 parent c3eed84 commit d4b35cd
Show file tree
Hide file tree
Showing 225 changed files with 1,843 additions and 2,690 deletions.
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 @@ -6,12 +6,8 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
AgentPool,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import type { AgentPool } from "@azure/arm-containerregistry";
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";

Expand All @@ -23,29 +19,24 @@ import "dotenv/config";
*/
async function agentPoolsCreate(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const agentPoolName = "myAgentPool";
const agentPool: AgentPool = {
count: 1,
location: "WESTUS",
os: "Linux",
tags: { key: "value" },
tier: "S1"
tier: "S1",
};
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.agentPools.beginCreateAndWait(
resourceGroupName,
registryName,
agentPoolName,
agentPool
agentPool,
);
console.log(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
Expand All @@ -20,21 +18,16 @@ import "dotenv/config";
*/
async function agentPoolsDelete(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const agentPoolName = "myAgentPool";
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.agentPools.beginDeleteAndWait(
resourceGroupName,
registryName,
agentPoolName
agentPoolName,
);
console.log(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
Expand All @@ -20,21 +18,16 @@ import "dotenv/config";
*/
async function agentPoolsGetQueueStatus(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const agentPoolName = "myAgentPool";
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.agentPools.getQueueStatus(
resourceGroupName,
registryName,
agentPoolName
agentPoolName,
);
console.log(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
Expand All @@ -20,22 +18,13 @@ import "dotenv/config";
*/
async function agentPoolsGet(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const agentPoolName = "myAgentPool";
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const result = await client.agentPools.get(
resourceGroupName,
registryName,
agentPoolName
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.agentPools.get(resourceGroupName, registryName, agentPoolName);
console.log(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
Expand All @@ -20,21 +18,13 @@ import "dotenv/config";
*/
async function agentPoolsList(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.agentPools.list(
resourceGroupName,
registryName
)) {
for await (const item of client.agentPools.list(resourceGroupName, registryName)) {
resArray.push(item);
}
console.log(resArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
AgentPoolUpdateParameters,
ContainerRegistryManagementClient
} from "@azure/arm-containerregistry";
import type { AgentPoolUpdateParameters } from "@azure/arm-containerregistry";
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";

Expand All @@ -23,23 +19,18 @@ import "dotenv/config";
*/
async function agentPoolsUpdate(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "4385cf00-2d3a-425a-832f-f4285b1c9dce";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const agentPoolName = "myAgentPool";
const updateParameters: AgentPoolUpdateParameters = { count: 1 };
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.agentPools.beginUpdateAndWait(
resourceGroupName,
registryName,
agentPoolName,
updateParameters
updateParameters,
);
console.log(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { ContainerRegistryManagementClient } from "@azure/arm-containerregistry";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
Expand All @@ -20,25 +18,20 @@ import "dotenv/config";
*/
async function archiveVersionCreate(): Promise<void> {
const subscriptionId =
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
const resourceGroupName =
process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
process.env["CONTAINERREGISTRY_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000";
const resourceGroupName = process.env["CONTAINERREGISTRY_RESOURCE_GROUP"] || "myResourceGroup";
const registryName = "myRegistry";
const packageType = "rpm";
const archiveName = "myArchiveName";
const archiveVersionName = "myArchiveVersionName";
const credential = new DefaultAzureCredential();
const client = new ContainerRegistryManagementClient(
credential,
subscriptionId
);
const client = new ContainerRegistryManagementClient(credential, subscriptionId);
const result = await client.archiveVersions.beginCreateAndWait(
resourceGroupName,
registryName,
packageType,
archiveName,
archiveVersionName
archiveVersionName,
);
console.log(result);
}
Expand Down
Loading

0 comments on commit d4b35cd

Please sign in to comment.