Skip to content

Commit 7bf3751

Browse files
feat(api): api update
1 parent 6e0e152 commit 7bf3751

File tree

7 files changed

+162
-8
lines changed

7 files changed

+162
-8
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1791
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-64483197e6ec54fe413eb3d5e1aa5802dd66280506b340471310d18aaf2e7893.yml
3-
openapi_spec_hash: a6226495494c058cd1753989aaa27b06
1+
configured_endpoints: 1793
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2119f3b01d3ef7f8c45c95c01f473a249a08f79bad8297e7aa4b2d2665503bc9.yml
3+
openapi_spec_hash: a52c7f5deed1454a7288c7c374b1e569
44
config_hash: de4c81cee29cd7dd907279e8916b334f

api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,11 @@ Types:
16461646

16471647
- <code><a href="./src/resources/logpush/edge.ts">InstantLogpushJob</a></code>
16481648

1649+
Methods:
1650+
1651+
- <code title="post /zones/{zone_id}/logpush/edge">client.logpush.edge.<a href="./src/resources/logpush/edge.ts">create</a>({ ...params }) -> InstantLogpushJob | null</code>
1652+
- <code title="get /zones/{zone_id}/logpush/edge">client.logpush.edge.<a href="./src/resources/logpush/edge.ts">get</a>({ ...params }) -> InstantLogpushJobsSinglePage</code>
1653+
16491654
## Jobs
16501655

16511656
Types:

