Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 3.17 KB

README.md

File metadata and controls

116 lines (88 loc) · 3.17 KB
Pangea Logo

documentation Discourse

Pangea Java SDK

A Java SDK for integrating with Pangea services. Supports Java 11, 17, and 21.

Installation

GA releases

Via Gradle:

implementation("cloud.pangea:pangea-sdk:3.12.0")

Via Maven:

<dependency>
  <groupId>cloud.pangea</groupId>
  <artifactId>pangea-sdk</artifactId>
  <version>3.12.0</version>
</dependency>

Beta releases

Pre-release versions may be available with the beta denotation in the version number. These releases serve to preview beta services and APIs. Per Semantic Versioning, they are considered unstable and do not carry the same compatibility guarantees as stable releases. Beta changelog

Via Gradle:

implementation("cloud.pangea:pangea-sdk:3.8.0-beta-3")

Via Maven:

<dependency>
  <groupId>cloud.pangea</groupId>
  <artifactId>pangea-sdk</artifactId>
  <version>3.8.0-beta-3</version>
</dependency>

Usage

General usage would be to create a token for a service through the Pangea Console and then construct an API client for that respective service. The below example shows how this can be done for Secure Audit Log to log a simple event:

import cloud.pangeacyber.pangea.audit.AuditClient;
import cloud.pangeacyber.pangea.audit.models.StandardEvent;
import cloud.pangeacyber.pangea.audit.models.LogConfig;
import cloud.pangeacyber.pangea.audit.responses.LogResponse;
import cloud.pangeacyber.pangea.exceptions.ConfigException;
import cloud.pangeacyber.pangea.Config;

// ...

// Load client configuration from environment variables `PANGEA_AUDIT_TOKEN` and
// `PANGEA_DOMAIN`.
Config cfg = null;
try {
    cfg = Config.fromEnvironment(AuditClient.serviceName);
} catch (ConfigException e){
    // Handle error.
}

// Create a Secure Audit Log client.
var client = new AuditClient.Builder(cfg).build();

// Create a basic event.
var event = new StandardEvent.Builder("Hello, World!")
    .action("Login")
    .actor("Terminal")
    .build();

// Optional configuration.
var logConfig = new LogConfig.Builder().build();

// Log the event.
LogResponse response = null;
try {
    response = client.log(event, logConfig);
} catch (Exception e) {
    // Handle error.
}