Skip to content

rootlyhq/rootly-java

Repository files navigation

rootly-java

Java client library for Rootly incident management platform, auto-generated from OpenAPI specifications.

Installation

Maven

Add this dependency to your project's POM:

<dependency>
  <groupId>com.rootly.client</groupId>
  <artifactId>rootly</artifactId>
  <version>0.0.4</version>
</dependency>

Gradle

Add this dependency to your project's build file:

dependencies {
    implementation 'com.rootly.client:rootly:0.0.4'
}

Local Installation

To install the API client library to your local Maven repository:

./gradlew publishToMavenLocal
# or
mvn clean install

Usage

import com.rootly.client.ApiClient;
import com.rootly.client.Configuration;
import com.rootly.client.auth.HttpBearerAuth;
import com.rootly.client.api.IncidentsApi;
import com.rootly.client.model.IncidentList;

public class Example {
    public static void main(String[] args) {
        // Create and configure the API client
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath("https://api.rootly.com");

        // Configure authentication
        HttpBearerAuth bearerAuth = (HttpBearerAuth) client.getAuthentication("bearer_auth");
        bearerAuth.setBearerToken("YOUR_API_TOKEN");

        // Use the client to make API calls
        IncidentsApi incidentsApi = new IncidentsApi(client);
        try {
            IncidentList incidents = incidentsApi.listIncidents(null, null, null);
            System.out.println(incidents);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Getting Your API Key

  1. Navigate to Organization dropdown > Organization Settings > API Keys
  2. Generate a new API key
  3. Use the token in your client configuration

Development

Prerequisites

Generating the Code

The SDK is auto-generated from the Rootly OpenAPI specification:

# Fetch latest spec and regenerate code
make build

This will:

  1. Fetch the OpenAPI spec from Rootly's S3 bucket
  2. Generate Java code using OpenAPI Generator
  3. Apply necessary patches

Building and Testing

  • Build: ./gradlew build or mvn clean package
  • Test: ./gradlew test or mvn test
  • Format code: ./gradlew spotlessApply or mvn spotless:apply

API Features

JSON:API Specification

Rootly uses the JSON:API specification:

  • Content-Type: application/vnd.api+json
  • Structured responses with data, attributes, and relationships
  • Standardized error handling

Rate Limiting

  • 3000 requests per 60-second sliding window (per API key)
  • Response headers include:
    • RateLimit-Limit: Maximum requests allowed
    • RateLimit-Remaining: Remaining requests in current window
    • RateLimit-Reset: UTC epoch seconds when window resets

Contact your Rootly Customer Success Manager to adjust limits.

Pagination

Use page[number] and page[size] query parameters:

// Example: Fetch page 2 with 25 items per page
IncidentList incidents = incidentsApi.listIncidents(
    25,      // page[size]
    2,       // page[number]
    null     // additional filters
);

Generated Code Structure

  • API Classes (com.rootly.client.api.*): Client implementations for all API endpoints
  • Model Classes (com.rootly.client.model.*): Data transfer objects for requests/responses
  • Core Client (com.rootly.client.ApiClient): HTTP client with authentication support
  • Authentication (com.rootly.client.auth.*): Bearer token, API key, and basic auth implementations

Contributing

This library is auto-generated from OpenAPI specifications. For API changes or issues:

  • Report bugs or request features in this repository
  • API specification changes should be directed to Rootly

Automatically generated by OpenAPI Generator

Packages

 
 
 

Languages