Skip to content

Commit

Permalink
Arch board review feedback for ACR (#21913)
Browse files Browse the repository at this point in the history
* Update ACR changes

* Update the swagger to the new values.

* read me update

* Add support for ACR beta 3

* Incorporate CR comments
  • Loading branch information
pallavit authored Jun 1, 2021
1 parent f064db0 commit a0c60af
Show file tree
Hide file tree
Showing 74 changed files with 4,082 additions and 4,811 deletions.
69 changes: 35 additions & 34 deletions sdk/containerregistry/azure-containers-containerregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ More information at [Azure Container Registry portal][container_registry_create_

<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L29-L33 -->
```Java
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient();
}
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ContainerRegistryClient client = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient();
```

<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L37-L41 -->
```Java
ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildAsyncClient();
}
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ContainerRegistryAsyncClient client = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildAsyncClient();
```

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).
Expand All @@ -63,14 +63,14 @@ The user must use this setting on a registry that has been enabled for anonymous
In this mode, the user can only call listRepositoryNames method and its overload. All the other calls will fail.
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)

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

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

Iterate through the collection of repositories in the registry.

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

### List tags with anonymous access

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

RegistryArtifact image = anonymousClient.getArtifact(repositoryName, digest);
PagedIterable<ArtifactTagProperties> tags = image.listTags();
PagedIterable<ArtifactTagProperties> tags = image.listTagProperties();

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

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

### Set artifact properties

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

