From c2185e1397a99beec2e6b0c8b8f1ffdf3906fd46 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 03:38:17 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#501) --- .stats.yml | 2 +- api.md | 56 ++++- src/resources/{ => calls}/calls.ts | 7 + src/resources/calls/index.ts | 4 + src/resources/calls/turn/index.ts | 17 ++ src/resources/calls/turn/keys.ts | 184 +++++++++++++++ src/resources/calls/turn/turn.ts | 23 ++ src/resources/index.ts | 2 +- src/resources/radar/http/ases/ases.ts | 5 + .../radar/http/ases/browser-family.ts | 211 ++++++++++++++++++ src/resources/radar/http/ases/index.ts | 1 + .../radar/http/locations/browser-family.ts | 211 ++++++++++++++++++ src/resources/radar/http/locations/index.ts | 1 + .../radar/http/locations/locations.ts | 5 + tests/api-resources/{ => calls}/calls.test.ts | 0 tests/api-resources/calls/turn/keys.test.ts | 109 +++++++++ .../radar/http/ases/browser-family.test.ts | 58 +++++ .../http/locations/browser-family.test.ts | 58 +++++ 18 files changed, 944 insertions(+), 10 deletions(-) rename src/resources/{ => calls}/calls.ts (95%) create mode 100644 src/resources/calls/index.ts create mode 100644 src/resources/calls/turn/index.ts create mode 100644 src/resources/calls/turn/keys.ts create mode 100644 src/resources/calls/turn/turn.ts create mode 100644 src/resources/radar/http/ases/browser-family.ts create mode 100644 src/resources/radar/http/locations/browser-family.ts rename tests/api-resources/{ => calls}/calls.test.ts (100%) create mode 100644 tests/api-resources/calls/turn/keys.test.ts create mode 100644 tests/api-resources/radar/http/ases/browser-family.test.ts create mode 100644 tests/api-resources/radar/http/locations/browser-family.test.ts diff --git a/.stats.yml b/.stats.yml index 59bc235f9c..4a6241d303 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1274 +configured_endpoints: 1281 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml diff --git a/api.md b/api.md index 7320b0fdef..16cb24a44a 100644 --- a/api.md +++ b/api.md @@ -5991,6 +5991,16 @@ Methods: - client.radar.http.locations.tlsVersion.get(tlsVersion, { ...params }) -> TLSVersionGetResponse +#### BrowserFamily + +Types: + +- BrowserFamilyGetResponse + +Methods: + +- client.radar.http.locations.browserFamily.get(browserFamily, { ...params }) -> BrowserFamilyGetResponse + ### Ases Types: @@ -6071,6 +6081,16 @@ Methods: - client.radar.http.ases.tlsVersion.get(tlsVersion, { ...params }) -> TLSVersionGetResponse +#### BrowserFamily + +Types: + +- BrowserFamilyGetResponse + +Methods: + +- client.radar.http.ases.browserFamily.get(browserFamily, { ...params }) -> BrowserFamilyGetResponse + ### Summary Types: @@ -6356,17 +6376,37 @@ Methods: Types: -- CallsApp -- CallsAppWithSecret -- CallListResponse +- CallsApp +- CallsAppWithSecret +- CallListResponse + +Methods: + +- client.calls.create({ ...params }) -> CallsAppWithSecret +- client.calls.update(appId, { ...params }) -> CallsApp +- client.calls.list({ ...params }) -> CallListResponsesSinglePage +- client.calls.delete(appId, { ...params }) -> CallsApp +- client.calls.get(appId, { ...params }) -> CallsApp + +## Turn + +### Keys + +Types: + +- KeyCreateResponse +- KeyUpdateResponse +- KeyListResponse +- KeyDeleteResponse +- KeyGetResponse Methods: -- client.calls.create({ ...params }) -> CallsAppWithSecret -- client.calls.update(appId, { ...params }) -> CallsApp -- client.calls.list({ ...params }) -> CallListResponsesSinglePage -- client.calls.delete(appId, { ...params }) -> CallsApp -- client.calls.get(appId, { ...params }) -> CallsApp +- client.calls.turn.keys.create({ ...params }) -> KeyCreateResponse +- client.calls.turn.keys.update(keyId, { ...params }) -> KeyUpdateResponse +- client.calls.turn.keys.list({ ...params }) -> KeyListResponsesSinglePage +- client.calls.turn.keys.delete(keyId, { ...params }) -> KeyDeleteResponse +- client.calls.turn.keys.get(keyId, { ...params }) -> KeyGetResponse # CloudforceOne diff --git a/src/resources/calls.ts b/src/resources/calls/calls.ts similarity index 95% rename from src/resources/calls.ts rename to src/resources/calls/calls.ts index 59ca0fee2f..9f7fce2060 100644 --- a/src/resources/calls.ts +++ b/src/resources/calls/calls.ts @@ -2,9 +2,12 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; +import * as TurnAPI from 'cloudflare/resources/calls/turn/turn'; import { SinglePage } from 'cloudflare/pagination'; export class Calls extends APIResource { + turn: TurnAPI.Turn = new TurnAPI.Turn(this._client); + /** * Creates a new Cloudflare calls app. An app is an unique enviroment where each * Session can access all Tracks within the app. @@ -171,3 +174,7 @@ export interface CallGetParams { */ account_id: string; } + +export namespace Calls { + export import Turn = TurnAPI.Turn; +} diff --git a/src/resources/calls/index.ts b/src/resources/calls/index.ts new file mode 100644 index 0000000000..439e0bd2e8 --- /dev/null +++ b/src/resources/calls/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Calls } from './calls'; +export { Turn } from './turn/index'; diff --git a/src/resources/calls/turn/index.ts b/src/resources/calls/turn/index.ts new file mode 100644 index 0000000000..4938951d2b --- /dev/null +++ b/src/resources/calls/turn/index.ts @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + KeyCreateResponse, + KeyUpdateResponse, + KeyListResponse, + KeyDeleteResponse, + KeyGetResponse, + KeyCreateParams, + KeyUpdateParams, + KeyListParams, + KeyDeleteParams, + KeyGetParams, + KeyListResponsesSinglePage, + Keys, +} from './keys'; +export { Turn } from './turn'; diff --git a/src/resources/calls/turn/keys.ts b/src/resources/calls/turn/keys.ts new file mode 100644 index 0000000000..1db762dafa --- /dev/null +++ b/src/resources/calls/turn/keys.ts @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Core from 'cloudflare/core'; +import { APIResource } from 'cloudflare/resource'; +import * as KeysAPI from 'cloudflare/resources/calls/turn/keys'; +import { SinglePage } from 'cloudflare/pagination'; + +export class Keys extends APIResource { + /** + * Creates a new Cloudflare Calls TURN key. + */ + create(params: KeyCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { account_id, ...body } = params; + return this._client.post(`/accounts/${account_id}/calls/turn_keys`, { body, ...options }); + } + + /** + * Edit details for a single TURN key. + */ + update( + keyId: string, + params: KeyUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { account_id, ...body } = params; + return ( + this._client.put(`/accounts/${account_id}/calls/turn_keys/${keyId}`, { + body, + ...options, + }) as Core.APIPromise<{ result: KeyUpdateResponse }> + )._thenUnwrap((obj) => obj.result); + } + + /** + * Lists all TURN keys in the Cloudflare account + */ + list( + params: KeyListParams, + options?: Core.RequestOptions, + ): Core.PagePromise { + const { account_id } = params; + return this._client.getAPIList( + `/accounts/${account_id}/calls/turn_keys`, + KeyListResponsesSinglePage, + options, + ); + } + + /** + * Deletes a TURN key from Cloudflare Calls + */ + delete( + keyId: string, + params: KeyDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { account_id } = params; + return ( + this._client.delete(`/accounts/${account_id}/calls/turn_keys/${keyId}`, options) as Core.APIPromise<{ + result: KeyDeleteResponse; + }> + )._thenUnwrap((obj) => obj.result); + } + + /** + * Fetches details for a single TURN key. + */ + get(keyId: string, params: KeyGetParams, options?: Core.RequestOptions): Core.APIPromise { + const { account_id } = params; + return ( + this._client.get(`/accounts/${account_id}/calls/turn_keys/${keyId}`, options) as Core.APIPromise<{ + result: KeyGetResponse; + }> + )._thenUnwrap((obj) => obj.result); + } +} + +export class KeyListResponsesSinglePage extends SinglePage {} + +export interface KeyCreateResponse { + /** + * The date and time the item was created. + */ + created?: string; + + /** + * Bearer token + */ + key?: string; + + /** + * The date and time the item was last modified. + */ + modified?: string; + + /** + * A short description of a TURN key, not shown to end users. + */ + name?: string; + + /** + * A Cloudflare-generated unique identifier for a item. + */ + uid?: string; +} + +/** + * Bearer token + */ +export type KeyUpdateResponse = string; + +/** + * Bearer token + */ +export type KeyListResponse = string; + +/** + * Bearer token + */ +export type KeyDeleteResponse = string; + +/** + * Bearer token + */ +export type KeyGetResponse = string; + +export interface KeyCreateParams { + /** + * Path param: The account identifier tag. + */ + account_id: string; + + /** + * Body param: A short description of a TURN key, not shown to end users. + */ + name?: string; +} + +export interface KeyUpdateParams { + /** + * Path param: The account identifier tag. + */ + account_id: string; + + /** + * Body param: A short description of a TURN key, not shown to end users. + */ + name?: string; +} + +export interface KeyListParams { + /** + * The account identifier tag. + */ + account_id: string; +} + +export interface KeyDeleteParams { + /** + * The account identifier tag. + */ + account_id: string; +} + +export interface KeyGetParams { + /** + * The account identifier tag. + */ + account_id: string; +} + +export namespace Keys { + export import KeyCreateResponse = KeysAPI.KeyCreateResponse; + export import KeyUpdateResponse = KeysAPI.KeyUpdateResponse; + export import KeyListResponse = KeysAPI.KeyListResponse; + export import KeyDeleteResponse = KeysAPI.KeyDeleteResponse; + export import KeyGetResponse = KeysAPI.KeyGetResponse; + export import KeyListResponsesSinglePage = KeysAPI.KeyListResponsesSinglePage; + export import KeyCreateParams = KeysAPI.KeyCreateParams; + export import KeyUpdateParams = KeysAPI.KeyUpdateParams; + export import KeyListParams = KeysAPI.KeyListParams; + export import KeyDeleteParams = KeysAPI.KeyDeleteParams; + export import KeyGetParams = KeysAPI.KeyGetParams; +} diff --git a/src/resources/calls/turn/turn.ts b/src/resources/calls/turn/turn.ts new file mode 100644 index 0000000000..4d67c839d6 --- /dev/null +++ b/src/resources/calls/turn/turn.ts @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from 'cloudflare/resource'; +import * as KeysAPI from 'cloudflare/resources/calls/turn/keys'; + +export class Turn extends APIResource { + keys: KeysAPI.Keys = new KeysAPI.Keys(this._client); +} + +export namespace Turn { + export import Keys = KeysAPI.Keys; + export import KeyCreateResponse = KeysAPI.KeyCreateResponse; + export import KeyUpdateResponse = KeysAPI.KeyUpdateResponse; + export import KeyListResponse = KeysAPI.KeyListResponse; + export import KeyDeleteResponse = KeysAPI.KeyDeleteResponse; + export import KeyGetResponse = KeysAPI.KeyGetResponse; + export import KeyListResponsesSinglePage = KeysAPI.KeyListResponsesSinglePage; + export import KeyCreateParams = KeysAPI.KeyCreateParams; + export import KeyUpdateParams = KeysAPI.KeyUpdateParams; + export import KeyListParams = KeysAPI.KeyListParams; + export import KeyDeleteParams = KeysAPI.KeyDeleteParams; + export import KeyGetParams = KeysAPI.KeyGetParams; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index a901306862..37791955af 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -12,7 +12,7 @@ export { Billing } from './billing/billing'; export { BotManagement } from './bot-management'; export { BrandProtection } from './brand-protection'; export { Cache } from './cache/cache'; -export { Calls } from './calls'; +export { Calls } from './calls/calls'; export { CertificateAuthorities } from './certificate-authorities/certificate-authorities'; export { Challenges } from './challenges/challenges'; export { ClientCertificates } from './client-certificates'; diff --git a/src/resources/radar/http/ases/ases.ts b/src/resources/radar/http/ases/ases.ts index 61495dc822..e2c0997380 100644 --- a/src/resources/radar/http/ases/ases.ts +++ b/src/resources/radar/http/ases/ases.ts @@ -5,6 +5,7 @@ import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; import * as AsesAPI from 'cloudflare/resources/radar/http/ases/ases'; import * as BotClassAPI from 'cloudflare/resources/radar/http/ases/bot-class'; +import * as BrowserFamilyAPI from 'cloudflare/resources/radar/http/ases/browser-family'; import * as DeviceTypeAPI from 'cloudflare/resources/radar/http/ases/device-type'; import * as HTTPMethodAPI from 'cloudflare/resources/radar/http/ases/http-method'; import * as HTTPProtocolAPI from 'cloudflare/resources/radar/http/ases/http-protocol'; @@ -20,6 +21,7 @@ export class Ases extends APIResource { ipVersion: IPVersionAPI.IPVersion = new IPVersionAPI.IPVersion(this._client); os: OSAPI.OS = new OSAPI.OS(this._client); tlsVersion: TLSVersionAPI.TLSVersion = new TLSVersionAPI.TLSVersion(this._client); + browserFamily: BrowserFamilyAPI.BrowserFamily = new BrowserFamilyAPI.BrowserFamily(this._client); /** * Get the top autonomous systems by HTTP traffic. Values are a percentage out of @@ -240,4 +242,7 @@ export namespace Ases { export import TLSVersion = TLSVersionAPI.TLSVersion; export import TLSVersionGetResponse = TLSVersionAPI.TLSVersionGetResponse; export import TLSVersionGetParams = TLSVersionAPI.TLSVersionGetParams; + export import BrowserFamily = BrowserFamilyAPI.BrowserFamily; + export import BrowserFamilyGetResponse = BrowserFamilyAPI.BrowserFamilyGetResponse; + export import BrowserFamilyGetParams = BrowserFamilyAPI.BrowserFamilyGetParams; } diff --git a/src/resources/radar/http/ases/browser-family.ts b/src/resources/radar/http/ases/browser-family.ts new file mode 100644 index 0000000000..e8300d2aa4 --- /dev/null +++ b/src/resources/radar/http/ases/browser-family.ts @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Core from 'cloudflare/core'; +import { APIResource } from 'cloudflare/resource'; +import { isRequestOptions } from 'cloudflare/core'; +import * as BrowserFamilyAPI from 'cloudflare/resources/radar/http/ases/browser-family'; + +export class BrowserFamily extends APIResource { + /** + * Get the top autonomous systems (AS), by HTTP traffic, of the requested browser + * family. Values are a percentage out of the total traffic. + */ + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + query?: BrowserFamilyGetParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + options?: Core.RequestOptions, + ): Core.APIPromise; + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + query: BrowserFamilyGetParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(query)) { + return this.get(browserFamily, {}, query); + } + return ( + this._client.get(`/radar/http/top/ases/browser_family/${browserFamily}`, { + query, + ...options, + }) as Core.APIPromise<{ result: BrowserFamilyGetResponse }> + )._thenUnwrap((obj) => obj.result); + } +} + +export interface BrowserFamilyGetResponse { + meta: BrowserFamilyGetResponse.Meta; + + top_0: Array; +} + +export namespace BrowserFamilyGetResponse { + export interface Meta { + dateRange: Array; + + lastUpdated: string; + + confidenceInfo?: Meta.ConfidenceInfo; + } + + export namespace Meta { + export interface DateRange { + /** + * Adjusted end of date range. + */ + endTime: string; + + /** + * Adjusted start of date range. + */ + startTime: string; + } + + export interface ConfidenceInfo { + annotations?: Array; + + level?: number; + } + + export namespace ConfidenceInfo { + export interface Annotation { + dataSource: string; + + description: string; + + eventType: string; + + isInstantaneous: unknown; + + endTime?: string; + + linkedUrl?: string; + + startTime?: string; + } + } + } + + export interface Top0 { + clientASN: number; + + clientASName: string; + + value: string; + } +} + +export interface BrowserFamilyGetParams { + /** + * Array of comma separated list of ASNs, start with `-` to exclude from results. + * For example, `-174, 3356` excludes results from AS174, but includes results from + * AS3356. + */ + asn?: Array; + + /** + * Filter for bot class. Refer to + * [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + */ + botClass?: Array<'LIKELY_AUTOMATED' | 'LIKELY_HUMAN'>; + + /** + * Array of comma separated list of continents (alpha-2 continent codes). Start + * with `-` to exclude from results. For example, `-EU,NA` excludes results from + * Europe, but includes results from North America. + */ + continent?: Array; + + /** + * End of the date range (inclusive). + */ + dateEnd?: Array; + + /** + * For example, use `7d` and `7dControl` to compare this week with the previous + * week. Use this parameter or set specific start and end dates (`dateStart` and + * `dateEnd` parameters). + */ + dateRange?: Array< + | '1d' + | '2d' + | '7d' + | '14d' + | '28d' + | '12w' + | '24w' + | '52w' + | '1dControl' + | '2dControl' + | '7dControl' + | '14dControl' + | '28dControl' + | '12wControl' + | '24wControl' + >; + + /** + * Array of datetimes to filter the start of a series. + */ + dateStart?: Array; + + /** + * Filter for device type. + */ + deviceType?: Array<'DESKTOP' | 'MOBILE' | 'OTHER'>; + + /** + * Format results are returned in. + */ + format?: 'JSON' | 'CSV'; + + /** + * Filter for http protocol. + */ + httpProtocol?: Array<'HTTP' | 'HTTPS'>; + + /** + * Filter for http version. + */ + httpVersion?: Array<'HTTPv1' | 'HTTPv2' | 'HTTPv3'>; + + /** + * Filter for ip version. + */ + ipVersion?: Array<'IPv4' | 'IPv6'>; + + /** + * Limit the number of objects in the response. + */ + limit?: number; + + /** + * Array of comma separated list of locations (alpha-2 country codes). Start with + * `-` to exclude from results. For example, `-US,PT` excludes results from the US, + * but includes results from PT. + */ + location?: Array; + + /** + * Array of names that will be used to name the series in responses. + */ + name?: Array; + + /** + * Filter for os name. + */ + os?: Array<'WINDOWS' | 'MACOSX' | 'IOS' | 'ANDROID' | 'CHROMEOS' | 'LINUX' | 'SMART_TV'>; + + /** + * Filter for tls version. + */ + tlsVersion?: Array<'TLSv1_0' | 'TLSv1_1' | 'TLSv1_2' | 'TLSv1_3' | 'TLSvQUIC'>; +} + +export namespace BrowserFamily { + export import BrowserFamilyGetResponse = BrowserFamilyAPI.BrowserFamilyGetResponse; + export import BrowserFamilyGetParams = BrowserFamilyAPI.BrowserFamilyGetParams; +} diff --git a/src/resources/radar/http/ases/index.ts b/src/resources/radar/http/ases/index.ts index b33588dc98..badc76c9e0 100644 --- a/src/resources/radar/http/ases/index.ts +++ b/src/resources/radar/http/ases/index.ts @@ -2,6 +2,7 @@ export { AseGetResponse, AseGetParams, Ases } from './ases'; export { BotClassGetResponse, BotClassGetParams, BotClass } from './bot-class'; +export { BrowserFamilyGetResponse, BrowserFamilyGetParams, BrowserFamily } from './browser-family'; export { DeviceTypeGetResponse, DeviceTypeGetParams, DeviceType } from './device-type'; export { HTTPMethodGetResponse, HTTPMethodGetParams, HTTPMethod } from './http-method'; export { HTTPProtocolGetResponse, HTTPProtocolGetParams, HTTPProtocol } from './http-protocol'; diff --git a/src/resources/radar/http/locations/browser-family.ts b/src/resources/radar/http/locations/browser-family.ts new file mode 100644 index 0000000000..359da6983d --- /dev/null +++ b/src/resources/radar/http/locations/browser-family.ts @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Core from 'cloudflare/core'; +import { APIResource } from 'cloudflare/resource'; +import { isRequestOptions } from 'cloudflare/core'; +import * as BrowserFamilyAPI from 'cloudflare/resources/radar/http/locations/browser-family'; + +export class BrowserFamily extends APIResource { + /** + * Get the top locations, by HTTP traffic, of the requested browser family. Values + * are a percentage out of the total traffic. + */ + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + query?: BrowserFamilyGetParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + options?: Core.RequestOptions, + ): Core.APIPromise; + get( + browserFamily: 'CHROME' | 'EDGE' | 'FIREFOX' | 'SAFARI', + query: BrowserFamilyGetParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(query)) { + return this.get(browserFamily, {}, query); + } + return ( + this._client.get(`/radar/http/top/locations/browser_family/${browserFamily}`, { + query, + ...options, + }) as Core.APIPromise<{ result: BrowserFamilyGetResponse }> + )._thenUnwrap((obj) => obj.result); + } +} + +export interface BrowserFamilyGetResponse { + meta: BrowserFamilyGetResponse.Meta; + + top_0: Array; +} + +export namespace BrowserFamilyGetResponse { + export interface Meta { + dateRange: Array; + + lastUpdated: string; + + confidenceInfo?: Meta.ConfidenceInfo; + } + + export namespace Meta { + export interface DateRange { + /** + * Adjusted end of date range. + */ + endTime: string; + + /** + * Adjusted start of date range. + */ + startTime: string; + } + + export interface ConfidenceInfo { + annotations?: Array; + + level?: number; + } + + export namespace ConfidenceInfo { + export interface Annotation { + dataSource: string; + + description: string; + + eventType: string; + + isInstantaneous: unknown; + + endTime?: string; + + linkedUrl?: string; + + startTime?: string; + } + } + } + + export interface Top0 { + clientCountryAlpha2: string; + + clientCountryName: string; + + value: string; + } +} + +export interface BrowserFamilyGetParams { + /** + * Array of comma separated list of ASNs, start with `-` to exclude from results. + * For example, `-174, 3356` excludes results from AS174, but includes results from + * AS3356. + */ + asn?: Array; + + /** + * Filter for bot class. Refer to + * [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + */ + botClass?: Array<'LIKELY_AUTOMATED' | 'LIKELY_HUMAN'>; + + /** + * Array of comma separated list of continents (alpha-2 continent codes). Start + * with `-` to exclude from results. For example, `-EU,NA` excludes results from + * Europe, but includes results from North America. + */ + continent?: Array; + + /** + * End of the date range (inclusive). + */ + dateEnd?: Array; + + /** + * For example, use `7d` and `7dControl` to compare this week with the previous + * week. Use this parameter or set specific start and end dates (`dateStart` and + * `dateEnd` parameters). + */ + dateRange?: Array< + | '1d' + | '2d' + | '7d' + | '14d' + | '28d' + | '12w' + | '24w' + | '52w' + | '1dControl' + | '2dControl' + | '7dControl' + | '14dControl' + | '28dControl' + | '12wControl' + | '24wControl' + >; + + /** + * Array of datetimes to filter the start of a series. + */ + dateStart?: Array; + + /** + * Filter for device type. + */ + deviceType?: Array<'DESKTOP' | 'MOBILE' | 'OTHER'>; + + /** + * Format results are returned in. + */ + format?: 'JSON' | 'CSV'; + + /** + * Filter for http protocol. + */ + httpProtocol?: Array<'HTTP' | 'HTTPS'>; + + /** + * Filter for http version. + */ + httpVersion?: Array<'HTTPv1' | 'HTTPv2' | 'HTTPv3'>; + + /** + * Filter for ip version. + */ + ipVersion?: Array<'IPv4' | 'IPv6'>; + + /** + * Limit the number of objects in the response. + */ + limit?: number; + + /** + * Array of comma separated list of locations (alpha-2 country codes). Start with + * `-` to exclude from results. For example, `-US,PT` excludes results from the US, + * but includes results from PT. + */ + location?: Array; + + /** + * Array of names that will be used to name the series in responses. + */ + name?: Array; + + /** + * Filter for os name. + */ + os?: Array<'WINDOWS' | 'MACOSX' | 'IOS' | 'ANDROID' | 'CHROMEOS' | 'LINUX' | 'SMART_TV'>; + + /** + * Filter for tls version. + */ + tlsVersion?: Array<'TLSv1_0' | 'TLSv1_1' | 'TLSv1_2' | 'TLSv1_3' | 'TLSvQUIC'>; +} + +export namespace BrowserFamily { + export import BrowserFamilyGetResponse = BrowserFamilyAPI.BrowserFamilyGetResponse; + export import BrowserFamilyGetParams = BrowserFamilyAPI.BrowserFamilyGetParams; +} diff --git a/src/resources/radar/http/locations/index.ts b/src/resources/radar/http/locations/index.ts index 71c3e1f088..c1bf9e23b8 100644 --- a/src/resources/radar/http/locations/index.ts +++ b/src/resources/radar/http/locations/index.ts @@ -1,6 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { BotClassGetResponse, BotClassGetParams, BotClass } from './bot-class'; +export { BrowserFamilyGetResponse, BrowserFamilyGetParams, BrowserFamily } from './browser-family'; export { DeviceTypeGetResponse, DeviceTypeGetParams, DeviceType } from './device-type'; export { HTTPMethodGetResponse, HTTPMethodGetParams, HTTPMethod } from './http-method'; export { HTTPProtocolGetResponse, HTTPProtocolGetParams, HTTPProtocol } from './http-protocol'; diff --git a/src/resources/radar/http/locations/locations.ts b/src/resources/radar/http/locations/locations.ts index 631f096fc9..83a4968a0e 100644 --- a/src/resources/radar/http/locations/locations.ts +++ b/src/resources/radar/http/locations/locations.ts @@ -5,6 +5,7 @@ import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; import * as LocationsAPI from 'cloudflare/resources/radar/http/locations/locations'; import * as BotClassAPI from 'cloudflare/resources/radar/http/locations/bot-class'; +import * as BrowserFamilyAPI from 'cloudflare/resources/radar/http/locations/browser-family'; import * as DeviceTypeAPI from 'cloudflare/resources/radar/http/locations/device-type'; import * as HTTPMethodAPI from 'cloudflare/resources/radar/http/locations/http-method'; import * as HTTPProtocolAPI from 'cloudflare/resources/radar/http/locations/http-protocol'; @@ -20,6 +21,7 @@ export class Locations extends APIResource { ipVersion: IPVersionAPI.IPVersion = new IPVersionAPI.IPVersion(this._client); os: OSAPI.OS = new OSAPI.OS(this._client); tlsVersion: TLSVersionAPI.TLSVersion = new TLSVersionAPI.TLSVersion(this._client); + browserFamily: BrowserFamilyAPI.BrowserFamily = new BrowserFamilyAPI.BrowserFamily(this._client); /** * Get the top locations by HTTP traffic. Values are a percentage out of the total @@ -240,4 +242,7 @@ export namespace Locations { export import TLSVersion = TLSVersionAPI.TLSVersion; export import TLSVersionGetResponse = TLSVersionAPI.TLSVersionGetResponse; export import TLSVersionGetParams = TLSVersionAPI.TLSVersionGetParams; + export import BrowserFamily = BrowserFamilyAPI.BrowserFamily; + export import BrowserFamilyGetResponse = BrowserFamilyAPI.BrowserFamilyGetResponse; + export import BrowserFamilyGetParams = BrowserFamilyAPI.BrowserFamilyGetParams; } diff --git a/tests/api-resources/calls.test.ts b/tests/api-resources/calls/calls.test.ts similarity index 100% rename from tests/api-resources/calls.test.ts rename to tests/api-resources/calls/calls.test.ts diff --git a/tests/api-resources/calls/turn/keys.test.ts b/tests/api-resources/calls/turn/keys.test.ts new file mode 100644 index 0000000000..fd67d29cbf --- /dev/null +++ b/tests/api-resources/calls/turn/keys.test.ts @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Cloudflare from 'cloudflare'; +import { Response } from 'node-fetch'; + +const cloudflare = new Cloudflare({ + apiKey: '144c9defac04969c7bfad8efaa8ea194', + apiEmail: 'user@example.com', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource keys', () => { + test('create: only required params', async () => { + const responsePromise = cloudflare.calls.turn.keys.create({ + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + 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); + }); + + test('create: required and optional params', async () => { + const response = await cloudflare.calls.turn.keys.create({ + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + name: 'my-turn-key', + }); + }); + + test('update: only required params', async () => { + const responsePromise = cloudflare.calls.turn.keys.update('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + 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); + }); + + test('update: required and optional params', async () => { + const response = await cloudflare.calls.turn.keys.update('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + name: 'my-turn-key', + }); + }); + + test('list: only required params', async () => { + const responsePromise = cloudflare.calls.turn.keys.list({ + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + 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); + }); + + test('list: required and optional params', async () => { + const response = await cloudflare.calls.turn.keys.list({ + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + }); + + test('delete: only required params', async () => { + const responsePromise = cloudflare.calls.turn.keys.delete('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + 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); + }); + + test('delete: required and optional params', async () => { + const response = await cloudflare.calls.turn.keys.delete('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + }); + + test('get: only required params', async () => { + const responsePromise = cloudflare.calls.turn.keys.get('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + 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); + }); + + test('get: required and optional params', async () => { + const response = await cloudflare.calls.turn.keys.get('2a95132c15732412d22c1476fa83f27a', { + account_id: '023e105f4ecef8ad9ca31a8372d0c353', + }); + }); +}); diff --git a/tests/api-resources/radar/http/ases/browser-family.test.ts b/tests/api-resources/radar/http/ases/browser-family.test.ts new file mode 100644 index 0000000000..a79058603a --- /dev/null +++ b/tests/api-resources/radar/http/ases/browser-family.test.ts @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Cloudflare from 'cloudflare'; +import { Response } from 'node-fetch'; + +const cloudflare = new Cloudflare({ + apiKey: '144c9defac04969c7bfad8efaa8ea194', + apiEmail: 'user@example.com', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource browserFamily', () => { + test('get', async () => { + const responsePromise = cloudflare.radar.http.ases.browserFamily.get('CHROME'); + 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); + }); + + test('get: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + cloudflare.radar.http.ases.browserFamily.get('CHROME', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Cloudflare.NotFoundError); + }); + + test('get: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + cloudflare.radar.http.ases.browserFamily.get( + 'CHROME', + { + asn: ['string', 'string', 'string'], + botClass: ['LIKELY_AUTOMATED', 'LIKELY_HUMAN'], + continent: ['string', 'string', 'string'], + dateEnd: ['2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z'], + dateRange: ['1d', '2d', '7d'], + dateStart: ['2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z'], + deviceType: ['DESKTOP', 'MOBILE', 'OTHER'], + format: 'JSON', + httpProtocol: ['HTTP', 'HTTPS'], + httpVersion: ['HTTPv1', 'HTTPv2', 'HTTPv3'], + ipVersion: ['IPv4', 'IPv6'], + limit: 5, + location: ['string', 'string', 'string'], + name: ['string', 'string', 'string'], + os: ['WINDOWS', 'MACOSX', 'IOS'], + tlsVersion: ['TLSv1_0', 'TLSv1_1', 'TLSv1_2'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Cloudflare.NotFoundError); + }); +}); diff --git a/tests/api-resources/radar/http/locations/browser-family.test.ts b/tests/api-resources/radar/http/locations/browser-family.test.ts new file mode 100644 index 0000000000..b6e1c9ef0f --- /dev/null +++ b/tests/api-resources/radar/http/locations/browser-family.test.ts @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Cloudflare from 'cloudflare'; +import { Response } from 'node-fetch'; + +const cloudflare = new Cloudflare({ + apiKey: '144c9defac04969c7bfad8efaa8ea194', + apiEmail: 'user@example.com', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource browserFamily', () => { + test('get', async () => { + const responsePromise = cloudflare.radar.http.locations.browserFamily.get('CHROME'); + 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); + }); + + test('get: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + cloudflare.radar.http.locations.browserFamily.get('CHROME', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Cloudflare.NotFoundError); + }); + + test('get: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + cloudflare.radar.http.locations.browserFamily.get( + 'CHROME', + { + asn: ['string', 'string', 'string'], + botClass: ['LIKELY_AUTOMATED', 'LIKELY_HUMAN'], + continent: ['string', 'string', 'string'], + dateEnd: ['2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z'], + dateRange: ['1d', '2d', '7d'], + dateStart: ['2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z', '2019-12-27T18:11:19.117Z'], + deviceType: ['DESKTOP', 'MOBILE', 'OTHER'], + format: 'JSON', + httpProtocol: ['HTTP', 'HTTPS'], + httpVersion: ['HTTPv1', 'HTTPv2', 'HTTPv3'], + ipVersion: ['IPv4', 'IPv6'], + limit: 5, + location: ['string', 'string', 'string'], + name: ['string', 'string', 'string'], + os: ['WINDOWS', 'MACOSX', 'IOS'], + tlsVersion: ['TLSv1_0', 'TLSv1_1', 'TLSv1_2'], + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Cloudflare.NotFoundError); + }); +});