Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OpenAPI spec update via Stainless API #98

Merged
merged 1 commit into from
Feb 29, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ import { fetch } from 'undici'; // as one example
import Cloudflare from 'cloudflare';

const client = new Cloudflare({
fetch: async (url: RequestInfo, init?: RequestInfo): Promise<Response> => {
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
console.log('About to make a request', url, init);
const response = await fetch(url, init);
console.log('Got response', response);
Expand Down
15 changes: 11 additions & 4 deletions src/resources/firewall/access-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class AccessRules extends APIResource {
params: AccessRuleEditParams,
options?: Core.RequestOptions,
): Core.APIPromise<AccessRuleEditResponse | null> {
const { account_identifier, ...body } = params;
const { account_id, zone_id, ...body } = params;
return (
this._client.patch(`/${account_identifier}/${identifier}/firewall/access_rules/rules/:identifier`, {
this._client.patch(`/${account_id}/${zone_id}/firewall/access_rules/rules/${identifier}`, {
body,
...options,
}) as Core.APIPromise<{ result: AccessRuleEditResponse | null }>
Expand Down Expand Up @@ -323,9 +323,16 @@ export interface AccessRuleDeleteParams {

export interface AccessRuleEditParams {
/**
* Path param:
* Path param: The Account ID to use for this endpoint. Mutually exclusive with the
* Zone ID.
*/
account_id: string;

/**
* Path param: The Zone ID to use for this endpoint. Mutually exclusive with the
* Account ID.
*/
account_identifier: unknown;
zone_id: string;

/**
* Body param: The rule configuration.
Expand Down
13 changes: 10 additions & 3 deletions src/resources/rulesets/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export class Rules extends APIResource {
params: RuleEditParams,
options?: Core.RequestOptions,
): Core.APIPromise<RuleEditResponse> {
const { account_id, ...body } = params;
const { account_id, zone_id, ...body } = params;
return (
this._client.patch(`/${account_id}/${rulesetId}/rulesets/${ruleId}/rules/:rule_id`, {
this._client.patch(`/${account_id}/${zone_id}/rulesets/${rulesetId}/rules/${ruleId}`, {
body,
...options,
}) as Core.APIPromise<{ result: RuleEditResponse }>
Expand Down Expand Up @@ -1819,10 +1819,17 @@ export interface RuleDeleteParams {

export interface RuleEditParams {
/**
* Path param: The unique ID of the account.
* Path param: The Account ID to use for this endpoint. Mutually exclusive with the
* Zone ID.
*/
account_id: string;

/**
* Path param: The Zone ID to use for this endpoint. Mutually exclusive with the
* Account ID.
*/
zone_id: string;

/**
* Body param: An object configuring where the rule will be placed.
*/
Expand Down
5 changes: 3 additions & 2 deletions tests/api-resources/firewall/access-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('resource accessRules', () => {
test.skip('edit: only required params', async () => {
const responsePromise = cloudflare.firewall.accessRules.edit(
{},
{ account_identifier: {}, configuration: {}, mode: 'challenge' },
{ account_id: 'string', zone_id: 'string', configuration: {}, mode: 'challenge' },
);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -116,7 +116,8 @@ describe('resource accessRules', () => {
const response = await cloudflare.firewall.accessRules.edit(
{},
{
account_identifier: {},
account_id: 'string',
zone_id: 'string',
configuration: { target: 'ip', value: '198.51.100.4' },
mode: 'challenge',
notes: 'This rule is enabled because of an event that occurred on date X.',
Expand Down
7 changes: 2 additions & 5 deletions tests/api-resources/rulesets/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('resource rules', () => {
const responsePromise = cloudflare.rulesets.rules.edit(
'2f2feab2026849078ba485f918791bdc',
'3a03d665bac047339bb530ecb439a90d',
{ account_id: 'abf9b32d38c5f572afde3336ec0ce302' },
{ account_id: 'string', zone_id: 'string' },
);
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -83,10 +83,7 @@ describe('resource rules', () => {
const response = await cloudflare.rulesets.rules.edit(
'2f2feab2026849078ba485f918791bdc',
'3a03d665bac047339bb530ecb439a90d',
{
account_id: 'abf9b32d38c5f572afde3336ec0ce302',
position: { before: 'da5e8e506c8e7877fe06cdf4c41add54' },
},
{ account_id: 'string', zone_id: 'string', position: { before: 'da5e8e506c8e7877fe06cdf4c41add54' } },
);
});
});