@azure/container-registry 1.1.1-alpha.20250619.1 → 1.1.1-alpha.20250730.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/containerRegistryChallengeHandler.js +6 -3
- package/dist/browser/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/browser/containerRegistryClient.js +42 -50
- package/dist/browser/containerRegistryClient.js.map +1 -1
- package/dist/browser/containerRegistryTokenCredential.js +9 -1
- package/dist/browser/containerRegistryTokenCredential.js.map +1 -1
- package/dist/browser/containerRepository.js +41 -46
- package/dist/browser/containerRepository.js.map +1 -1
- package/dist/browser/content/containerRegistryContentClient.js +34 -32
- package/dist/browser/content/containerRegistryContentClient.js.map +1 -1
- package/dist/browser/generated/generatedClient.js +12 -3
- package/dist/browser/generated/generatedClient.js.map +1 -1
- package/dist/browser/generated/generatedClientContext.js +9 -2
- package/dist/browser/generated/generatedClientContext.js.map +1 -1
- package/dist/browser/generated/models/mappers.js +63 -29
- package/dist/browser/generated/models/mappers.js.map +1 -1
- package/dist/browser/generated/operations/authentication.js +1 -0
- package/dist/browser/generated/operations/authentication.js.map +1 -1
- package/dist/browser/generated/operations/containerRegistry.js +1 -0
- package/dist/browser/generated/operations/containerRegistry.js.map +1 -1
- package/dist/browser/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/browser/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/browser/registryArtifact.js +69 -53
- package/dist/browser/registryArtifact.js.map +1 -1
- package/dist/browser/transformations.js +13 -3
- package/dist/browser/transformations.js.map +1 -1
- package/dist/browser/utils/helpers.js +19 -35
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/retriableReadableStream.js +64 -56
- package/dist/browser/utils/retriableReadableStream.js.map +1 -1
- package/dist/browser/utils/tokenCycler.js +7 -6
- package/dist/browser/utils/tokenCycler.js.map +1 -1
- package/dist/commonjs/containerRegistryChallengeHandler.js +6 -3
- package/dist/commonjs/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/commonjs/containerRegistryClient.js +42 -50
- package/dist/commonjs/containerRegistryClient.js.map +1 -1
- package/dist/commonjs/containerRegistryTokenCredential.js +9 -1
- package/dist/commonjs/containerRegistryTokenCredential.js.map +1 -1
- package/dist/commonjs/containerRepository.js +41 -46
- package/dist/commonjs/containerRepository.js.map +1 -1
- package/dist/commonjs/content/containerRegistryContentClient.js +34 -31
- package/dist/commonjs/content/containerRegistryContentClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClient.js +12 -3
- package/dist/commonjs/generated/generatedClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClientContext.js +9 -2
- package/dist/commonjs/generated/generatedClientContext.js.map +1 -1
- package/dist/commonjs/generated/models/mappers.js +63 -29
- package/dist/commonjs/generated/models/mappers.js.map +1 -1
- package/dist/commonjs/generated/operations/authentication.js +1 -0
- package/dist/commonjs/generated/operations/authentication.js.map +1 -1
- package/dist/commonjs/generated/operations/containerRegistry.js +1 -0
- package/dist/commonjs/generated/operations/containerRegistry.js.map +1 -1
- package/dist/commonjs/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/commonjs/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/commonjs/registryArtifact.js +69 -53
- package/dist/commonjs/registryArtifact.js.map +1 -1
- package/dist/commonjs/transformations.js +13 -3
- package/dist/commonjs/transformations.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utils/helpers.js +19 -35
- package/dist/commonjs/utils/helpers.js.map +1 -1
- package/dist/commonjs/utils/retriableReadableStream.js +64 -56
- package/dist/commonjs/utils/retriableReadableStream.js.map +1 -1
- package/dist/commonjs/utils/tokenCycler.js +7 -6
- package/dist/commonjs/utils/tokenCycler.js.map +1 -1
- package/dist/esm/containerRegistryChallengeHandler.js +6 -3
- package/dist/esm/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/esm/containerRegistryClient.js +42 -50
- package/dist/esm/containerRegistryClient.js.map +1 -1
- package/dist/esm/containerRegistryTokenCredential.js +9 -1
- package/dist/esm/containerRegistryTokenCredential.js.map +1 -1
- package/dist/esm/containerRepository.js +41 -46
- package/dist/esm/containerRepository.js.map +1 -1
- package/dist/esm/content/containerRegistryContentClient.js +34 -32
- package/dist/esm/content/containerRegistryContentClient.js.map +1 -1
- package/dist/esm/generated/generatedClient.js +12 -3
- package/dist/esm/generated/generatedClient.js.map +1 -1
- package/dist/esm/generated/generatedClientContext.js +9 -2
- package/dist/esm/generated/generatedClientContext.js.map +1 -1
- package/dist/esm/generated/models/mappers.js +63 -29
- package/dist/esm/generated/models/mappers.js.map +1 -1
- package/dist/esm/generated/operations/authentication.js +1 -0
- package/dist/esm/generated/operations/authentication.js.map +1 -1
- package/dist/esm/generated/operations/containerRegistry.js +1 -0
- package/dist/esm/generated/operations/containerRegistry.js.map +1 -1
- package/dist/esm/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/esm/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/esm/registryArtifact.js +69 -53
- package/dist/esm/registryArtifact.js.map +1 -1
- package/dist/esm/transformations.js +13 -3
- package/dist/esm/transformations.js.map +1 -1
- package/dist/esm/utils/helpers.js +19 -35
- package/dist/esm/utils/helpers.js.map +1 -1
- package/dist/esm/utils/retriableReadableStream.js +64 -56
- package/dist/esm/utils/retriableReadableStream.js.map +1 -1
- package/dist/esm/utils/tokenCycler.js +7 -6
- package/dist/esm/utils/tokenCycler.js.map +1 -1
- package/dist/react-native/containerRegistryChallengeHandler.js +6 -3
- package/dist/react-native/containerRegistryChallengeHandler.js.map +1 -1
- package/dist/react-native/containerRegistryClient.js +42 -50
- package/dist/react-native/containerRegistryClient.js.map +1 -1
- package/dist/react-native/containerRegistryTokenCredential.js +9 -1
- package/dist/react-native/containerRegistryTokenCredential.js.map +1 -1
- package/dist/react-native/containerRepository.js +41 -46
- package/dist/react-native/containerRepository.js.map +1 -1
- package/dist/react-native/content/containerRegistryContentClient.js +34 -32
- package/dist/react-native/content/containerRegistryContentClient.js.map +1 -1
- package/dist/react-native/generated/generatedClient.js +12 -3
- package/dist/react-native/generated/generatedClient.js.map +1 -1
- package/dist/react-native/generated/generatedClientContext.js +9 -2
- package/dist/react-native/generated/generatedClientContext.js.map +1 -1
- package/dist/react-native/generated/models/mappers.js +63 -29
- package/dist/react-native/generated/models/mappers.js.map +1 -1
- package/dist/react-native/generated/operations/authentication.js +1 -0
- package/dist/react-native/generated/operations/authentication.js.map +1 -1
- package/dist/react-native/generated/operations/containerRegistry.js +1 -0
- package/dist/react-native/generated/operations/containerRegistry.js.map +1 -1
- package/dist/react-native/generated/operations/containerRegistryBlob.js +1 -0
- package/dist/react-native/generated/operations/containerRegistryBlob.js.map +1 -1
- package/dist/react-native/registryArtifact.js +69 -53
- package/dist/react-native/registryArtifact.js.map +1 -1
- package/dist/react-native/transformations.js +13 -3
- package/dist/react-native/transformations.js.map +1 -1
- package/dist/react-native/utils/helpers.js +19 -35
- package/dist/react-native/utils/helpers.js.map +1 -1
- package/dist/react-native/utils/retriableReadableStream.js +64 -56
- package/dist/react-native/utils/retriableReadableStream.js.map +1 -1
- package/dist/react-native/utils/tokenCycler.js +7 -6
- package/dist/react-native/utils/tokenCycler.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.ContainerRepositoryImpl = void 0;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
const tracing_js_1 = require("./tracing.js");
|
|
8
7
|
const registryArtifact_js_1 = require("./registryArtifact.js");
|
|
9
8
|
const transformations_js_1 = require("./transformations.js");
|
|
@@ -13,6 +12,15 @@ const helpers_js_1 = require("./utils/helpers.js");
|
|
|
13
12
|
* @internal
|
|
14
13
|
*/
|
|
15
14
|
class ContainerRepositoryImpl {
|
|
15
|
+
client;
|
|
16
|
+
/**
|
|
17
|
+
* The Azure Container Registry endpoint.
|
|
18
|
+
*/
|
|
19
|
+
registryEndpoint;
|
|
20
|
+
/**
|
|
21
|
+
* Repository name.
|
|
22
|
+
*/
|
|
23
|
+
name;
|
|
16
24
|
/**
|
|
17
25
|
* Creates an instance of a ContainerRepository.
|
|
18
26
|
* @param registryEndpoint - the URL to the Container Registry endpoint
|
|
@@ -83,7 +91,7 @@ class ContainerRepositoryImpl {
|
|
|
83
91
|
canList: options.canList,
|
|
84
92
|
canRead: options.canRead,
|
|
85
93
|
};
|
|
86
|
-
return tracing_js_1.tracingClient.withSpan("ContainerRepositoryImpl.updateProperties",
|
|
94
|
+
return tracing_js_1.tracingClient.withSpan("ContainerRepositoryImpl.updateProperties", { ...options, value }, (updatedOptions) => {
|
|
87
95
|
return this.client.containerRegistry.updateProperties(this.name, updatedOptions);
|
|
88
96
|
});
|
|
89
97
|
}
|
|
@@ -122,53 +130,40 @@ class ContainerRepositoryImpl {
|
|
|
122
130
|
byPage: (settings = {}) => this.listManifestsPage(settings, options),
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
listManifestsItems() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
for (var _d = true, _e = tslib_1.__asyncValues(this.listManifestsPage({}, options)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
130
|
-
_c = _f.value;
|
|
131
|
-
_d = false;
|
|
132
|
-
const page = _c;
|
|
133
|
-
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
137
|
-
finally {
|
|
138
|
-
try {
|
|
139
|
-
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
|
|
140
|
-
}
|
|
141
|
-
finally { if (e_1) throw e_1.error; }
|
|
142
|
-
}
|
|
143
|
-
});
|
|
133
|
+
async *listManifestsItems(options = {}) {
|
|
134
|
+
for await (const page of this.listManifestsPage({}, options)) {
|
|
135
|
+
yield* page;
|
|
136
|
+
}
|
|
144
137
|
}
|
|
145
|
-
listManifestsPage(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
138
|
+
async *listManifestsPage(continuationState, options = {}) {
|
|
139
|
+
const orderby = (0, transformations_js_1.toServiceManifestOrderBy)(options.order);
|
|
140
|
+
if (!continuationState.continuationToken) {
|
|
141
|
+
const optionsComplete = {
|
|
142
|
+
...options,
|
|
143
|
+
n: continuationState.maxPageSize,
|
|
144
|
+
orderby,
|
|
145
|
+
};
|
|
146
|
+
const currentPage = await this.client.containerRegistry.getManifests(this.name, optionsComplete);
|
|
147
|
+
continuationState.continuationToken = (0, helpers_js_1.extractNextLink)(currentPage.link);
|
|
148
|
+
if (currentPage.manifests) {
|
|
149
|
+
const array = currentPage.manifests.map((t) => (0, transformations_js_1.toArtifactManifestProperties)(t, this.name, currentPage.registryLoginServer));
|
|
150
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
151
|
+
value: continuationState.continuationToken,
|
|
152
|
+
enumerable: true,
|
|
153
|
+
});
|
|
159
154
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
155
|
+
}
|
|
156
|
+
while (continuationState.continuationToken) {
|
|
157
|
+
const currentPage = await this.client.containerRegistry.getManifestsNext(this.name, continuationState.continuationToken, options);
|
|
158
|
+
continuationState.continuationToken = (0, helpers_js_1.extractNextLink)(currentPage.link);
|
|
159
|
+
if (currentPage.manifests) {
|
|
160
|
+
const array = currentPage.manifests.map((t) => (0, transformations_js_1.toArtifactManifestProperties)(t, this.name, currentPage.registryLoginServer));
|
|
161
|
+
yield Object.defineProperty(array, "continuationToken", {
|
|
162
|
+
value: continuationState.continuationToken,
|
|
163
|
+
enumerable: true,
|
|
164
|
+
});
|
|
170
165
|
}
|
|
171
|
-
}
|
|
166
|
+
}
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
169
|
exports.ContainerRepositoryImpl = ContainerRepositoryImpl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAQlC,6CAA6C;AAQ7C,+DAA6D;AAC7D,6DAA8F;AAC9F,mDAAqD;AAqHrD;;;GAGG;AACH,MAAa,uBAAuB;IAWlC;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,0BAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,WAAmB;QACpC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,0CAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC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,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,MAAM,WAAW,GAAG,sBAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CACtE,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAA,CAAC;gBACF,iBAAiB,CAAC,iBAAiB,GAAG,IAAA,4BAAe,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;oBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,IAAA,iDAA4B,EAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;oBACF,4BAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;wBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;wBAC1C,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAA,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF;AAvMD,0DAuMC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerRepository.js","sourceRoot":"","sources":["../../src/containerRepository.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,6CAA6C;AAQ7C,+DAA6D;AAC7D,6DAA8F;AAC9F,mDAAqD;AAqHrD;;;GAGG;AACH,MAAa,uBAAuB;IACjB,MAAM,CAAkB;IACzC;;OAEG;IACa,gBAAgB,CAAS;IACzC;;OAEG;IACa,IAAI,CAAS;IAE7B;;;;;OAKG;IACH,YAAY,gBAAwB,EAAE,IAAY,EAAE,MAAuB;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,UAAmC,EAAE;QACvD,OAAO,0BAAa,CAAC,QAAQ,CAC3B,gCAAgC,EAChC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAClF,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,WAAmB;QACpC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,0CAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9F,CAAC;IAED;;;OAGG;IACI,KAAK,CAA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,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,iBAAiB,EACnC,OAAO,CACR,CAAC;YACF,iBAAiB,CAAC,iBAAiB,GAAG,IAAA,4BAAe,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACxE,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,IAAA,iDAA4B,EAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,mBAAoB,CAAC,CAC7E,CAAC;gBACF,MAAM,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE;oBACtD,KAAK,EAAE,iBAAiB,CAAC,iBAAiB;oBAC1C,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAvMD,0DAuMC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/// <reference lib=\"esnext.asynciterable\" />\n\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { PageSettings, PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nimport type { GeneratedClient, RepositoryWriteableProperties } from \"./generated/index.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport type {\n ArtifactManifestOrder,\n ContainerRepositoryProperties,\n ArtifactManifestProperties,\n ManifestPageResponse,\n} from \"./models.js\";\nimport type { RegistryArtifact } from \"./registryArtifact.js\";\nimport { RegistryArtifactImpl } from \"./registryArtifact.js\";\nimport { toArtifactManifestProperties, toServiceManifestOrderBy } from \"./transformations.js\";\nimport { extractNextLink } from \"./utils/helpers.js\";\n\n/**\n * Options for delete repository operation.\n */\nexport interface DeleteRepositoryOptions extends OperationOptions {}\n/**\n * Options for the `listRegistryArtifacts` method of `ContainerRepository`.\n */\nexport interface ListManifestPropertiesOptions extends OperationOptions {\n /** order in which the manifest properties are returned */\n order?: ArtifactManifestOrder;\n}\n/**\n * Options for the `getProperties` method of `ContainerRepository`.\n */\nexport interface GetRepositoryPropertiesOptions extends OperationOptions {}\n/**\n * Options for the `setProperties` method of `ContainerRepository`.\n */\nexport interface UpdateRepositoryPropertiesOptions extends OperationOptions {\n /** Whether or not this repository can be deleted */\n canDelete?: boolean;\n /** Whether or not this repository can be written to */\n canWrite?: boolean;\n /** Whether or not include this repository when listing repositories */\n canList?: boolean;\n /** Whether or not this repository can be read */\n canRead?: boolean;\n}\n\n/**\n * A `repository` in a container registry is a logical grouping of images or artifacts that share the same name. For example,\n * different versions of a `hello-world` application could have tags `v1` and `v2`, and be grouped by the repository `hello-world`.\n *\n * The {@link ContainerRepository} interface is a helper that groups information and operations about a repository in this\n * container registry.\n */\nexport interface ContainerRepository {\n /**\n * The Azure Container Registry endpoint.\n */\n readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n readonly name: string;\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n delete(options?: DeleteRepositoryOptions): Promise<void>;\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n getArtifact(tagOrDigest: string): RegistryArtifact;\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n getProperties(options?: GetRepositoryPropertiesOptions): Promise<ContainerRepositoryProperties>;\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties>;\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n listManifestProperties(\n options?: ListManifestPropertiesOptions,\n ): PagedAsyncIterableIterator<ArtifactManifestProperties>;\n}\n\n/**\n * The client class used to interact with the Container Registry service.\n * @internal\n */\nexport class ContainerRepositoryImpl {\n private readonly client: GeneratedClient;\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly registryEndpoint: string;\n /**\n * Repository name.\n */\n public readonly name: string;\n\n /**\n * Creates an instance of a ContainerRepository.\n * @param registryEndpoint - the URL to the Container Registry endpoint\n * @param name - the name of the repository\n * @param client - the generated client that interacts with service\n */\n constructor(registryEndpoint: string, name: string, client: GeneratedClient) {\n this.registryEndpoint = registryEndpoint;\n this.name = name;\n\n this.client = client;\n }\n\n /**\n * Deletes this repository and all artifacts that are part of its logical group.\n *\n * @param options - optional configuration for the operation\n */\n public async delete(options: DeleteRepositoryOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.delete\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteRepository(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an helper instance of {@link RegistryArtifact} for the given tag or digest.\n * @param tagOrDigest - the tag or digest of the artifact\n */\n public getArtifact(tagOrDigest: string): RegistryArtifact {\n if (!tagOrDigest) {\n throw new Error(\"invalid tagOrDigest\");\n }\n return new RegistryArtifactImpl(this.registryEndpoint, this.name, tagOrDigest, this.client);\n }\n\n /**\n * Retrieves the properties of this repository.\n * @param options - The options for the operation.\n */\n public async getProperties(\n options: GetRepositoryPropertiesOptions = {},\n ): Promise<ContainerRepositoryProperties> {\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.getProperties\",\n options,\n (updatedOptions) => {\n return this.client.containerRegistry.getProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Updates the properties of this repository.\n *\n * Example usage:\n *\n * ```ts snippet:ContainerRepositoryUpdateProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * const updated = await repository.updateProperties({\n * canDelete: false,\n * canList: false,\n * canRead: false,\n * canWrite: false,\n * });\n * ```\n * @param options - The options for the operation.\n */\n public async updateProperties(\n options: UpdateRepositoryPropertiesOptions,\n ): Promise<ContainerRepositoryProperties> {\n const value: RepositoryWriteableProperties = {\n canDelete: options.canDelete,\n canWrite: options.canWrite,\n canList: options.canList,\n canRead: options.canRead,\n };\n\n return tracingClient.withSpan(\n \"ContainerRepositoryImpl.updateProperties\",\n { ...options, value },\n (updatedOptions) => {\n return this.client.containerRegistry.updateProperties(this.name, updatedOptions);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list manifest properties.\n * This is useful for determining the collection of artifacts associated with\n * this repository, as each artifact is uniquely identified by its manifest.\n *\n * Example using `for-await-of` syntax:\n *\n * ```ts snippet:ContainerRepositoryListManifestProperties\n * import { ContainerRegistryClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repositoryName = \"library/hello-world\";\n * const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential());\n * const repository = client.getRepository(repositoryName);\n *\n * for await (const manifest of repository.listManifestProperties()) {\n * console.log(\"manifest: \", manifest);\n * }\n * ```\n *\n * @param options - The options for the operation.\n */\n public listManifestProperties(\n options: ListManifestPropertiesOptions = {},\n ): PagedAsyncIterableIterator<ArtifactManifestProperties, ManifestPageResponse> {\n const iter = this.listManifestsItems(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings: PageSettings = {}) => this.listManifestsPage(settings, options),\n };\n }\n\n private async *listManifestsItems(\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ArtifactManifestProperties> {\n for await (const page of this.listManifestsPage({}, options)) {\n yield* page;\n }\n }\n\n private async *listManifestsPage(\n continuationState: PageSettings,\n options: ListManifestPropertiesOptions = {},\n ): AsyncIterableIterator<ManifestPageResponse> {\n const orderby = toServiceManifestOrderBy(options.order);\n if (!continuationState.continuationToken) {\n const optionsComplete = {\n ...options,\n n: continuationState.maxPageSize,\n orderby,\n };\n const currentPage = await this.client.containerRegistry.getManifests(\n this.name,\n optionsComplete,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n while (continuationState.continuationToken) {\n const currentPage = await this.client.containerRegistry.getManifestsNext(\n this.name,\n continuationState.continuationToken,\n options,\n );\n continuationState.continuationToken = extractNextLink(currentPage.link);\n if (currentPage.manifests) {\n const array = currentPage.manifests.map((t) =>\n toArtifactManifestProperties(t, this.name, currentPage.registryLoginServer!),\n );\n yield Object.defineProperty(array, \"continuationToken\", {\n value: continuationState.continuationToken,\n enumerable: true,\n });\n }\n }\n }\n}\n"]}
|
|
@@ -49,6 +49,15 @@ exports.DigestMismatchError = DigestMismatchError;
|
|
|
49
49
|
* The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.
|
|
50
50
|
*/
|
|
51
51
|
class ContainerRegistryContentClient {
|
|
52
|
+
/**
|
|
53
|
+
* The Azure Container Registry endpoint.
|
|
54
|
+
*/
|
|
55
|
+
endpoint;
|
|
56
|
+
/**
|
|
57
|
+
* The name of the repository that logically groups the artifact parts.
|
|
58
|
+
*/
|
|
59
|
+
repositoryName;
|
|
60
|
+
client;
|
|
52
61
|
/**
|
|
53
62
|
* Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.
|
|
54
63
|
*
|
|
@@ -71,13 +80,14 @@ class ContainerRegistryContentClient {
|
|
|
71
80
|
* @param options - optional configuration used to send requests to the service
|
|
72
81
|
*/
|
|
73
82
|
constructor(endpoint, repositoryName, credential, options = {}) {
|
|
74
|
-
var _a, _b;
|
|
75
83
|
if (!endpoint) {
|
|
76
84
|
throw new Error("invalid endpoint");
|
|
77
85
|
}
|
|
78
86
|
this.endpoint = endpoint;
|
|
79
87
|
this.repositoryName = repositoryName;
|
|
80
|
-
const internalPipelineOptions =
|
|
88
|
+
const internalPipelineOptions = {
|
|
89
|
+
...options,
|
|
90
|
+
loggingOptions: {
|
|
81
91
|
logger: logger_js_1.logger.info,
|
|
82
92
|
// This array contains header names we want to log that are not already
|
|
83
93
|
// included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
|
|
@@ -89,9 +99,10 @@ class ContainerRegistryContentClient {
|
|
|
89
99
|
"_nouploadcache",
|
|
90
100
|
"_state",
|
|
91
101
|
],
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
const defaultScope = `${options.audience ?? "https://containerregistry.azure.net"}/.default`;
|
|
105
|
+
const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;
|
|
95
106
|
const authClient = new index_js_1.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
96
107
|
this.client = new index_js_1.GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);
|
|
97
108
|
this.client.pipeline.addPolicy((0, core_rest_pipeline_1.bearerTokenAuthenticationPolicy)({
|
|
@@ -117,22 +128,24 @@ class ContainerRegistryContentClient {
|
|
|
117
128
|
*/
|
|
118
129
|
async setManifest(manifest, options = {}) {
|
|
119
130
|
return tracing_js_1.tracingClient.withSpan("ContainerRegistryContentClient.uploadManifest", options, async (updatedOptions) => {
|
|
120
|
-
var _a;
|
|
121
131
|
let manifestBody;
|
|
122
|
-
let tagOrDigest = options
|
|
132
|
+
let tagOrDigest = options?.tag;
|
|
123
133
|
if (Buffer.isBuffer(manifest)) {
|
|
124
134
|
manifestBody = manifest;
|
|
125
|
-
tagOrDigest
|
|
135
|
+
tagOrDigest ??= await (0, digest_js_1.calculateDigest)(manifest);
|
|
126
136
|
}
|
|
127
137
|
else if (isReadableStream(manifest)) {
|
|
128
138
|
manifestBody = await (0, helpers_js_1.readStreamToEnd)(manifest);
|
|
129
|
-
tagOrDigest
|
|
139
|
+
tagOrDigest ??= await (0, digest_js_1.calculateDigest)(manifestBody);
|
|
130
140
|
}
|
|
131
141
|
else {
|
|
132
142
|
manifestBody = Buffer.from(JSON.stringify(manifest));
|
|
133
|
-
tagOrDigest
|
|
143
|
+
tagOrDigest ??= await (0, digest_js_1.calculateDigest)(manifestBody);
|
|
134
144
|
}
|
|
135
|
-
const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody,
|
|
145
|
+
const createManifestResult = await this.client.containerRegistry.createManifest(this.repositoryName, tagOrDigest, manifestBody, {
|
|
146
|
+
contentType: options?.mediaType ?? models_js_1.KnownManifestMediaType.OciImageManifest,
|
|
147
|
+
...updatedOptions,
|
|
148
|
+
});
|
|
136
149
|
assertHasProperty(createManifestResult, "dockerContentDigest");
|
|
137
150
|
return { digest: createManifestResult.dockerContentDigest };
|
|
138
151
|
});
|
|
@@ -145,7 +158,10 @@ class ContainerRegistryContentClient {
|
|
|
145
158
|
*/
|
|
146
159
|
async getManifest(tagOrDigest, options = {}) {
|
|
147
160
|
return tracing_js_1.tracingClient.withSpan("ContainerRegistryContentClient.downloadManifest", options, async (updatedOptions) => {
|
|
148
|
-
const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest,
|
|
161
|
+
const response = await this.client.containerRegistry.getManifest(this.repositoryName, tagOrDigest, {
|
|
162
|
+
accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(", "),
|
|
163
|
+
...updatedOptions,
|
|
164
|
+
});
|
|
149
165
|
assertHasProperty(response, "mediaType");
|
|
150
166
|
const content = response.readableStreamBody
|
|
151
167
|
? await (0, helpers_js_1.readStreamToEnd)(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)
|
|
@@ -183,7 +199,6 @@ class ContainerRegistryContentClient {
|
|
|
183
199
|
*/
|
|
184
200
|
async uploadBlob(blob, options = {}) {
|
|
185
201
|
return tracing_js_1.tracingClient.withSpan("ContainerRegistryContentClient.uploadBlob", options, async (updatedOptions) => {
|
|
186
|
-
var _a, e_1, _b, _c;
|
|
187
202
|
const blobStream = Buffer.isBuffer(blob) ? node_stream_1.Readable.from(blob) : blob;
|
|
188
203
|
const startUploadResult = await this.client.containerRegistryBlob.startUpload(this.repositoryName, updatedOptions);
|
|
189
204
|
assertHasProperty(startUploadResult, "location");
|
|
@@ -191,24 +206,12 @@ class ContainerRegistryContentClient {
|
|
|
191
206
|
const chunks = (0, helpers_js_1.readChunksFromStream)(blobStream, CHUNK_SIZE);
|
|
192
207
|
const hash = node_crypto_1.default.createHash("sha256");
|
|
193
208
|
let bytesUploaded = 0;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
|
|
201
|
-
bytesUploaded += chunk.byteLength;
|
|
202
|
-
assertHasProperty(result, "location");
|
|
203
|
-
location = result.location.substring(1);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
207
|
-
finally {
|
|
208
|
-
try {
|
|
209
|
-
if (!_d && !_a && (_b = chunks_1.return)) await _b.call(chunks_1);
|
|
210
|
-
}
|
|
211
|
-
finally { if (e_1) throw e_1.error; }
|
|
209
|
+
for await (const chunk of chunks) {
|
|
210
|
+
hash.write(chunk);
|
|
211
|
+
const result = await this.client.containerRegistryBlob.uploadChunk(location, chunk, updatedOptions);
|
|
212
|
+
bytesUploaded += chunk.byteLength;
|
|
213
|
+
assertHasProperty(result, "location");
|
|
214
|
+
location = result.location.substring(1);
|
|
212
215
|
}
|
|
213
216
|
hash.end();
|
|
214
217
|
const digest = `sha256:${hash.digest("hex")}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRegistryContentClient.js","sourceRoot":"","sources":["../../../src/content/containerRegistryContentClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,kEAAuF;AAEvF,oDAAwD;AACxD,kGAA2E;AAC3E,gGAAiG;AACjG,4CAAsC;AACtC,kDAAqD;AAcrD,2CAAqD;AAErD,oDAAsF;AACtF,6CAAuC;AACvC,8CAA8C;AAC9C,sEAAiC;AACjC,oFAA8E;AAE9E,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAExC,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAC3C,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AAExD,MAAM,6BAA6B,GAAG;IACpC,kCAAsB,CAAC,gBAAgB;IACvC,kCAAsB,CAAC,cAAc;IACrC,yCAAyC;IACzC,2DAA2D;IAC3D,gDAAgD;CACjD,CAAC;AAEF,SAAS,gBAAgB,CAAC,IAAS;IACjC,OA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AAC,EACD,CAAC,EACD,eAAe,CAAC,aAAa,EAC7B;oBACE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClC,KAAK,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,GAAG,EAAE,CAAC;wBACX,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBAExD,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;4BAChC,MAAM,IAAI,mBAAmB,CAC3B,iFAAiF,CAClF,CAAC;wBACJ,CAAC;oBACH,CAAC;iBACF,CACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA/UD,wEA+UC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy, RestError } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"../generated/index.js\";\nimport { ChallengeHandler } from \"../containerRegistryChallengeHandler.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"../containerRegistryTokenCredential.js\";\nimport { logger } from \"../logger.js\";\nimport { calculateDigest } from \"../utils/digest.js\";\nimport type {\n DeleteBlobOptions,\n DeleteManifestOptions,\n DownloadBlobOptions,\n DownloadBlobResult,\n GetManifestOptions,\n GetManifestResult,\n UploadBlobOptions,\n UploadBlobResult,\n SetManifestOptions,\n SetManifestResult,\n OciImageManifest,\n} from \"./models.js\";\nimport { KnownManifestMediaType } from \"./models.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { isDigest, readChunksFromStream, readStreamToEnd } from \"../utils/helpers.js\";\nimport { Readable } from \"node:stream\";\nimport { tracingClient } from \"../tracing.js\";\nimport crypto from \"node:crypto\";\nimport { RetriableReadableStream } from \"../utils/retriableReadableStream.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\nconst CHUNK_SIZE = 4 * 1024 * 1024; // 4 MB\nconst MAX_MANIFEST_SIZE_BYTES = 4 * 1024 * 1024; // 4 MB\n\nconst ACCEPTED_MANIFEST_MEDIA_TYPES = [\n KnownManifestMediaType.OciImageManifest,\n KnownManifestMediaType.DockerManifest,\n \"application/vnd.oci.image.index.v1+json\",\n \"application/vnd.docker.distribution.manifest.list.v2+json\",\n \"application/vnd.docker.container.image.v1+json\",\n];\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction assertHasProperty<T, U extends keyof T>(\n obj: T,\n property: U,\n): asserts obj is T & Required<Pick<T, U>> {\n if (!Object.prototype.hasOwnProperty.call(obj, property)) {\n throw new RestError(`Expected property ${String(property)} to be defined.`);\n }\n}\n\n/**\n * Error thrown when the Docker content digest returned from the\n * server does not match the digest calculated from the content.\n */\nexport class DigestMismatchError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DigestMismatchError\";\n }\n}\n\n/**\n * Client options used to configure Container Registry Blob API requests.\n */\nexport interface ContainerRegistryContentClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.\n */\nexport class ContainerRegistryContentClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n /**\n * The name of the repository that logically groups the artifact parts.\n */\n public readonly repositoryName: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeCreateContainerRegistryContentClient\n * import { ContainerRegistryContentClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repository = \"library/hello-world\";\n * const client = new ContainerRegistryContentClient(\n * endpoint,\n * repository,\n * new DefaultAzureCredential(),\n * );\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param repositoryName - the name of the repository that logically groups the artifact parts\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n repositoryName: string,\n credential: TokenCredential,\n options: ContainerRegistryContentClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n this.repositoryName = repositoryName;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\n \"last\",\n \"n\",\n \"orderby\",\n \"digest\",\n \"_nouploadcache\",\n \"_state\",\n ],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Delete a blob.\n * @param digest - the digest of the blob to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteBlob(digest: string, options: DeleteBlobOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteBlob\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistryBlob.deleteBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload a manifest for an OCI artifact.\n *\n * @param manifest - the manifest to upload.\n */\n public async setManifest(\n manifest: Buffer | NodeJS.ReadableStream | OciImageManifest | Record<string, unknown>,\n options: SetManifestOptions = {},\n ): Promise<SetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadManifest\",\n options,\n async (updatedOptions) => {\n let manifestBody: Buffer | (() => NodeJS.ReadableStream);\n let tagOrDigest: string | undefined = options?.tag;\n\n if (Buffer.isBuffer(manifest)) {\n manifestBody = manifest;\n tagOrDigest ??= await calculateDigest(manifest);\n } else if (isReadableStream(manifest)) {\n manifestBody = await readStreamToEnd(manifest);\n tagOrDigest ??= await calculateDigest(manifestBody);\n } else {\n manifestBody = Buffer.from(JSON.stringify(manifest));\n tagOrDigest ??= await calculateDigest(manifestBody);\n }\n\n const createManifestResult = await this.client.containerRegistry.createManifest(\n this.repositoryName,\n tagOrDigest,\n manifestBody,\n {\n contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,\n ...updatedOptions,\n },\n );\n\n assertHasProperty(createManifestResult, \"dockerContentDigest\");\n\n return { digest: createManifestResult.dockerContentDigest };\n },\n );\n }\n\n /**\n * Downloads the manifest for an OCI artifact.\n *\n * @param tagOrDigest - a tag or digest that identifies the artifact\n * @returns - the downloaded manifest.\n */\n public async getManifest(\n tagOrDigest: string,\n options: GetManifestOptions = {},\n ): Promise<GetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadManifest\",\n options,\n async (updatedOptions) => {\n const response = await this.client.containerRegistry.getManifest(\n this.repositoryName,\n tagOrDigest,\n {\n accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(\", \"),\n ...updatedOptions,\n },\n );\n\n assertHasProperty(response, \"mediaType\");\n\n const content = response.readableStreamBody\n ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)\n : Buffer.alloc(0);\n\n const expectedDigest = await calculateDigest(content);\n\n if (isDigest(tagOrDigest) && expectedDigest !== tagOrDigest) {\n throw new DigestMismatchError(\n \"Digest of downloaded manifest does not match the input digest\",\n );\n }\n\n if (response.dockerContentDigest !== expectedDigest) {\n throw new DigestMismatchError(\n \"Computed digest of downloaded manifest does not match the value of the Docker-Content-Digest header\",\n );\n }\n\n return {\n digest: response.dockerContentDigest,\n mediaType: response.mediaType,\n content,\n manifest: JSON.parse(content.toString(\"utf-8\")),\n };\n },\n );\n }\n\n /**\n * Delete a manifest. Doing so effectively deletes an artifact from the registry.\n *\n * @param digest - the digest of the manifest to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteManifest(digest: string, options: DeleteManifestOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteManifest\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteManifest(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload an artifact blob.\n *\n * @param blobStream - the stream containing the blob data.\n */\n public async uploadBlob(\n blob: NodeJS.ReadableStream | Buffer,\n options: UploadBlobOptions = {},\n ): Promise<UploadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadBlob\",\n options,\n async (updatedOptions) => {\n const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;\n\n const startUploadResult = await this.client.containerRegistryBlob.startUpload(\n this.repositoryName,\n updatedOptions,\n );\n\n assertHasProperty(startUploadResult, \"location\");\n let location = startUploadResult.location.substring(1);\n\n const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);\n const hash = crypto.createHash(\"sha256\");\n\n let bytesUploaded = 0;\n\n for await (const chunk of chunks) {\n hash.write(chunk);\n const result = await this.client.containerRegistryBlob.uploadChunk(\n location,\n chunk,\n updatedOptions,\n );\n\n bytesUploaded += chunk.byteLength;\n\n assertHasProperty(result, \"location\");\n location = result.location.substring(1);\n }\n\n hash.end();\n const digest = `sha256:${hash.digest(\"hex\")}`;\n\n const { dockerContentDigest: digestFromResponse } =\n await this.client.containerRegistryBlob.completeUpload(digest, location, updatedOptions);\n\n if (digest !== digestFromResponse) {\n throw new DigestMismatchError(\n \"Digest of blob to upload does not match the digest from the server.\",\n );\n }\n\n return { digest, sizeInBytes: bytesUploaded };\n },\n );\n }\n\n /**\n * Download a blob that is part of an artifact.\n *\n * @param digest - the digest of the blob to download\n * @param options - optional configuration used to send requests to the service\n * @returns - the downloaded blob\n */\n public async downloadBlob(\n digest: string,\n options: DownloadBlobOptions = {},\n ): Promise<DownloadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadBlob\",\n options,\n async (updatedOptions) => {\n const initialResponse = await this.client.containerRegistryBlob.getBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n\n assertHasProperty(initialResponse, \"readableStreamBody\");\n assertHasProperty(initialResponse, \"contentLength\");\n\n const hash = crypto.createHash(\"sha256\");\n\n return {\n digest,\n content: new RetriableReadableStream(\n initialResponse.readableStreamBody,\n async (pos) => {\n const retryResponse = await this.client.containerRegistryBlob.getChunk(\n this.repositoryName,\n digest,\n `${pos}-`,\n updatedOptions,\n );\n\n assertHasProperty(retryResponse, \"readableStreamBody\");\n return retryResponse.readableStreamBody;\n },\n 0,\n initialResponse.contentLength,\n {\n onData: (data) => hash.write(data),\n onEnd: () => {\n hash.end();\n const calculatedDigest = `sha256:${hash.digest(\"hex\")}`;\n\n if (digest !== calculatedDigest) {\n throw new DigestMismatchError(\n \"Digest calculated from downloaded blob content does not match digest requested.\",\n );\n }\n },\n },\n ),\n };\n },\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"containerRegistryContentClient.js","sourceRoot":"","sources":["../../../src/content/containerRegistryContentClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,kEAAuF;AAEvF,oDAAwD;AACxD,kGAA2E;AAC3E,gGAAiG;AACjG,4CAAsC;AACtC,kDAAqD;AAcrD,2CAAqD;AAErD,oDAAsF;AACtF,6CAAuC;A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AAG,EAAE,EAAE;oBACZ,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CACpE,IAAI,CAAC,cAAc,EACnB,MAAM,EACN,GAAG,GAAG,GAAG,EACT,cAAc,CACf,CAAC;oBAEF,iBAAiB,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;oBACvD,OAAO,aAAa,CAAC,kBAAkB,CAAC;gBAC1C,CAAC,EACD,CAAC,EACD,eAAe,CAAC,aAAa,EAC7B;oBACE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;oBAClC,KAAK,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,GAAG,EAAE,CAAC;wBACX,MAAM,gBAAgB,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBAExD,IAAI,MAAM,KAAK,gBAAgB,EAAE,CAAC;4BAChC,MAAM,IAAI,mBAAmB,CAC3B,iFAAiF,CAClF,CAAC;wBACJ,CAAC;oBACH,CAAC;iBACF,CACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA/UD,wEA+UC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { bearerTokenAuthenticationPolicy, RestError } from \"@azure/core-rest-pipeline\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { GeneratedClient } from \"../generated/index.js\";\nimport { ChallengeHandler } from \"../containerRegistryChallengeHandler.js\";\nimport { ContainerRegistryRefreshTokenCredential } from \"../containerRegistryTokenCredential.js\";\nimport { logger } from \"../logger.js\";\nimport { calculateDigest } from \"../utils/digest.js\";\nimport type {\n DeleteBlobOptions,\n DeleteManifestOptions,\n DownloadBlobOptions,\n DownloadBlobResult,\n GetManifestOptions,\n GetManifestResult,\n UploadBlobOptions,\n UploadBlobResult,\n SetManifestOptions,\n SetManifestResult,\n OciImageManifest,\n} from \"./models.js\";\nimport { KnownManifestMediaType } from \"./models.js\";\nimport type { CommonClientOptions } from \"@azure/core-client\";\nimport { isDigest, readChunksFromStream, readStreamToEnd } from \"../utils/helpers.js\";\nimport { Readable } from \"node:stream\";\nimport { tracingClient } from \"../tracing.js\";\nimport crypto from \"node:crypto\";\nimport { RetriableReadableStream } from \"../utils/retriableReadableStream.js\";\n\nconst LATEST_API_VERSION = \"2021-07-01\";\n\nconst CHUNK_SIZE = 4 * 1024 * 1024; // 4 MB\nconst MAX_MANIFEST_SIZE_BYTES = 4 * 1024 * 1024; // 4 MB\n\nconst ACCEPTED_MANIFEST_MEDIA_TYPES = [\n KnownManifestMediaType.OciImageManifest,\n KnownManifestMediaType.DockerManifest,\n \"application/vnd.oci.image.index.v1+json\",\n \"application/vnd.docker.distribution.manifest.list.v2+json\",\n \"application/vnd.docker.container.image.v1+json\",\n];\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction assertHasProperty<T, U extends keyof T>(\n obj: T,\n property: U,\n): asserts obj is T & Required<Pick<T, U>> {\n if (!Object.prototype.hasOwnProperty.call(obj, property)) {\n throw new RestError(`Expected property ${String(property)} to be defined.`);\n }\n}\n\n/**\n * Error thrown when the Docker content digest returned from the\n * server does not match the digest calculated from the content.\n */\nexport class DigestMismatchError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DigestMismatchError\";\n }\n}\n\n/**\n * Client options used to configure Container Registry Blob API requests.\n */\nexport interface ContainerRegistryContentClientOptions extends CommonClientOptions {\n /**\n * Gets or sets the audience to use for authentication with Azure Active Directory.\n * The authentication scope will be set from this audience.\n * See {@link KnownContainerRegistryAudience} for known audience values.\n */\n audience?: string;\n /**\n * The version of service API to make calls against.\n */\n serviceVersion?: \"2021-07-01\";\n}\n\n/**\n * The Azure Container Registry blob client, responsible for uploading and downloading blobs and manifests, the building blocks of artifacts.\n */\nexport class ContainerRegistryContentClient {\n /**\n * The Azure Container Registry endpoint.\n */\n public readonly endpoint: string;\n\n /**\n * The name of the repository that logically groups the artifact parts.\n */\n public readonly repositoryName: string;\n\n private client: GeneratedClient;\n\n /**\n * Creates an instance of a ContainerRegistryContentClient for managing container images and artifacts.\n *\n * Example usage:\n * ```ts snippet:SampleReadmeCreateContainerRegistryContentClient\n * import { ContainerRegistryContentClient } from \"@azure/container-registry\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const endpoint = \"https://myregistryname.azurecr.io\";\n * const repository = \"library/hello-world\";\n * const client = new ContainerRegistryContentClient(\n * endpoint,\n * repository,\n * new DefaultAzureCredential(),\n * );\n * ```\n * @param endpoint - the URL endpoint of the container registry\n * @param repositoryName - the name of the repository that logically groups the artifact parts\n * @param credential - used to authenticate requests to the service\n * @param options - optional configuration used to send requests to the service\n */\n constructor(\n endpoint: string,\n repositoryName: string,\n credential: TokenCredential,\n options: ContainerRegistryContentClientOptions = {},\n ) {\n if (!endpoint) {\n throw new Error(\"invalid endpoint\");\n }\n\n this.endpoint = endpoint;\n this.repositoryName = repositoryName;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n loggingOptions: {\n logger: logger.info,\n // This array contains header names we want to log that are not already\n // included as safe. Unknown/unsafe headers are logged as \"<REDACTED>\".\n additionalAllowedQueryParameters: [\n \"last\",\n \"n\",\n \"orderby\",\n \"digest\",\n \"_nouploadcache\",\n \"_state\",\n ],\n },\n };\n\n const defaultScope = `${options.audience ?? \"https://containerregistry.azure.net\"}/.default`;\n const serviceVersion = options.serviceVersion ?? LATEST_API_VERSION;\n const authClient = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client = new GeneratedClient(endpoint, serviceVersion, internalPipelineOptions);\n this.client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: [defaultScope],\n challengeCallbacks: new ChallengeHandler(\n new ContainerRegistryRefreshTokenCredential(authClient, defaultScope, credential),\n ),\n }),\n );\n }\n\n /**\n * Delete a blob.\n * @param digest - the digest of the blob to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteBlob(digest: string, options: DeleteBlobOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteBlob\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistryBlob.deleteBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload a manifest for an OCI artifact.\n *\n * @param manifest - the manifest to upload.\n */\n public async setManifest(\n manifest: Buffer | NodeJS.ReadableStream | OciImageManifest | Record<string, unknown>,\n options: SetManifestOptions = {},\n ): Promise<SetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadManifest\",\n options,\n async (updatedOptions) => {\n let manifestBody: Buffer | (() => NodeJS.ReadableStream);\n let tagOrDigest: string | undefined = options?.tag;\n\n if (Buffer.isBuffer(manifest)) {\n manifestBody = manifest;\n tagOrDigest ??= await calculateDigest(manifest);\n } else if (isReadableStream(manifest)) {\n manifestBody = await readStreamToEnd(manifest);\n tagOrDigest ??= await calculateDigest(manifestBody);\n } else {\n manifestBody = Buffer.from(JSON.stringify(manifest));\n tagOrDigest ??= await calculateDigest(manifestBody);\n }\n\n const createManifestResult = await this.client.containerRegistry.createManifest(\n this.repositoryName,\n tagOrDigest,\n manifestBody,\n {\n contentType: options?.mediaType ?? KnownManifestMediaType.OciImageManifest,\n ...updatedOptions,\n },\n );\n\n assertHasProperty(createManifestResult, \"dockerContentDigest\");\n\n return { digest: createManifestResult.dockerContentDigest };\n },\n );\n }\n\n /**\n * Downloads the manifest for an OCI artifact.\n *\n * @param tagOrDigest - a tag or digest that identifies the artifact\n * @returns - the downloaded manifest.\n */\n public async getManifest(\n tagOrDigest: string,\n options: GetManifestOptions = {},\n ): Promise<GetManifestResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadManifest\",\n options,\n async (updatedOptions) => {\n const response = await this.client.containerRegistry.getManifest(\n this.repositoryName,\n tagOrDigest,\n {\n accept: ACCEPTED_MANIFEST_MEDIA_TYPES.join(\", \"),\n ...updatedOptions,\n },\n );\n\n assertHasProperty(response, \"mediaType\");\n\n const content = response.readableStreamBody\n ? await readStreamToEnd(response.readableStreamBody, MAX_MANIFEST_SIZE_BYTES)\n : Buffer.alloc(0);\n\n const expectedDigest = await calculateDigest(content);\n\n if (isDigest(tagOrDigest) && expectedDigest !== tagOrDigest) {\n throw new DigestMismatchError(\n \"Digest of downloaded manifest does not match the input digest\",\n );\n }\n\n if (response.dockerContentDigest !== expectedDigest) {\n throw new DigestMismatchError(\n \"Computed digest of downloaded manifest does not match the value of the Docker-Content-Digest header\",\n );\n }\n\n return {\n digest: response.dockerContentDigest,\n mediaType: response.mediaType,\n content,\n manifest: JSON.parse(content.toString(\"utf-8\")),\n };\n },\n );\n }\n\n /**\n * Delete a manifest. Doing so effectively deletes an artifact from the registry.\n *\n * @param digest - the digest of the manifest to delete\n * @param options - optional configuration used to send requests to the service\n */\n public async deleteManifest(digest: string, options: DeleteManifestOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.deleteManifest\",\n options,\n async (updatedOptions) => {\n await this.client.containerRegistry.deleteManifest(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Upload an artifact blob.\n *\n * @param blobStream - the stream containing the blob data.\n */\n public async uploadBlob(\n blob: NodeJS.ReadableStream | Buffer,\n options: UploadBlobOptions = {},\n ): Promise<UploadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.uploadBlob\",\n options,\n async (updatedOptions) => {\n const blobStream = Buffer.isBuffer(blob) ? Readable.from(blob) : blob;\n\n const startUploadResult = await this.client.containerRegistryBlob.startUpload(\n this.repositoryName,\n updatedOptions,\n );\n\n assertHasProperty(startUploadResult, \"location\");\n let location = startUploadResult.location.substring(1);\n\n const chunks = readChunksFromStream(blobStream, CHUNK_SIZE);\n const hash = crypto.createHash(\"sha256\");\n\n let bytesUploaded = 0;\n\n for await (const chunk of chunks) {\n hash.write(chunk);\n const result = await this.client.containerRegistryBlob.uploadChunk(\n location,\n chunk,\n updatedOptions,\n );\n\n bytesUploaded += chunk.byteLength;\n\n assertHasProperty(result, \"location\");\n location = result.location.substring(1);\n }\n\n hash.end();\n const digest = `sha256:${hash.digest(\"hex\")}`;\n\n const { dockerContentDigest: digestFromResponse } =\n await this.client.containerRegistryBlob.completeUpload(digest, location, updatedOptions);\n\n if (digest !== digestFromResponse) {\n throw new DigestMismatchError(\n \"Digest of blob to upload does not match the digest from the server.\",\n );\n }\n\n return { digest, sizeInBytes: bytesUploaded };\n },\n );\n }\n\n /**\n * Download a blob that is part of an artifact.\n *\n * @param digest - the digest of the blob to download\n * @param options - optional configuration used to send requests to the service\n * @returns - the downloaded blob\n */\n public async downloadBlob(\n digest: string,\n options: DownloadBlobOptions = {},\n ): Promise<DownloadBlobResult> {\n return tracingClient.withSpan(\n \"ContainerRegistryContentClient.downloadBlob\",\n options,\n async (updatedOptions) => {\n const initialResponse = await this.client.containerRegistryBlob.getBlob(\n this.repositoryName,\n digest,\n updatedOptions,\n );\n\n assertHasProperty(initialResponse, \"readableStreamBody\");\n assertHasProperty(initialResponse, \"contentLength\");\n\n const hash = crypto.createHash(\"sha256\");\n\n return {\n digest,\n content: new RetriableReadableStream(\n initialResponse.readableStreamBody,\n async (pos) => {\n const retryResponse = await this.client.containerRegistryBlob.getChunk(\n this.repositoryName,\n digest,\n `${pos}-`,\n updatedOptions,\n );\n\n assertHasProperty(retryResponse, \"readableStreamBody\");\n return retryResponse.readableStreamBody;\n },\n 0,\n initialResponse.contentLength,\n {\n onData: (data) => hash.write(data),\n onEnd: () => {\n hash.end();\n const calculatedDigest = `sha256:${hash.digest(\"hex\")}`;\n\n if (digest !== calculatedDigest) {\n throw new DigestMismatchError(\n \"Digest calculated from downloaded blob content does not match digest requested.\",\n );\n }\n },\n },\n ),\n };\n },\n );\n }\n}\n"]}
|
|
@@ -13,6 +13,8 @@ const coreClient = tslib_1.__importStar(require("@azure/core-client"));
|
|
|
13
13
|
const index_js_1 = require("./operations/index.js");
|
|
14
14
|
/** @internal */
|
|
15
15
|
class GeneratedClient extends coreClient.ServiceClient {
|
|
16
|
+
url;
|
|
17
|
+
apiVersion;
|
|
16
18
|
/**
|
|
17
19
|
* Initializes a new instance of the GeneratedClient class.
|
|
18
20
|
* @param url Registry login URL
|
|
@@ -20,7 +22,6 @@ class GeneratedClient extends coreClient.ServiceClient {
|
|
|
20
22
|
* @param options The parameter options
|
|
21
23
|
*/
|
|
22
24
|
constructor(url, apiVersion, options) {
|
|
23
|
-
var _a, _b;
|
|
24
25
|
if (url === undefined) {
|
|
25
26
|
throw new Error("'url' cannot be null");
|
|
26
27
|
}
|
|
@@ -38,9 +39,14 @@ class GeneratedClient extends coreClient.ServiceClient {
|
|
|
38
39
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
39
40
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
40
41
|
: `${packageDetails}`;
|
|
41
|
-
const optionsWithDefaults =
|
|
42
|
+
const optionsWithDefaults = {
|
|
43
|
+
...defaults,
|
|
44
|
+
...options,
|
|
45
|
+
userAgentOptions: {
|
|
42
46
|
userAgentPrefix
|
|
43
|
-
},
|
|
47
|
+
},
|
|
48
|
+
endpoint: options.endpoint ?? options.baseUri ?? "{url}"
|
|
49
|
+
};
|
|
44
50
|
super(optionsWithDefaults);
|
|
45
51
|
// Parameter assignments
|
|
46
52
|
this.url = url;
|
|
@@ -75,6 +81,9 @@ class GeneratedClient extends coreClient.ServiceClient {
|
|
|
75
81
|
};
|
|
76
82
|
this.pipeline.addPolicy(apiVersionPolicy);
|
|
77
83
|
}
|
|
84
|
+
containerRegistry;
|
|
85
|
+
containerRegistryBlob;
|
|
86
|
+
authentication;
|
|
78
87
|
}
|
|
79
88
|
exports.GeneratedClient = GeneratedClient;
|
|
80
89
|
//# sourceMappingURL=generatedClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAMjD,oDAI+B;AAQ/B,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAMjD,oDAI+B;AAQ/B,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa;IAC3D,GAAG,CAAS;IACZ,UAAU,CAAqB;IAE/B;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;QAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,0CAA0C,CAAC;QAClE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBA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CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,iBAAiB,CAAoB;IACrC,qBAAqB,CAAwB;IAC7C,cAAc,CAAiB;CAChC;AArFD,0CAqFC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport {\n ContainerRegistryImpl,\n ContainerRegistryBlobImpl,\n AuthenticationImpl\n} from \"./operations/index.js\";\nimport {\n ContainerRegistry,\n ContainerRegistryBlob,\n Authentication\n} from \"./operationsInterfaces/index.js\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClient extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClient class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n endpoint: options.endpoint ?? options.baseUri ?? \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n this.containerRegistry = new ContainerRegistryImpl(this);\n this.containerRegistryBlob = new ContainerRegistryBlobImpl(this);\n this.authentication = new AuthenticationImpl(this);\n this.addCustomApiVersionPolicy(apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n }\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n containerRegistry: ContainerRegistry;\n containerRegistryBlob: ContainerRegistryBlob;\n authentication: Authentication;\n}\n"]}
|
|
@@ -12,6 +12,8 @@ const tslib_1 = require("tslib");
|
|
|
12
12
|
const coreClient = tslib_1.__importStar(require("@azure/core-client"));
|
|
13
13
|
/** @internal */
|
|
14
14
|
class GeneratedClientContext extends coreClient.ServiceClient {
|
|
15
|
+
url;
|
|
16
|
+
apiVersion;
|
|
15
17
|
/**
|
|
16
18
|
* Initializes a new instance of the GeneratedClientContext class.
|
|
17
19
|
* @param url Registry login URL
|
|
@@ -36,9 +38,14 @@ class GeneratedClientContext extends coreClient.ServiceClient {
|
|
|
36
38
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
37
39
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
38
40
|
: `${packageDetails}`;
|
|
39
|
-
const optionsWithDefaults =
|
|
41
|
+
const optionsWithDefaults = {
|
|
42
|
+
...defaults,
|
|
43
|
+
...options,
|
|
44
|
+
userAgentOptions: {
|
|
40
45
|
userAgentPrefix
|
|
41
|
-
},
|
|
46
|
+
},
|
|
47
|
+
baseUri: options.endpoint || "{url}"
|
|
48
|
+
};
|
|
42
49
|
super(optionsWithDefaults);
|
|
43
50
|
// Parameter assignments
|
|
44
51
|
this.url = url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAGjD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAGjD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAClE,GAAG,CAAS;IACZ,UAAU,CAAqB;IAE/B;;;;;OAKG;IACH,YACE,GAAW,EACX,UAA8B,EAC9B,OAAuC;QAEvC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,mCAAmC,CAAC;QAC3D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB;YACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;SACrC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAjDD,wDAiDC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { ApiVersion20210701, GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n url: string;\n apiVersion: ApiVersion20210701;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param url Registry login URL\n * @param apiVersion Api Version\n * @param options The parameter options\n */\n constructor(\n url: string,\n apiVersion: ApiVersion20210701,\n options?: GeneratedClientOptionalParams\n ) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n if (apiVersion === undefined) {\n throw new Error(\"'apiVersion' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-container-registry/1.1.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n this.apiVersion = apiVersion;\n }\n}\n"]}
|