JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'co.novu:co.novu.sdk:0.2.0'
Maven:
<dependency>
<groupId>co.novu</groupId>
<artifactId>co.novu.sdk</artifactId>
<version>0.2.0</version>
</dependency>
After cloning the git repository to your file system you can build the SDK artifact from source to the build
directory by running ./gradlew build
on *nix systems or gradlew.bat
on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signing
On Windows:
gradlew.bat publishToMavenLocal -Pskip.signing
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
TriggerEventRequestDto req = TriggerEventRequestDto.builder()
.name("workflow_identifier")
.to(java.util.List.of(
To.of(TopicPayloadDto.builder()
.topicKey("topic_key")
.type(TopicPayloadDtoType.TOPIC)
.build())))
.overrides(TriggerEventRequestDtoOverrides.builder()
.build())
.payload(TriggerEventRequestDtoPayload.builder()
.build())
.build();
EventsControllerTriggerResponse res = sdk.events().trigger()
.request(req)
.call();
if (res.triggerEventResponseDto().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
- list - Get api keys
- regenerate - Regenerate api keys
- cancel - Cancel triggered event
- trigger - Trigger event
- triggerBroadcast - Broadcast event to all
- triggerBulk - Bulk trigger event
- retrieve - Get execution details
- create - Create integration
- delete - Delete integration
- list - Get integrations
- listActive - Get active integrations
- setAsPrimary - Set integration as primary
- update - Update integration
- retrieve - Get webhook support status for provider
- create - Layout creation
- delete - Delete layout
- list - Filter layouts
- retrieve - Get layout
- setAsDefault - Set default layout
- update - Update a layout
- delete - Delete message
- deleteByTransactionId - Delete messages by transactionId
- retrieve - Get messages
- create - Create workflow group
- delete - Delete workflow group
- list - Get workflow groups
- retrieve - Get workflow group
- update - Update workflow group
- create - Create an organization
- list - Fetch all organizations
- rename - Rename organization name
- retrieve - Fetch current organization details
- update - Update organization branding details
- delete - Remove a member from organization using memberId
- list - Fetch all members of current organizations
- create - Create subscriber
- createBulk - Bulk create subscribers
- delete - Delete subscriber
- list - Get subscribers
- retrieve - Get subscriber
- update - Update subscriber
- append - Modify subscriber credentials
- delete - Delete subscriber credentials by providerId
- update - Update subscriber credentials
- chatAccessOauth - Handle chat oauth
- chatAccessOauthCallBack - Handle providers oauth redirect
- markAll - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
- markAllAs - Mark a subscriber messages as seen, read, unseen or unread
- updateAsSeen - Mark message action as seen
- retrieve - Get in-app notification feed for a particular subscriber
- unseenCount - Get the unseen in-app notifications count for subscribers feed
- updateOnlineFlag - Update subscriber online status
- list - Get subscriber preferences
- retrieveByLevel - Get subscriber preferences by level
- update - Update subscriber preference
- updateGlobal - Update subscriber global preferences
- create - Create tenant
- delete - Delete tenant
- list - Get tenants
- retrieve - Get tenant
- update - Update tenant
- create - Topic creation
- delete - Delete topic
- list - Filter topics
- rename - Rename a topic
- retrieve - Get topic
- create - Create workflow
- delete - Delete workflow
- list - Get workflows
- retrieve - Get workflow
- update - Update workflow
- retrieve - Get available variables
- update - Update workflow status
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a next
method that can be called to pull down the next group of results. The next
function returns an Optional
value, which isPresent
until there are no more pages to be fetched.
Here's an example of one such pagination call:
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
SubscribersControllerListSubscribersResponse res = sdk.subscribers().list()
.page(7685.78d)
.limit(10d)
.call();
while (true) {
if (res.object().isPresent()) {
// handle response
Optional<SubscribersControllerListSubscribersResponse> nextRes = res.next();
if (nextRes.isPresent()) {
res = nextRes.get();
} else {
break;
}
}
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, you can provide a RetryConfig
object through the retryConfig
builder method:
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.BackoffStrategy;
import co.novu.co.novu.sdk.utils.EventStream;
import co.novu.co.novu.sdk.utils.RetryConfig;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.retryConfig(RetryConfig.builder()
.backoff(BackoffStrategy.builder()
.initialInterval(1L, TimeUnit.MILLISECONDS)
.maxInterval(50L, TimeUnit.MILLISECONDS)
.maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
.baseFactor(1.1)
.jitterFactor(0.15)
.retryConnectError(false)
.build())
.build())
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
If you'd like to override the default retry strategy for all operations that support retries, you can provide a configuration at SDK initialization:
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.BackoffStrategy;
import co.novu.co.novu.sdk.utils.EventStream;
import co.novu.co.novu.sdk.utils.RetryConfig;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.retryConfig(RetryConfig.builder()
.backoff(BackoffStrategy.builder()
.initialInterval(1L, TimeUnit.MILLISECONDS)
.maxInterval(50L, TimeUnit.MILLISECONDS)
.maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
.baseFactor(1.1)
.jitterFactor(0.15)
.retryConnectError(false)
.build())
.build())
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Exception type.
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
You can override the default server globally by passing a server index to the serverIndex
builder method when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://api.novu.co |
None |
1 | https://eu.api.novu.co |
None |
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.serverIndex(1)
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
The default server can also be overridden globally by passing a URL to the serverURL
builder method when initializing the SDK client instance. For example:
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.serverURL("https://api.novu.co")
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
apiKey |
apiKey | API key |
To authenticate with the API the apiKey
parameter must be set when initializing the SDK client instance. For example:
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
ChangesControllerApplyDiffResponse res = sdk.changes().apply()
.changeId("<value>")
.call();
if (res.changeResponseDtos().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!