Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Mar 21, 2024
1 parent 6bbd7bb commit 2274ba0
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 38 deletions.
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,51 @@ console.log(raw.headers.get('X-My-Header'));
console.log(zone.id);
```

## Customizing the fetch client
### Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented
endpoints, params, or response properties, the library can still be used.

#### Undocumented endpoints

To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
Options on the client, such as retries, will be respected when making these requests.

```ts
await client.post('/some/path', {
body: { some_prop: 'foo' },
query: { some_query_arg: 'bar' },
});
```

#### Undocumented params

To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
send will be sent as-is.

```ts
client.foo.create({
foo: 'my_param',
bar: 12,
// @ts-expect-error baz is not yet public
baz: 'undocumented option',
});
```

For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
extra param in the body.

If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
options.

#### Undocumented properties

To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
the response object, or cast the response object to the requisite type. Like the request params, we do not
validate or strip extra properties from the response from the API.

### Customizing the fetch client

By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.

Expand All @@ -219,6 +263,8 @@ import Cloudflare from 'cloudflare';
To do the inverse, add `import "cloudflare/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/cloudflare/cloudflare-typescript/tree/main/src/_shims#readme)).

### Logging and middleware

You may also provide a custom `fetch` function when instantiating the client,
which can be used to inspect or alter the `Request` or `Response` before/after each request:

Expand All @@ -239,7 +285,7 @@ const client = new Cloudflare({
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
This is intended for debugging purposes only and may change in the future without notice.

## Configuring an HTTP(S) Agent (e.g., for proxies)
### Configuring an HTTP(S) Agent (e.g., for proxies)

By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.

Expand Down
20 changes: 10 additions & 10 deletions src/resources/dns/records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export type DNSRecord =
| DNSRecord.A
| DNSRecord.AAAA
| DNSRecord.CAA
| DNSRecord.Cert
| DNSRecord.CERT
| DNSRecord.CNAME
| DNSRecord.DNSKEY
| DNSRecord.DS
Expand All @@ -183,7 +183,7 @@ export type DNSRecord =
| DNSRecord.NAPTR
| DNSRecord.NS
| DNSRecord.PTR
| DNSRecord.Smimea
| DNSRecord.SMIMEA
| DNSRecord.SRV
| DNSRecord.SSHFP
| DNSRecord.SVCB
Expand Down Expand Up @@ -511,11 +511,11 @@ export namespace DNSRecord {
}
}

export interface Cert {
export interface CERT {
/**
* Components of a CERT record.
*/
data: Cert.Data;
data: CERT.Data;

/**
* DNS record name (or @ for the zone apex) in Punycode.
Expand Down Expand Up @@ -557,7 +557,7 @@ export namespace DNSRecord {
/**
* Extra Cloudflare-specific information about the record.
*/
meta?: Cert.Meta;
meta?: CERT.Meta;

/**
* When the record was last modified.
Expand Down Expand Up @@ -592,7 +592,7 @@ export namespace DNSRecord {
zone_name?: string;
}

export namespace Cert {
export namespace CERT {
/**
* Components of a CERT record.
*/
Expand Down Expand Up @@ -1688,11 +1688,11 @@ export namespace DNSRecord {
}
}

export interface Smimea {
export interface SMIMEA {
/**
* Components of a SMIMEA record.
*/
data: Smimea.Data;
data: SMIMEA.Data;

/**
* DNS record name (or @ for the zone apex) in Punycode.
Expand Down Expand Up @@ -1734,7 +1734,7 @@ export namespace DNSRecord {
/**
* Extra Cloudflare-specific information about the record.
*/
meta?: Smimea.Meta;
meta?: SMIMEA.Meta;

/**
* When the record was last modified.
Expand Down Expand Up @@ -1769,7 +1769,7 @@ export namespace DNSRecord {
zone_name?: string;
}

export namespace Smimea {
export namespace SMIMEA {
/**
* Components of a SMIMEA record.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type BindingGetResponse =
| BindingGetResponse.WorkersQueueBinding
| BindingGetResponse.WorkersD1Binding
| BindingGetResponse.WorkersDispatchNamespaceBinding
| BindingGetResponse.WorkersMTLSCertBinding;
| BindingGetResponse.WorkersMTLSCERTBinding;

export namespace BindingGetResponse {
export interface WorkersKVNamespaceBinding {
Expand Down Expand Up @@ -221,7 +221,7 @@ export namespace BindingGetResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface SettingEditResponse {
| SettingEditResponse.WorkersQueueBinding
| SettingEditResponse.WorkersD1Binding
| SettingEditResponse.WorkersDispatchNamespaceBinding
| SettingEditResponse.WorkersMTLSCertBinding
| SettingEditResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -280,7 +280,7 @@ export namespace SettingEditResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -451,7 +451,7 @@ export interface SettingGetResponse {
| SettingGetResponse.WorkersQueueBinding
| SettingGetResponse.WorkersD1Binding
| SettingGetResponse.WorkersDispatchNamespaceBinding
| SettingGetResponse.WorkersMTLSCertBinding
| SettingGetResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -677,7 +677,7 @@ export namespace SettingGetResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -888,7 +888,7 @@ export namespace SettingEditParams {
| Result.WorkersQueueBinding
| Result.WorkersD1Binding
| Result.WorkersDispatchNamespaceBinding
| Result.WorkersMTLSCertBinding
| Result.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -1069,7 +1069,7 @@ export namespace SettingEditParams {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* The class of resource that the binding provides.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/resources/workers/scripts/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface SettingEditResponse {
| SettingEditResponse.WorkersQueueBinding
| SettingEditResponse.WorkersD1Binding
| SettingEditResponse.WorkersDispatchNamespaceBinding
| SettingEditResponse.WorkersMTLSCertBinding
| SettingEditResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -279,7 +279,7 @@ export namespace SettingEditResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -450,7 +450,7 @@ export interface SettingGetResponse {
| SettingGetResponse.WorkersQueueBinding
| SettingGetResponse.WorkersD1Binding
| SettingGetResponse.WorkersDispatchNamespaceBinding
| SettingGetResponse.WorkersMTLSCertBinding
| SettingGetResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -676,7 +676,7 @@ export namespace SettingGetResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -886,7 +886,7 @@ export namespace SettingEditParams {
| Result.WorkersQueueBinding
| Result.WorkersD1Binding
| Result.WorkersDispatchNamespaceBinding
| Result.WorkersMTLSCertBinding
| Result.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -1067,7 +1067,7 @@ export namespace SettingEditParams {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* The class of resource that the binding provides.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/resources/workers/services/environments/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface SettingEditResponse {
| SettingEditResponse.WorkersQueueBinding
| SettingEditResponse.WorkersD1Binding
| SettingEditResponse.WorkersDispatchNamespaceBinding
| SettingEditResponse.WorkersMTLSCertBinding
| SettingEditResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -280,7 +280,7 @@ export namespace SettingEditResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -451,7 +451,7 @@ export interface SettingGetResponse {
| SettingGetResponse.WorkersQueueBinding
| SettingGetResponse.WorkersD1Binding
| SettingGetResponse.WorkersDispatchNamespaceBinding
| SettingGetResponse.WorkersMTLSCertBinding
| SettingGetResponse.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -677,7 +677,7 @@ export namespace SettingGetResponse {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* A JavaScript variable name for the binding.
*/
Expand Down Expand Up @@ -888,7 +888,7 @@ export namespace SettingEditParams {
| Result.WorkersQueueBinding
| Result.WorkersD1Binding
| Result.WorkersDispatchNamespaceBinding
| Result.WorkersMTLSCertBinding
| Result.WorkersMTLSCERTBinding
>;

/**
Expand Down Expand Up @@ -1069,7 +1069,7 @@ export namespace SettingEditParams {
}
}

export interface WorkersMTLSCertBinding {
export interface WorkersMTLSCERTBinding {
/**
* The class of resource that the binding provides.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/resources/zero-trust/gateway/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export namespace ZeroTrustGatewayRules {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
untrusted_cert?: RuleSettings.UntrustedCert;
untrusted_cert?: RuleSettings.UntrustedCERT;
}

export namespace RuleSettings {
Expand Down Expand Up @@ -476,7 +476,7 @@ export namespace ZeroTrustGatewayRules {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
export interface UntrustedCert {
export interface UntrustedCERT {
/**
* The action performed when an untrusted certificate is seen. The default action
* is an error with HTTP code 526.
Expand Down Expand Up @@ -750,7 +750,7 @@ export namespace RuleCreateParams {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
untrusted_cert?: RuleSettings.UntrustedCert;
untrusted_cert?: RuleSettings.UntrustedCERT;
}

export namespace RuleSettings {
Expand Down Expand Up @@ -944,7 +944,7 @@ export namespace RuleCreateParams {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
export interface UntrustedCert {
export interface UntrustedCERT {
/**
* The action performed when an untrusted certificate is seen. The default action
* is an error with HTTP code 526.
Expand Down Expand Up @@ -1214,7 +1214,7 @@ export namespace RuleUpdateParams {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
untrusted_cert?: RuleSettings.UntrustedCert;
untrusted_cert?: RuleSettings.UntrustedCERT;
}

export namespace RuleSettings {
Expand Down Expand Up @@ -1408,7 +1408,7 @@ export namespace RuleUpdateParams {
/**
* Configure behavior when an upstream cert is invalid or an SSL error occurs.
*/
export interface UntrustedCert {
export interface UntrustedCERT {
/**
* The action performed when an untrusted certificate is seen. The default action
* is an error with HTTP code 526.
Expand Down

0 comments on commit 2274ba0

Please sign in to comment.