Skip to content

Latest commit

 

History

History
258 lines (185 loc) · 14.9 KB

File metadata and controls

258 lines (185 loc) · 14.9 KB

Contexts

Overview

Available Operations

Create

Create a new context with the specified type, id, and data. Returns 409 if context already exists.

  **type** and **id** are required fields, **data** is optional, if the context already exists, it returns the 409 response

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Contexts.CreateAsync(createContextRequestDto: new CreateContextRequestDto() {
    Type = "tenant",
    Id = "org-acme",
    Data = new Dictionary<string, object>() {
        { "tenantName", "Acme Corp" },
        { "region", "us-east-1" },
        { "settings", new Dictionary<string, object>() {
            { "theme", "dark" },
        } },
    },
});

// handle response

Parameters

Parameter Type Required Description
CreateContextRequestDto CreateContextRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

ContextsControllerCreateContextResponse

Errors

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

List

Retrieve a paginated list of all contexts, optionally filtered by type and key pattern.

  **type** and **id** are optional fields, if provided, only contexts with the matching type and id will be returned.
  **search** is an optional field, if provided, only contexts with the matching key pattern will be returned.
  Checkout all possible parameters in the query section below for more details

Example Usage

using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

ContextsControllerListContextsRequest req = new ContextsControllerListContextsRequest() {
    Limit = 10D,
    Id = "tenant-prod-123",
    Search = "tenant",
};

var res = await sdk.Contexts.ListAsync(req);

// handle response

Parameters

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

Response

ContextsControllerListContextsResponse

Errors

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

Update

Update the data of an existing context. type and id are required fields, data is required. Only the data field is updated, the rest of the context is not affected. If the context does not exist, it returns the 404 response

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Contexts.UpdateAsync(
    id: "<id>",
    type: "<value>",
    updateContextRequestDto: new UpdateContextRequestDto() {
        Data = new Dictionary<string, object>() {
            { "tenantName", "Acme Corp" },
            { "region", "us-east-1" },
            { "settings", new Dictionary<string, object>() {
                { "theme", "dark" },
            } },
        },
    }
);

// handle response

Parameters

Parameter Type Required Description
Id string ✔️ Context ID
Type string ✔️ Context type
UpdateContextRequestDto UpdateContextRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

ContextsControllerUpdateContextResponse

Errors

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

Retrieve

Retrieve a specific context by its type and id. type and id are required fields, if the context does not exist, it returns the 404 response

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Contexts.RetrieveAsync(
    id: "<id>",
    type: "<value>"
);

// handle response

Parameters

Parameter Type Required Description
Id string ✔️ Context ID
Type string ✔️ Context type
IdempotencyKey string A header for idempotency purposes

Response

ContextsControllerGetContextResponse

Errors

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

Delete

Delete a context by its type and id. type and id are required fields, if the context does not exist, it returns the 404 response

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Contexts.DeleteAsync(
    id: "<id>",
    type: "<value>"
);

// handle response

Parameters

Parameter Type Required Description
Id string ✔️ Context ID
Type string ✔️ Context type
IdempotencyKey string A header for idempotency purposes

Response

ContextsControllerDeleteContextResponse

Errors

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