API Documentation

The documentation for the SwiftyRx can be found at https://acme.swiftyrx.dev/api/ui/

Client Installation

The Java client is published to Maven Central as com.rxfoundry.clients:swifty-api. One artifact holds both the main API client (com.rxfoundry.clients.swifty) and the OAuth client (com.rxfoundry.clients.swifty_oauth). It needs Java 11 or later.

Each build of a release branch (release/X.Y.Z, the rc-X.Y.Z.N candidates) that builds new images publishes the client as X.Y.Z.N, the same version as the build. Release versions are on Maven Central itself, so no extra repository is needed: Maven resolves from it by default, and Gradle with mavenCentral(). They are permanent: a version is never replaced or removed, so a pinned version always builds the same way. The first are 1.20.0.N versions, from Ibis (1.20) builds; the published ones are listed at https://central.sonatype.com/artifact/com.rxfoundry.clients/swifty-api.

Use the version of the SwiftyRx you call. Every environment reports it, without authentication, at GET /swifty/1/version, for example:

$ curl https://<tenant>.<environment host>/swifty/1/version
{"version": "1.20.0.7067"}

Depend on that version, replacing X.Y.Z.N below. If it isn’t listed on Central (a build that changed no images publishes nothing, and the environment reports the build of the image it runs), use the newest listed version of the same release. When an environment moves to a new build, move the dependency with it.

<dependency>
    <groupId>com.rxfoundry.clients</groupId>
    <artifactId>swifty-api</artifactId>
    <version>X.Y.Z.N</version>
</dependency>

The jar’s sources and Javadoc are published alongside it, and every file is signed with the RxFoundry release key.

Example Usage

Authorization

SwiftyOAuthApiWrapper.java
 1import com.rxfoundry.clients.swifty_oauth.ApiClient;
 2import com.rxfoundry.clients.swifty_oauth.ApiException;
 3import com.rxfoundry.clients.swifty_oauth.Configuration;
 4import com.rxfoundry.clients.swifty_oauth.api.OAuthApi;
 5import com.rxfoundry.clients.swifty_oauth.model.GetTokenRequest;
 6import com.rxfoundry.clients.swifty_oauth.model.TokenResponse;
 7
 8public class SwiftyOAuthApiWrapper {
 9    String host;
10    String scheme;
11    String port;
12
13    public SwiftyOAuthApiWrapper(String host, String scheme, String port) {
14        this.host = host;
15        this.scheme = scheme;
16        this.port = port;
17    }
18
19    public TokenResponse getAuthorizationToken(String username, String password){
20        // getting Authorization Token
21        ApiClient defaultClient = Configuration.getDefaultApiClient();
22
23        try {
24            defaultClient.setHost(this.host);
25            defaultClient.setPort(Integer.parseInt(this.port));
26            defaultClient.setScheme(this.scheme);
27
28            OAuthApi apiInstance = new OAuthApi(defaultClient);
29            GetTokenRequest getTokenRequest = new GetTokenRequest().username(username).password(password).grantType("password");
30
31            TokenResponse result = apiInstance.getToken(getTokenRequest);
32            System.out.println(result);
33            return result;
34        } catch (ApiException e) {
35            System.err.println("Exception when calling OAuthApi#getToken");
36            System.err.println("Status code: " + e.getCode());
37            System.err.println("Reason: " + e.getResponseBody());
38            System.err.println("Response headers: " + e.getResponseHeaders());
39            throw new RuntimeException("Failed to authorize to API", e);
40        } catch (NumberFormatException e) {
41            throw new RuntimeException("Port needs to be a valid integer", e);
42        }
43    }
44}

Full Example

A more complete example of using the Java SDK is forthcoming.