From f8a7e75d7b226a175b0f84f379e18343aa01517a Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Wed, 21 Feb 2024 23:01:05 +0000
Subject: [PATCH] feat: update via SDK Studio (#62)
---
api.md | 10 +-
src/resources/radar/index.ts | 8 +-
src/resources/radar/radar.ts | 2 +
src/resources/radar/ranking/domain.ts | 104 +++++++++++++++++
src/resources/radar/ranking/index.ts | 6 +-
src/resources/radar/ranking/ranking.ts | 107 +++++++++++++++++-
.../radar/ranking/domain.test.ts | 53 +++++++++
.../radar/ranking/ranking.test.ts | 38 +++++++
8 files changed, 313 insertions(+), 15 deletions(-)
create mode 100644 src/resources/radar/ranking/domain.ts
create mode 100644 tests/api-resources/radar/ranking/domain.test.ts
diff --git a/api.md b/api.md
index cb53d987c3..9298cbdbfe 100644
--- a/api.md
+++ b/api.md
@@ -6175,22 +6175,22 @@ Methods:
Types:
- RankingTimeseriesGroupsResponse
+- RankingTopResponse
Methods:
- client.radar.ranking.timeseriesGroups({ ...params }) -> RankingTimeseriesGroupsResponse
+- client.radar.ranking.top({ ...params }) -> RankingTopResponse
-### Ranking
+### Domain
Types:
-- RankingGetResponse
-- RankingTopResponse
+- DomainGetResponse
Methods:
-- client.radar.ranking.ranking.get(domain, { ...params }) -> RankingGetResponse
-- client.radar.ranking.ranking.top({ ...params }) -> RankingTopResponse
+- client.radar.ranking.domain.get(domain, { ...params }) -> DomainGetResponse
## TrafficAnomalies
diff --git a/src/resources/radar/index.ts b/src/resources/radar/index.ts
index 7b2314fcc0..5572a2838a 100644
--- a/src/resources/radar/index.ts
+++ b/src/resources/radar/index.ts
@@ -28,7 +28,13 @@ export { HTTP } from './http/index';
export { NetflowTimeseriesResponse, NetflowTimeseriesParams, Netflows } from './netflows/index';
export { Quality } from './quality/index';
export { Radar } from './radar';
-export { RankingTimeseriesGroupsResponse, RankingTimeseriesGroupsParams, Ranking } from './ranking/index';
+export {
+ RankingTimeseriesGroupsResponse,
+ RankingTopResponse,
+ RankingTimeseriesGroupsParams,
+ RankingTopParams,
+ Ranking,
+} from './ranking/index';
export { SearchGlobalResponse, SearchGlobalParams, Search } from './search';
export {
TrafficAnomalyGetResponse,
diff --git a/src/resources/radar/radar.ts b/src/resources/radar/radar.ts
index 750cff1aca..4a0bc50ce2 100644
--- a/src/resources/radar/radar.ts
+++ b/src/resources/radar/radar.ts
@@ -80,7 +80,9 @@ export namespace Radar {
export import Quality = QualityAPI.Quality;
export import Ranking = RankingAPI.Ranking;
export import RankingTimeseriesGroupsResponse = RankingAPI.RankingTimeseriesGroupsResponse;
+ export import RankingTopResponse = RankingAPI.RankingTopResponse;
export import RankingTimeseriesGroupsParams = RankingAPI.RankingTimeseriesGroupsParams;
+ export import RankingTopParams = RankingAPI.RankingTopParams;
export import TrafficAnomalies = TrafficAnomaliesAPI.TrafficAnomalies;
export import TrafficAnomalyGetResponse = TrafficAnomaliesAPI.TrafficAnomalyGetResponse;
export import TrafficAnomalyGetParams = TrafficAnomaliesAPI.TrafficAnomalyGetParams;
diff --git a/src/resources/radar/ranking/domain.ts b/src/resources/radar/ranking/domain.ts
new file mode 100644
index 0000000000..565240f374
--- /dev/null
+++ b/src/resources/radar/ranking/domain.ts
@@ -0,0 +1,104 @@
+// File generated from our OpenAPI spec by Stainless.
+
+import * as Core from 'cloudflare/core';
+import { APIResource } from 'cloudflare/resource';
+import { isRequestOptions } from 'cloudflare/core';
+import * as DomainAPI from 'cloudflare/resources/radar/ranking/domain';
+
+export class Domain extends APIResource {
+ /**
+ * Gets Domains Rank details. Cloudflare provides an ordered rank for the top 100
+ * domains, but for the remainder it only provides ranking buckets like top 200
+ * thousand, top one million, etc.. These are available through Radar datasets
+ * endpoints.
+ */
+ get(
+ domain: string,
+ query?: DomainGetParams,
+ options?: Core.RequestOptions,
+ ): Core.APIPromise;
+ get(domain: string, options?: Core.RequestOptions): Core.APIPromise;
+ get(
+ domain: string,
+ query: DomainGetParams | Core.RequestOptions = {},
+ options?: Core.RequestOptions,
+ ): Core.APIPromise {
+ if (isRequestOptions(query)) {
+ return this.get(domain, {}, query);
+ }
+ return (
+ this._client.get(`/radar/ranking/domain/${domain}`, { query, ...options }) as Core.APIPromise<{
+ result: DomainGetResponse;
+ }>
+ )._thenUnwrap((obj) => obj.result);
+ }
+}
+
+export interface DomainGetResponse {
+ details_0: DomainGetResponse.Details0;
+}
+
+export namespace DomainGetResponse {
+ export interface Details0 {
+ categories: Array;
+
+ top_locations: Array;
+
+ /**
+ * Only available in POPULAR ranking for the most recent ranking.
+ */
+ bucket?: string;
+
+ rank?: number;
+ }
+
+ export namespace Details0 {
+ export interface Category {
+ id: number;
+
+ name: string;
+
+ superCategoryId: number;
+ }
+
+ export interface TopLocation {
+ locationCode: string;
+
+ locationName: string;
+
+ rank: number;
+ }
+ }
+}
+
+export interface DomainGetParams {
+ /**
+ * Array of dates to filter the ranking.
+ */
+ date?: Array;
+
+ /**
+ * Format results are returned in.
+ */
+ format?: 'JSON' | 'CSV';
+
+ /**
+ * Limit the number of objects in the response.
+ */
+ limit?: number;
+
+ /**
+ * Array of names that will be used to name the series in responses.
+ */
+ name?: Array;
+
+ /**
+ * The ranking type.
+ */
+ rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY';
+}
+
+export namespace Domain {
+ export import DomainGetResponse = DomainAPI.DomainGetResponse;
+ export import DomainGetParams = DomainAPI.DomainGetParams;
+}
diff --git a/src/resources/radar/ranking/index.ts b/src/resources/radar/ranking/index.ts
index b7d5174487..47929e7920 100644
--- a/src/resources/radar/ranking/index.ts
+++ b/src/resources/radar/ranking/index.ts
@@ -1,10 +1,10 @@
// File generated from our OpenAPI spec by Stainless.
+export { DomainGetResponse, DomainGetParams, Domain } from './domain';
export {
- RankingGetResponse,
+ RankingTimeseriesGroupsResponse,
RankingTopResponse,
- RankingGetParams,
+ RankingTimeseriesGroupsParams,
RankingTopParams,
Ranking,
} from './ranking';
-export { RankingTimeseriesGroupsResponse, RankingTimeseriesGroupsParams, Ranking } from './ranking';
diff --git a/src/resources/radar/ranking/ranking.ts b/src/resources/radar/ranking/ranking.ts
index c16710569a..dc20a2a287 100644
--- a/src/resources/radar/ranking/ranking.ts
+++ b/src/resources/radar/ranking/ranking.ts
@@ -3,11 +3,11 @@
import * as Core from 'cloudflare/core';
import { APIResource } from 'cloudflare/resource';
import { isRequestOptions } from 'cloudflare/core';
-import { Ranking } from './ranking';
import * as RankingAPI from 'cloudflare/resources/radar/ranking/ranking';
+import * as DomainAPI from 'cloudflare/resources/radar/ranking/domain';
export class Ranking extends APIResource {
- ranking: Ranking = new Ranking(this._client);
+ domain: DomainAPI.Domain = new DomainAPI.Domain(this._client);
/**
* Gets Domains Rank updates change over time. Raw values are returned.
@@ -30,6 +30,28 @@ export class Ranking extends APIResource {
}>
)._thenUnwrap((obj) => obj.result);
}
+
+ /**
+ * Get top or trending domains based on their rank. Popular domains are domains of
+ * broad appeal based on how people use the Internet. Trending domains are domains
+ * that are generating a surge in interest. For more information on top domains,
+ * see https://blog.cloudflare.com/radar-domain-rankings/.
+ */
+ top(query?: RankingTopParams, options?: Core.RequestOptions): Core.APIPromise;
+ top(options?: Core.RequestOptions): Core.APIPromise;
+ top(
+ query: RankingTopParams | Core.RequestOptions = {},
+ options?: Core.RequestOptions,
+ ): Core.APIPromise {
+ if (isRequestOptions(query)) {
+ return this.top({}, query);
+ }
+ return (
+ this._client.get('/radar/ranking/top', { query, ...options }) as Core.APIPromise<{
+ result: RankingTopResponse;
+ }>
+ )._thenUnwrap((obj) => obj.result);
+ }
}
export interface RankingTimeseriesGroupsResponse {
@@ -63,6 +85,47 @@ export namespace RankingTimeseriesGroupsResponse {
}
}
+export interface RankingTopResponse {
+ meta: RankingTopResponse.Meta;
+
+ top_0: Array;
+}
+
+export namespace RankingTopResponse {
+ export interface Meta {
+ top_0: Meta.Top0;
+ }
+
+ export namespace Meta {
+ export interface Top0 {
+ date: string;
+ }
+ }
+
+ export interface Top0 {
+ categories: Array;
+
+ domain: string;
+
+ rank: number;
+
+ /**
+ * Only available in TRENDING rankings.
+ */
+ pctRankChange?: number;
+ }
+
+ export namespace Top0 {
+ export interface Category {
+ id: number;
+
+ name: string;
+
+ superCategoryId: number;
+ }
+ }
+}
+
export interface RankingTimeseriesGroupsParams {
/**
* End of the date range (inclusive).
@@ -128,12 +191,44 @@ export interface RankingTimeseriesGroupsParams {
rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY';
}
+export interface RankingTopParams {
+ /**
+ * Array of dates to filter the ranking.
+ */
+ date?: Array;
+
+ /**
+ * Format results are returned in.
+ */
+ format?: 'JSON' | 'CSV';
+
+ /**
+ * Limit the number of objects in the response.
+ */
+ limit?: number;
+
+ /**
+ * Array of locations (alpha-2 country codes).
+ */
+ location?: Array;
+
+ /**
+ * Array of names that will be used to name the series in responses.
+ */
+ name?: Array;
+
+ /**
+ * The ranking type.
+ */
+ rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY';
+}
+
export namespace Ranking {
export import RankingTimeseriesGroupsResponse = RankingAPI.RankingTimeseriesGroupsResponse;
- export import RankingTimeseriesGroupsParams = RankingAPI.RankingTimeseriesGroupsParams;
- export import Ranking = RankingAPI.Ranking;
- export import RankingGetResponse = RankingAPI.RankingGetResponse;
export import RankingTopResponse = RankingAPI.RankingTopResponse;
- export import RankingGetParams = RankingAPI.RankingGetParams;
+ export import RankingTimeseriesGroupsParams = RankingAPI.RankingTimeseriesGroupsParams;
export import RankingTopParams = RankingAPI.RankingTopParams;
+ export import Domain = DomainAPI.Domain;
+ export import DomainGetResponse = DomainAPI.DomainGetResponse;
+ export import DomainGetParams = DomainAPI.DomainGetParams;
}
diff --git a/tests/api-resources/radar/ranking/domain.test.ts b/tests/api-resources/radar/ranking/domain.test.ts
new file mode 100644
index 0000000000..b01aa98533
--- /dev/null
+++ b/tests/api-resources/radar/ranking/domain.test.ts
@@ -0,0 +1,53 @@
+// File generated from our OpenAPI spec by Stainless.
+
+import Cloudflare from 'cloudflare';
+import { Response } from 'node-fetch';
+
+const cloudflare = new Cloudflare({
+ apiKey: '144c9defac04969c7bfad8efaa8ea194',
+ apiEmail: 'user@example.com',
+ apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY',
+ userServiceKey:
+ 'v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719',
+ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
+});
+
+describe('resource domain', () => {
+ // skipped: tests are disabled for the time being
+ test.skip('get', async () => {
+ const responsePromise = cloudflare.radar.ranking.domain.get('google.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('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.ranking.domain.get('google.com', { path: '/_stainless_unknown_path' }),
+ ).rejects.toThrow(Cloudflare.NotFoundError);
+ });
+
+ // skipped: tests are disabled for the time being
+ test.skip('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.ranking.domain.get(
+ 'google.com',
+ {
+ date: ['string', 'string', 'string'],
+ format: 'JSON',
+ limit: 5,
+ name: ['string', 'string', 'string'],
+ rankingType: 'POPULAR',
+ },
+ { path: '/_stainless_unknown_path' },
+ ),
+ ).rejects.toThrow(Cloudflare.NotFoundError);
+ });
+});
diff --git a/tests/api-resources/radar/ranking/ranking.test.ts b/tests/api-resources/radar/ranking/ranking.test.ts
index 8697823cb8..fbf354fa50 100644
--- a/tests/api-resources/radar/ranking/ranking.test.ts
+++ b/tests/api-resources/radar/ranking/ranking.test.ts
@@ -53,4 +53,42 @@ describe('resource ranking', () => {
),
).rejects.toThrow(Cloudflare.NotFoundError);
});
+
+ // skipped: tests are disabled for the time being
+ test.skip('top', async () => {
+ const responsePromise = cloudflare.radar.ranking.top();
+ 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('top: 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.ranking.top({ path: '/_stainless_unknown_path' })).rejects.toThrow(
+ Cloudflare.NotFoundError,
+ );
+ });
+
+ // skipped: tests are disabled for the time being
+ test.skip('top: 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.ranking.top(
+ {
+ date: ['string', 'string', 'string'],
+ format: 'JSON',
+ limit: 5,
+ location: ['string', 'string', 'string'],
+ name: ['string', 'string', 'string'],
+ rankingType: 'POPULAR',
+ },
+ { path: '/_stainless_unknown_path' },
+ ),
+ ).rejects.toThrow(Cloudflare.NotFoundError);
+ });
});