🌐 AI搜索 & 代理 主页
Skip to content

Commit e1ca1f5

Browse files
stainless-app[bot]meorphis
authored andcommitted
feat(dex): add commands support (#2220)
1 parent 0b14332 commit e1ca1f5

File tree

11 files changed

+501
-1
lines changed

11 files changed

+501
-1
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1450
1+
configured_endpoints: 1454
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-24f32ff8cc230aecb28b850e99ed99f6f66fba898e64194d21052c4c2b869a24.yml

api.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,6 +4865,34 @@ Types:
48654865
- <code><a href="./src/resources/zero-trust/dex/dex.ts">NetworkPathResponse</a></code>
48664866
- <code><a href="./src/resources/zero-trust/dex/dex.ts">Percentiles</a></code>
48674867

4868+
### Commands
4869+
4870+
Types:
4871+
4872+
- <code><a href="./src/resources/zero-trust/dex/commands/commands.ts">CommandCreateResponse</a></code>
4873+
- <code><a href="./src/resources/zero-trust/dex/commands/commands.ts">CommandListResponse</a></code>
4874+
4875+
Methods:
4876+
4877+
- <code title="post /accounts/{account_id}/commands">client.zeroTrust.dex.commands.<a href="./src/resources/zero-trust/dex/commands/commands.ts">create</a>({ ...params }) -> CommandCreateResponse</code>
4878+
- <code title="get /accounts/{account_id}/commands">client.zeroTrust.dex.commands.<a href="./src/resources/zero-trust/dex/commands/commands.ts">list</a>({ ...params }) -> CommandListResponsesV4PagePagination</code>
4879+
4880+
#### Downloads
4881+
4882+
Methods:
4883+
4884+
- <code title="get /accounts/{account_id}/commands/{command_id}/downloads/{filename}">client.zeroTrust.dex.commands.downloads.<a href="./src/resources/zero-trust/dex/commands/downloads.ts">get</a>(commandId, filename, { ...params }) -> Response</code>
4885+
4886+
#### Quota
4887+
4888+
Types:
4889+
4890+
- <code><a href="./src/resources/zero-trust/dex/commands/quota.ts">QuotaGetResponse</a></code>
4891+
4892+
Methods:
4893+
4894+
- <code title="get /accounts/{account_id}/commands/quota">client.zeroTrust.dex.commands.quota.<a href="./src/resources/zero-trust/dex/commands/quota.ts">get</a>({ ...params }) -> QuotaGetResponse</code>
4895+
48684896
### Colos
48694897

48704898
Types:
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../../../resource';
4+
import * as Core from '../../../../core';
5+
import * as DownloadsAPI from './downloads';
6+
import { DownloadGetParams, Downloads } from './downloads';
7+
import * as QuotaAPI from './quota';
8+
import { Quota, QuotaGetParams, QuotaGetResponse } from './quota';
9+
import { V4PagePagination, type V4PagePaginationParams } from '../../../../pagination';
10+
11+
export class Commands extends APIResource {
12+
downloads: DownloadsAPI.Downloads = new DownloadsAPI.Downloads(this._client);
13+
quota: QuotaAPI.Quota = new QuotaAPI.Quota(this._client);
14+
15+
/**
16+
* Initiate commands for up to 10 devices per account
17+
*/
18+
create(params: CommandCreateParams, options?: Core.RequestOptions): Core.APIPromise<CommandCreateResponse> {
19+
const { account_id, ...body } = params;
20+
return (
21+
this._client.post(`/accounts/${account_id}/commands`, { body, ...options }) as Core.APIPromise<{
22+
result: CommandCreateResponse;
23+
}>
24+
)._thenUnwrap((obj) => obj.result);
25+
}
26+
27+
/**
28+
* Retrieves a paginated list of commands issued to devices under the specified
29+
* account, optionally filtered by time range, device, or other parameters
30+
*/
31+
list(
32+
params: CommandListParams,
33+
options?: Core.RequestOptions,
34+
): Core.PagePromise<CommandListResponsesV4PagePagination, CommandListResponse> {
35+
const { account_id, ...query } = params;
36+
return this._client.getAPIList(`/accounts/${account_id}/commands`, CommandListResponsesV4PagePagination, {
37+
query,
38+
...options,
39+
});
40+
}
41+
}
42+
43+
export class CommandListResponsesV4PagePagination extends V4PagePagination<CommandListResponse> {}
44+
45+
export interface CommandCreateResponse {
46+
/**
47+
* List of created commands
48+
*/
49+
commands?: Array<CommandCreateResponse.Command>;
50+
}
51+
52+
export namespace CommandCreateResponse {
53+
export interface Command {
54+
/**
55+
* Unique identifier for the command
56+
*/
57+
id?: string;
58+
59+
/**
60+
* Command arguments
61+
*/
62+
args?: Record<string, string>;
63+
64+
/**
65+
* Identifier for the device associated with the command
66+
*/
67+
device_id?: string;
68+
69+
/**
70+
* Current status of the command
71+
*/
72+
status?: 'PENDING_EXEC' | 'PENDING_UPLOAD' | 'SUCCESS' | 'FAILED';
73+
74+
/**
75+
* Type of the command (e.g., "pcap" or "warp-diag")
76+
*/
77+
type?: string;
78+
}
79+
}
80+
81+
export interface CommandListResponse {
82+
commands?: Array<CommandListResponse.Command>;
83+
}
84+
85+
export namespace CommandListResponse {
86+
export interface Command {
87+
id?: string;
88+
89+
completed_date?: string | null;
90+
91+
created_date?: string;
92+
93+
device_id?: string;
94+
95+
filename?: string | null;
96+
97+
status?: string;
98+
99+
type?: string;
100+
101+
user_email?: string;
102+
}
103+
}
104+
105+
export interface CommandCreateParams {
106+
/**
107+
* Path param: unique identifier linked to an account in the API request path
108+
*/
109+
account_id: string;
110+
111+
/**
112+
* Body param: List of device-level commands to execute
113+
*/
114+
commands: Array<CommandCreateParams.Command>;
115+
}
116+
117+
export namespace CommandCreateParams {
118+
export interface Command {
119+
/**
120+
* Type of command to execute on the device
121+
*/
122+
command_type: 'pcap' | 'warp-diag';
123+
124+
/**
125+
* Unique identifier for the device
126+
*/
127+
device_id: string;
128+
129+
/**
130+
* Email tied to the device
131+
*/
132+
user_email: string;
133+
134+
command_args?: Command.CommandArgs;
135+
}
136+
137+
export namespace Command {
138+
export interface CommandArgs {
139+
/**
140+
* List of interfaces to capture packets on
141+
*/
142+
interfaces?: Array<'default' | 'tunnel'>;
143+
144+
/**
145+
* Maximum file size (in MB) for the capture file. Specifies the maximum file size
146+
* of the warp-diag zip artifact that can be uploaded. If the zip artifact exceeds
147+
* the specified max file size, it will NOT be uploaded
148+
*/
149+
'max-file-size-mb'?: number;
150+
151+
/**
152+
* Maximum number of bytes to save for each packet
153+
*/
154+
'packet-size-bytes'?: number;
155+
156+
/**
157+
* Test an IP address from all included or excluded ranges. Tests an IP address
158+
* from all included or excluded ranges. Essentially the same as running 'route get
159+
* <ip>'' and collecting the results. This option may increase the time taken to
160+
* collect the warp-diag
161+
*/
162+
'test-all-routes'?: boolean;
163+
164+
/**
165+
* Limit on capture duration (in minutes)
166+
*/
167+
'time-limit-min'?: number;
168+
}
169+
}
170+
}
171+
172+
export interface CommandListParams extends V4PagePaginationParams {
173+
/**
174+
* Path param: unique identifier linked to an account in the API request path
175+
*/
176+
account_id: string;
177+
178+
/**
179+
* Query param: Optionally filter executed commands by command type
180+
*/
181+
command_type?: string;
182+
183+
/**
184+
* Query param: Unique identifier for a device
185+
*/
186+
device_id?: string;
187+
188+
/**
189+
* Query param: Start time for the query in ISO (RFC3339 - ISO 8601) format
190+
*/
191+
from?: string;
192+
193+
/**
194+
* Query param: Optionally filter executed commands by status
195+
*/
196+
status?: 'PENDING_EXEC' | 'PENDING_UPLOAD' | 'SUCCESS' | 'FAILED';
197+
198+
/**
199+
* Query param: End time for the query in ISO (RFC3339 - ISO 8601) format
200+
*/
201+
to?: string;
202+
203+
/**
204+
* Query param: Email tied to the device
205+
*/
206+
user_email?: string;
207+
}
208+
209+
Commands.CommandListResponsesV4PagePagination = CommandListResponsesV4PagePagination;
210+
Commands.Downloads = Downloads;
211+
Commands.Quota = Quota;
212+
213+
export declare namespace Commands {
214+
export {
215+
type CommandCreateResponse as CommandCreateResponse,
216+
type CommandListResponse as CommandListResponse,
217+
CommandListResponsesV4PagePagination as CommandListResponsesV4PagePagination,
218+
type CommandCreateParams as CommandCreateParams,
219+
type CommandListParams as CommandListParams,
220+
};
221+
222+
export { Downloads as Downloads, type DownloadGetParams as DownloadGetParams };
223+
224+
export { Quota as Quota, type QuotaGetResponse as QuotaGetResponse, type QuotaGetParams as QuotaGetParams };
225+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../../../resource';
4+
import * as Core from '../../../../core';
5+
import { type Response } from '../../../../_shims/index';
6+
7+
export class Downloads extends APIResource {
8+
/**
9+
* Downloads artifacts for an executed command. Bulk downloads are not supported
10+
*/
11+
get(
12+
commandId: string,
13+
filename: string,
14+
params: DownloadGetParams,
15+
options?: Core.RequestOptions,
16+
): Core.APIPromise<Response> {
17+
const { account_id } = params;
18+
return this._client.get(`/accounts/${account_id}/commands/${commandId}/downloads/${filename}`, {
19+
...options,
20+
__binaryResponse: true,
21+
});
22+
}
23+
}
24+
25+
export interface DownloadGetParams {
26+
/**
27+
* unique identifier linked to an account in the API request path
28+
*/
29+
account_id: string;
30+
}
31+
32+
export declare namespace Downloads {
33+
export { type DownloadGetParams as DownloadGetParams };
34+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export {
4+
CommandListResponsesV4PagePagination,
5+
Commands,
6+
type CommandCreateResponse,
7+
type CommandListResponse,
8+
type CommandCreateParams,
9+
type CommandListParams,
10+
} from './commands';
11+
export { Downloads, type DownloadGetParams } from './downloads';
12+
export { Quota, type QuotaGetResponse, type QuotaGetParams } from './quota';
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../../../resource';
4+
import * as Core from '../../../../core';
5+
6+
export class Quota extends APIResource {
7+
/**
8+
* Retrieves the current quota usage and limits for device commands within a
9+
* specific account, including the time when the quota will reset
10+
*/
11+
get(params: QuotaGetParams, options?: Core.RequestOptions): Core.APIPromise<QuotaGetResponse> {
12+
const { account_id } = params;
13+
return (
14+
this._client.get(`/accounts/${account_id}/commands/quota`, options) as Core.APIPromise<{
15+
result: QuotaGetResponse;
16+
}>
17+
)._thenUnwrap((obj) => obj.result);
18+
}
19+
}
20+
21+
export interface QuotaGetResponse {
22+
/**
23+
* The remaining number of commands that can be initiated for an account
24+
*/
25+
quota: number;
26+
27+
/**
28+
* The number of commands that have been initiated for an account
29+
*/
30+
quota_usage: number;
31+
32+
/**
33+
* The time when the quota resets
34+
*/
35+
reset_time: string;
36+
}
37+
38+
export interface QuotaGetParams {
39+
/**
40+
* unique identifier linked to an account in the API request path
41+
*/
42+
account_id: string;
43+
}
44+
45+
export declare namespace Quota {
46+
export { type QuotaGetResponse as QuotaGetResponse, type QuotaGetParams as QuotaGetParams };
47+
}

0 commit comments

Comments
 (0)