Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 11, 2024
1 parent 87135d2 commit 554b69e
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 66 deletions.
15 changes: 12 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4047,16 +4047,25 @@ Methods:

##### Settings

Types:

- <code><a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">SettingEditResponse</a></code>
- <code><a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">SettingGetResponse</a></code>

Methods:

- <code title="patch /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings">client.workersForPlatforms.dispatch.namespaces.scripts.settings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">edit</a>(dispatchNamespace, scriptName, { ...params }) -> ScriptSetting</code>
- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings">client.workersForPlatforms.dispatch.namespaces.scripts.settings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">get</a>(dispatchNamespace, scriptName, { ...params }) -> ScriptSetting</code>
- <code title="patch /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings">client.workersForPlatforms.dispatch.namespaces.scripts.settings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">edit</a>(dispatchNamespace, scriptName, { ...params }) -> SettingEditResponse</code>
- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/settings">client.workersForPlatforms.dispatch.namespaces.scripts.settings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/settings.ts">get</a>(dispatchNamespace, scriptName, { ...params }) -> SettingGetResponse</code>

##### Bindings

Types:

- <code><a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts">BindingGetResponse</a></code>

Methods:

- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings">client.workersForPlatforms.dispatch.namespaces.scripts.bindings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts">get</a>(dispatchNamespace, scriptName, { ...params }) -> Binding</code>
- <code title="get /accounts/{account_id}/workers/dispatch/namespaces/{dispatch_namespace}/scripts/{script_name}/bindings">client.workersForPlatforms.dispatch.namespaces.scripts.bindings.<a href="./src/resources/workers-for-platforms/dispatch/namespaces/scripts/bindings.ts">get</a>(dispatchNamespace, scriptName, { ...params }) -> BindingGetResponse</code>

# ZeroTrust

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Namespaces extends APIResource {
}

/**
* Fetch a Workers for Platforms namespace.
* Get a Workers for Platforms namespace.
*/
get(
dispatchNamespace: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ export class Bindings extends APIResource {
scriptName: string,
params: BindingGetParams,
options?: Core.RequestOptions,
): Core.APIPromise<WorkersAPI.Binding> {
): Core.APIPromise<BindingGetResponse> {
const { account_id } = params;
return this._client.get(
`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/bindings`,
options,
);
return (
this._client.get(
`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/bindings`,
options,
) as Core.APIPromise<{ result: BindingGetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

/**
* List of bindings attached to this Worker
*/
export type BindingGetResponse = Array<WorkersAPI.Binding>;

export interface BindingGetParams {
/**
* Identifier
Expand All @@ -32,5 +39,6 @@ export interface BindingGetParams {
}

export namespace Bindings {
export import BindingGetResponse = BindingsAPI.BindingGetResponse;
export import BindingGetParams = BindingsAPI.BindingGetParams;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export interface ContentUpdateParams {
* module must be present. This should be referenced either in the metadata as
* `main_module` (esm)/`body_part` (service worker) or as a header
* `CF-WORKER-MAIN-MODULE-PART` (esm) /`CF-WORKER-BODY-PART` (service worker) by
* part name.
* part name. Source maps may also be included using the `application/source-map`
* content type.
*/
'<any part name>'?: Array<Uploadable>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { BindingGetParams, Bindings } from './bindings';
export { BindingGetResponse, BindingGetParams, Bindings } from './bindings';
export { ContentUpdateParams, ContentGetParams, Content } from './content';
export { Script, ScriptUpdateParams, ScriptDeleteParams, ScriptGetParams, Scripts } from './scripts';
export { SettingEditParams, SettingGetParams, Settings } from './settings';
export {
SettingEditResponse,
SettingGetResponse,
SettingEditParams,
SettingGetParams,
Settings,
} from './settings';
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export class Scripts extends APIResource {
bindings: BindingsAPI.Bindings = new BindingsAPI.Bindings(this._client);

/**
* Upload a worker module to a Workers for Platforms namespace.
* Upload a worker module to a Workers for Platforms namespace. You can find an
* example of the metadata on our docs:
* https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/metadata/
*/
update(
dispatchNamespace: string,
Expand Down Expand Up @@ -105,7 +107,8 @@ export namespace ScriptUpdateParams {
* Body param: A module comprising a Worker script, often a javascript file.
* Multiple modules may be provided as separate named parts, but at least one
* module must be present and referenced in the metadata as `main_module` or
* `body_part` by part name.
* `body_part` by part name. Source maps may also be included using the
* `application/source-map` content type.
*/
'<any part name>'?: Array<Uploadable>;

Expand Down Expand Up @@ -240,8 +243,11 @@ export namespace Scripts {
export import ContentUpdateParams = ContentAPI.ContentUpdateParams;
export import ContentGetParams = ContentAPI.ContentGetParams;
export import Settings = SettingsAPI.Settings;
export import SettingEditResponse = SettingsAPI.SettingEditResponse;
export import SettingGetResponse = SettingsAPI.SettingGetResponse;
export import SettingEditParams = SettingsAPI.SettingEditParams;
export import SettingGetParams = SettingsAPI.SettingGetParams;
export import Bindings = BindingsAPI.Bindings;
export import BindingGetResponse = BindingsAPI.BindingGetResponse;
export import BindingGetParams = BindingsAPI.BindingGetParams;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import * as SettingsAPI from 'cloudflare/resources/workers-for-platforms/dispatch/namespaces/scripts/settings';
import * as Shared from 'cloudflare/resources/shared';
import * as ScriptsAPI from 'cloudflare/resources/workers/scripts/scripts';
import * as WorkersAPI from 'cloudflare/resources/workers/workers';
import * as TailAPI from 'cloudflare/resources/workers/scripts/tail';
import { multipartFormRequestOptions } from 'cloudflare/core';

export class Settings extends APIResource {
/**
Expand All @@ -15,13 +16,13 @@ export class Settings extends APIResource {
scriptName: string,
params: SettingEditParams,
options?: Core.RequestOptions,
): Core.APIPromise<ScriptsAPI.ScriptSetting> {
): Core.APIPromise<SettingEditResponse> {
const { account_id, ...body } = params;
return (
this._client.patch(
`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/settings`,
{ body, ...options },
) as Core.APIPromise<{ result: ScriptsAPI.ScriptSetting }>
multipartFormRequestOptions({ body, ...options }),
) as Core.APIPromise<{ result: SettingEditResponse }>
)._thenUnwrap((obj) => obj.result);
}

Expand All @@ -33,42 +34,212 @@ export class Settings extends APIResource {
scriptName: string,
params: SettingGetParams,
options?: Core.RequestOptions,
): Core.APIPromise<ScriptsAPI.ScriptSetting> {
): Core.APIPromise<SettingGetResponse> {
const { account_id } = params;
return (
this._client.get(
`/accounts/${account_id}/workers/dispatch/namespaces/${dispatchNamespace}/scripts/${scriptName}/settings`,
options,
) as Core.APIPromise<{ result: ScriptsAPI.ScriptSetting }>
) as Core.APIPromise<{ result: SettingGetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

export interface SettingEditParams {
export interface SettingEditResponse {
/**
* Path param: Identifier
* List of bindings attached to this Worker
*/
account_id: string;
bindings?: Array<WorkersAPI.Binding>;

/**
* Body param:
* Opt your Worker into changes after this date
*/
errors: Array<Shared.ResponseInfo>;
compatibility_date?: string;

/**
* Body param:
* Opt your Worker into specific changes
*/
messages: Array<Shared.ResponseInfo>;
compatibility_flags?: Array<string>;

/**
* Body param:
* Limits to apply for this Worker.
*/
limits?: SettingEditResponse.Limits;

/**
* Whether Logpush is turned on for the Worker.
*/
logpush?: boolean;

/**
* Migrations to apply for Durable Objects associated with this Worker.
*/
migrations?: WorkersAPI.SingleStepMigration | WorkersAPI.SteppedMigration;

placement?: WorkersAPI.PlacementConfiguration;

/**
* Tags to help you manage your Workers
*/
tags?: Array<string>;

/**
* List of Workers that will consume logs from the attached Worker.
*/
tail_consumers?: Array<TailAPI.ConsumerScript>;

/**
* Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound').
*/
result: ScriptsAPI.ScriptSetting;
usage_model?: string;
}

export namespace SettingEditResponse {
/**
* Body param: Whether the API call was successful
* Limits to apply for this Worker.
*/
success: true;
export interface Limits {
/**
* The amount of CPU time this Worker can use in milliseconds.
*/
cpu_ms?: number;
}
}

export interface SettingGetResponse {
/**
* List of bindings attached to this Worker
*/
bindings?: Array<WorkersAPI.Binding>;

/**
* Opt your Worker into changes after this date
*/
compatibility_date?: string;

/**
* Opt your Worker into specific changes
*/
compatibility_flags?: Array<string>;

/**
* Limits to apply for this Worker.
*/
limits?: SettingGetResponse.Limits;

/**
* Whether Logpush is turned on for the Worker.
*/
logpush?: boolean;

/**
* Migrations to apply for Durable Objects associated with this Worker.
*/
migrations?: WorkersAPI.SingleStepMigration | WorkersAPI.SteppedMigration;

placement?: WorkersAPI.PlacementConfiguration;

/**
* Tags to help you manage your Workers
*/
tags?: Array<string>;

/**
* List of Workers that will consume logs from the attached Worker.
*/
tail_consumers?: Array<TailAPI.ConsumerScript>;

/**
* Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound').
*/
usage_model?: string;
}

export namespace SettingGetResponse {
/**
* Limits to apply for this Worker.
*/
export interface Limits {
/**
* The amount of CPU time this Worker can use in milliseconds.
*/
cpu_ms?: number;
}
}

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

/**
* Body param:
*/
settings?: SettingEditParams.Settings;
}

export namespace SettingEditParams {
export interface Settings {
/**
* List of bindings attached to this Worker
*/
bindings?: Array<WorkersAPI.Binding>;

/**
* Opt your Worker into changes after this date
*/
compatibility_date?: string;

/**
* Opt your Worker into specific changes
*/
compatibility_flags?: Array<string>;

/**
* Limits to apply for this Worker.
*/
limits?: Settings.Limits;

/**
* Whether Logpush is turned on for the Worker.
*/
logpush?: boolean;

/**
* Migrations to apply for Durable Objects associated with this Worker.
*/
migrations?: WorkersAPI.SingleStepMigration | WorkersAPI.SteppedMigration;

placement?: WorkersAPI.PlacementConfiguration;

/**
* Tags to help you manage your Workers
*/
tags?: Array<string>;

/**
* List of Workers that will consume logs from the attached Worker.
*/
tail_consumers?: Array<TailAPI.ConsumerScript>;

/**
* Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound').
*/
usage_model?: string;
}

export namespace Settings {
/**
* Limits to apply for this Worker.
*/
export interface Limits {
/**
* The amount of CPU time this Worker can use in milliseconds.
*/
cpu_ms?: number;
}
}
}

export interface SettingGetParams {
Expand All @@ -79,6 +250,8 @@ export interface SettingGetParams {
}

export namespace Settings {
export import SettingEditResponse = SettingsAPI.SettingEditResponse;
export import SettingGetResponse = SettingsAPI.SettingGetResponse;
export import SettingEditParams = SettingsAPI.SettingEditParams;
export import SettingGetParams = SettingsAPI.SettingGetParams;
}
Loading

0 comments on commit 554b69e

Please sign in to comment.