Skip to content

Latest commit

 

History

History
411 lines (288 loc) · 24.2 KB

File metadata and controls

411 lines (288 loc) · 24.2 KB

Environments

Overview

Environments allow you to manage different stages of your application development lifecycle. Each environment has its own set of API keys and configurations, enabling you to separate development, staging, and production workflows. https://docs.novu.co/platform/environments

Available Operations

  • getTags - List environment tags
  • diff - Compare resources between environments
  • publish - Publish resources to target environment
  • create - Create an environment
  • list - List all environments
  • update - Update an environment
  • delete - Delete an environment

getTags

Retrieve all unique tags used in workflows within the specified environment. These tags can be used for filtering workflows.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();



$response = $sdk->environments->getTags(
    environmentId: '6615943e7ace93b0540ae377'
);

if ($response->getEnvironmentTagsDtos !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
environmentId string ✔️ Environment internal ID (MongoDB ObjectId) or identifier 6615943e7ace93b0540ae377
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerGetEnvironmentTagsResponse

Errors

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

diff

Compares workflows and other resources between the source and target environments, returning detailed diff information including additions, modifications, and deletions.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$diffEnvironmentRequestDto = new Components\DiffEnvironmentRequestDto(
    sourceEnvironmentId: '507f1f77bcf86cd799439011',
);

$response = $sdk->environments->diff(
    targetEnvironmentId: '6615943e7ace93b0540ae377',
    diffEnvironmentRequestDto: $diffEnvironmentRequestDto

);

if ($response->diffEnvironmentResponseDto !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
targetEnvironmentId string ✔️ Target environment ID (MongoDB ObjectId) to compare against 6615943e7ace93b0540ae377
diffEnvironmentRequestDto Components\DiffEnvironmentRequestDto ✔️ Diff request configuration
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerDiffEnvironmentResponse

Errors

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

publish

Publishes all workflows and resources from the source environment to the target environment. Optionally specify specific resources to publish or use dryRun mode to preview changes.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$publishEnvironmentRequestDto = new Components\PublishEnvironmentRequestDto(
    sourceEnvironmentId: '507f1f77bcf86cd799439011',
    resources: [
        new Components\ResourceToPublishDto(
            resourceType: Components\ResourceTypeEnum::Regular,
            resourceId: 'workflow-id-1',
        ),
    ],
);

$response = $sdk->environments->publish(
    targetEnvironmentId: '6615943e7ace93b0540ae377',
    publishEnvironmentRequestDto: $publishEnvironmentRequestDto

);

if ($response->publishEnvironmentResponseDto !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
targetEnvironmentId string ✔️ Target environment ID (MongoDB ObjectId) to publish resources to 6615943e7ace93b0540ae377
publishEnvironmentRequestDto Components\PublishEnvironmentRequestDto ✔️ Publish request configuration
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerPublishEnvironmentResponse

Errors

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

create

Creates a new environment within the current organization. Environments allow you to manage different stages of your application development lifecycle. Each environment has its own set of API keys and configurations.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$createEnvironmentRequestDto = new Components\CreateEnvironmentRequestDto(
    name: 'Production Environment',
    parentId: '60d5ecb8b3b3a30015f3e1a1',
    color: '#3498db',
);

$response = $sdk->environments->create(
    createEnvironmentRequestDto: $createEnvironmentRequestDto
);

if ($response->environmentResponseDto !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
createEnvironmentRequestDto Components\CreateEnvironmentRequestDto ✔️ N/A
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerV1CreateEnvironmentResponse

Errors

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

list

This API returns a list of environments for the current organization. Each environment contains its configuration, API keys (if user has access), and metadata.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();



$response = $sdk->environments->list(

);

if ($response->environmentResponseDtos !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerV1ListMyEnvironmentsResponse

Errors

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

update

Update an environment by its unique identifier environmentId. You can modify the environment name, identifier, color, and other configuration settings.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$updateEnvironmentRequestDto = new Components\UpdateEnvironmentRequestDto();

$response = $sdk->environments->update(
    environmentId: '<id>',
    updateEnvironmentRequestDto: $updateEnvironmentRequestDto

);

if ($response->environmentResponseDto !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
environmentId string ✔️ The unique identifier of the environment
updateEnvironmentRequestDto Components\UpdateEnvironmentRequestDto ✔️ N/A
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerV1UpdateMyEnvironmentResponse

Errors

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

delete

Delete an environment by its unique identifier environmentId. This action is irreversible and will remove the environment and all its associated data.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use novu;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();



$response = $sdk->environments->delete(
    environmentId: '<id>'
);

if ($response->statusCode === 200) {
    // handle response
}

Parameters

Parameter Type Required Description
environmentId string ✔️ The unique identifier of the environment
idempotencyKey ?string A header for idempotency purposes

Response

?Operations\EnvironmentsControllerV1DeleteEnvironmentResponse

Errors

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