Skip to content

Commit 38c9dbd

Browse files
committed
feat(api): add autogenerated stat endpoint from Stainless
Cherry-picked from stainless/preview/feature/hypeman-cp - Add client.instances.stat() method - Add PathInfo response type - Add InstanceStatParams query parameters
1 parent 113b412 commit 38c9dbd

File tree

7 files changed

+103
-4
lines changed

7 files changed

+103
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 29
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-95df8b193133def744aa61dc372f286663ffc20d833488d242fa288af65adc39.yml
3-
openapi_spec_hash: 833120a235ecb298688c2fb1122b3574
4-
config_hash: 48d3be2bdbf56b770c9695a338382558
1+
configured_endpoints: 30
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-28e78b73c796f9ee866671ed946402b5d569e683c3207d57c9143eb7d6f83fb6.yml
3+
openapi_spec_hash: fce0ac8713369a5f048bac684ed34fc8
4+
config_hash: f65a6a2bcef49a9f623212f9de6d6f6f

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Methods:
2727
Types:
2828

2929
- <code><a href="./src/resources/instances/instances.ts">Instance</a></code>
30+
- <code><a href="./src/resources/instances/instances.ts">PathInfo</a></code>
3031
- <code><a href="./src/resources/instances/instances.ts">PortMapping</a></code>
3132
- <code><a href="./src/resources/instances/instances.ts">VolumeMount</a></code>
3233
- <code><a href="./src/resources/instances/instances.ts">InstanceListResponse</a></code>
@@ -42,6 +43,7 @@ Methods:
4243
- <code title="post /instances/{id}/restore">client.instances.<a href="./src/resources/instances/instances.ts">restore</a>(id) -> Instance</code>
4344
- <code title="post /instances/{id}/standby">client.instances.<a href="./src/resources/instances/instances.ts">standby</a>(id) -> Instance</code>
4445
- <code title="post /instances/{id}/start">client.instances.<a href="./src/resources/instances/instances.ts">start</a>(id) -> Instance</code>
46+
- <code title="get /instances/{id}/stat">client.instances.<a href="./src/resources/instances/instances.ts">stat</a>(id, { ...params }) -> PathInfo</code>
4547
- <code title="post /instances/{id}/stop">client.instances.<a href="./src/resources/instances/instances.ts">stop</a>(id) -> Instance</code>
4648

4749
## Volumes

