Skip to content

Java API clients for the POMS Rest API's (Frontend API, Backend API, Pages Publisher)

License

Notifications You must be signed in to change notification settings

npo-poms/api-clients

Repository files navigation

api-clients

Table of Contents

Build Status Maven Central codecov javadoc snapshots

Java API clients for the POMS Rest API’s (Frontend API, Backend API, Pages Publisher)

The clients are basicly generated using resteasy to proxy the actual service interface, and they are decorated with some interceptors and similar techniques to arrange the appropriate authentication, to let the generated client automaticly fill common parameters, and things like that.

We also add a common way to instantiate (using the builder pattern) and configure them.

It is split up in several modules. These are the important ones:

bom

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>nl.vpro.poms</groupId>
        <artifactId>poms-bom</artifactId>
        <version>8.0-SNAPSHOT</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>


...
<dependencies>
  <dependency>
    <groupId>nl.vpro.poms.api-clients</groupId>
    <artifactId>frontend-api-client</artifactId>
  </dependency>
  <dependency>
    <groupId>nl.vpro.poms.api-clients</groupId>
    <artifactId>media-backend-api-client</artifactId>
  </dependency>
  <dependency>
    <groupId>nl.vpro.poms.api-clients</groupId>
    <artifactId>pages-backend-api-client</artifactId>
  </dependency>
  <dependency>
    <groupId>nl.vpro.poms.api-clients</groupId>
    <artifactId>client-extras</artifactId>
  </dependency>
</dependencies>

configuration

The clients can be configured by code and/or a configuration file in ${user.home}/conf/apiclient.properties.

frontend api
    NpoApiClients clients = NpoApiClients.configured(nl.vpro.util.Env.TEST).build();
    NpoApiMediaUtil util = new NpoApiMediaUtil(clients);
    try(CloseableIterator<MediaObject> i = util.iterate(null, "vpro-predictions")) {
      i.forEachRemaining(mediaObject -> {
         log.info("{}", i.next());
      });
    }
backend api
 try (var client = MediaRestClient.configured(Env.PROD).build()) {
    MediaObject mediaObject = client.getFull("WO_VPRO_025678");
    log.info("{}", mediaObject);
 }

There are also 'providers' available to configure them easily via spring XML’s or for example XML’s of magnolia CMS (which uses guice)

Versions

Version java

>= 8.x

jakarta.*, java 17

7.11 branch

support for javax will be from here.

>= 7.5.x

java 17

7.4.x

java 11

TODO

  • Document how to wire via spring xml

About

Java API clients for the POMS Rest API's (Frontend API, Backend API, Pages Publisher)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages