Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 15, 2024
1 parent c3f1288 commit 94c67b4
Show file tree
Hide file tree
Showing 13 changed files with 359 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1256
configured_endpoints: 1259
26 changes: 26 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6357,3 +6357,29 @@ Methods:
- <code title="delete /accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}">client.cloudforceOne.requests.priority.<a href="./src/resources/cloudforce-one/requests/priority.ts">delete</a>(accountIdentifier, priorityIdentifer) -> PriorityDeleteResponse</code>
- <code title="get /accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}">client.cloudforceOne.requests.priority.<a href="./src/resources/cloudforce-one/requests/priority.ts">get</a>(accountIdentifier, priorityIdentifer) -> Item</code>
- <code title="get /accounts/{account_identifier}/cloudforce-one/requests/priority/quota">client.cloudforceOne.requests.priority.<a href="./src/resources/cloudforce-one/requests/priority.ts">quota</a>(accountIdentifier) -> Quota</code>

# EventNotifications

## R2

### Configuration

Types:

- <code><a href="./src/resources/event-notifications/r2/configuration/configuration.ts">ConfigurationGetResponse</a></code>

Methods:

- <code title="get /accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration">client.eventNotifications.r2.configuration.<a href="./src/resources/event-notifications/r2/configuration/configuration.ts">get</a>(bucketName, { ...params }) -> ConfigurationGetResponse</code>

#### Queues

Types:

- <code><a href="./src/resources/event-notifications/r2/configuration/queues.ts">QueueUpdateResponse</a></code>
- <code><a href="./src/resources/event-notifications/r2/configuration/queues.ts">QueueDeleteResponse</a></code>

Methods:

- <code title="put /accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}">client.eventNotifications.r2.configuration.queues.<a href="./src/resources/event-notifications/r2/configuration/queues.ts">update</a>(bucketName, queueId, { ...params }) -> QueueUpdateResponse</code>
- <code title="delete /accounts/{account_id}/event_notifications/r2/{bucket_name}/configuration/queues/{queue_id}">client.eventNotifications.r2.configuration.queues.<a href="./src/resources/event-notifications/r2/configuration/queues.ts">delete</a>(bucketName, queueId, { ...params }) -> QueueDeleteResponse</code>
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class Cloudflare extends Core.APIClient {
snippets: API.Snippets = new API.Snippets(this);
calls: API.Calls = new API.Calls(this);
cloudforceOne: API.CloudforceOne = new API.CloudforceOne(this);
eventNotifications: API.EventNotifications = new API.EventNotifications(this);

protected override defaultQuery(): Core.DefaultQuery | undefined {
return this._options.defaultQuery;
Expand Down Expand Up @@ -549,6 +550,8 @@ export namespace Cloudflare {

export import CloudforceOne = API.CloudforceOne;

export import EventNotifications = API.EventNotifications;

export import AuditLog = API.AuditLog;
export import CloudflareTunnel = API.CloudflareTunnel;
export import ErrorData = API.ErrorData;
Expand Down
12 changes: 12 additions & 0 deletions src/resources/event-notifications/event-notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from 'cloudflare/resource';
import * as R2API from 'cloudflare/resources/event-notifications/r2/r2';

export class EventNotifications extends APIResource {
r2: R2API.R2 = new R2API.R2(this._client);
}

export namespace EventNotifications {
export import R2 = R2API.R2;
}
4 changes: 4 additions & 0 deletions src/resources/event-notifications/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { EventNotifications } from './event-notifications';
export { R2 } from './r2/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import * as ConfigurationAPI from 'cloudflare/resources/event-notifications/r2/configuration/configuration';
import * as QueuesAPI from 'cloudflare/resources/event-notifications/r2/configuration/queues';

export class Configuration extends APIResource {
queues: QueuesAPI.Queues = new QueuesAPI.Queues(this._client);

/**
* Returns all notification rules for each queue for which bucket notifications are
* produced.
*/
get(
bucketName: string,
params: ConfigurationGetParams,
options?: Core.RequestOptions,
): Core.APIPromise<ConfigurationGetResponse> {
const { account_id } = params;
return (
this._client.get(
`/accounts/${account_id}/event_notifications/r2/${bucketName}/configuration`,
options,
) as Core.APIPromise<{ result: ConfigurationGetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

export type ConfigurationGetResponse = Record<string, Record<string, ConfigurationGetResponse.mq_detail>>;

export namespace ConfigurationGetResponse {
export interface mq_detail {
/**
* Queue ID that will receive notifications based on the configured rules
*/
queue: string;

/**
* Array of rules to drive notifications
*/
rules: Array<mq_detail.Rule>;
}

export namespace mq_detail {
export interface Rule {
/**
* Array of R2 object actions that will trigger notifications
*/
actions: Array<
'PutObject' | 'CopyObject' | 'DeleteObject' | 'CompleteMultipartUpload' | 'AbortMultipartUpload'
>;

/**
* Notifications will be sent only for objects with this prefix
*/
prefix?: string;

/**
* Notifications will be sent only for objects with this suffix
*/
suffix?: string;
}
}
}

export interface ConfigurationGetParams {
/**
* Identifier
*/
account_id: string;
}

export namespace Configuration {
export import ConfigurationGetResponse = ConfigurationAPI.ConfigurationGetResponse;
export import ConfigurationGetParams = ConfigurationAPI.ConfigurationGetParams;
export import Queues = QueuesAPI.Queues;
export import QueueUpdateResponse = QueuesAPI.QueueUpdateResponse;
export import QueueDeleteResponse = QueuesAPI.QueueDeleteResponse;
export import QueueUpdateParams = QueuesAPI.QueueUpdateParams;
export import QueueDeleteParams = QueuesAPI.QueueDeleteParams;
}
10 changes: 10 additions & 0 deletions src/resources/event-notifications/r2/configuration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { ConfigurationGetResponse, ConfigurationGetParams, Configuration } from './configuration';
export {
QueueUpdateResponse,
QueueDeleteResponse,
QueueUpdateParams,
QueueDeleteParams,
Queues,
} from './queues';
98 changes: 98 additions & 0 deletions src/resources/event-notifications/r2/configuration/queues.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import * as QueuesAPI from 'cloudflare/resources/event-notifications/r2/configuration/queues';

export class Queues extends APIResource {
/**
* Define the rules for a given queue which will determine event notification
* production.
*/
update(
bucketName: string,
queueId: string,
params: QueueUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<QueueUpdateResponse> {
const { account_id, ...body } = params;
return (
this._client.put(
`/accounts/${account_id}/event_notifications/r2/${bucketName}/configuration/queues/${queueId}`,
{ body, ...options },
) as Core.APIPromise<{ result: QueueUpdateResponse }>
)._thenUnwrap((obj) => obj.result);
}

/**
* Turn off all event notifications configured for delivery to a given queue. No
* further notifications will be produced for the queue once complete.
*/
delete(
bucketName: string,
queueId: string,
params: QueueDeleteParams,
options?: Core.RequestOptions,
): Core.APIPromise<QueueDeleteResponse> {
const { account_id } = params;
return (
this._client.delete(
`/accounts/${account_id}/event_notifications/r2/${bucketName}/configuration/queues/${queueId}`,
options,
) as Core.APIPromise<{ result: QueueDeleteResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

export interface QueueUpdateResponse {
event_notification_detail_id?: string;
}

export type QueueDeleteResponse = unknown | Array<unknown> | string;

export interface QueueUpdateParams {
/**
* Path param: Identifier
*/
account_id: string;

/**
* Body param: Array of rules to drive notifications
*/
rules?: Array<QueueUpdateParams.Rule>;
}

export namespace QueueUpdateParams {
export interface Rule {
/**
* Array of R2 object actions that will trigger notifications
*/
actions: Array<
'PutObject' | 'CopyObject' | 'DeleteObject' | 'CompleteMultipartUpload' | 'AbortMultipartUpload'
>;

/**
* Notifications will be sent only for objects with this prefix
*/
prefix?: string;

/**
* Notifications will be sent only for objects with this suffix
*/
suffix?: string;
}
}

export interface QueueDeleteParams {
/**
* Identifier
*/
account_id: string;
}

export namespace Queues {
export import QueueUpdateResponse = QueuesAPI.QueueUpdateResponse;
export import QueueDeleteResponse = QueuesAPI.QueueDeleteResponse;
export import QueueUpdateParams = QueuesAPI.QueueUpdateParams;
export import QueueDeleteParams = QueuesAPI.QueueDeleteParams;
}
4 changes: 4 additions & 0 deletions src/resources/event-notifications/r2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { ConfigurationGetResponse, ConfigurationGetParams, Configuration } from './configuration/index';
export { R2 } from './r2';
14 changes: 14 additions & 0 deletions src/resources/event-notifications/r2/r2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from 'cloudflare/resource';
import * as ConfigurationAPI from 'cloudflare/resources/event-notifications/r2/configuration/configuration';

export class R2 extends APIResource {
configuration: ConfigurationAPI.Configuration = new ConfigurationAPI.Configuration(this._client);
}

export namespace R2 {
export import Configuration = ConfigurationAPI.Configuration;
export import ConfigurationGetResponse = ConfigurationAPI.ConfigurationGetResponse;
export import ConfigurationGetParams = ConfigurationAPI.ConfigurationGetParams;
}
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { DNSSECResource } from './dnssec';
export { Diagnostics } from './diagnostics/diagnostics';
export { DurableObjects } from './durable-objects/durable-objects';
export { EmailRouting } from './email-routing/email-routing';
export { EventNotifications } from './event-notifications/event-notifications';
export { Filters } from './filters';
export { Firewall } from './firewall/firewall';
export { Healthchecks } from './healthchecks/healthchecks';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

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

describe('resource configuration', () => {
// skipped: tests are disabled for the time being
test.skip('get: only required params', async () => {
const responsePromise = cloudflare.eventNotifications.r2.configuration.get(
'023e105f4ecef8ad9ca31a8372d0c353',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);
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);
});

// skipped: tests are disabled for the time being
test.skip('get: required and optional params', async () => {
const response = await cloudflare.eventNotifications.r2.configuration.get(
'023e105f4ecef8ad9ca31a8372d0c353',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

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

describe('resource queues', () => {
// skipped: tests are disabled for the time being
test.skip('update: only required params', async () => {
const responsePromise = cloudflare.eventNotifications.r2.configuration.queues.update(
'023e105f4ecef8ad9ca31a8372d0c353',
'023e105f4ecef8ad9ca31a8372d0c353',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);
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);
});

// skipped: tests are disabled for the time being
test.skip('update: required and optional params', async () => {
const response = await cloudflare.eventNotifications.r2.configuration.queues.update(
'023e105f4ecef8ad9ca31a8372d0c353',
'023e105f4ecef8ad9ca31a8372d0c353',
{
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
rules: [
{ actions: ['PutObject', 'CopyObject'], prefix: 'img/', suffix: '.jpeg' },
{ actions: ['PutObject', 'CopyObject'], prefix: 'img/', suffix: '.jpeg' },
{ actions: ['PutObject', 'CopyObject'], prefix: 'img/', suffix: '.jpeg' },
],
},
);
});

// skipped: tests are disabled for the time being
test.skip('delete: only required params', async () => {
const responsePromise = cloudflare.eventNotifications.r2.configuration.queues.delete(
'023e105f4ecef8ad9ca31a8372d0c353',
'023e105f4ecef8ad9ca31a8372d0c353',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);
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);
});

// skipped: tests are disabled for the time being
test.skip('delete: required and optional params', async () => {
const response = await cloudflare.eventNotifications.r2.configuration.queues.delete(
'023e105f4ecef8ad9ca31a8372d0c353',
'023e105f4ecef8ad9ca31a8372d0c353',
{ account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);
});
});

0 comments on commit 94c67b4

Please sign in to comment.