Skip to content

Commit

Permalink
feat: update via SDK Studio (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Feb 19, 2024
1 parent 85e706d commit 5c7031d
Show file tree
Hide file tree
Showing 66 changed files with 2,630 additions and 1,636 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1137
configured_endpoints: 1147
78 changes: 58 additions & 20 deletions api.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as qs from 'qs';
import * as Pagination from 'cloudflare/pagination';
import * as API from 'cloudflare/resources/index';

export interface ClientOptions {
Expand Down Expand Up @@ -354,10 +355,19 @@ export namespace Cloudflare {

export import RequestOptions = Core.RequestOptions;

export import V4PagePagination = Pagination.V4PagePagination;
export import V4PagePaginationParams = Pagination.V4PagePaginationParams;
export import V4PagePaginationResponse = Pagination.V4PagePaginationResponse;

export import V4PagePaginationArray = Pagination.V4PagePaginationArray;
export import V4PagePaginationArrayParams = Pagination.V4PagePaginationArrayParams;
export import V4PagePaginationArrayResponse = Pagination.V4PagePaginationArrayResponse;

export import Accounts = API.Accounts;
export import AccountUpdateResponse = API.AccountUpdateResponse;
export import AccountListResponse = API.AccountListResponse;
export import AccountGetResponse = API.AccountGetResponse;
export import AccountListResponsesV4PagePaginationArray = API.AccountListResponsesV4PagePaginationArray;
export import AccountUpdateParams = API.AccountUpdateParams;
export import AccountListParams = API.AccountListParams;

Expand All @@ -377,6 +387,7 @@ export namespace Cloudflare {
export import MembershipListResponse = API.MembershipListResponse;
export import MembershipDeleteResponse = API.MembershipDeleteResponse;
export import MembershipGetResponse = API.MembershipGetResponse;
export import MembershipListResponsesV4PagePaginationArray = API.MembershipListResponsesV4PagePaginationArray;
export import MembershipUpdateParams = API.MembershipUpdateParams;
export import MembershipListParams = API.MembershipListParams;

Expand All @@ -391,6 +402,7 @@ export namespace Cloudflare {
export import ZoneListResponse = API.ZoneListResponse;
export import ZoneDeleteResponse = API.ZoneDeleteResponse;
export import ZoneGetResponse = API.ZoneGetResponse;
export import ZoneListResponsesV4PagePaginationArray = API.ZoneListResponsesV4PagePaginationArray;
export import ZoneCreateParams = API.ZoneCreateParams;
export import ZoneUpdateParams = API.ZoneUpdateParams;
export import ZoneListParams = API.ZoneListParams;
Expand Down Expand Up @@ -463,6 +475,7 @@ export namespace Cloudflare {
export import CustomCertificateListResponse = API.CustomCertificateListResponse;
export import CustomCertificateDeleteResponse = API.CustomCertificateDeleteResponse;
export import CustomCertificateGetResponse = API.CustomCertificateGetResponse;
export import CustomCertificateListResponsesV4PagePaginationArray = API.CustomCertificateListResponsesV4PagePaginationArray;
export import CustomCertificateCreateParams = API.CustomCertificateCreateParams;
export import CustomCertificateUpdateParams = API.CustomCertificateUpdateParams;
export import CustomCertificateListParams = API.CustomCertificateListParams;
Expand Down Expand Up @@ -492,6 +505,7 @@ export namespace Cloudflare {
export import DNSRecordGetResponse = API.DNSRecordGetResponse;
export import DNSRecordImportResponse = API.DNSRecordImportResponse;
export import DNSRecordScanResponse = API.DNSRecordScanResponse;
export import DNSRecordListResponsesV4PagePaginationArray = API.DNSRecordListResponsesV4PagePaginationArray;
export import DNSRecordCreateParams = API.DNSRecordCreateParams;
export import DNSRecordUpdateParams = API.DNSRecordUpdateParams;
export import DNSRecordListParams = API.DNSRecordListParams;
Expand Down Expand Up @@ -561,6 +575,7 @@ export namespace Cloudflare {
export import RateLimitUpdateResponse = API.RateLimitUpdateResponse;
export import RateLimitListResponse = API.RateLimitListResponse;
export import RateLimitGetResponse = API.RateLimitGetResponse;
export import RateLimitListResponsesV4PagePaginationArray = API.RateLimitListResponsesV4PagePaginationArray;
export import RateLimitUpdateParams = API.RateLimitUpdateParams;
export import RateLimitListParams = API.RateLimitListParams;

Expand Down Expand Up @@ -643,6 +658,7 @@ export namespace Cloudflare {
export import DNSFirewallListResponse = API.DNSFirewallListResponse;
export import DNSFirewallDeleteResponse = API.DNSFirewallDeleteResponse;
export import DNSFirewallGetResponse = API.DNSFirewallGetResponse;
export import DNSFirewallListResponsesV4PagePaginationArray = API.DNSFirewallListResponsesV4PagePaginationArray;
export import DNSFirewallCreateParams = API.DNSFirewallCreateParams;
export import DNSFirewallUpdateParams = API.DNSFirewallUpdateParams;
export import DNSFirewallListParams = API.DNSFirewallListParams;
Expand All @@ -659,6 +675,7 @@ export namespace Cloudflare {
export import AccountMemberListResponse = API.AccountMemberListResponse;
export import AccountMemberDeleteResponse = API.AccountMemberDeleteResponse;
export import AccountMemberGetResponse = API.AccountMemberGetResponse;
export import AccountMemberListResponsesV4PagePaginationArray = API.AccountMemberListResponsesV4PagePaginationArray;
export import AccountMemberCreateParams = API.AccountMemberCreateParams;
export import AccountMemberUpdateParams = API.AccountMemberUpdateParams;
export import AccountMemberListParams = API.AccountMemberListParams;
Expand Down Expand Up @@ -735,6 +752,7 @@ export namespace Cloudflare {
export import WarpConnectorListResponse = API.WarpConnectorListResponse;
export import WarpConnectorDeleteResponse = API.WarpConnectorDeleteResponse;
export import WarpConnectorGetResponse = API.WarpConnectorGetResponse;
export import WarpConnectorListResponsesV4PagePaginationArray = API.WarpConnectorListResponsesV4PagePaginationArray;
export import WarpConnectorCreateParams = API.WarpConnectorCreateParams;
export import WarpConnectorUpdateParams = API.WarpConnectorUpdateParams;
export import WarpConnectorListParams = API.WarpConnectorListParams;
Expand Down
128 changes: 128 additions & 0 deletions src/pagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// File generated from our OpenAPI spec by Stainless.

import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';

export interface V4PagePaginationResponse<Item> {
result: V4PagePaginationResponse.Result;

result_info: V4PagePaginationResponse.ResultInfo;
}

export namespace V4PagePaginationResponse {
export interface Result {
items?: Array<Item>;
}

export interface ResultInfo {
page?: number;

per_page?: number;
}
}

export interface V4PagePaginationParams {
page?: number;

per_page?: number;
}

export class V4PagePagination<Item> extends AbstractPage<Item> implements V4PagePaginationResponse<Item> {
result: V4PagePaginationResponse.Result;

result_info: V4PagePaginationResponse.ResultInfo;

constructor(
client: APIClient,
response: Response,
body: V4PagePaginationResponse<Item>,
options: FinalRequestOptions,
) {
super(client, response, body, options);

this.result = body.result || {};
this.result_info = body.result_info || {};
}

getPaginatedItems(): Item[] {
return this.result?.items ?? [];
}

// @deprecated Please use `nextPageInfo()` instead
nextPageParams(): Partial<V4PagePaginationParams> | null {
const info = this.nextPageInfo();
if (!info) return null;
if ('params' in info) return info.params;
const params = Object.fromEntries(info.url.searchParams);
if (!Object.keys(params).length) return null;
return params;
}

nextPageInfo(): PageInfo | null {
const query = this.options.query as V4PagePaginationParams;
const currentPage = query?.page ?? 1;

return { params: { page: currentPage + 1 } };
}
}

export interface V4PagePaginationArrayResponse<Item> {
result: Array<Item>;

result_info: V4PagePaginationArrayResponse.ResultInfo;
}

export namespace V4PagePaginationArrayResponse {
export interface ResultInfo {
page?: number;

per_page?: number;
}
}

export interface V4PagePaginationArrayParams {
page?: number;

per_page?: number;
}

export class V4PagePaginationArray<Item>
extends AbstractPage<Item>
implements V4PagePaginationArrayResponse<Item>
{
result: Array<Item>;

result_info: V4PagePaginationArrayResponse.ResultInfo;

constructor(
client: APIClient,
response: Response,
body: V4PagePaginationArrayResponse<Item>,
options: FinalRequestOptions,
) {
super(client, response, body, options);

this.result = body.result || [];
this.result_info = body.result_info || {};
}

getPaginatedItems(): Item[] {
return this.result ?? [];
}

// @deprecated Please use `nextPageInfo()` instead
nextPageParams(): Partial<V4PagePaginationArrayParams> | null {
const info = this.nextPageInfo();
if (!info) return null;
if ('params' in info) return info.params;
const params = Object.fromEntries(info.url.searchParams);
if (!Object.keys(params).length) return null;
return params;
}

nextPageInfo(): PageInfo | null {
const query = this.options.query as V4PagePaginationArrayParams;
const currentPage = query?.page ?? 1;

return { params: { page: currentPage + 1 } };
}
}
Loading

0 comments on commit 5c7031d

Please sign in to comment.