Skip to content

Latest commit

 

History

History
352 lines (253 loc) · 21.7 KB

File metadata and controls

352 lines (253 loc) · 21.7 KB

EnvironmentVariables

Overview

Available Operations

  • list - List all variables
  • create - Create a variable
  • retrieve - Get environment variable
  • update - Update a variable
  • delete - Delete environment variable
  • usage - Retrieve a variable usage

list

Returns all environment variables for the current organization. Secret values are masked.

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.EnvironmentVariablesControllerListEnvironmentVariablesResponse;
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();

        EnvironmentVariablesControllerListEnvironmentVariablesResponse res = sdk.environmentVariables().list()
                .call();

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

Parameters

Parameter Type Required Description
search Optional<String> Filter variables by key (case-insensitive partial match)
idempotencyKey Optional<String> A header for idempotency purposes

Response

EnvironmentVariablesControllerListEnvironmentVariablesResponse

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 */*

create

Creates a new environment variable. Keys must be uppercase with underscores only (e.g. BASE_URL). Secret variables are encrypted at rest and masked in API responses.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.CreateEnvironmentVariableRequestDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentVariablesControllerCreateEnvironmentVariableResponse;
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();

        EnvironmentVariablesControllerCreateEnvironmentVariableResponse res = sdk.environmentVariables().create()
                .body(CreateEnvironmentVariableRequestDto.builder()
                    .key("<key>")
                    .build())
                .call();

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

Parameters

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

Response

EnvironmentVariablesControllerCreateEnvironmentVariableResponse

Errors

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

retrieve

Returns a single environment variable by key. Secret values are masked.

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.EnvironmentVariablesControllerGetEnvironmentVariableResponse;
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();

        EnvironmentVariablesControllerGetEnvironmentVariableResponse res = sdk.environmentVariables().retrieve()
                .variableKey("BASE_URL")
                .call();

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

Parameters

Parameter Type Required Description Example
variableKey String ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotencyKey Optional<String> A header for idempotency purposes

Response

EnvironmentVariablesControllerGetEnvironmentVariableResponse

Errors

Error Type Status Code Content Type
models/errors/ErrorDto 414 application/json
models/errors/ErrorDto 400, 401, 403, 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 an existing environment variable. Providing values replaces all existing per-environment values.

Example Usage

package hello.world;

import co.novu.Novu;
import co.novu.models.components.UpdateEnvironmentVariableRequestDto;
import co.novu.models.errors.ErrorDto;
import co.novu.models.errors.ValidationErrorDto;
import co.novu.models.operations.EnvironmentVariablesControllerUpdateEnvironmentVariableResponse;
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();

        EnvironmentVariablesControllerUpdateEnvironmentVariableResponse res = sdk.environmentVariables().update()
                .variableKey("BASE_URL")
                .body(UpdateEnvironmentVariableRequestDto.builder()
                    .build())
                .call();

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

Parameters

Parameter Type Required Description Example
variableKey String ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotencyKey Optional<String> A header for idempotency purposes
body UpdateEnvironmentVariableRequestDto ✔️ N/A

Response

EnvironmentVariablesControllerUpdateEnvironmentVariableResponse

Errors

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

delete

Deletes an environment variable by key.

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.EnvironmentVariablesControllerDeleteEnvironmentVariableResponse;
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();

        EnvironmentVariablesControllerDeleteEnvironmentVariableResponse res = sdk.environmentVariables().delete()
                .variableKey("BASE_URL")
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description Example
variableKey String ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotencyKey Optional<String> A header for idempotency purposes

Response

EnvironmentVariablesControllerDeleteEnvironmentVariableResponse

Errors

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

usage

Returns the workflows that reference this environment variable via {{env.KEY}} in their step controls. variableId is required.

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.EnvironmentVariablesControllerGetEnvironmentVariableUsageResponse;
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();

        EnvironmentVariablesControllerGetEnvironmentVariableUsageResponse res = sdk.environmentVariables().usage()
                .variableKey("BASE_URL")
                .call();

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

Parameters

Parameter Type Required Description Example
variableKey String ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotencyKey Optional<String> A header for idempotency purposes

Response

EnvironmentVariablesControllerGetEnvironmentVariableUsageResponse

Errors

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