From 1df362c4fc2bfab889e57407ef29ae8df3e65122 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:49:33 +0000 Subject: [PATCH] feat: OpenAPI spec update via Stainless API (#13) --- .stats.yml | 2 +- api.md | 8 - src/resources/audit-logs.ts | 10 +- src/resources/diagnostics/diagnostics.ts | 2 - src/resources/diagnostics/index.ts | 6 +- src/resources/diagnostics/traceroutes.ts | 197 +----------------- src/resources/pcaps/pcaps.ts | 64 +++--- src/resources/purge-caches.ts | 18 +- src/resources/users/audit-logs.ts | 10 +- .../diagnostics/traceroutes.test.ts | 41 ---- 10 files changed, 54 insertions(+), 304 deletions(-) delete mode 100644 tests/api-resources/diagnostics/traceroutes.test.ts diff --git a/.stats.yml b/.stats.yml index 55af302ca9..ba61f90792 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1147 +configured_endpoints: 1146 diff --git a/api.md b/api.md index d467d6d59a..90cb06e970 100644 --- a/api.md +++ b/api.md @@ -3415,14 +3415,6 @@ Methods: ## Traceroutes -Types: - -- TracerouteDiagnosticsTracerouteResponse - -Methods: - -- client.diagnostics.traceroutes.diagnosticsTraceroute(accountIdentifier, { ...params }) -> TracerouteDiagnosticsTracerouteResponse | null - # DLPs ## Patterns diff --git a/src/resources/audit-logs.ts b/src/resources/audit-logs.ts index 0097b1ab4e..0318db89df 100644 --- a/src/resources/audit-logs.ts +++ b/src/resources/audit-logs.ts @@ -33,7 +33,7 @@ export class AuditLogs extends APIResource { export type AuditLogAuditLogsGetAccountAuditLogsResponse = | AuditLogAuditLogsGetAccountAuditLogsResponse.UnionMember0 - | AuditLogAuditLogsGetAccountAuditLogsResponse.L8Gbc7nLAPIResponseCommon; + | AuditLogAuditLogsGetAccountAuditLogsResponse.WWzvNeD7APIResponseCommon; export namespace AuditLogAuditLogsGetAccountAuditLogsResponse { export interface UnionMember0 { @@ -145,10 +145,10 @@ export namespace AuditLogAuditLogsGetAccountAuditLogsResponse { } } - export interface L8Gbc7nLAPIResponseCommon { - errors: Array; + export interface WWzvNeD7APIResponseCommon { + errors: Array; - messages: Array; + messages: Array; result: unknown | Array | string; @@ -158,7 +158,7 @@ export namespace AuditLogAuditLogsGetAccountAuditLogsResponse { success: true; } - export namespace L8Gbc7nLAPIResponseCommon { + export namespace WWzvNeD7APIResponseCommon { export interface Error { code: number; diff --git a/src/resources/diagnostics/diagnostics.ts b/src/resources/diagnostics/diagnostics.ts index 8015515bdc..beca25f306 100644 --- a/src/resources/diagnostics/diagnostics.ts +++ b/src/resources/diagnostics/diagnostics.ts @@ -9,6 +9,4 @@ export class Diagnostics extends APIResource { export namespace Diagnostics { export import Traceroutes = TraceroutesAPI.Traceroutes; - export import TracerouteDiagnosticsTracerouteResponse = TraceroutesAPI.TracerouteDiagnosticsTracerouteResponse; - export import TracerouteDiagnosticsTracerouteParams = TraceroutesAPI.TracerouteDiagnosticsTracerouteParams; } diff --git a/src/resources/diagnostics/index.ts b/src/resources/diagnostics/index.ts index e12a88214d..c0548e8689 100644 --- a/src/resources/diagnostics/index.ts +++ b/src/resources/diagnostics/index.ts @@ -1,8 +1,4 @@ // File generated from our OpenAPI spec by Stainless. export { Diagnostics } from './diagnostics'; -export { - TracerouteDiagnosticsTracerouteResponse, - TracerouteDiagnosticsTracerouteParams, - Traceroutes, -} from './traceroutes'; +export { Traceroutes } from './traceroutes'; diff --git a/src/resources/diagnostics/traceroutes.ts b/src/resources/diagnostics/traceroutes.ts index 9bba2b1a37..44d77c3f61 100644 --- a/src/resources/diagnostics/traceroutes.ts +++ b/src/resources/diagnostics/traceroutes.ts @@ -1,200 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; -import * as TraceroutesAPI from 'cloudflare/resources/diagnostics/traceroutes'; -export class Traceroutes extends APIResource { - /** - * Run traceroutes from Cloudflare colos. - */ - diagnosticsTraceroute( - accountIdentifier: string, - body: TracerouteDiagnosticsTracerouteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - return ( - this._client.post(`/accounts/${accountIdentifier}/diagnostics/traceroute`, { - body, - ...options, - }) as Core.APIPromise<{ result: TracerouteDiagnosticsTracerouteResponse | null }> - )._thenUnwrap((obj) => obj.result); - } -} - -export type TracerouteDiagnosticsTracerouteResponse = - Array; - -export namespace TracerouteDiagnosticsTracerouteResponse { - export interface TracerouteDiagnosticsTracerouteResponseItem { - colos?: Array; - - /** - * The target hostname, IPv6, or IPv6 address. - */ - target?: string; - } - - export namespace TracerouteDiagnosticsTracerouteResponseItem { - export interface Colo { - colo?: Colo.Colo; - - /** - * Errors resulting from collecting traceroute from colo to target. - */ - error?: - | '' - | 'Could not gather traceroute data: Code 1' - | 'Could not gather traceroute data: Code 2' - | 'Could not gather traceroute data: Code 3' - | 'Could not gather traceroute data: Code 4'; - - hops?: Array; - - /** - * Aggregated statistics from all hops about the target. - */ - target_summary?: unknown; - - /** - * Total time of traceroute in ms. - */ - traceroute_time_ms?: number; - } - - export namespace Colo { - export interface Colo { - /** - * Source colo city. - */ - city?: string; - - /** - * Source colo name. - */ - name?: string; - } - - export interface Hop { - /** - * An array of node objects. - */ - nodes?: Array; - - /** - * Number of packets where no response was received. - */ - packets_lost?: number; - - /** - * Number of packets sent with specified TTL. - */ - packets_sent?: number; - - /** - * The time to live (TTL). - */ - packets_ttl?: number; - } - - export namespace Hop { - export interface Node { - /** - * AS number associated with the node object. - */ - asn?: string; - - /** - * IP address of the node. - */ - ip?: string; - - /** - * Field appears if there is an additional annotation printed when the probe - * returns. Field also appears when running a GRE+ICMP traceroute to denote which - * traceroute a node comes from. - */ - labels?: Array; - - /** - * Maximum RTT in ms. - */ - max_rtt_ms?: number; - - /** - * Mean RTT in ms. - */ - mean_rtt_ms?: number; - - /** - * Minimum RTT in ms. - */ - min_rtt_ms?: number; - - /** - * Host name of the address, this may be the same as the IP address. - */ - name?: string; - - /** - * Number of packets with a response from this node. - */ - packet_count?: number; - - /** - * Standard deviation of the RTTs in ms. - */ - std_dev_rtt_ms?: number; - } - } - } - } -} - -export interface TracerouteDiagnosticsTracerouteParams { - targets: Array; - - /** - * If no source colo names specified, all colos will be used. China colos are - * unavailable for traceroutes. - */ - colos?: Array; - - options?: TracerouteDiagnosticsTracerouteParams.Options; -} - -export namespace TracerouteDiagnosticsTracerouteParams { - export interface Options { - /** - * Max TTL. - */ - max_ttl?: number; - - /** - * Type of packet sent. - */ - packet_type?: 'icmp' | 'tcp' | 'udp' | 'gre' | 'gre+icmp'; - - /** - * Number of packets sent at each TTL. - */ - packets_per_ttl?: number; - - /** - * For UDP and TCP, specifies the destination port. For ICMP, specifies the initial - * ICMP sequence value. Default value 0 will choose the best value to use for each - * protocol. - */ - port?: number; - - /** - * Set the time (in seconds) to wait for a response to a probe. - */ - wait_time?: number; - } -} - -export namespace Traceroutes { - export import TracerouteDiagnosticsTracerouteResponse = TraceroutesAPI.TracerouteDiagnosticsTracerouteResponse; - export import TracerouteDiagnosticsTracerouteParams = TraceroutesAPI.TracerouteDiagnosticsTracerouteParams; -} +export class Traceroutes extends APIResource {} diff --git a/src/resources/pcaps/pcaps.ts b/src/resources/pcaps/pcaps.ts index ca0c1ec33c..2b9e731cec 100644 --- a/src/resources/pcaps/pcaps.ts +++ b/src/resources/pcaps/pcaps.ts @@ -56,11 +56,11 @@ export class Pcaps extends APIResource { } export type PcapGetResponse = - | PcapGetResponse.GEiiakUrPcapsResponseSimple - | PcapGetResponse.GEiiakUrPcapsResponseFull; + | PcapGetResponse.RsDvnQmDPcapsResponseSimple + | PcapGetResponse.RsDvnQmDPcapsResponseFull; export namespace PcapGetResponse { - export interface GEiiakUrPcapsResponseSimple { + export interface RsDvnQmDPcapsResponseSimple { /** * The ID for the packet capture. */ @@ -69,7 +69,7 @@ export namespace PcapGetResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseSimple.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseSimple.FilterV1; /** * The status of the packet capture request. @@ -106,7 +106,7 @@ export namespace PcapGetResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseSimple { + export namespace RsDvnQmDPcapsResponseSimple { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -138,7 +138,7 @@ export namespace PcapGetResponse { } } - export interface GEiiakUrPcapsResponseFull { + export interface RsDvnQmDPcapsResponseFull { /** * The ID for the packet capture. */ @@ -171,7 +171,7 @@ export namespace PcapGetResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseFull.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseFull.FilterV1; /** * The status of the packet capture request. @@ -208,7 +208,7 @@ export namespace PcapGetResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseFull { + export namespace RsDvnQmDPcapsResponseFull { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -242,11 +242,11 @@ export namespace PcapGetResponse { } export type PcapMagicPcapCollectionCreatePcapRequestResponse = - | PcapMagicPcapCollectionCreatePcapRequestResponse.GEiiakUrPcapsResponseSimple - | PcapMagicPcapCollectionCreatePcapRequestResponse.GEiiakUrPcapsResponseFull; + | PcapMagicPcapCollectionCreatePcapRequestResponse.RsDvnQmDPcapsResponseSimple + | PcapMagicPcapCollectionCreatePcapRequestResponse.RsDvnQmDPcapsResponseFull; export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { - export interface GEiiakUrPcapsResponseSimple { + export interface RsDvnQmDPcapsResponseSimple { /** * The ID for the packet capture. */ @@ -255,7 +255,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseSimple.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseSimple.FilterV1; /** * The status of the packet capture request. @@ -292,7 +292,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseSimple { + export namespace RsDvnQmDPcapsResponseSimple { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -324,7 +324,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { } } - export interface GEiiakUrPcapsResponseFull { + export interface RsDvnQmDPcapsResponseFull { /** * The ID for the packet capture. */ @@ -357,7 +357,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseFull.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseFull.FilterV1; /** * The status of the packet capture request. @@ -394,7 +394,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseFull { + export namespace RsDvnQmDPcapsResponseFull { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -428,12 +428,12 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestResponse { } export type PcapMagicPcapCollectionListPacketCaptureRequestsResponse = Array< - | PcapMagicPcapCollectionListPacketCaptureRequestsResponse.GEiiakUrPcapsResponseSimple - | PcapMagicPcapCollectionListPacketCaptureRequestsResponse.GEiiakUrPcapsResponseFull + | PcapMagicPcapCollectionListPacketCaptureRequestsResponse.RsDvnQmDPcapsResponseSimple + | PcapMagicPcapCollectionListPacketCaptureRequestsResponse.RsDvnQmDPcapsResponseFull >; export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { - export interface GEiiakUrPcapsResponseSimple { + export interface RsDvnQmDPcapsResponseSimple { /** * The ID for the packet capture. */ @@ -442,7 +442,7 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseSimple.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseSimple.FilterV1; /** * The status of the packet capture request. @@ -479,7 +479,7 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseSimple { + export namespace RsDvnQmDPcapsResponseSimple { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -511,7 +511,7 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { } } - export interface GEiiakUrPcapsResponseFull { + export interface RsDvnQmDPcapsResponseFull { /** * The ID for the packet capture. */ @@ -544,7 +544,7 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: GEiiakUrPcapsResponseFull.FilterV1; + filter_v1?: RsDvnQmDPcapsResponseFull.FilterV1; /** * The status of the packet capture request. @@ -581,7 +581,7 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { type?: 'simple' | 'full'; } - export namespace GEiiakUrPcapsResponseFull { + export namespace RsDvnQmDPcapsResponseFull { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -615,11 +615,11 @@ export namespace PcapMagicPcapCollectionListPacketCaptureRequestsResponse { } export type PcapMagicPcapCollectionCreatePcapRequestParams = - | PcapMagicPcapCollectionCreatePcapRequestParams.GEiiakUrPcapsRequestSimple - | PcapMagicPcapCollectionCreatePcapRequestParams.GEiiakUrPcapsRequestFull; + | PcapMagicPcapCollectionCreatePcapRequestParams.RsDvnQmDPcapsRequestSimple + | PcapMagicPcapCollectionCreatePcapRequestParams.RsDvnQmDPcapsRequestFull; export namespace PcapMagicPcapCollectionCreatePcapRequestParams { - export interface GEiiakUrPcapsRequestSimple { + export interface RsDvnQmDPcapsRequestSimple { /** * The limit of packets contained in a packet capture. */ @@ -644,10 +644,10 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestParams { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: PcapMagicPcapCollectionCreatePcapRequestParams.GEiiakUrPcapsRequestSimple.FilterV1; + filter_v1?: PcapMagicPcapCollectionCreatePcapRequestParams.RsDvnQmDPcapsRequestSimple.FilterV1; } - export namespace GEiiakUrPcapsRequestSimple { + export namespace RsDvnQmDPcapsRequestSimple { /** * The packet capture filter. When this field is empty, all packets are captured. */ @@ -679,7 +679,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestParams { } } - export interface GEiiakUrPcapsRequestFull { + export interface RsDvnQmDPcapsRequestFull { /** * The name of the data center used for the packet capture. This can be a specific * colo (ord02) or a multi-colo name (ORD). This field only applies to `full` @@ -717,7 +717,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestParams { /** * The packet capture filter. When this field is empty, all packets are captured. */ - filter_v1?: PcapMagicPcapCollectionCreatePcapRequestParams.GEiiakUrPcapsRequestFull.FilterV1; + filter_v1?: PcapMagicPcapCollectionCreatePcapRequestParams.RsDvnQmDPcapsRequestFull.FilterV1; /** * The limit of packets contained in a packet capture. @@ -725,7 +725,7 @@ export namespace PcapMagicPcapCollectionCreatePcapRequestParams { packet_limit?: number; } - export namespace GEiiakUrPcapsRequestFull { + export namespace RsDvnQmDPcapsRequestFull { /** * The packet capture filter. When this field is empty, all packets are captured. */ diff --git a/src/resources/purge-caches.ts b/src/resources/purge-caches.ts index 2f98c917a1..33b01c734f 100644 --- a/src/resources/purge-caches.ts +++ b/src/resources/purge-caches.ts @@ -56,12 +56,12 @@ export interface PurgeCachZonePurgeResponse { } export type PurgeCachZonePurgeParams = - | PurgeCachZonePurgeParams.K9HAoHwQFlex - | PurgeCachZonePurgeParams.K9HAoHwQEverything - | PurgeCachZonePurgeParams.K9HAoHwQFiles; + | PurgeCachZonePurgeParams.MsVw2EBcFlex + | PurgeCachZonePurgeParams.MsVw2EBcEverything + | PurgeCachZonePurgeParams.MsVw2EBcFiles; export namespace PurgeCachZonePurgeParams { - export interface K9HAoHwQFlex { + export interface MsVw2EBcFlex { hosts?: Array; prefixes?: Array; @@ -69,16 +69,16 @@ export namespace PurgeCachZonePurgeParams { tags?: Array; } - export interface K9HAoHwQEverything { + export interface MsVw2EBcEverything { purge_everything?: boolean; } - export interface K9HAoHwQFiles { - files?: Array; + export interface MsVw2EBcFiles { + files?: Array; } - export namespace K9HAoHwQFiles { - export interface K9HAoHwQURLAndHeaders { + export namespace MsVw2EBcFiles { + export interface MsVw2EBcURLAndHeaders { headers?: unknown; url?: string; diff --git a/src/resources/users/audit-logs.ts b/src/resources/users/audit-logs.ts index a80cfc4602..4a023e7be6 100644 --- a/src/resources/users/audit-logs.ts +++ b/src/resources/users/audit-logs.ts @@ -25,7 +25,7 @@ export class AuditLogs extends APIResource { export type AuditLogListResponse = | AuditLogListResponse.UnionMember0 - | AuditLogListResponse.L8Gbc7nLAPIResponseCommon; + | AuditLogListResponse.WWzvNeD7APIResponseCommon; export namespace AuditLogListResponse { export interface UnionMember0 { @@ -137,10 +137,10 @@ export namespace AuditLogListResponse { } } - export interface L8Gbc7nLAPIResponseCommon { - errors: Array; + export interface WWzvNeD7APIResponseCommon { + errors: Array; - messages: Array; + messages: Array; result: unknown | Array | string; @@ -150,7 +150,7 @@ export namespace AuditLogListResponse { success: true; } - export namespace L8Gbc7nLAPIResponseCommon { + export namespace WWzvNeD7APIResponseCommon { export interface Error { code: number; diff --git a/tests/api-resources/diagnostics/traceroutes.test.ts b/tests/api-resources/diagnostics/traceroutes.test.ts deleted file mode 100644 index 9d31cc1325..0000000000 --- a/tests/api-resources/diagnostics/traceroutes.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const cloudflare = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'dev@cloudflare.com', - apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY', - userServiceKey: 'My User Service Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource traceroutes', () => { - // skipped: tests are disabled for the time being - test.skip('diagnosticsTraceroute: only required params', async () => { - const responsePromise = cloudflare.diagnostics.traceroutes.diagnosticsTraceroute( - '023e105f4ecef8ad9ca31a8372d0c353', - { targets: ['203.0.113.1', 'cloudflare.com'] }, - ); - 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('diagnosticsTraceroute: required and optional params', async () => { - const response = await cloudflare.diagnostics.traceroutes.diagnosticsTraceroute( - '023e105f4ecef8ad9ca31a8372d0c353', - { - targets: ['203.0.113.1', 'cloudflare.com'], - colos: ['den', 'sin'], - options: { max_ttl: 15, packet_type: 'icmp', packets_per_ttl: 0, port: 0, wait_time: 1 }, - }, - ); - }); -});