Skip to content

Latest commit

 

History

History
279 lines (186 loc) · 20.8 KB

File metadata and controls

279 lines (186 loc) · 20.8 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

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.list()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
search Optional[str] Filter variables by key (case-insensitive partial match)
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerListEnvironmentVariablesResponse

Errors

Error Type Status Code Content Type
models.ErrorDto 414 application/json
models.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
models.ValidationErrorDto 422 application/json
models.ErrorDto 500 application/json
models.APIError 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

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.create(create_environment_variable_request_dto={
        "key": "<key>",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
create_environment_variable_request_dto models.CreateEnvironmentVariableRequestDto ✔️ N/A
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerCreateEnvironmentVariableResponse

Errors

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

retrieve

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

Example Usage

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.retrieve(variable_key="BASE_URL")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
variable_key str ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerGetEnvironmentVariableResponse

Errors

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

update

Updates an existing environment variable. Providing values merges them into the existing per-environment values by _environmentId; envs not present in the request keep their stored value. Submitting the masked secret placeholder (the value returned by read endpoints for secret variables) as a real value is rejected.

Example Usage

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.update(variable_key="BASE_URL", update_environment_variable_request_dto={})

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
variable_key str ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
update_environment_variable_request_dto models.UpdateEnvironmentVariableRequestDto ✔️ N/A
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerUpdateEnvironmentVariableResponse

Errors

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

delete

Deletes an environment variable by key.

Example Usage

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.delete(variable_key="BASE_URL")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
variable_key str ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerDeleteEnvironmentVariableResponse

Errors

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

usage

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

Example Usage

from novu_py import Novu


with Novu(
    secret_key="YOUR_SECRET_KEY_HERE",
) as novu:

    res = novu.environment_variables.usage(variable_key="BASE_URL")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
variable_key str ✔️ The unique key of the environment variable (e.g. BASE_URL) BASE_URL
idempotency_key Optional[str] A header for idempotency purposes
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.EnvironmentVariablesControllerGetEnvironmentVariableUsageResponse

Errors

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