Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 1680
configured_endpoints: 1681
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-22aa409339ba3ba4e61a86e7e94dc5a66082c5c20615d1d30e3b9499d6407e31.yml
openapi_spec_hash: e5eb84a55caa82c6dfdc82b7fbe3e8aa
config_hash: 713ebf60a015dd910800437b34425bea
config_hash: 6861676932ec6aacb336d1cdc59ca521
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7995,6 +7995,16 @@ Methods:

- <code title="patch /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status">client.workflows.instances.status.<a href="./src/resources/workflows/instances/status.ts">edit</a>(workflowName, instanceId, { ...params }) -> StatusEditResponse</code>

### Events

Types:

- <code><a href="./src/resources/workflows/instances/events.ts">EventCreateResponse</a></code>

Methods:

- <code title="post /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}">client.workflows.instances.events.<a href="./src/resources/workflows/instances/events.ts">create</a>(workflowName, instanceId, eventType, { ...params }) -> EventCreateResponse</code>

## Versions

Types:
Expand Down
43 changes: 43 additions & 0 deletions src/resources/workflows/instances/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../resource';
import * as Core from '../../../core';

export class Events extends APIResource {
/**
* Send event to instance
*/
create(
workflowName: string,
instanceId: string,
eventType: string,
params: EventCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<EventCreateResponse> {
const { account_id, body } = params ?? {};
return (
this._client.post(
`/accounts/${account_id}/workflows/${workflowName}/instances/${instanceId}/events/${eventType}`,
{ body: body, ...options },
) as Core.APIPromise<{ result: EventCreateResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

export type EventCreateResponse = unknown;

export interface EventCreateParams {
/**
* Path param:
*/
account_id: string;

/**
* Body param:
*/
body?: unknown;
}

export declare namespace Events {
export { type EventCreateResponse as EventCreateResponse, type EventCreateParams as EventCreateParams };
}
1 change: 1 addition & 0 deletions src/resources/workflows/instances/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Events, type EventCreateResponse, type EventCreateParams } from './events';
export {
InstanceListResponsesV4PagePaginationArray,
InstanceBulkResponsesSinglePage,
Expand Down
10 changes: 10 additions & 0 deletions src/resources/workflows/instances/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import { APIResource } from '../../../resource';
import * as Core from '../../../core';
import * as EventsAPI from './events';
import { EventCreateParams, EventCreateResponse, Events } from './events';
import * as StatusAPI from './status';
import { Status, StatusEditParams, StatusEditResponse } from './status';
import { SinglePage, V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination';

export class Instances extends APIResource {
status: StatusAPI.Status = new StatusAPI.Status(this._client);
events: EventsAPI.Events = new EventsAPI.Events(this._client);

/**
* Create a new workflow instance
Expand Down Expand Up @@ -356,6 +359,7 @@ export interface InstanceGetParams {
Instances.InstanceListResponsesV4PagePaginationArray = InstanceListResponsesV4PagePaginationArray;
Instances.InstanceBulkResponsesSinglePage = InstanceBulkResponsesSinglePage;
Instances.Status = Status;
Instances.Events = Events;

export declare namespace Instances {
export {
Expand All @@ -376,4 +380,10 @@ export declare namespace Instances {
type StatusEditResponse as StatusEditResponse,
type StatusEditParams as StatusEditParams,
};

export {
Events as Events,
type EventCreateResponse as EventCreateResponse,
type EventCreateParams as EventCreateParams,
};
}
32 changes: 32 additions & 0 deletions tests/api-resources/workflows/instances/events.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const client = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource events', () => {
test('create: only required params', async () => {
const responsePromise = client.workflows.instances.events.create('x', 'x', 'x', {
account_id: 'account_id',
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('create: required and optional params', async () => {
const response = await client.workflows.instances.events.create('x', 'x', 'x', {
account_id: 'account_id',
body: {},
});
});
});