Skip to content

Latest commit

 

History

History
481 lines (364 loc) · 25.4 KB

File metadata and controls

481 lines (364 loc) · 25.4 KB

Workflows

Overview

All notifications are sent via a workflow. Each workflow acts as a container for the logic and blueprint that are associated with a type of notification in your system. https://docs.novu.co/workflows

Available Operations

create

Creates a new workflow in the Novu Cloud environment

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.*;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerCreateResponse;
import java.lang.Exception;
import java.util.List;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerCreateResponse res = sdk.workflows().create()
                .body(CreateWorkflowDto.builder()
                    .name("<value>")
                    .workflowId("<id>")
                    .steps(List.of())
                    .preferences(PreferencesRequestDto.builder()
                        .user(User.of(PreferencesRequestDtoWorkflowPreferencesDto.builder()
                            .all(PreferencesRequestDtoWorkflowPreferencesDtoAll.of(WorkflowPreferenceDto.builder()
                                .build()))
                            .channels(Map.ofEntries(
                                Map.entry("email", ChannelPreferenceDto.builder()
                                    .build()),
                                Map.entry("sms", ChannelPreferenceDto.builder()
                                    .enabled(false)
                                    .build())))
                            .build()))
                        .workflow(PreferencesRequestDtoWorkflow.builder()
                            .all(WorkflowAll.of(WorkflowPreferenceDto.builder()
                                .build()))
                            .channels(Map.ofEntries(
                                Map.entry("email", ChannelPreferenceDto.builder()
                                    .build()),
                                Map.entry("sms", ChannelPreferenceDto.builder()
                                    .enabled(false)
                                    .build())))
                            .build())
                        .build())
                    .build())
                .call();

        if (res.workflowResponseDto().isPresent()) {
            System.out.println(res.workflowResponseDto().get());
        }
    }
}

Parameters

Parameter Type Required Description
idempotencyKey Optional<String> A header for idempotency purposes
body CreateWorkflowDto ✔️ Workflow creation details

Response

WorkflowControllerCreateResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

list

Retrieves a list of workflows with optional filtering and pagination

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerSearchWorkflowsRequest;
import co.novu.models.operations.WorkflowControllerSearchWorkflowsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerSearchWorkflowsRequest req = WorkflowControllerSearchWorkflowsRequest.builder()
                .limit(10d)
                .offset(0d)
                .build();

        WorkflowControllerSearchWorkflowsResponse res = sdk.workflows().list()
                .request(req)
                .call();

        if (res.listWorkflowResponse().isPresent()) {
            System.out.println(res.listWorkflowResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request WorkflowControllerSearchWorkflowsRequest ✔️ The request object to use for the request.

Response

WorkflowControllerSearchWorkflowsResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

update

Updates the details of an existing workflow, here workflowId is the identifier of the workflow

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.*;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerUpdateResponse;
import java.lang.Exception;
import java.util.List;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerUpdateResponse res = sdk.workflows().update()
                .workflowId("<id>")
                .body(UpdateWorkflowDto.builder()
                    .name("<value>")
                    .steps(List.of())
                    .preferences(PreferencesRequestDto.builder()
                        .user(User.of(PreferencesRequestDtoWorkflowPreferencesDto.builder()
                            .all(PreferencesRequestDtoWorkflowPreferencesDtoAll.of(WorkflowPreferenceDto.builder()
                                .build()))
                            .channels(Map.ofEntries(
                                Map.entry("email", ChannelPreferenceDto.builder()
                                    .build()),
                                Map.entry("sms", ChannelPreferenceDto.builder()
                                    .enabled(false)
                                    .build())))
                            .build()))
                        .workflow(PreferencesRequestDtoWorkflow.builder()
                            .all(WorkflowAll.of(WorkflowPreferenceDto.builder()
                                .build()))
                            .channels(Map.ofEntries(
                                Map.entry("email", ChannelPreferenceDto.builder()
                                    .build()),
                                Map.entry("sms", ChannelPreferenceDto.builder()
                                    .enabled(false)
                                    .build())))
                            .build())
                        .build())
                    .origin(ResourceOriginEnum.EXTERNAL)
                    .build())
                .call();

        if (res.workflowResponseDto().isPresent()) {
            System.out.println(res.workflowResponseDto().get());
        }
    }
}

Parameters

Parameter Type Required Description
workflowId String ✔️ N/A
idempotencyKey Optional<String> A header for idempotency purposes
body UpdateWorkflowDto ✔️ Workflow update details

Response

WorkflowControllerUpdateResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

workflowDetails

Fetches details of a specific workflow by its unique identifier workflowId

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerGetWorkflowResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerGetWorkflowResponse res = sdk.workflows().workflowDetails()
                .workflowId("<id>")
                .call();

        if (res.workflowResponseDto().isPresent()) {
            System.out.println(res.workflowResponseDto().get());
        }
    }
}

Parameters

Parameter Type Required Description
workflowId String ✔️ N/A
environmentId Optional<String> N/A
idempotencyKey Optional<String> A header for idempotency purposes

Response

WorkflowControllerGetWorkflowResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

delete

Removes a specific workflow by its unique identifier workflowId

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerRemoveWorkflowResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerRemoveWorkflowResponse res = sdk.workflows().delete()
                .workflowId("<id>")
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
workflowId String ✔️ N/A
idempotencyKey Optional<String> A header for idempotency purposes

Response

WorkflowControllerRemoveWorkflowResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

modify

Partially updates a workflow by its unique identifier workflowId

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.PatchWorkflowDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerPatchWorkflowResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerPatchWorkflowResponse res = sdk.workflows().modify()
                .workflowId("<id>")
                .body(PatchWorkflowDto.builder()
                    .build())
                .call();

        if (res.workflowResponseDto().isPresent()) {
            System.out.println(res.workflowResponseDto().get());
        }
    }
}

Parameters

Parameter Type Required Description
workflowId String ✔️ N/A
idempotencyKey Optional<String> A header for idempotency purposes
body PatchWorkflowDto ✔️ Workflow patch details

Response

WorkflowControllerPatchWorkflowResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*

sync

Synchronizes a workflow to the target environment

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.SyncWorkflowDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.WorkflowControllerSyncResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ErrorDto, ValidationErrorDto, Exception {

        Novu sdk = Novu.builder()
                .secretKey("YOUR_SECRET_KEY_HERE")
            .build();

        WorkflowControllerSyncResponse res = sdk.workflows().sync()
                .workflowId("<id>")
                .body(SyncWorkflowDto.builder()
                    .targetEnvironmentId("<id>")
                    .build())
                .call();

        if (res.workflowResponseDto().isPresent()) {
            System.out.println(res.workflowResponseDto().get());
        }
    }
}

Parameters

Parameter Type Required Description
workflowId String ✔️ N/A
idempotencyKey Optional<String> A header for idempotency purposes
body SyncWorkflowDto ✔️ Sync workflow details

Response

WorkflowControllerSyncResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models/errors/ValidationErrorDto 422 application/json
models/errors/ErrorDto 500 application/json
models/errors/APIException 4XX, 5XX */*