Apicurio Studio

Managing Apicurio Registry content using a Java client

Apicurio Registry Java client

You can manage artifacts stored in Apicurio Registry using a Java client application. You can create, read, update, or delete artifacts stored in the registry using the Apicurio Registry Java client classes.

You can access the Apicurio Registry Java client by adding the correct dependency to your project, see Writing Apicurio Registry client applications.

The Apicurio Registry client is auto-closeable and is implemented using Retrofit and OkHttp as base libraries. This gives you the ability to customize its use, for example, by adding custom headers or enabling Transport Layer Security (TLS) authentication. For more details, see Apicurio Registry Java client configuration.

Writing Apicurio Registry client applications

This section explains how to manage artifacts stored in Apicurio Registry using a Java client application. The Apicurio Registry Java client extends the Autocloseable interface.

Prerequisites
Procedure
  1. Add the following dependency to your Maven project:

    <dependency>
        <groupId>io.apicurio</groupId>
        <artifactId>apicurio-registry-rest-client</artifactId>
        <version>${apicurio-registry.version}</version>
    </dependency>
  2. Create a registry client as follows:

    public class ClientExample {
    
        private static final RegistryRestClient client;
    
         public static void main(String[] args) throws Exception {
            // Create a registry client
            String registryUrl = "https://registry.my-domain.com/api"; (1)
            RegistryRestClient client = RegistryRestClientFactory.create(registryUrl); (2)
        }
    }
    1 You must specify the Apicurio Registry URL with the /api endpoint.
    2 For more options when creating a Apicurio Registry client, see the Java client configuration in the next section.
  3. When the client is created, you can use all the operations from the Apicurio Registry REST API through the client. For more details, see the Apicurio Registry REST API documentation.

Additional resources

Apicurio Registry Java client configuration

The Apicurio Registry Java client includes the following configuration options, based on the client factory:

Table 1. Apicurio Registry Java client configuration options
Option Description Arguments

Plain client

Basic REST client used to interact with a running registry.

baseUrl

Custom HTTP client

Registry client using an OkHttpClient provided by the user.

baseUrl, okhttpClient

Custom configuration

Registry client that accepts a map containing custom configuration. This is useful, for example, to add custom headers to the calls.

baseUrl, Map<String Object> configs

Custom header configuration

To configure custom headers, you must add the apicurio.registry.request.headers prefix to the configs map key. For example, a key of apicurio.registry.request.headers.Authorization with a value of Basic: xxxxx results in a header of Authorization with value of Basic: xxxxx.

TLS configuration

You can configure Transport Layer Security (TLS) authentication for the Apicurio Registry Java client using the following properties:

  • apicurio.registry.request.ssl.truststore.location

  • apicurio.registry.request.ssl.truststore.password

  • apicurio.registry.request.ssl.truststore.type

  • apicurio.registry.request.ssl.keystore.location

  • apicurio.registry.request.ssl.keystore.password

  • apicurio.registry.request.ssl.keystore.type

  • apicurio.registry.request.ssl.key.password