|
| 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 | +} |
0 commit comments