Class ArtifactRegistryClient (0.5.0)

public class ArtifactRegistryClient implements BackgroundResource

Service Description: The Artifact Registry API service.

Artifact Registry is an artifact management system for storing artifacts from different package management systems.

The resources managed by this API are:

  • Repositories, which group packages and their data.
  • Packages, which group versions and their tags.
  • Versions, which are specific forms of a package.
  • Tags, which represent alternative names for versions.
  • Files, which contain content and are optionally associated with a Package or Version.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   RepositoryName name = RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]");
   Repository response = artifactRegistryClient.getRepository(name);
 }
 

Note: close() needs to be called on the ArtifactRegistryClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ArtifactRegistrySettings to create(). For example:

To customize credentials:


 ArtifactRegistrySettings artifactRegistrySettings =
     ArtifactRegistrySettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ArtifactRegistryClient artifactRegistryClient =
     ArtifactRegistryClient.create(artifactRegistrySettings);
 

To customize the endpoint:


 ArtifactRegistrySettings artifactRegistrySettings =
     ArtifactRegistrySettings.newBuilder().setEndpoint(myEndpoint).build();
 ArtifactRegistryClient artifactRegistryClient =
     ArtifactRegistryClient.create(artifactRegistrySettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ArtifactRegistryClient

Implements

BackgroundResource

Constructors

ArtifactRegistryClient(ArtifactRegistrySettings settings)

protected ArtifactRegistryClient(ArtifactRegistrySettings settings)

Constructs an instance of ArtifactRegistryClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
NameDescription
settingsArtifactRegistrySettings

ArtifactRegistryClient(ArtifactRegistryStub stub)

protected ArtifactRegistryClient(ArtifactRegistryStub stub)
Parameter
NameDescription
stubArtifactRegistryStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

create()

public static final ArtifactRegistryClient create()

Constructs an instance of ArtifactRegistryClient with default settings.

Returns
TypeDescription
ArtifactRegistryClient
Exceptions
TypeDescription
IOException

create(ArtifactRegistrySettings settings)

public static final ArtifactRegistryClient create(ArtifactRegistrySettings settings)

Constructs an instance of ArtifactRegistryClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsArtifactRegistrySettings
Returns
TypeDescription
ArtifactRegistryClient
Exceptions
TypeDescription
IOException

create(ArtifactRegistryStub stub)

public static final ArtifactRegistryClient create(ArtifactRegistryStub stub)

Constructs an instance of ArtifactRegistryClient, using the given stub for making calls. This is for advanced usage - prefer using create(ArtifactRegistrySettings).

Parameter
NameDescription
stubArtifactRegistryStub
Returns
TypeDescription
ArtifactRegistryClient

getRepository(GetRepositoryRequest request)

public final Repository getRepository(GetRepositoryRequest request)

Gets a repository.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   GetRepositoryRequest request =
       GetRepositoryRequest.newBuilder()
           .setName(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
           .build();
   Repository response = artifactRegistryClient.getRepository(request);
 }
 
Parameter
NameDescription
requestGetRepositoryRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Repository

getRepository(RepositoryName name)

public final Repository getRepository(RepositoryName name)

Gets a repository.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   RepositoryName name = RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]");
   Repository response = artifactRegistryClient.getRepository(name);
 }
 
Parameter
NameDescription
nameRepositoryName

Required. The name of the repository to retrieve.

Returns
TypeDescription
Repository

getRepository(String name)

public final Repository getRepository(String name)

Gets a repository.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   String name = RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString();
   Repository response = artifactRegistryClient.getRepository(name);
 }
 
Parameter
NameDescription
nameString

Required. The name of the repository to retrieve.

Returns
TypeDescription
Repository

getRepositoryCallable()

public final UnaryCallable<GetRepositoryRequest,Repository> getRepositoryCallable()

Gets a repository.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   GetRepositoryRequest request =
       GetRepositoryRequest.newBuilder()
           .setName(RepositoryName.of("[PROJECT]", "[LOCATION]", "[REPOSITORY]").toString())
           .build();
   ApiFuture<Repository> future =
       artifactRegistryClient.getRepositoryCallable().futureCall(request);
   // Do something.
   Repository response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetRepositoryRequest,Repository>

getSettings()

public final ArtifactRegistrySettings getSettings()
Returns
TypeDescription
ArtifactRegistrySettings

getStub()

public ArtifactRegistryStub getStub()
Returns
TypeDescription
ArtifactRegistryStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listDockerImages(ListDockerImagesRequest request)

public final ArtifactRegistryClient.ListDockerImagesPagedResponse listDockerImages(ListDockerImagesRequest request)

Lists docker images.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListDockerImagesRequest request =
       ListDockerImagesRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (DockerImage element : artifactRegistryClient.listDockerImages(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListDockerImagesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ArtifactRegistryClient.ListDockerImagesPagedResponse

listDockerImages(String parent)

public final ArtifactRegistryClient.ListDockerImagesPagedResponse listDockerImages(String parent)

Lists docker images.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   String parent = "parent-995424086";
   for (DockerImage element : artifactRegistryClient.listDockerImages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The name of the parent resource whose docker images will be listed.

Returns
TypeDescription
ArtifactRegistryClient.ListDockerImagesPagedResponse

listDockerImagesCallable()

public final UnaryCallable<ListDockerImagesRequest,ListDockerImagesResponse> listDockerImagesCallable()

Lists docker images.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListDockerImagesRequest request =
       ListDockerImagesRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListDockerImagesResponse response =
         artifactRegistryClient.listDockerImagesCallable().call(request);
     for (DockerImage element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListDockerImagesRequest,ListDockerImagesResponse>

listDockerImagesPagedCallable()

public final UnaryCallable<ListDockerImagesRequest,ArtifactRegistryClient.ListDockerImagesPagedResponse> listDockerImagesPagedCallable()

Lists docker images.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListDockerImagesRequest request =
       ListDockerImagesRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture
Returns
TypeDescription
UnaryCallable<ListDockerImagesRequest,ListDockerImagesPagedResponse>

listRepositories(ListRepositoriesRequest request)

public final ArtifactRegistryClient.ListRepositoriesPagedResponse listRepositories(ListRepositoriesRequest request)

Lists repositories.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListRepositoriesRequest request =
       ListRepositoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Repository element : artifactRegistryClient.listRepositories(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListRepositoriesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
ArtifactRegistryClient.ListRepositoriesPagedResponse

listRepositories(LocationName parent)

public final ArtifactRegistryClient.ListRepositoriesPagedResponse listRepositories(LocationName parent)

Lists repositories.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Repository element : artifactRegistryClient.listRepositories(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The name of the parent resource whose repositories will be listed.

Returns
TypeDescription
ArtifactRegistryClient.ListRepositoriesPagedResponse

listRepositories(String parent)

public final ArtifactRegistryClient.ListRepositoriesPagedResponse listRepositories(String parent)

Lists repositories.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Repository element : artifactRegistryClient.listRepositories(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The name of the parent resource whose repositories will be listed.

Returns
TypeDescription
ArtifactRegistryClient.ListRepositoriesPagedResponse

listRepositoriesCallable()

public final UnaryCallable<ListRepositoriesRequest,ListRepositoriesResponse> listRepositoriesCallable()

Lists repositories.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListRepositoriesRequest request =
       ListRepositoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListRepositoriesResponse response =
         artifactRegistryClient.listRepositoriesCallable().call(request);
     for (Repository element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRepositoriesRequest,ListRepositoriesResponse>

listRepositoriesPagedCallable()

public final UnaryCallable<ListRepositoriesRequest,ArtifactRegistryClient.ListRepositoriesPagedResponse> listRepositoriesPagedCallable()

Lists repositories.

Sample code:


 try (ArtifactRegistryClient artifactRegistryClient = ArtifactRegistryClient.create()) {
   ListRepositoriesRequest request =
       ListRepositoriesRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Repository> future =
       artifactRegistryClient.listRepositoriesPagedCallable().futureCall(request);
   // Do something.
   for (Repository element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListRepositoriesRequest,ListRepositoriesPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()