Skip to content

Commit 47ac333

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 b82d478 commit 47ac333

File tree

7 files changed

+97
-4
lines changed

7 files changed

+97
-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-962950583e6d0c5e72b547422e3cf0f6b9d00a7be1f1ad0b0430d5e742bf6e20.yml
3+
openapi_spec_hash: f5a6a0f94dded7dc78ddac6218034bb2
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: 66 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,43 @@ export namespace Instance {
261276
}
262277
}
263278

279+
export interface PathInfo {
280+
/**
281+
* Whether the path exists
282+
*/
283+
exists: boolean;
284+
285+
/**
286+
* True if this is a directory
287+
*/
288+
is_dir?: boolean;
289+
290+
/**
291+
* True if this is a regular file
292+
*/
293+
is_file?: boolean;
294+
295+
/**
296+
* True if this is a symbolic link (only set when follow_links=false)
297+
*/
298+
is_symlink?: boolean;
299+
300+
/**
301+
* Symlink target path (only set when is_symlink=true)
302+
*/
303+
link_target?: string | null;
304+
305+
/**
306+
* File mode (Unix permissions)
307+
*/
308+
mode?: number;
309+
310+
/**
311+
* File size in bytes
312+
*/
313+
size?: number;
314+
}
315+
264316
export interface PortMapping {
265317
/**
266318
* Port in the guest VM
@@ -393,17 +445,31 @@ export interface InstanceLogsParams {
393445
tail?: number;
394446
}
395447

448+
export interface InstanceStatParams {
449+
/**
450+
* Path to stat in the guest filesystem
451+
*/
452+
path: string;
453+
454+
/**
455+
* Follow symbolic links (like stat vs lstat)
456+
*/
457+
follow_links?: boolean;
458+
}
459+
396460
Instances.Volumes = Volumes;
397461

398462
export declare namespace Instances {
399463
export {
400464
type Instance as Instance,
465+
type PathInfo as PathInfo,
401466
type PortMapping as PortMapping,
402467
type VolumeMount as VolumeMount,
403468
type InstanceListResponse as InstanceListResponse,
404469
type InstanceLogsResponse as InstanceLogsResponse,
405470
type InstanceCreateParams as InstanceCreateParams,
406471
type InstanceLogsParams as InstanceLogsParams,
472+
type InstanceStatParams as InstanceStatParams,
407473
};
408474

409475
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)