Skip to content

Commit

Permalink
feat: update via SDK Studio (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Feb 21, 2024
1 parent fef83d3 commit f8a7e75
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 15 deletions.
10 changes: 5 additions & 5 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6175,22 +6175,22 @@ Methods:
Types:

- <code><a href="./src/resources/radar/ranking/ranking.ts">RankingTimeseriesGroupsResponse</a></code>
- <code><a href="./src/resources/radar/ranking/ranking.ts">RankingTopResponse</a></code>

Methods:

- <code title="get /radar/ranking/timeseries_groups">client.radar.ranking.<a href="./src/resources/radar/ranking/ranking.ts">timeseriesGroups</a>({ ...params }) -> RankingTimeseriesGroupsResponse</code>
- <code title="get /radar/ranking/top">client.radar.ranking.<a href="./src/resources/radar/ranking/ranking.ts">top</a>({ ...params }) -> RankingTopResponse</code>

### Ranking
### Domain

Types:

- <code><a href="./src/resources/radar/ranking/ranking.ts">RankingGetResponse</a></code>
- <code><a href="./src/resources/radar/ranking/ranking.ts">RankingTopResponse</a></code>
- <code><a href="./src/resources/radar/ranking/domain.ts">DomainGetResponse</a></code>

Methods:

- <code title="get /radar/ranking/domain/{domain}">client.radar.ranking.ranking.<a href="./src/resources/radar/ranking/ranking.ts">get</a>(domain, { ...params }) -> RankingGetResponse</code>
- <code title="get /radar/ranking/top">client.radar.ranking.ranking.<a href="./src/resources/radar/ranking/ranking.ts">top</a>({ ...params }) -> RankingTopResponse</code>
- <code title="get /radar/ranking/domain/{domain}">client.radar.ranking.domain.<a href="./src/resources/radar/ranking/domain.ts">get</a>(domain, { ...params }) -> DomainGetResponse</code>

## TrafficAnomalies

Expand Down
8 changes: 7 additions & 1 deletion src/resources/radar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/resources/radar/radar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
104 changes: 104 additions & 0 deletions src/resources/radar/ranking/domain.ts
Original file line number Diff line number Diff line change
@@ -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<DomainGetResponse>;
get(domain: string, options?: Core.RequestOptions): Core.APIPromise<DomainGetResponse>;
get(
domain: string,
query: DomainGetParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<DomainGetResponse> {
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<Details0.Category>;

top_locations: Array<Details0.TopLocation>;

/**
* 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<string | null>;

/**
* 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<string>;

/**
* The ranking type.
*/
rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY';
}

export namespace Domain {
export import DomainGetResponse = DomainAPI.DomainGetResponse;
export import DomainGetParams = DomainAPI.DomainGetParams;
}
6 changes: 3 additions & 3 deletions src/resources/radar/ranking/index.ts
Original file line number Diff line number Diff line change
@@ -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';
107 changes: 101 additions & 6 deletions src/resources/radar/ranking/ranking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<RankingTopResponse>;
top(options?: Core.RequestOptions): Core.APIPromise<RankingTopResponse>;
top(
query: RankingTopParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<RankingTopResponse> {
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 {
Expand Down Expand Up @@ -63,6 +85,47 @@ export namespace RankingTimeseriesGroupsResponse {
}
}

export interface RankingTopResponse {
meta: RankingTopResponse.Meta;

top_0: Array<RankingTopResponse.Top0>;
}

export namespace RankingTopResponse {
export interface Meta {
top_0: Meta.Top0;
}

export namespace Meta {
export interface Top0 {
date: string;
}
}

export interface Top0 {
categories: Array<Top0.Category>;

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).
Expand Down Expand Up @@ -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<string | null>;

/**
* 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<string>;

/**
* Array of names that will be used to name the series in responses.
*/
name?: Array<string>;

/**
* 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;
}
53 changes: 53 additions & 0 deletions tests/api-resources/radar/ranking/domain.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading

0 comments on commit f8a7e75

Please sign in to comment.