New KOBI documentation is available: https://adeo-ccdp.gitbook.io/kobi/

Requirements

  • Maven
  • Java 8
  • Spring Context
  • Spring WebFlux

Dependency

1
2
3
4
5
<dependency>
    <groupId>io.kobi</groupId>
    <artifactId>kobi-registry-api-client</artifactId>
    <version>2.6.18</version>
</dependency>

Configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
    "kobi.registration": {
        "base-url": "<Registry API url>",
        "headers": {
          "X-API-Key": "<Registry API key>"
        },
        "max-connections": 100,
        "connect-timeout": 500,
        "timeout": 5000,
        "max-in-memory-size": 1048576,
        "keep-alive": true,
        "tcp-no-delay": true,
        "insecure": false
    },
    "resilience4j.circuitbreaker": {
        "configs": {
            "registry": {
                <See resilience4j circuit breaker configuration>
            }
        }
  }
}
If the API key security is enable on the Resolver API, you need to set the “X-API-Key” header to be authorized with the right API Key.
If you are calling the API through a gateway, and you need to send custom headers you just have to set them into the headers' property as following:
“headers”: {
“a header”: “a header value”,
“another header”: “another header value”,
}
Note that in this case it’s the gateway which should set the “X-API-Key” header, so you don’t need to add it in your configuration.

Usage

In your Spring project, you need to allow Spring to scan the package “io.kobi.registry.client”.
After that you can import the Resolver API client bean (class: io.kobi.registry.client.api.RegistryApiClient).
Then use it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@Service
public class Service {
    private final RegistryApiClient registryApiClient;

    /**
     * Constructor with bean injection.
     * @param registryApiClient Registry rest client bean
     **/
    public Service(final RegistryApiClient registryApiClient) {
        this.registryApiClient = registryApiClient;
    }

    /**
     * Register an application in the registry.
     * @param application the application data.
     * @param activate if true activate application immediately, else a verification is made by registry before activating the application
     * @return a registered application mono.
     **/
    public Mono<ApplicationResource> registerApplication(final ApplicationResource application, final boolean activate) {
        return registryApiClient.applications()
                                .post(application, activate);
    }

    /**
     * Gets the sites and experiences using the application.
     * @param applicationId the application identifier.
     * @return a site and experience flux.
     **/
    public Flux<RegistrySearchResponse> getSitesAndExperiencesUsingApplication(final String applicationId) {
        return registryApiClient.application(applicationId)
                                .using()
                                .get();
    }

    /**
     * Gets all application matching the environment, the name and the version.
     * @param env the application environment.
     * @param name the application name.
     * @param version the application version.
     * @return an application flux.
     **/
    public Flux<ApplicationResource> getApplications(@Nullable final String env, @Nullable final String name, @Nullable final String version) {
        return registryApiClient.application()
                                .get(env, name, version);
    }


    /**
     * Gets sites configuration.
     * @param version the site configuration version filter, if null all versions.
     * @return a site configuration flux.
     **/
    public Flux<SiteConfigResource> getSiteConfigurations(@Nullable final String version) {
        return registryApiClient.sites()
                                .get(version);
    }

    /**
     * Gets site configuration.
     * @param siteId the site identifier.
     * @param version the site configuration version, if null current live version.
     * @return a site configuration mono
     **/
    public Mono<SiteConfigResource> getSiteConfiguration(final String siteId, @Nullable final String version) {
        return registryApiClient.sites(siteId)
                                .get(version);
    }

}
What's on this Page