scripts/detect-breaking-changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ TEST_PATHS=(
138138
tests/api-resources/logpush/datasets/datasets.test.ts
139139
tests/api-resources/logpush/datasets/fields.test.ts
140140
tests/api-resources/logpush/datasets/jobs.test.ts
141+
tests/api-resources/logpush/edge.test.ts
141142
tests/api-resources/logpush/jobs.test.ts
142143
tests/api-resources/logpush/ownership.test.ts
143144
tests/api-resources/logpush/validate.test.ts

src/resources/logpush/edge.ts

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,52 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
import { SinglePage } from '../../pagination';
46

5-
export class Edge extends APIResource {}
7+
export class Edge extends APIResource {
8+
/**
9+
* Creates a new Instant Logs job for a zone.
10+
*
11+
* @example
12+
* ```ts
13+
* const instantLogpushJob = await client.logpush.edge.create({
14+
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
15+
* });
16+
* ```
17+
*/
18+
create(params: EdgeCreateParams, options?: Core.RequestOptions): Core.APIPromise<InstantLogpushJob | null> {
19+
const { zone_id, ...body } = params;
20+
return (
21+
this._client.post(`/zones/${zone_id}/logpush/edge`, { body, ...options }) as Core.APIPromise<{
22+
result: InstantLogpushJob | null;
23+
}>
24+
)._thenUnwrap((obj) => obj.result);
25+
}
26+
27+
/**
28+
* Lists Instant Logs jobs for a zone.
29+
*
30+
* @example
31+
* ```ts
32+
* // Automatically fetches more pages as needed.
33+
* for await (const instantLogpushJob of client.logpush.edge.get(
34+
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
35+
* )) {
36+
* // ...
37+
* }
38+
* ```
39+
*/
40+
get(
41+
params: EdgeGetParams,
42+
options?: Core.RequestOptions,
43+
): Core.PagePromise<InstantLogpushJobsSinglePage, InstantLogpushJob | null> {
44+
const { zone_id } = params;
45+
return this._client.getAPIList(`/zones/${zone_id}/logpush/edge`, InstantLogpushJobsSinglePage, options);
46+
}
47+
}
48+
49+
export class InstantLogpushJobsSinglePage extends SinglePage<InstantLogpushJob | null> {}
650

751
export interface InstantLogpushJob {
852
/**
@@ -32,6 +76,43 @@ export interface InstantLogpushJob {
3276
session_id?: string;
3377
}
3478

79+
export interface EdgeCreateParams {
80+
/**
81+
* Path param: Identifier.
82+
*/
83+
zone_id: string;
84+
85+
/**
86+
* Body param: Comma-separated list of fields.
87+
*/
88+
fields?: string;
89+
90+
/**
91+
* Body param: Filters to drill down into specific events.
92+
*/
93+
filter?: string;
94+
95+
/**
96+
* Body param: The sample parameter is the sample rate of the records set by the
97+
* client: "sample": 1 is 100% of records "sample": 10 is 10% and so on.
98+
*/
99+
sample?: number;
100+
}
101+
102+
export interface EdgeGetParams {
103+
/**
104+
* Identifier.
105+
*/
106+
zone_id: string;
107+
}
108+
109+
Edge.InstantLogpushJobsSinglePage = InstantLogpushJobsSinglePage;
110+
35111
export declare namespace Edge {
36-
export { type InstantLogpushJob as InstantLogpushJob };
112+
export {
113+
type InstantLogpushJob as InstantLogpushJob,
114+
InstantLogpushJobsSinglePage as InstantLogpushJobsSinglePage,
115+
type EdgeCreateParams as EdgeCreateParams,
116+
type EdgeGetParams as EdgeGetParams,
117+
};
37118
}

src/resources/logpush/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
export { Datasets } from './datasets/index';
4-
export { Edge, type InstantLogpushJob } from './edge';
4+
export {
5+
InstantLogpushJobsSinglePage,
6+
Edge,
7+
type InstantLogpushJob,
8+
type EdgeCreateParams,
9+
type EdgeGetParams,
10+
} from './edge';
511
export { Logpush } from './logpush';
612
export {
713
LogpushJobsSinglePage,

src/resources/logpush/logpush.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
import { APIResource } from '../../resource';
44
import * as EdgeAPI from './edge';
5-
import { Edge, InstantLogpushJob } from './edge';
5+
import {
6+
Edge,
7+
EdgeCreateParams,
8+
EdgeGetParams,
9+
InstantLogpushJob,
10+
InstantLogpushJobsSinglePage,
11+
} from './edge';
612
import * as JobsAPI from './jobs';
713
import {
814
JobCreateParams,
@@ -47,6 +53,7 @@ export class Logpush extends APIResource {
4753

4854
Logpush.Datasets = Datasets;
4955
Logpush.Edge = Edge;
56+
Logpush.InstantLogpushJobsSinglePage = InstantLogpushJobsSinglePage;
5057
Logpush.Jobs = Jobs;
5158
Logpush.LogpushJobsSinglePage = LogpushJobsSinglePage;
5259
Logpush.Ownership = Ownership;
@@ -55,7 +62,13 @@ Logpush.Validate = Validate;
5562
export declare namespace Logpush {
5663
export { Datasets as Datasets };
5764

58-
export { Edge as Edge, type InstantLogpushJob as InstantLogpushJob };
65+
export {
66+
Edge as Edge,
67+
type InstantLogpushJob as InstantLogpushJob,
68+
InstantLogpushJobsSinglePage as InstantLogpushJobsSinglePage,
69+
type EdgeCreateParams as EdgeCreateParams,
70+
type EdgeGetParams as EdgeGetParams,
71+
};
5972

6073
export {
6174
Jobs as Jobs,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Cloudflare from 'cloudflare';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Cloudflare({
7+
apiKey: '144c9defac04969c7bfad8efaa8ea194',
8+
apiEmail: '[email protected]',
9+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
10+
});
11+
12+
describe('resource edge', () => {
13+
test('create: only required params', async () => {
14+
const responsePromise = client.logpush.edge.create({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
15+
const rawResponse = await responsePromise.asResponse();
16+
expect(rawResponse).toBeInstanceOf(Response);
17+
const response = await responsePromise;
18+
expect(response).not.toBeInstanceOf(Response);
19+
const dataAndResponse = await responsePromise.withResponse();
20+
expect(dataAndResponse.data).toBe(response);
21+
expect(dataAndResponse.response).toBe(rawResponse);
22+
});
23+
24+
test('create: required and optional params', async () => {
25+
const response = await client.logpush.edge.create({
26+
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
27+
fields:
28+
'ClientIP,ClientRequestHost,ClientRequestMethod,ClientRequestURI,EdgeEndTimestamp,EdgeResponseBytes,EdgeResponseStatus,EdgeStartTimestamp,RayID',
29+
filter: '{"where":{"and":[{"key":"ClientCountry","operator":"neq","value":"ca"}]}}',
30+
sample: 1,
31+
});
32+
});
33+
34+
test('get: only required params', async () => {
35+
const responsePromise = client.logpush.edge.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
36+
const rawResponse = await responsePromise.asResponse();
37+
expect(rawResponse).toBeInstanceOf(Response);
38+
const response = await responsePromise;
39+
expect(response).not.toBeInstanceOf(Response);
40+
const dataAndResponse = await responsePromise.withResponse();
41+
expect(dataAndResponse.data).toBe(response);
42+
expect(dataAndResponse.response).toBe(rawResponse);
43+
});
44+
45+
test('get: required and optional params', async () => {
46+
const response = await client.logpush.edge.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
47+
});
48+
});

0 commit comments

Comments
 (0)