@leaflow/sdk 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,6 +90,10 @@ export type RenameInstanceBody = NonNullable<operations["rename-instance"]["requ
90
90
  export type ActOnInstanceResult = operations["act-on-instance"]["responses"][200]["content"]["application/json"];
91
91
  /** `POST /api/v1/instances/{instanceId}/actions` 的请求体。 */
92
92
  export type ActOnInstanceBody = NonNullable<operations["act-on-instance"]["requestBody"]>["content"]["application/json"];
93
+ /** `POST /api/v1/instances/{instanceId}/commands` 成功时的响应体。 */
94
+ export type RunInstanceCommandResult = operations["run-instance-command"]["responses"][200]["content"]["application/json"];
95
+ /** `POST /api/v1/instances/{instanceId}/commands` 的请求体。 */
96
+ export type RunInstanceCommandBody = NonNullable<operations["run-instance-command"]["requestBody"]>["content"]["application/json"];
93
97
  /** `POST /api/v1/instances/{instanceId}/console` 成功时的响应体。 */
94
98
  export type OpenInstanceConsoleResult = operations["open-instance-console"]["responses"][200]["content"]["application/json"];
95
99
  /** `GET /api/v1/instances/{instanceId}/console-output` 成功时的响应体。 */
@@ -434,6 +434,38 @@ export interface paths {
434
434
  patch?: never;
435
435
  trace?: never;
436
436
  };
437
+ "/api/v1/instances/{instanceId}/commands": {
438
+ parameters: {
439
+ query?: never;
440
+ header?: never;
441
+ path?: never;
442
+ cookie?: never;
443
+ };
444
+ get?: never;
445
+ put?: never;
446
+ /**
447
+ * Run a command on an instance
448
+ * @description Runs one command over SSH and returns what it wrote. **This is not a shell.** There is no terminal, no standard input and no way to answer a prompt: a command that waits for input produces nothing and is killed at the timeout. Chain steps with `&&`, or write a script and run that.
449
+ *
450
+ * Three conditions must hold; the instance is unreachable otherwise:
451
+ *
452
+ * - it is `running`
453
+ * - a floating IP is bound to it, since this endpoint connects over the public internet
454
+ * - its security group permits inbound TCP 22
455
+ *
456
+ * Authentication uses the key the platform attaches to every instance at creation, so nothing has to be set up first. The instance must have applied that key at first boot, which images without a full cloud-init do not do.
457
+ *
458
+ * **The host key is not verified.** Anyone in a position to intercept the connection can read the command and all of its output, so do not pass credentials this way.
459
+ *
460
+ * Each stream is capped at 1 MiB. Beyond that the rest is discarded and `truncated` is true.
461
+ */
462
+ post: operations["run-instance-command"];
463
+ delete?: never;
464
+ options?: never;
465
+ head?: never;
466
+ patch?: never;
467
+ trace?: never;
468
+ };
437
469
  "/api/v1/instances/{instanceId}/console": {
438
470
  parameters: {
439
471
  query?: never;
@@ -1467,6 +1499,33 @@ export interface components {
1467
1499
  /** @description Applies to `reboot` only. A forced reboot does not wait for the operating system to shut down and unwritten data is lost; use it when the system is unresponsive */
1468
1500
  force?: boolean;
1469
1501
  };
1502
+ RunCommandRequestBody: {
1503
+ /** @description Run by the login shell, so pipes, redirection and `&&` work. It cannot read standard input */
1504
+ command: string;
1505
+ /**
1506
+ * Format: int64
1507
+ * @description Kill the command after this long. 60 when omitted
1508
+ */
1509
+ timeout_seconds?: number;
1510
+ /**
1511
+ * @description The SSH user to log in as. It is the account the platform sets a password for at creation
1512
+ * @default root
1513
+ */
1514
+ username?: string;
1515
+ };
1516
+ CommandResultResponseBody: {
1517
+ /**
1518
+ * Format: int64
1519
+ * @description Null when the command was killed rather than finishing on its own, which includes the timeout
1520
+ */
1521
+ exit_code: number | null;
1522
+ stderr: string;
1523
+ stdout: string;
1524
+ /** @description True when the command was still running at the timeout and was killed */
1525
+ timed_out: boolean;
1526
+ /** @description True when either stream hit the 1 MiB cap and the rest was discarded */
1527
+ truncated: boolean;
1528
+ };
1470
1529
  ConsoleResponseBody: {
1471
1530
  /** @description Connection address of the remote console; single-use and expires within minutes */
1472
1531
  console_url: string;
@@ -2817,6 +2876,41 @@ export interface operations {
2817
2876
  };
2818
2877
  };
2819
2878
  };
2879
+ "run-instance-command": {
2880
+ parameters: {
2881
+ query?: never;
2882
+ header?: never;
2883
+ path: {
2884
+ instanceId: string;
2885
+ };
2886
+ cookie?: never;
2887
+ };
2888
+ requestBody: {
2889
+ content: {
2890
+ "application/json": components["schemas"]["RunCommandRequestBody"];
2891
+ };
2892
+ };
2893
+ responses: {
2894
+ /** @description OK */
2895
+ 200: {
2896
+ headers: {
2897
+ [name: string]: unknown;
2898
+ };
2899
+ content: {
2900
+ "application/json": components["schemas"]["CommandResultResponseBody"];
2901
+ };
2902
+ };
2903
+ /** @description Error */
2904
+ default: {
2905
+ headers: {
2906
+ [name: string]: unknown;
2907
+ };
2908
+ content: {
2909
+ "application/json": components["schemas"]["Error"];
2910
+ };
2911
+ };
2912
+ };
2913
+ };
2820
2914
  "open-instance-console": {
2821
2915
  parameters: {
2822
2916
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {