Skip to content

Commit a0c60af

Browse files
authored
Arch board review feedback for ACR (Azure#21913)
* Update ACR changes * Update the swagger to the new values. * read me update * Add support for ACR beta 3 * Incorporate CR comments
1 parent f064db0 commit a0c60af

File tree

74 files changed

+4082
-4811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4082
-4811
lines changed

sdk/containerregistry/azure-containers-containerregistry/README.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ More information at [Azure Container Registry portal][container_registry_create_
3939

4040
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L29-L33 -->
4141
```Java
42-
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
43-
.endpoint(endpoint)
44-
.credential(credential)
45-
.buildClient();
46-
}
42+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
43+
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
44+
.endpoint(endpoint)
45+
.credential(credential)
46+
.buildClient();
4747
```
4848

4949
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L37-L41 -->
5050
```Java
51-
ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder()
52-
.endpoint(endpoint)
53-
.credential(credential)
54-
.buildAsyncClient();
55-
}
51+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
52+
ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder()
53+
.endpoint(endpoint)
54+
.credential(credential)
55+
.buildAsyncClient();
5656
```
5757

5858
For more information on using AAD with Azure Container Registry, please see the service's [Authentication Overview](https://docs.microsoft.com/azure/container-registry/container-registry-authentication).
@@ -63,14 +63,14 @@ The user must use this setting on a registry that has been enabled for anonymous
6363
In this mode, the user can only call listRepositoryNames method and its overload. All the other calls will fail.
6464
For more information please read [Anonymous Pull Access](https://docs.microsoft.com/azure/container-registry/container-registry-faq#how-do-i-enable-anonymous-pull-access)
6565

66-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L70-L72 -->
66+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L71-L73 -->
6767
```Java
6868
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
6969
.endpoint(endpoint)
7070
.buildClient();
7171
```
7272

73-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L76-L78 -->
73+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L77-L79 -->
7474
```Java
7575
ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder()
7676
.endpoint(endpoint)
@@ -105,7 +105,7 @@ For more information please see [Container Registry Concepts](https://docs.micro
105105

106106
Iterate through the collection of repositories in the registry.
107107

108-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L44-L50 -->
108+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L45-L51 -->
109109
```Java
110110
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
111111
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
@@ -118,16 +118,16 @@ client.listRepositoryNames().forEach(repository -> System.out.println(repository
118118

119119
### List tags with anonymous access
120120

121-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L137-L148 -->
121+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L138-L149 -->
122122
```Java
123123
ContainerRegistryClient anonymousClient = new ContainerRegistryClientBuilder()
124124
.endpoint(endpoint)
125125
.buildClient();
126126

127127
RegistryArtifact image = anonymousClient.getArtifact(repositoryName, digest);
128-
PagedIterable<ArtifactTagProperties> tags = image.listTags();
128+
PagedIterable<ArtifactTagProperties> tags = image.listTagProperties();
129129

130-
System.out.printf(String.format("%s has the following aliases:", image.getFullyQualifiedName()));
130+
System.out.printf(String.format("%s has the following aliases:", image.getFullyQualifiedReference()));
131131

132132
for (ArtifactTagProperties tag : tags) {
133133
System.out.printf(String.format("%s/%s:%s", anonymousClient.getEndpoint(), repositoryName, tag.getName()));
@@ -136,7 +136,7 @@ for (ArtifactTagProperties tag : tags) {
136136

137137
### Set artifact properties
138138

139-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L116-L129 -->
139+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L117-L130 -->
140140
```Java
141141
TokenCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
142142

@@ -156,7 +156,7 @@ image.updateTagProperties(
156156

157157
### Delete Images
158158

159-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L82-L110 -->
159+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L83-L111 -->
160160
```Java
161161
TokenCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
162162

@@ -171,8 +171,8 @@ for (String repositoryName : client.listRepositoryNames()) {
171171

172172
// Obtain the images ordered from newest to oldest
173173
PagedIterable<ArtifactManifestProperties> imageManifests =
174-
repository.listManifests(
175-
ManifestOrderBy.LAST_UPDATED_ON_DESCENDING,
174+
repository.listManifestProperties(
175+
ArtifactManifestOrderBy.LAST_UPDATED_ON_DESCENDING,
176176
Context.NONE);
177177

178178
imageManifests.stream().skip(imagesCountToKeep)
@@ -190,7 +190,7 @@ for (String repositoryName : client.listRepositoryNames()) {
190190
```
191191

192192
### Delete repository with anonymous access throws
193-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L152-L164 -->
193+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L153-L165 -->
194194
```Java
195195
final String endpoint = getEndpoint();
196196
final String repositoryName = getRepositoryName();
@@ -202,7 +202,7 @@ ContainerRegistryClient anonymousClient = new ContainerRegistryClientBuilder()
202202
try {
203203
anonymousClient.deleteRepository(repositoryName);
204204
System.out.println("Unexpected Success: Delete is not allowed on anonymous access");
205-
} catch (Exception ex) {
205+
} catch (ClientAuthenticationException ex) {
206206
System.out.println("Expected exception: Delete is not allowed on anonymous access");
207207
}
208208
```
@@ -212,19 +212,20 @@ try {
212212
All container registry service operations will throw a
213213
[HttpResponseException][HttpResponseException] on failure.
214214

215-
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L66 -->
215+
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L67 -->
216216
```Java
217-
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
218-
ContainerRepository containerRepository = new ContainerRegistryClientBuilder()
219-
.endpoint(endpoint)
220-
.credential(credential)
221-
.buildClient()
222-
.getRepository(repositoryName);
223-
try {
224-
containerRepository.getProperties();
225-
} catch (HttpResponseException exception) {
226-
// Do something with the exception.
227-
}
217+
public void getPropertiesThrows() {
218+
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
219+
ContainerRepository containerRepository = new ContainerRegistryClientBuilder()
220+
.endpoint(endpoint)
221+
.credential(credential)
222+
.buildClient()
223+
.getRepository(repositoryName);
224+
try {
225+
containerRepository.getProperties();
226+
} catch (HttpResponseException exception) {
227+
// Do something with the exception.
228+
}
228229
```
229230

230231
## Next steps

sdk/containerregistry/azure-containers-containerregistry/src/main/java/com/azure/containers/containerregistry/ContainerRegistryAsyncClient.java

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
*
3131
* <p><strong>Instantiating an asynchronous Container Registry client</strong></p>
3232
*
33-
* {@codesnippet com.azure.containers.containerregistry.async.repository.instantiation}
33+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.instantiation}
34+
*
35+
* <p><strong>Instantiating an asynchronous Container Registry client using a custom pipeline</strong></p>
36+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.pipeline.instantiation}
3437
*
3538
* <p>View {@link ContainerRegistryClientBuilder this} for additional ways to construct the client.</p>
3639
*
@@ -68,6 +71,10 @@ public String getEndpoint() {
6871
/**
6972
* List all the repository names in this registry.
7073
*
74+
* <p><strong>List repository names in the registry.</strong></p>
75+
*
76+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.listRepositoryNames}
77+
*
7178
* @return list of repository names.
7279
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
7380
*/
@@ -112,11 +119,15 @@ Mono<PagedResponse<String>> listRepositoryNamesNextSinglePageAsync(String nextLi
112119
/**
113120
* Delete the repository identified by 'repositoryName'.
114121
*
122+
* <p><strong>Delete a repository in the registry.</strong></p>
123+
*
124+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.deleteRepositoryWithResponse#String}
125+
*
115126
* @param repositoryName Name of the repository (including the namespace).
116127
* @return the completion.
117128
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
118-
* @throws NullPointerException thrown if the 'repositoryName' is null.
119-
* @throws IllegalArgumentException thrown if the 'repositoryName' is null.
129+
* @throws NullPointerException thrown if the {@code repositoryName} is null.
130+
* @throws IllegalArgumentException thrown if the {@code repositoryName} is null.
120131
*/
121132
@ServiceMethod(returns = ReturnType.SINGLE)
122133
public Mono<Response<Void>> deleteRepositoryWithResponse(String repositoryName) {
@@ -142,13 +153,16 @@ Mono<Response<Void>> deleteRepositoryWithResponse(String repositoryName, Context
142153
}
143154

144155
/**
145-
* Delete the repository identified by 'repositoryName'.
156+
* Delete the repository identified by {@code repositoryName}.
157+
*
158+
* <p><strong>Delete a repository in the registry.</strong></p>
159+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.deleteRepository#String}
146160
*
147161
* @param repositoryName Name of the image (including the namespace).
148-
* @return deleted repository properties.
162+
* @return the completion stream.
149163
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
150-
* @throws NullPointerException thrown if the 'repositoryName' is null.
151-
* @throws IllegalArgumentException thrown if 'repositoryName' is empty.
164+
* @throws NullPointerException thrown if the {@code repositoryName} is null.
165+
* @throws IllegalArgumentException thrown if {@code repositoryName} is empty.
152166
*/
153167
@ServiceMethod(returns = ReturnType.SINGLE)
154168
public Mono<Void> deleteRepository(String repositoryName) {
@@ -162,10 +176,13 @@ Mono<Void> deleteRepository(String repositoryName, Context context) {
162176
/**
163177
* Creates a new instance of {@link ContainerRepositoryAsync} object for the specified repository.
164178
*
179+
* <p><strong>Create an instance of ContainerRepositoryAsync helper type</strong></p>
180+
* {@codesnippet com.azure.containers.containerregistry.containeregistryasyncclient.getRepository}
181+
*
165182
* @param repositoryName Name of the repository to reference.
166183
* @return A new {@link ContainerRepositoryAsync} for the desired repository.
167-
* @throws NullPointerException if 'repositoryName' is null.
168-
* @throws IllegalArgumentException if 'repositoryName' is empty.
184+
* @throws NullPointerException if {@code repositoryName} is null.
185+
* @throws IllegalArgumentException if {@code repositoryName} is empty.
169186
*/
170187
public ContainerRepositoryAsync getRepository(String repositoryName) {
171188
return new ContainerRepositoryAsync(repositoryName, httpPipeline, endpoint, apiVersion);
@@ -174,13 +191,14 @@ public ContainerRepositoryAsync getRepository(String repositoryName) {
174191
/**
175192
* Creates a new instance of {@link RegistryArtifactAsync} object for the specified artifact.
176193
*
194+
* <p><strong>Create an instance of RegistryArtifactAsync helper type</strong></p>
195+
* {@codesnippet com.azure.containers.containerregistry.containeregistryasyncclient.getArtifact}
196+
*
177197
* @param repositoryName Name of the repository to reference.
178198
* @param digest Either a tag or digest that uniquely identifies the artifact.
179199
* @return A new {@link RegistryArtifactAsync RegistryArtifactAsync} for the desired repository.
180-
* @throws NullPointerException if 'repositoryName' is null.
181-
* @throws IllegalArgumentException if 'repositoryName' is empty.
182-
* @throws NullPointerException if 'digest' is null.
183-
* @throws IllegalArgumentException if 'digest' is empty.
200+
* @throws NullPointerException if {@code repositoryName} or {@code digest} is null.
201+
* @throws IllegalArgumentException if {@code repositoryName} or {@code digest} is empty.
184202
*/
185203
public RegistryArtifactAsync getArtifact(String repositoryName, String digest) {
186204
return new RegistryArtifactAsync(repositoryName, digest, httpPipeline, endpoint, apiVersion);

sdk/containerregistry/azure-containers-containerregistry/src/main/java/com/azure/containers/containerregistry/ContainerRegistryClient.java

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
* that can be used to perform operations on repository and artifacts.
1919
*
2020
* <p><strong>Instantiating a synchronous Container Registry client</strong></p>
21+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.instantiation}
2122
*
22-
* {@codesnippet com.azure.containers.containerregistry.repository.instantiation}
23+
* <p><strong>Instantiating a synchronous Container Registry client with custom pipeline</strong></p>
24+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.pipeline.instantiation}
2325
*
2426
* <p>View {@link ContainerRegistryClientBuilder this} for additional ways to construct the client.</p>
2527
*
@@ -44,7 +46,11 @@ public String getEndpoint() {
4446
/**
4547
* List all the repository names in this registry.
4648
*
47-
* @return list of repositories.
49+
* <p><strong>List the repository names in the registry.</strong></p>
50+
*
51+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.listRepositoryNames}
52+
*
53+
* @return list of repository names.
4854
* @throws ClientAuthenticationException thrown if the client credentials do not have access to perform this operation.
4955
*/
5056
@ServiceMethod(returns = ReturnType.COLLECTION)
@@ -55,6 +61,9 @@ public PagedIterable<String> listRepositoryNames() {
5561
/**
5662
* List all the repository names in this registry.
5763
*
64+
* <p><strong>List the repository names in the registry.</strong></p>
65+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.listRepositoryNames#Context}
66+
*
5867
* @param context The context to associate with this operation.
5968
* @return list of repositories.
6069
* @throws ClientAuthenticationException thrown if the client credentials do not have access to perform this operation.
@@ -65,27 +74,33 @@ public PagedIterable<String> listRepositoryNames(Context context) {
6574
}
6675

6776
/**
68-
* Delete the repository identified by 'repositoryName'.
77+
* Delete the repository identified by {@code repositoryName}.
78+
*
79+
* <p><strong>Delete a repository in the registry.</strong></p>
80+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.deleteRepository#String}
6981
*
7082
* @param repositoryName Name of the repository (including the namespace).
7183
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
72-
* @throws NullPointerException thrown if the 'repositoryName' is null.
73-
* @throws IllegalArgumentException thrown if the 'repositoryName' is empty.
84+
* @throws NullPointerException thrown if the {@code repositoryName} is null.
85+
* @throws IllegalArgumentException thrown if the {@code repositoryName} is empty.
7486
*/
7587
@ServiceMethod(returns = ReturnType.SINGLE)
7688
public void deleteRepository(String repositoryName) {
7789
this.deleteRepositoryWithResponse(repositoryName, Context.NONE);
7890
}
7991

8092
/**
81-
* Delete the repository identified by 'repositoryName'.
93+
* Delete the repository identified by {@code repositoryName}.
94+
*
95+
* <p><strong>Delete a repository in the registry.</strong></p>
96+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.deleteRepositoryWithResponse#String-Context}
8297
*
8398
* @param repositoryName Name of the repository (including the namespace).
8499
* @param context The context to associate with this operation.
85100
* @return Completion response.
86101
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
87-
* @throws NullPointerException thrown if the 'repositoryName' is null.
88-
* @throws IllegalArgumentException thrown if the 'repositoryName' is empty.
102+
* @throws NullPointerException thrown if the {@code repositoryName} is null.
103+
* @throws IllegalArgumentException thrown if the {@code repositoryName} is empty.
89104
*/
90105
@ServiceMethod(returns = ReturnType.SINGLE)
91106
public Response<Void> deleteRepositoryWithResponse(String repositoryName, Context context) {
@@ -95,10 +110,13 @@ public Response<Void> deleteRepositoryWithResponse(String repositoryName, Contex
95110
/**
96111
* Creates a new instance of {@link ContainerRepository} object for the specified repository.
97112
*
113+
* <p><strong>Create a ContainerRegistry helper instance.</strong></p>
114+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.getRepository}
115+
*
98116
* @param repositoryName Name of the repository to reference.
99117
* @return A new {@link ContainerRepository} for the desired repository.
100-
* @throws NullPointerException if 'repositoryName' is null.
101-
* @throws IllegalArgumentException if 'repositoryName' is empty.
118+
* @throws NullPointerException if {@code repositoryName} is null.
119+
* @throws IllegalArgumentException if {@code repositoryName} is empty.
102120
*/
103121
public ContainerRepository getRepository(String repositoryName) {
104122
return new ContainerRepository(this.asyncClient.getRepository(repositoryName));
@@ -107,13 +125,15 @@ public ContainerRepository getRepository(String repositoryName) {
107125
/**
108126
* Creates a new instance of {@link RegistryArtifact} object for the specified artifact.
109127
*
128+
* <p><strong>Create a RegistryArtifact helper instance.</strong></p>
129+
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.getArtifact}
130+
*
131+
*
110132
* @param repositoryName Name of the repository to reference.
111133
* @param digest Either a tag or digest that uniquely identifies the artifact.
112134
* @return A new {@link RegistryArtifact} object for the desired repository.
113-
* @throws NullPointerException if 'repositoryName' is null.
114-
* @throws IllegalArgumentException if 'repositoryName' is empty.
115-
* @throws NullPointerException if 'digest' is null.
116-
* @throws IllegalArgumentException if 'digest' is empty.
135+
* @throws NullPointerException if {@code repositoryName} or {@code digest} is null.
136+
* @throws IllegalArgumentException if {@code repositoryName} or {@code digest} is empty.
117137
*/
118138
public RegistryArtifact getArtifact(String repositoryName, String digest) {
119139
return new RegistryArtifact(this.asyncClient.getArtifact(repositoryName, digest));

0 commit comments

Comments
 (0)