src/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ import {
4949
InstanceListResponse,
5050
InstanceLogsParams,
5151
InstanceLogsResponse,
52+
InstanceStatParams,
5253
Instances,
54+
PathInfo,
5355
PortMapping,
5456
VolumeMount,
5557
} from './resources/instances/instances';
@@ -780,12 +782,14 @@ export declare namespace Hypeman {
780782
export {
781783
Instances as Instances,
782784
type Instance as Instance,
785+
type PathInfo as PathInfo,
783786
type PortMapping as PortMapping,
784787
type VolumeMount as VolumeMount,
785788
type InstanceListResponse as InstanceListResponse,
786789
type InstanceLogsResponse as InstanceLogsResponse,
787790
type InstanceCreateParams as InstanceCreateParams,
788791
type InstanceLogsParams as InstanceLogsParams,
792+
type InstanceStatParams as InstanceStatParams,
789793
};
790794

791795
export {

src/resources/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ export {
2323
export {
2424
Instances,
2525
type Instance,
26+
type PathInfo,
2627
type PortMapping,
2728
type VolumeMount,
2829
type InstanceListResponse,
2930
type InstanceLogsResponse,
3031
type InstanceCreateParams,
3132
type InstanceLogsParams,
33+
type InstanceStatParams,
3234
} from './instances/instances';
3335
export {
3436
Volumes,

src/resources/instances/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
export {
44
Instances,
55
type Instance,
6+
type PathInfo,
67
type PortMapping,
78
type VolumeMount,
89
type InstanceListResponse,
910
type InstanceLogsResponse,
1011
type InstanceCreateParams,
1112
type InstanceLogsParams,
13+
type InstanceStatParams,
1214
} from './instances';
1315
export { Volumes, type VolumeAttachParams, type VolumeDetachParams } from './volumes';

src/resources/instances/instances.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ export class Instances extends APIResource {
131131
return this._client.post(path`/instances/${id}/start`, options);
132132
}
133133

134+
/**
135+
* Returns information about a path in the guest filesystem. Useful for checking if
136+
* a path exists, its type, and permissions before performing file operations.
137+
*
138+
* @example
139+
* ```ts
140+
* const pathInfo = await client.instances.stat('id', {
141+
* path: 'path',
142+
* });
143+
* ```
144+
*/
145+
stat(id: string, query: InstanceStatParams, options?: RequestOptions): APIPromise<PathInfo> {
146+
return this._client.get(path`/instances/${id}/stat`, { query, ...options });
147+
}
148+
134149
/**
135150
* Stop instance (graceful shutdown)
136151
*
@@ -261,6 +276,49 @@ export namespace Instance {
261276
}
262277
}
263278

279+
export interface PathInfo {
280+
/**
281+
* Whether the path exists
282+
*/
283+
exists: boolean;
284+
285+
/**
286+
* Error message if stat failed (e.g., permission denied). Only set when exists is
287+
* false due to an error rather than the path not existing.
288+
*/
289+
error?: string | null;
290+
291+
/**
292+
* True if this is a directory
293+
*/
294+
is_dir?: boolean;
295+
296+
/**
297+
* True if this is a regular file
298+
*/
299+
is_file?: boolean;
300+
301+
/**
302+
* True if this is a symbolic link (only set when follow_links=false)
303+
*/
304+
is_symlink?: boolean;
305+
306+
/**
307+
* Symlink target path (only set when is_symlink=true)
308+
*/
309+
link_target?: string | null;
310+
311+
/**
312+
* File mode (Unix permissions)
313+
*/
314+
mode?: number;
315+
316+
/**
317+
* File size in bytes
318+
*/
319+
size?: number;
320+
}
321+
264322
export interface PortMapping {
265323
/**
266324
* Port in the guest VM
@@ -393,17 +451,31 @@ export interface InstanceLogsParams {
393451
tail?: number;
394452
}
395453

454+
export interface InstanceStatParams {
455+
/**
456+
* Path to stat in the guest filesystem
457+
*/
458+
path: string;
459+
460+
/**
461+
* Follow symbolic links (like stat vs lstat)
462+
*/
463+
follow_links?: boolean;
464+
}
465+
396466
Instances.Volumes = Volumes;
397467

398468
export declare namespace Instances {
399469
export {
400470
type Instance as Instance,
471+
type PathInfo as PathInfo,
401472
type PortMapping as PortMapping,
402473
type VolumeMount as VolumeMount,
403474
type InstanceListResponse as InstanceListResponse,
404475
type InstanceLogsResponse as InstanceLogsResponse,
405476
type InstanceCreateParams as InstanceCreateParams,
406477
type InstanceLogsParams as InstanceLogsParams,
478+
type InstanceStatParams as InstanceStatParams,
407479
};
408480

409481
export {

tests/api-resources/instances/instances.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,23 @@ describe('resource instances', () => {
143143
expect(dataAndResponse.response).toBe(rawResponse);
144144
});
145145

146+
// Prism tests are disabled
147+
test.skip('stat: only required params', async () => {
148+
const responsePromise = client.instances.stat('id', { path: 'path' });
149+
const rawResponse = await responsePromise.asResponse();
150+
expect(rawResponse).toBeInstanceOf(Response);
151+
const response = await responsePromise;
152+
expect(response).not.toBeInstanceOf(Response);
153+
const dataAndResponse = await responsePromise.withResponse();
154+
expect(dataAndResponse.data).toBe(response);
155+
expect(dataAndResponse.response).toBe(rawResponse);
156+
});
157+
158+
// Prism tests are disabled
159+
test.skip('stat: required and optional params', async () => {
160+
const response = await client.instances.stat('id', { path: 'path', follow_links: true });
161+
});
162+
146163
// Prism tests are disabled
147164
test.skip('stop', async () => {
148165
const responsePromise = client.instances.stop('id');

0 commit comments

Comments
 (0)