Expand All @@ -156,7 +156,7 @@ image.updateTagProperties(

### Delete Images

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

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

// Obtain the images ordered from newest to oldest
PagedIterable<ArtifactManifestProperties> imageManifests =
repository.listManifests(
ManifestOrderBy.LAST_UPDATED_ON_DESCENDING,
repository.listManifestProperties(
ArtifactManifestOrderBy.LAST_UPDATED_ON_DESCENDING,
Context.NONE);

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

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

<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L66 -->
<!-- embedme ./src/samples/java/com/azure/containers/containerregistry/ReadmeSamples.java#L56-L67 -->
```Java
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ContainerRepository containerRepository = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient()
.getRepository(repositoryName);
try {
containerRepository.getProperties();
} catch (HttpResponseException exception) {
// Do something with the exception.
}
public void getPropertiesThrows() {
DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
ContainerRepository containerRepository = new ContainerRegistryClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient()
.getRepository(repositoryName);
try {
containerRepository.getProperties();
} catch (HttpResponseException exception) {
// Do something with the exception.
}
```

## Next steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
*
* <p><strong>Instantiating an asynchronous Container Registry client</strong></p>
*
* {@codesnippet com.azure.containers.containerregistry.async.repository.instantiation}
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.instantiation}
*
* <p><strong>Instantiating an asynchronous Container Registry client using a custom pipeline</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.pipeline.instantiation}
*
* <p>View {@link ContainerRegistryClientBuilder this} for additional ways to construct the client.</p>
*
Expand Down Expand Up @@ -68,6 +71,10 @@ public String getEndpoint() {
/**
* List all the repository names in this registry.
*
* <p><strong>List repository names in the registry.</strong></p>
*
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.listRepositoryNames}
*
* @return list of repository names.
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
*/
Expand Down Expand Up @@ -112,11 +119,15 @@ Mono<PagedResponse<String>> listRepositoryNamesNextSinglePageAsync(String nextLi
/**
* Delete the repository identified by 'repositoryName'.
*
* <p><strong>Delete a repository in the registry.</strong></p>
*
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.deleteRepositoryWithResponse#String}
*
* @param repositoryName Name of the repository (including the namespace).
* @return the completion.
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
* @throws NullPointerException thrown if the 'repositoryName' is null.
* @throws IllegalArgumentException thrown if the 'repositoryName' is null.
* @throws NullPointerException thrown if the {@code repositoryName} is null.
* @throws IllegalArgumentException thrown if the {@code repositoryName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteRepositoryWithResponse(String repositoryName) {
Expand All @@ -142,13 +153,16 @@ Mono<Response<Void>> deleteRepositoryWithResponse(String repositoryName, Context
}

/**
* Delete the repository identified by 'repositoryName'.
* Delete the repository identified by {@code repositoryName}.
*
* <p><strong>Delete a repository in the registry.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryAsyncClient.deleteRepository#String}
*
* @param repositoryName Name of the image (including the namespace).
* @return deleted repository properties.
* @return the completion stream.
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
* @throws NullPointerException thrown if the 'repositoryName' is null.
* @throws IllegalArgumentException thrown if 'repositoryName' is empty.
* @throws NullPointerException thrown if the {@code repositoryName} is null.
* @throws IllegalArgumentException thrown if {@code repositoryName} is empty.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteRepository(String repositoryName) {
Expand All @@ -162,10 +176,13 @@ Mono<Void> deleteRepository(String repositoryName, Context context) {
/**
* Creates a new instance of {@link ContainerRepositoryAsync} object for the specified repository.
*
* <p><strong>Create an instance of ContainerRepositoryAsync helper type</strong></p>
* {@codesnippet com.azure.containers.containerregistry.containeregistryasyncclient.getRepository}
*
* @param repositoryName Name of the repository to reference.
* @return A new {@link ContainerRepositoryAsync} for the desired repository.
* @throws NullPointerException if 'repositoryName' is null.
* @throws IllegalArgumentException if 'repositoryName' is empty.
* @throws NullPointerException if {@code repositoryName} is null.
* @throws IllegalArgumentException if {@code repositoryName} is empty.
*/
public ContainerRepositoryAsync getRepository(String repositoryName) {
return new ContainerRepositoryAsync(repositoryName, httpPipeline, endpoint, apiVersion);
Expand All @@ -174,13 +191,14 @@ public ContainerRepositoryAsync getRepository(String repositoryName) {
/**
* Creates a new instance of {@link RegistryArtifactAsync} object for the specified artifact.
*
* <p><strong>Create an instance of RegistryArtifactAsync helper type</strong></p>
* {@codesnippet com.azure.containers.containerregistry.containeregistryasyncclient.getArtifact}
*
* @param repositoryName Name of the repository to reference.
* @param digest Either a tag or digest that uniquely identifies the artifact.
* @return A new {@link RegistryArtifactAsync RegistryArtifactAsync} for the desired repository.
* @throws NullPointerException if 'repositoryName' is null.
* @throws IllegalArgumentException if 'repositoryName' is empty.
* @throws NullPointerException if 'digest' is null.
* @throws IllegalArgumentException if 'digest' is empty.
* @throws NullPointerException if {@code repositoryName} or {@code digest} is null.
* @throws IllegalArgumentException if {@code repositoryName} or {@code digest} is empty.
*/
public RegistryArtifactAsync getArtifact(String repositoryName, String digest) {
return new RegistryArtifactAsync(repositoryName, digest, httpPipeline, endpoint, apiVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* that can be used to perform operations on repository and artifacts.
*
* <p><strong>Instantiating a synchronous Container Registry client</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.instantiation}
*
* {@codesnippet com.azure.containers.containerregistry.repository.instantiation}
* <p><strong>Instantiating a synchronous Container Registry client with custom pipeline</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.pipeline.instantiation}
*
* <p>View {@link ContainerRegistryClientBuilder this} for additional ways to construct the client.</p>
*
Expand All @@ -44,7 +46,11 @@ public String getEndpoint() {
/**
* List all the repository names in this registry.
*
* @return list of repositories.
* <p><strong>List the repository names in the registry.</strong></p>
*
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.listRepositoryNames}
*
* @return list of repository names.
* @throws ClientAuthenticationException thrown if the client credentials do not have access to perform this operation.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
Expand All @@ -55,6 +61,9 @@ public PagedIterable<String> listRepositoryNames() {
/**
* List all the repository names in this registry.
*
* <p><strong>List the repository names in the registry.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.listRepositoryNames#Context}
*
* @param context The context to associate with this operation.
* @return list of repositories.
* @throws ClientAuthenticationException thrown if the client credentials do not have access to perform this operation.
Expand All @@ -65,27 +74,33 @@ public PagedIterable<String> listRepositoryNames(Context context) {
}

/**
* Delete the repository identified by 'repositoryName'.
* Delete the repository identified by {@code repositoryName}.
*
* <p><strong>Delete a repository in the registry.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.deleteRepository#String}
*
* @param repositoryName Name of the repository (including the namespace).
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
* @throws NullPointerException thrown if the 'repositoryName' is null.
* @throws IllegalArgumentException thrown if the 'repositoryName' is empty.
* @throws NullPointerException thrown if the {@code repositoryName} is null.
* @throws IllegalArgumentException thrown if the {@code repositoryName} is empty.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteRepository(String repositoryName) {
this.deleteRepositoryWithResponse(repositoryName, Context.NONE);
}

/**
* Delete the repository identified by 'repositoryName'.
* Delete the repository identified by {@code repositoryName}.
*
* <p><strong>Delete a repository in the registry.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.deleteRepositoryWithResponse#String-Context}
*
* @param repositoryName Name of the repository (including the namespace).
* @param context The context to associate with this operation.
* @return Completion response.
* @throws ClientAuthenticationException thrown if the client's credentials do not have access to modify the namespace.
* @throws NullPointerException thrown if the 'repositoryName' is null.
* @throws IllegalArgumentException thrown if the 'repositoryName' is empty.
* @throws NullPointerException thrown if the {@code repositoryName} is null.
* @throws IllegalArgumentException thrown if the {@code repositoryName} is empty.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteRepositoryWithResponse(String repositoryName, Context context) {
Expand All @@ -95,10 +110,13 @@ public Response<Void> deleteRepositoryWithResponse(String repositoryName, Contex
/**
* Creates a new instance of {@link ContainerRepository} object for the specified repository.
*
* <p><strong>Create a ContainerRegistry helper instance.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.getRepository}
*
* @param repositoryName Name of the repository to reference.
* @return A new {@link ContainerRepository} for the desired repository.
* @throws NullPointerException if 'repositoryName' is null.
* @throws IllegalArgumentException if 'repositoryName' is empty.
* @throws NullPointerException if {@code repositoryName} is null.
* @throws IllegalArgumentException if {@code repositoryName} is empty.
*/
public ContainerRepository getRepository(String repositoryName) {
return new ContainerRepository(this.asyncClient.getRepository(repositoryName));
Expand All @@ -107,13 +125,15 @@ public ContainerRepository getRepository(String repositoryName) {
/**
* Creates a new instance of {@link RegistryArtifact} object for the specified artifact.
*
* <p><strong>Create a RegistryArtifact helper instance.</strong></p>
* {@codesnippet com.azure.containers.containerregistry.ContainerRegistryClient.getArtifact}
*
*
* @param repositoryName Name of the repository to reference.
* @param digest Either a tag or digest that uniquely identifies the artifact.
* @return A new {@link RegistryArtifact} object for the desired repository.
* @throws NullPointerException if 'repositoryName' is null.
* @throws IllegalArgumentException if 'repositoryName' is empty.
* @throws NullPointerException if 'digest' is null.
* @throws IllegalArgumentException if 'digest' is empty.
* @throws NullPointerException if {@code repositoryName} or {@code digest} is null.
* @throws IllegalArgumentException if {@code repositoryName} or {@code digest} is empty.
*/
public RegistryArtifact getArtifact(String repositoryName, String digest) {
return new RegistryArtifact(this.asyncClient.getArtifact(repositoryName, digest));
Expand Down
Loading

0 comments on commit a0c60af

Please sign in to comment.