diff --git a/api.md b/api.md index d38e8312cf..b6456ce89c 100644 --- a/api.md +++ b/api.md @@ -6198,28 +6198,6 @@ Types: - LabeledRegion - LighthouseReport - Trend -- SpeedDeleteResponse - -Methods: - -- client.speed.delete(url, { ...params }) -> SpeedDeleteResponse -- client.speed.scheduleGet(url, { ...params }) -> Schedule -- client.speed.trendsList(url, { ...params }) -> Trend - -## Tests - -Types: - -- Test -- TestListResponse -- TestDeleteResponse - -Methods: - -- client.speed.tests.create(url, { ...params }) -> Test -- client.speed.tests.list(url, { ...params }) -> TestListResponse -- client.speed.tests.delete(url, { ...params }) -> TestDeleteResponse -- client.speed.tests.get(url, testId, { ...params }) -> Test ## Schedule @@ -6227,10 +6205,13 @@ Types: - Schedule - ScheduleCreateResponse +- ScheduleDeleteResponse Methods: - client.speed.schedule.create(url, { ...params }) -> ScheduleCreateResponse +- client.speed.schedule.delete(url, { ...params }) -> ScheduleDeleteResponse +- client.speed.schedule.get(url, { ...params }) -> Schedule ## Availabilities @@ -6246,11 +6227,27 @@ Methods: Types: -- PageListResponse +- PageListResponse + +Methods: + +- client.speed.pages.list({ ...params }) -> PageListResponsesSinglePage +- client.speed.pages.trend(url, { ...params }) -> Trend + +### Tests + +Types: + +- Test +- TestListResponse +- TestDeleteResponse Methods: -- client.speed.pages.list({ ...params }) -> PageListResponsesSinglePage +- client.speed.pages.tests.create(url, { ...params }) -> Test +- client.speed.pages.tests.list(url, { ...params }) -> TestListResponse +- client.speed.pages.tests.delete(url, { ...params }) -> TestDeleteResponse +- client.speed.pages.tests.get(url, testId, { ...params }) -> Test # DCVDelegation diff --git a/src/resources/speed/index.ts b/src/resources/speed/index.ts index df4eed41d5..8ec4511be4 100644 --- a/src/resources/speed/index.ts +++ b/src/resources/speed/index.ts @@ -1,16 +1,20 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { Availability, AvailabilityListParams, Availabilities } from './availabilities'; -export { PageListResponse, PageListParams, PageListResponsesSinglePage, Pages } from './pages'; -export { Schedule, ScheduleCreateResponse, ScheduleCreateParams, ScheduleResource } from './schedule'; -export { Speed } from './speed'; export { - Test, - TestListResponse, - TestDeleteResponse, - TestCreateParams, - TestListParams, - TestDeleteParams, - TestGetParams, - Tests, -} from './tests'; + PageListResponse, + PageListParams, + PageTrendParams, + PageListResponsesSinglePage, + Pages, +} from './pages/index'; +export { + Schedule, + ScheduleCreateResponse, + ScheduleDeleteResponse, + ScheduleCreateParams, + ScheduleDeleteParams, + ScheduleGetParams, + ScheduleResource, +} from './schedule'; +export { Speed } from './speed'; diff --git a/src/resources/speed/pages.ts b/src/resources/speed/pages.ts deleted file mode 100644 index f064f0ef83..0000000000 --- a/src/resources/speed/pages.ts +++ /dev/null @@ -1,55 +0,0 @@ -// 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 PagesAPI from 'cloudflare/resources/speed/pages'; -import * as SpeedAPI from 'cloudflare/resources/speed/speed'; -import * as TestsAPI from 'cloudflare/resources/speed/tests'; -import { SinglePage } from 'cloudflare/pagination'; - -export class Pages extends APIResource { - /** - * Lists all webpages which have been tested. - */ - list( - params: PageListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id } = params; - return this._client.getAPIList(`/zones/${zone_id}/speed_api/pages`, PageListResponsesSinglePage, options); - } -} - -export class PageListResponsesSinglePage extends SinglePage {} - -export interface PageListResponse { - /** - * A test region with a label. - */ - region?: SpeedAPI.LabeledRegion; - - /** - * The frequency of the test. - */ - scheduleFrequency?: 'DAILY' | 'WEEKLY'; - - tests?: Array; - - /** - * A URL. - */ - url?: string; -} - -export interface PageListParams { - /** - * Identifier - */ - zone_id: string; -} - -export namespace Pages { - export import PageListResponse = PagesAPI.PageListResponse; - export import PageListResponsesSinglePage = PagesAPI.PageListResponsesSinglePage; - export import PageListParams = PagesAPI.PageListParams; -} diff --git a/src/resources/speed/pages/index.ts b/src/resources/speed/pages/index.ts new file mode 100644 index 0000000000..670d3863fe --- /dev/null +++ b/src/resources/speed/pages/index.ts @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + PageListResponse, + PageListParams, + PageTrendParams, + PageListResponsesSinglePage, + Pages, +} from './pages'; +export { + Test, + TestListResponse, + TestDeleteResponse, + TestCreateParams, + TestListParams, + TestDeleteParams, + TestGetParams, + Tests, +} from './tests'; diff --git a/src/resources/speed/pages/pages.ts b/src/resources/speed/pages/pages.ts new file mode 100644 index 0000000000..b8893dbbba --- /dev/null +++ b/src/resources/speed/pages/pages.ts @@ -0,0 +1,141 @@ +// 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 PagesAPI from 'cloudflare/resources/speed/pages/pages'; +import * as SpeedAPI from 'cloudflare/resources/speed/speed'; +import * as TestsAPI from 'cloudflare/resources/speed/pages/tests'; +import { SinglePage } from 'cloudflare/pagination'; + +export class Pages extends APIResource { + tests: TestsAPI.Tests = new TestsAPI.Tests(this._client); + + /** + * Lists all webpages which have been tested. + */ + list( + params: PageListParams, + options?: Core.RequestOptions, + ): Core.PagePromise { + const { zone_id } = params; + return this._client.getAPIList(`/zones/${zone_id}/speed_api/pages`, PageListResponsesSinglePage, options); + } + + /** + * Lists the core web vital metrics trend over time for a specific page. + */ + trend( + url: string, + params: PageTrendParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { zone_id, ...query } = params; + return ( + this._client.get(`/zones/${zone_id}/speed_api/pages/${url}/trend`, { + query, + ...options, + }) as Core.APIPromise<{ result: SpeedAPI.Trend }> + )._thenUnwrap((obj) => obj.result); + } +} + +export class PageListResponsesSinglePage extends SinglePage {} + +export interface PageListResponse { + /** + * A test region with a label. + */ + region?: SpeedAPI.LabeledRegion; + + /** + * The frequency of the test. + */ + scheduleFrequency?: 'DAILY' | 'WEEKLY'; + + tests?: Array; + + /** + * A URL. + */ + url?: string; +} + +export interface PageListParams { + /** + * Identifier + */ + zone_id: string; +} + +export interface PageTrendParams { + /** + * Path param: Identifier + */ + zone_id: string; + + /** + * Query param: The type of device. + */ + deviceType: 'DESKTOP' | 'MOBILE'; + + /** + * Query param: A comma-separated list of metrics to include in the results. + */ + metrics: string; + + /** + * Query param: A test region. + */ + region: + | 'asia-east1' + | 'asia-northeast1' + | 'asia-northeast2' + | 'asia-south1' + | 'asia-southeast1' + | 'australia-southeast1' + | 'europe-north1' + | 'europe-southwest1' + | 'europe-west1' + | 'europe-west2' + | 'europe-west3' + | 'europe-west4' + | 'europe-west8' + | 'europe-west9' + | 'me-west1' + | 'southamerica-east1' + | 'us-central1' + | 'us-east1' + | 'us-east4' + | 'us-south1' + | 'us-west1'; + + /** + * Query param: + */ + start: string; + + /** + * Query param: The timezone of the start and end timestamps. + */ + tz: string; + + /** + * Query param: + */ + end?: string; +} + +export namespace Pages { + export import PageListResponse = PagesAPI.PageListResponse; + export import PageListResponsesSinglePage = PagesAPI.PageListResponsesSinglePage; + export import PageListParams = PagesAPI.PageListParams; + export import PageTrendParams = PagesAPI.PageTrendParams; + export import Tests = TestsAPI.Tests; + export import Test = TestsAPI.Test; + export import TestListResponse = TestsAPI.TestListResponse; + export import TestDeleteResponse = TestsAPI.TestDeleteResponse; + export import TestCreateParams = TestsAPI.TestCreateParams; + export import TestListParams = TestsAPI.TestListParams; + export import TestDeleteParams = TestsAPI.TestDeleteParams; + export import TestGetParams = TestsAPI.TestGetParams; +} diff --git a/src/resources/speed/tests.ts b/src/resources/speed/pages/tests.ts similarity index 98% rename from src/resources/speed/tests.ts rename to src/resources/speed/pages/tests.ts index daf5e7d618..77868fcb24 100644 --- a/src/resources/speed/tests.ts +++ b/src/resources/speed/pages/tests.ts @@ -2,7 +2,7 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; -import * as TestsAPI from 'cloudflare/resources/speed/tests'; +import * as TestsAPI from 'cloudflare/resources/speed/pages/tests'; import * as Shared from 'cloudflare/resources/shared'; import * as SpeedAPI from 'cloudflare/resources/speed/speed'; diff --git a/src/resources/speed/schedule.ts b/src/resources/speed/schedule.ts index 7a2ed77ffe..f0b05ee760 100644 --- a/src/resources/speed/schedule.ts +++ b/src/resources/speed/schedule.ts @@ -3,7 +3,7 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import * as ScheduleAPI from 'cloudflare/resources/speed/schedule'; -import * as TestsAPI from 'cloudflare/resources/speed/tests'; +import * as TestsAPI from 'cloudflare/resources/speed/pages/tests'; export class ScheduleResource extends APIResource { /** @@ -22,6 +22,36 @@ export class ScheduleResource extends APIResource { }) as Core.APIPromise<{ result: ScheduleCreateResponse }> )._thenUnwrap((obj) => obj.result); } + + /** + * Deletes a scheduled test for a page. + */ + delete( + url: string, + params: ScheduleDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { zone_id, region } = params; + return ( + this._client.delete(`/zones/${zone_id}/speed_api/schedule/${url}`, { + query: { region }, + ...options, + }) as Core.APIPromise<{ result: ScheduleDeleteResponse }> + )._thenUnwrap((obj) => obj.result); + } + + /** + * Retrieves the test schedule for a page in a specific region. + */ + get(url: string, params: ScheduleGetParams, options?: Core.RequestOptions): Core.APIPromise { + const { zone_id, ...query } = params; + return ( + this._client.get(`/zones/${zone_id}/speed_api/schedule/${url}`, { + query, + ...options, + }) as Core.APIPromise<{ result: Schedule }> + )._thenUnwrap((obj) => obj.result); + } } /** @@ -74,6 +104,13 @@ export interface ScheduleCreateResponse { test?: TestsAPI.Test; } +export interface ScheduleDeleteResponse { + /** + * Number of items affected. + */ + count?: number; +} + export interface ScheduleCreateParams { /** * Path param: Identifier @@ -107,8 +144,77 @@ export interface ScheduleCreateParams { | 'us-west1'; } +export interface ScheduleDeleteParams { + /** + * Path param: Identifier + */ + zone_id: string; + + /** + * Query param: A test region. + */ + region?: + | 'asia-east1' + | 'asia-northeast1' + | 'asia-northeast2' + | 'asia-south1' + | 'asia-southeast1' + | 'australia-southeast1' + | 'europe-north1' + | 'europe-southwest1' + | 'europe-west1' + | 'europe-west2' + | 'europe-west3' + | 'europe-west4' + | 'europe-west8' + | 'europe-west9' + | 'me-west1' + | 'southamerica-east1' + | 'us-central1' + | 'us-east1' + | 'us-east4' + | 'us-south1' + | 'us-west1'; +} + +export interface ScheduleGetParams { + /** + * Path param: Identifier + */ + zone_id: string; + + /** + * Query param: A test region. + */ + region?: + | 'asia-east1' + | 'asia-northeast1' + | 'asia-northeast2' + | 'asia-south1' + | 'asia-southeast1' + | 'australia-southeast1' + | 'europe-north1' + | 'europe-southwest1' + | 'europe-west1' + | 'europe-west2' + | 'europe-west3' + | 'europe-west4' + | 'europe-west8' + | 'europe-west9' + | 'me-west1' + | 'southamerica-east1' + | 'us-central1' + | 'us-east1' + | 'us-east4' + | 'us-south1' + | 'us-west1'; +} + export namespace ScheduleResource { export import Schedule = ScheduleAPI.Schedule; export import ScheduleCreateResponse = ScheduleAPI.ScheduleCreateResponse; + export import ScheduleDeleteResponse = ScheduleAPI.ScheduleDeleteResponse; export import ScheduleCreateParams = ScheduleAPI.ScheduleCreateParams; + export import ScheduleDeleteParams = ScheduleAPI.ScheduleDeleteParams; + export import ScheduleGetParams = ScheduleAPI.ScheduleGetParams; } diff --git a/src/resources/speed/speed.ts b/src/resources/speed/speed.ts index abcae49701..a67da1cf0d 100644 --- a/src/resources/speed/speed.ts +++ b/src/resources/speed/speed.ts @@ -1,68 +1,14 @@ // 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 AvailabilitiesAPI from 'cloudflare/resources/speed/availabilities'; -import * as PagesAPI from 'cloudflare/resources/speed/pages'; import * as ScheduleAPI from 'cloudflare/resources/speed/schedule'; -import * as TestsAPI from 'cloudflare/resources/speed/tests'; +import * as PagesAPI from 'cloudflare/resources/speed/pages/pages'; export class Speed extends APIResource { - tests: TestsAPI.Tests = new TestsAPI.Tests(this._client); schedule: ScheduleAPI.ScheduleResource = new ScheduleAPI.ScheduleResource(this._client); availabilities: AvailabilitiesAPI.Availabilities = new AvailabilitiesAPI.Availabilities(this._client); pages: PagesAPI.Pages = new PagesAPI.Pages(this._client); - - /** - * Deletes a scheduled test for a page. - */ - delete( - url: string, - params: SpeedDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, region } = params; - return ( - this._client.delete(`/zones/${zone_id}/speed_api/schedule/${url}`, { - query: { region }, - ...options, - }) as Core.APIPromise<{ result: SpeedDeleteResponse }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Retrieves the test schedule for a page in a specific region. - */ - scheduleGet( - url: string, - params: SpeedScheduleGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...query } = params; - return ( - this._client.get(`/zones/${zone_id}/speed_api/schedule/${url}`, { - query, - ...options, - }) as Core.APIPromise<{ result: ScheduleAPI.Schedule }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Lists the core web vital metrics trend over time for a specific page. - */ - trendsList( - url: string, - params: SpeedTrendsListParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...query } = params; - return ( - this._client.get(`/zones/${zone_id}/speed_api/pages/${url}/trend`, { - query, - ...options, - }) as Core.APIPromise<{ result: Trend }> - )._thenUnwrap((obj) => obj.result); - } } /** @@ -221,150 +167,14 @@ export interface Trend { tti?: Array; } -export interface SpeedDeleteResponse { - /** - * Number of items affected. - */ - count?: number; -} - -export interface SpeedDeleteParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: A test region. - */ - region?: - | 'asia-east1' - | 'asia-northeast1' - | 'asia-northeast2' - | 'asia-south1' - | 'asia-southeast1' - | 'australia-southeast1' - | 'europe-north1' - | 'europe-southwest1' - | 'europe-west1' - | 'europe-west2' - | 'europe-west3' - | 'europe-west4' - | 'europe-west8' - | 'europe-west9' - | 'me-west1' - | 'southamerica-east1' - | 'us-central1' - | 'us-east1' - | 'us-east4' - | 'us-south1' - | 'us-west1'; -} - -export interface SpeedScheduleGetParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: A test region. - */ - region?: - | 'asia-east1' - | 'asia-northeast1' - | 'asia-northeast2' - | 'asia-south1' - | 'asia-southeast1' - | 'australia-southeast1' - | 'europe-north1' - | 'europe-southwest1' - | 'europe-west1' - | 'europe-west2' - | 'europe-west3' - | 'europe-west4' - | 'europe-west8' - | 'europe-west9' - | 'me-west1' - | 'southamerica-east1' - | 'us-central1' - | 'us-east1' - | 'us-east4' - | 'us-south1' - | 'us-west1'; -} - -export interface SpeedTrendsListParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The type of device. - */ - deviceType: 'DESKTOP' | 'MOBILE'; - - /** - * Query param: A comma-separated list of metrics to include in the results. - */ - metrics: string; - - /** - * Query param: A test region. - */ - region: - | 'asia-east1' - | 'asia-northeast1' - | 'asia-northeast2' - | 'asia-south1' - | 'asia-southeast1' - | 'australia-southeast1' - | 'europe-north1' - | 'europe-southwest1' - | 'europe-west1' - | 'europe-west2' - | 'europe-west3' - | 'europe-west4' - | 'europe-west8' - | 'europe-west9' - | 'me-west1' - | 'southamerica-east1' - | 'us-central1' - | 'us-east1' - | 'us-east4' - | 'us-south1' - | 'us-west1'; - - /** - * Query param: - */ - start: string; - - /** - * Query param: The timezone of the start and end timestamps. - */ - tz: string; - - /** - * Query param: - */ - end?: string; -} - export namespace Speed { - export import Tests = TestsAPI.Tests; - export import Test = TestsAPI.Test; - export import TestListResponse = TestsAPI.TestListResponse; - export import TestDeleteResponse = TestsAPI.TestDeleteResponse; - export import TestCreateParams = TestsAPI.TestCreateParams; - export import TestListParams = TestsAPI.TestListParams; - export import TestDeleteParams = TestsAPI.TestDeleteParams; - export import TestGetParams = TestsAPI.TestGetParams; export import ScheduleResource = ScheduleAPI.ScheduleResource; export import Schedule = ScheduleAPI.Schedule; export import ScheduleCreateResponse = ScheduleAPI.ScheduleCreateResponse; + export import ScheduleDeleteResponse = ScheduleAPI.ScheduleDeleteResponse; export import ScheduleCreateParams = ScheduleAPI.ScheduleCreateParams; + export import ScheduleDeleteParams = ScheduleAPI.ScheduleDeleteParams; + export import ScheduleGetParams = ScheduleAPI.ScheduleGetParams; export import Availabilities = AvailabilitiesAPI.Availabilities; export import Availability = AvailabilitiesAPI.Availability; export import AvailabilityListParams = AvailabilitiesAPI.AvailabilityListParams; @@ -372,4 +182,5 @@ export namespace Speed { export import PageListResponse = PagesAPI.PageListResponse; export import PageListResponsesSinglePage = PagesAPI.PageListResponsesSinglePage; export import PageListParams = PagesAPI.PageListParams; + export import PageTrendParams = PagesAPI.PageTrendParams; } diff --git a/tests/api-resources/speed/pages.test.ts b/tests/api-resources/speed/pages.test.ts deleted file mode 100644 index b25b70a9fe..0000000000 --- a/tests/api-resources/speed/pages.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 pages', () => { - test('list: only required params', async () => { - const responsePromise = cloudflare.speed.pages.list({ zone_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.speed.pages.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - }); -}); diff --git a/tests/api-resources/speed/speed.test.ts b/tests/api-resources/speed/pages/pages.test.ts similarity index 53% rename from tests/api-resources/speed/speed.test.ts rename to tests/api-resources/speed/pages/pages.test.ts index 771ad03494..821f8e11f7 100644 --- a/tests/api-resources/speed/speed.test.ts +++ b/tests/api-resources/speed/pages/pages.test.ts @@ -9,11 +9,9 @@ const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', }); -describe('resource speed', () => { - test('delete: only required params', async () => { - const responsePromise = cloudflare.speed.delete('example.com', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); +describe('resource pages', () => { + test('list: only required params', async () => { + const responsePromise = cloudflare.speed.pages.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,36 +21,13 @@ describe('resource speed', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - test('delete: required and optional params', async () => { - const response = await cloudflare.speed.delete('example.com', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - region: 'us-central1', - }); - }); - - test('scheduleGet: only required params', async () => { - const responsePromise = cloudflare.speed.scheduleGet('example.com', { - zone_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('scheduleGet: required and optional params', async () => { - const response = await cloudflare.speed.scheduleGet('example.com', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - region: 'us-central1', - }); + test('list: required and optional params', async () => { + const response = await cloudflare.speed.pages.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); }); // TODO: investigate broken test - test.skip('trendsList: only required params', async () => { - const responsePromise = cloudflare.speed.trendsList('example.com', { + test.skip('trend: only required params', async () => { + const responsePromise = cloudflare.speed.pages.trend('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', deviceType: 'DESKTOP', metrics: 'performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls', @@ -70,8 +45,8 @@ describe('resource speed', () => { }); // TODO: investigate broken test - test.skip('trendsList: required and optional params', async () => { - const response = await cloudflare.speed.trendsList('example.com', { + test.skip('trend: required and optional params', async () => { + const response = await cloudflare.speed.pages.trend('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', deviceType: 'DESKTOP', metrics: 'performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls', diff --git a/tests/api-resources/speed/tests.test.ts b/tests/api-resources/speed/pages/tests.test.ts similarity index 82% rename from tests/api-resources/speed/tests.test.ts rename to tests/api-resources/speed/pages/tests.test.ts index 5b37bd5a55..a885f625f7 100644 --- a/tests/api-resources/speed/tests.test.ts +++ b/tests/api-resources/speed/pages/tests.test.ts @@ -11,7 +11,7 @@ const cloudflare = new Cloudflare({ describe('resource tests', () => { test('create: only required params', async () => { - const responsePromise = cloudflare.speed.tests.create('example.com', { + const responsePromise = cloudflare.speed.pages.tests.create('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); const rawResponse = await responsePromise.asResponse(); @@ -24,14 +24,14 @@ describe('resource tests', () => { }); test('create: required and optional params', async () => { - const response = await cloudflare.speed.tests.create('example.com', { + const response = await cloudflare.speed.pages.tests.create('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', region: 'us-central1', }); }); test('list: only required params', async () => { - const responsePromise = cloudflare.speed.tests.list('example.com', { + const responsePromise = cloudflare.speed.pages.tests.list('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); const rawResponse = await responsePromise.asResponse(); @@ -44,7 +44,7 @@ describe('resource tests', () => { }); test('list: required and optional params', async () => { - const response = await cloudflare.speed.tests.list('example.com', { + const response = await cloudflare.speed.pages.tests.list('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', page: 1, per_page: 20, @@ -53,7 +53,7 @@ describe('resource tests', () => { }); test('delete: only required params', async () => { - const responsePromise = cloudflare.speed.tests.delete('example.com', { + const responsePromise = cloudflare.speed.pages.tests.delete('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); const rawResponse = await responsePromise.asResponse(); @@ -66,14 +66,14 @@ describe('resource tests', () => { }); test('delete: required and optional params', async () => { - const response = await cloudflare.speed.tests.delete('example.com', { + const response = await cloudflare.speed.pages.tests.delete('example.com', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', region: 'us-central1', }); }); test('get: only required params', async () => { - const responsePromise = cloudflare.speed.tests.get('example.com', 'string', { + const responsePromise = cloudflare.speed.pages.tests.get('example.com', 'string', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); const rawResponse = await responsePromise.asResponse(); @@ -86,7 +86,7 @@ describe('resource tests', () => { }); test('get: required and optional params', async () => { - const response = await cloudflare.speed.tests.get('example.com', 'string', { + const response = await cloudflare.speed.pages.tests.get('example.com', 'string', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); }); diff --git a/tests/api-resources/speed/schedule.test.ts b/tests/api-resources/speed/schedule.test.ts index 4c2ded674d..8f9bc83e0b 100644 --- a/tests/api-resources/speed/schedule.test.ts +++ b/tests/api-resources/speed/schedule.test.ts @@ -29,4 +29,44 @@ describe('resource schedule', () => { region: 'us-central1', }); }); + + test('delete: only required params', async () => { + const responsePromise = cloudflare.speed.schedule.delete('example.com', { + zone_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.speed.schedule.delete('example.com', { + zone_id: '023e105f4ecef8ad9ca31a8372d0c353', + region: 'us-central1', + }); + }); + + test('get: only required params', async () => { + const responsePromise = cloudflare.speed.schedule.get('example.com', { + zone_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.speed.schedule.get('example.com', { + zone_id: '023e105f4ecef8ad9ca31a8372d0c353', + region: 'us-central1', + }); + }); });