@ostanin/podman 0.1.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.
- package/README.md +432 -0
- package/esm/_dnt.polyfills.d.ts +7 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/api/artifacts.d.ts +25 -0
- package/esm/api/artifacts.d.ts.map +1 -0
- package/esm/api/artifacts.js +89 -0
- package/esm/api/containers.d.ts +71 -0
- package/esm/api/containers.d.ts.map +1 -0
- package/esm/api/containers.js +234 -0
- package/esm/api/exec.d.ts +15 -0
- package/esm/api/exec.d.ts.map +1 -0
- package/esm/api/exec.js +45 -0
- package/esm/api/generate.d.ts +11 -0
- package/esm/api/generate.d.ts.map +1 -0
- package/esm/api/generate.js +24 -0
- package/esm/api/images.d.ts +55 -0
- package/esm/api/images.d.ts.map +1 -0
- package/esm/api/images.js +212 -0
- package/esm/api/kube.d.ts +13 -0
- package/esm/api/kube.d.ts.map +1 -0
- package/esm/api/kube.js +38 -0
- package/esm/api/manifests.d.ts +19 -0
- package/esm/api/manifests.d.ts.map +1 -0
- package/esm/api/manifests.js +60 -0
- package/esm/api/networks.d.ts +25 -0
- package/esm/api/networks.d.ts.map +1 -0
- package/esm/api/networks.js +95 -0
- package/esm/api/pods.d.ts +35 -0
- package/esm/api/pods.d.ts.map +1 -0
- package/esm/api/pods.js +120 -0
- package/esm/api/quadlets.d.ts +23 -0
- package/esm/api/quadlets.d.ts.map +1 -0
- package/esm/api/quadlets.js +56 -0
- package/esm/api/secrets.d.ts +17 -0
- package/esm/api/secrets.d.ts.map +1 -0
- package/esm/api/secrets.js +49 -0
- package/esm/api/system.d.ts +23 -0
- package/esm/api/system.d.ts.map +1 -0
- package/esm/api/system.js +98 -0
- package/esm/api/volumes.d.ts +23 -0
- package/esm/api/volumes.d.ts.map +1 -0
- package/esm/api/volumes.js +69 -0
- package/esm/client.d.ts +56 -0
- package/esm/client.d.ts.map +1 -0
- package/esm/client.js +63 -0
- package/esm/internal/query.d.ts +2 -0
- package/esm/internal/query.d.ts.map +1 -0
- package/esm/internal/query.js +24 -0
- package/esm/mod.d.ts +22 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +18 -0
- package/esm/package.json +3 -0
- package/esm/ssh_transport.d.ts +14 -0
- package/esm/ssh_transport.d.ts.map +1 -0
- package/esm/ssh_transport.js +85 -0
- package/esm/transport.d.ts +23 -0
- package/esm/transport.d.ts.map +1 -0
- package/esm/transport.js +112 -0
- package/esm/transport_core.d.ts +31 -0
- package/esm/transport_core.d.ts.map +1 -0
- package/esm/transport_core.js +75 -0
- package/esm/types/api.d.ts +61 -0
- package/esm/types/api.d.ts.map +1 -0
- package/esm/types/api.js +5 -0
- package/esm/types/errors.d.ts +21 -0
- package/esm/types/errors.d.ts.map +1 -0
- package/esm/types/errors.js +47 -0
- package/esm/types/openapi.d.ts +19552 -0
- package/esm/types/openapi.d.ts.map +1 -0
- package/esm/types/openapi.js +5 -0
- package/package.json +36 -0
- package/script/_dnt.polyfills.d.ts +7 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +2 -0
- package/script/api/artifacts.d.ts +25 -0
- package/script/api/artifacts.d.ts.map +1 -0
- package/script/api/artifacts.js +93 -0
- package/script/api/containers.d.ts +71 -0
- package/script/api/containers.d.ts.map +1 -0
- package/script/api/containers.js +238 -0
- package/script/api/exec.d.ts +15 -0
- package/script/api/exec.d.ts.map +1 -0
- package/script/api/exec.js +49 -0
- package/script/api/generate.d.ts +11 -0
- package/script/api/generate.d.ts.map +1 -0
- package/script/api/generate.js +28 -0
- package/script/api/images.d.ts +55 -0
- package/script/api/images.d.ts.map +1 -0
- package/script/api/images.js +216 -0
- package/script/api/kube.d.ts +13 -0
- package/script/api/kube.d.ts.map +1 -0
- package/script/api/kube.js +42 -0
- package/script/api/manifests.d.ts +19 -0
- package/script/api/manifests.d.ts.map +1 -0
- package/script/api/manifests.js +64 -0
- package/script/api/networks.d.ts +25 -0
- package/script/api/networks.d.ts.map +1 -0
- package/script/api/networks.js +99 -0
- package/script/api/pods.d.ts +35 -0
- package/script/api/pods.d.ts.map +1 -0
- package/script/api/pods.js +124 -0
- package/script/api/quadlets.d.ts +23 -0
- package/script/api/quadlets.d.ts.map +1 -0
- package/script/api/quadlets.js +60 -0
- package/script/api/secrets.d.ts +17 -0
- package/script/api/secrets.d.ts.map +1 -0
- package/script/api/secrets.js +53 -0
- package/script/api/system.d.ts +23 -0
- package/script/api/system.d.ts.map +1 -0
- package/script/api/system.js +102 -0
- package/script/api/volumes.d.ts +23 -0
- package/script/api/volumes.d.ts.map +1 -0
- package/script/api/volumes.js +73 -0
- package/script/client.d.ts +56 -0
- package/script/client.d.ts.map +1 -0
- package/script/client.js +67 -0
- package/script/internal/query.d.ts +2 -0
- package/script/internal/query.d.ts.map +1 -0
- package/script/internal/query.js +27 -0
- package/script/mod.d.ts +22 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +42 -0
- package/script/package.json +3 -0
- package/script/ssh_transport.d.ts +14 -0
- package/script/ssh_transport.d.ts.map +1 -0
- package/script/ssh_transport.js +121 -0
- package/script/transport.d.ts +23 -0
- package/script/transport.d.ts.map +1 -0
- package/script/transport.js +149 -0
- package/script/transport_core.d.ts +31 -0
- package/script/transport_core.d.ts.map +1 -0
- package/script/transport_core.js +78 -0
- package/script/types/api.d.ts +61 -0
- package/script/types/api.d.ts.map +1 -0
- package/script/types/api.js +6 -0
- package/script/types/errors.d.ts +21 -0
- package/script/types/errors.d.ts.map +1 -0
- package/script/types/errors.js +54 -0
- package/script/types/openapi.d.ts +19552 -0
- package/script/types/openapi.d.ts.map +1 -0
- package/script/types/openapi.js +6 -0
package/esm/api/kube.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class KubeApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Play a Kubernetes YAML file. Body can be YAML string or tar stream. */
|
|
9
|
+
async play(body, query) {
|
|
10
|
+
const path = `/play/kube${buildQuery(query)}`;
|
|
11
|
+
const contentType = typeof body === "string" ? "application/x-yaml" : "application/x-tar";
|
|
12
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
13
|
+
"Content-Type": contentType,
|
|
14
|
+
});
|
|
15
|
+
if (res.status !== 200)
|
|
16
|
+
await throwRawError(res, "POST", path);
|
|
17
|
+
return (await res.json());
|
|
18
|
+
}
|
|
19
|
+
/** Tear down pods/resources created by play kube. */
|
|
20
|
+
async down(query) {
|
|
21
|
+
const path = `/play/kube${buildQuery(query)}`;
|
|
22
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
23
|
+
if (status !== 200)
|
|
24
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
25
|
+
return json;
|
|
26
|
+
}
|
|
27
|
+
/** Apply Kubernetes YAML to the Podman system. */
|
|
28
|
+
async apply(body, query) {
|
|
29
|
+
const path = `/kube/apply${buildQuery(query)}`;
|
|
30
|
+
const contentType = typeof body === "string" ? "application/x-yaml" : "application/x-tar";
|
|
31
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
32
|
+
"Content-Type": contentType,
|
|
33
|
+
});
|
|
34
|
+
if (res.status !== 200)
|
|
35
|
+
await throwRawError(res, "POST", path);
|
|
36
|
+
return await res.json();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { IDResponse, ImageRemoveReport, ManifestCreateQuery, ManifestRemoveQuery, ManifestInspectQuery, ManifestModifyOptions, ManifestModifyQuery, ManifestModifyReport, ManifestPushQuery, Schema2ListPublic } from "../types/api.js";
|
|
3
|
+
export declare class ManifestsApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Create a manifest list. */
|
|
7
|
+
create(name: string, query: ManifestCreateQuery, opts?: ManifestModifyOptions): Promise<IDResponse>;
|
|
8
|
+
/** Inspect a manifest list. Returns null if not found. */
|
|
9
|
+
inspect(nameOrId: string, query?: ManifestInspectQuery): Promise<Schema2ListPublic | null>;
|
|
10
|
+
/** Check if a manifest list exists. */
|
|
11
|
+
exists(nameOrId: string): Promise<boolean>;
|
|
12
|
+
/** Modify a manifest list (add/remove/annotate). */
|
|
13
|
+
modify(nameOrId: string, opts: ManifestModifyOptions, query?: ManifestModifyQuery): Promise<ManifestModifyReport>;
|
|
14
|
+
/** Delete a manifest list. */
|
|
15
|
+
remove(nameOrId: string, query?: ManifestRemoveQuery): Promise<ImageRemoveReport>;
|
|
16
|
+
/** Push a manifest list to a registry. */
|
|
17
|
+
push(nameOrId: string, destination: string, query?: ManifestPushQuery): Promise<IDResponse>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=manifests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests.d.ts","sourceRoot":"","sources":["../../src/api/manifests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,YAAY;;gBAEX,SAAS,EAAE,SAAS;IAIhC,8BAA8B;IACxB,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,mBAAmB,EAC1B,IAAI,CAAC,EAAE,qBAAqB,GAC3B,OAAO,CAAC,UAAU,CAAC;IAOtB,0DAA0D;IACpD,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAQpC,uCAAuC;IACjC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMhD,oDAAoD;IAC9C,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,qBAAqB,EAC3B,KAAK,CAAC,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAOhC,8BAA8B;IACxB,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,mBAAmB,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAO7B,0CAA0C;IACpC,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,CAAC;CASvB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class ManifestsApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create a manifest list. */
|
|
9
|
+
async create(name, query, opts) {
|
|
10
|
+
const path = `/manifests/${encodeURIComponent(name)}${buildQuery(query)}`;
|
|
11
|
+
const { status, json } = await this.#t.request("POST", path, opts);
|
|
12
|
+
if (status !== 200 && status !== 201)
|
|
13
|
+
throw createPodmanError(status, json, "POST", path);
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
/** Inspect a manifest list. Returns null if not found. */
|
|
17
|
+
async inspect(nameOrId, query) {
|
|
18
|
+
const path = `/manifests/${encodeURIComponent(nameOrId)}/json${buildQuery(query)}`;
|
|
19
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
20
|
+
if (status === 404)
|
|
21
|
+
return null;
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "GET", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** Check if a manifest list exists. */
|
|
27
|
+
async exists(nameOrId) {
|
|
28
|
+
const path = `/manifests/${encodeURIComponent(nameOrId)}/exists`;
|
|
29
|
+
const { status } = await this.#t.request("GET", path);
|
|
30
|
+
return status === 204;
|
|
31
|
+
}
|
|
32
|
+
/** Modify a manifest list (add/remove/annotate). */
|
|
33
|
+
async modify(nameOrId, opts, query) {
|
|
34
|
+
const path = `/manifests/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
35
|
+
const { status, json } = await this.#t.request("PUT", path, opts);
|
|
36
|
+
if (status !== 200)
|
|
37
|
+
throw createPodmanError(status, json, "PUT", path);
|
|
38
|
+
return json;
|
|
39
|
+
}
|
|
40
|
+
/** Delete a manifest list. */
|
|
41
|
+
async remove(nameOrId, query) {
|
|
42
|
+
const path = `/manifests/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
43
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
44
|
+
if (status !== 200)
|
|
45
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
46
|
+
return json;
|
|
47
|
+
}
|
|
48
|
+
/** Push a manifest list to a registry. */
|
|
49
|
+
async push(nameOrId, destination, query) {
|
|
50
|
+
const path = `/manifests/${encodeURIComponent(nameOrId)}/push/${encodeURIComponent(destination)}${buildQuery(query)}`;
|
|
51
|
+
const headers = {};
|
|
52
|
+
const authHeader = this.#t.getAuthHeader();
|
|
53
|
+
if (authHeader)
|
|
54
|
+
headers["X-Registry-Auth"] = authHeader;
|
|
55
|
+
const res = await this.#t.requestRaw("POST", path, undefined, headers);
|
|
56
|
+
if (res.status !== 200)
|
|
57
|
+
await throwRawError(res, "POST", path);
|
|
58
|
+
return (await res.json());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { Network, NetworkConnectOptions, NetworkCreateOptions, NetworkDisconnectOptions, NetworkListQuery, NetworkPruneQuery, NetworkPruneReport, NetworkUpdateOptions } from "../types/api.js";
|
|
3
|
+
export declare class NetworksApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Create a new network. */
|
|
7
|
+
create(opts: NetworkCreateOptions): Promise<Network>;
|
|
8
|
+
/** Inspect a network. Returns `null` if the network is not found. */
|
|
9
|
+
inspect(nameOrId: string): Promise<Network | null>;
|
|
10
|
+
/** List networks, optionally filtered by the given query. */
|
|
11
|
+
list(query?: NetworkListQuery): Promise<Network[]>;
|
|
12
|
+
/** Remove a network. */
|
|
13
|
+
remove(nameOrId: string): Promise<void>;
|
|
14
|
+
/** Check if a network exists. Returns `true` on 204, `false` otherwise. */
|
|
15
|
+
exists(nameOrId: string): Promise<boolean>;
|
|
16
|
+
/** Update an existing network (e.g. add/remove DNS servers). Requires Podman 5.0+. */
|
|
17
|
+
update(nameOrId: string, opts: NetworkUpdateOptions): Promise<void>;
|
|
18
|
+
/** Connect a container to a network. */
|
|
19
|
+
connect(nameOrId: string, opts: NetworkConnectOptions): Promise<void>;
|
|
20
|
+
/** Disconnect a container from a network. */
|
|
21
|
+
disconnect(nameOrId: string, opts: NetworkDisconnectOptions): Promise<void>;
|
|
22
|
+
/** Remove unused networks. Returns a list of pruned networks. */
|
|
23
|
+
prune(query?: NetworkPruneQuery): Promise<NetworkPruneReport[]>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=networks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../src/api/networks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,OAAO,EACP,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,WAAW;;gBAEV,SAAS,EAAE,SAAS;IAIhC,4BAA4B;IACtB,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAO1D,qEAAqE;IAC/D,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAQxD,6DAA6D;IACvD,IAAI,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAOxD,wBAAwB;IAClB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,2EAA2E;IACrE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMhD,sFAAsF;IAChF,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzE,wCAAwC;IAClC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAa3E,6CAA6C;IACvC,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB,iEAAiE;IAC3D,KAAK,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAMtE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createPodmanError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class NetworksApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create a new network. */
|
|
9
|
+
async create(opts) {
|
|
10
|
+
const path = "/networks/create";
|
|
11
|
+
const { status, json } = await this.#t.request("POST", path, opts);
|
|
12
|
+
if (status !== 200)
|
|
13
|
+
throw createPodmanError(status, json, "POST", path);
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
/** Inspect a network. Returns `null` if the network is not found. */
|
|
17
|
+
async inspect(nameOrId) {
|
|
18
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}`;
|
|
19
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
20
|
+
if (status === 404)
|
|
21
|
+
return null;
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "GET", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** List networks, optionally filtered by the given query. */
|
|
27
|
+
async list(query) {
|
|
28
|
+
const path = `/networks/json${buildQuery(query)}`;
|
|
29
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
30
|
+
if (status !== 200)
|
|
31
|
+
throw createPodmanError(status, json, "GET", path);
|
|
32
|
+
return (json ?? []);
|
|
33
|
+
}
|
|
34
|
+
/** Remove a network. */
|
|
35
|
+
async remove(nameOrId) {
|
|
36
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}`;
|
|
37
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
38
|
+
if (status !== 200 && status !== 204) {
|
|
39
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Check if a network exists. Returns `true` on 204, `false` otherwise. */
|
|
43
|
+
async exists(nameOrId) {
|
|
44
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}/exists`;
|
|
45
|
+
const { status } = await this.#t.request("GET", path);
|
|
46
|
+
return status === 204;
|
|
47
|
+
}
|
|
48
|
+
/** Update an existing network (e.g. add/remove DNS servers). Requires Podman 5.0+. */
|
|
49
|
+
async update(nameOrId, opts) {
|
|
50
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}/update`;
|
|
51
|
+
const { status, json } = await this.#t.request("POST", path, opts);
|
|
52
|
+
if (status !== 200)
|
|
53
|
+
throw createPodmanError(status, json, "POST", path);
|
|
54
|
+
}
|
|
55
|
+
/** Connect a container to a network. */
|
|
56
|
+
async connect(nameOrId, opts) {
|
|
57
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}/connect`;
|
|
58
|
+
const res = await this.#t.requestRaw("POST", path, JSON.stringify(opts), {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
});
|
|
61
|
+
if (res.status !== 200) {
|
|
62
|
+
const text = await res.text();
|
|
63
|
+
let json = null;
|
|
64
|
+
try {
|
|
65
|
+
json = JSON.parse(text);
|
|
66
|
+
}
|
|
67
|
+
catch { /* plain text */ }
|
|
68
|
+
throw createPodmanError(res.status, json, "POST", path);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Disconnect a container from a network. */
|
|
72
|
+
async disconnect(nameOrId, opts) {
|
|
73
|
+
const path = `/networks/${encodeURIComponent(nameOrId)}/disconnect`;
|
|
74
|
+
const res = await this.#t.requestRaw("POST", path, JSON.stringify(opts), {
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
});
|
|
77
|
+
if (res.status !== 200) {
|
|
78
|
+
const text = await res.text();
|
|
79
|
+
let json = null;
|
|
80
|
+
try {
|
|
81
|
+
json = JSON.parse(text);
|
|
82
|
+
}
|
|
83
|
+
catch { /* plain text */ }
|
|
84
|
+
throw createPodmanError(res.status, json, "POST", path);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Remove unused networks. Returns a list of pruned networks. */
|
|
88
|
+
async prune(query) {
|
|
89
|
+
const path = `/networks/prune${buildQuery(query)}`;
|
|
90
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
91
|
+
if (status !== 200)
|
|
92
|
+
throw createPodmanError(status, json, "POST", path);
|
|
93
|
+
return (json ?? []);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { IDResponse, InspectPodData, ListPodsReport, PodRemoveQuery, PodKillQuery, PodKillReport, PodListQuery, PodPauseReport, PodPruneReport, PodRestartReport, PodRmReport, PodSpecGenerator, PodStartReport, PodStatsQuery, PodStatsReport, PodStopQuery, PodStopReport, PodTopOKBody, PodTopQuery, PodUnpauseReport } from "../types/api.js";
|
|
3
|
+
export declare class PodsApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Create a new pod from the given spec. */
|
|
7
|
+
create(spec: PodSpecGenerator): Promise<IDResponse>;
|
|
8
|
+
/** Inspect a pod. Returns `null` if the pod is not found. */
|
|
9
|
+
inspect(nameOrId: string): Promise<InspectPodData | null>;
|
|
10
|
+
/** List pods, optionally filtered by the given query. */
|
|
11
|
+
list(query?: PodListQuery): Promise<ListPodsReport[]>;
|
|
12
|
+
/** Remove a pod and optionally its containers. */
|
|
13
|
+
remove(nameOrId: string, query?: PodRemoveQuery): Promise<PodRmReport>;
|
|
14
|
+
/** Start all containers in a pod. */
|
|
15
|
+
start(nameOrId: string): Promise<PodStartReport>;
|
|
16
|
+
/** Stop all containers in a pod with an optional timeout. */
|
|
17
|
+
stop(nameOrId: string, query?: PodStopQuery): Promise<PodStopReport>;
|
|
18
|
+
/** Restart all containers in a pod. */
|
|
19
|
+
restart(nameOrId: string): Promise<PodRestartReport>;
|
|
20
|
+
/** Send a signal to all containers in a pod. */
|
|
21
|
+
kill(nameOrId: string, query?: PodKillQuery): Promise<PodKillReport>;
|
|
22
|
+
/** Pause all containers in a pod. */
|
|
23
|
+
pause(nameOrId: string): Promise<PodPauseReport>;
|
|
24
|
+
/** Unpause all containers in a pod. */
|
|
25
|
+
unpause(nameOrId: string): Promise<PodUnpauseReport>;
|
|
26
|
+
/** List processes running in the pod's containers. */
|
|
27
|
+
top(nameOrId: string, query?: PodTopQuery): Promise<PodTopOKBody>;
|
|
28
|
+
/** Check if a pod exists. Returns `true` on 204, `false` otherwise. */
|
|
29
|
+
exists(nameOrId: string): Promise<boolean>;
|
|
30
|
+
/** Get resource usage statistics for the pod's containers. */
|
|
31
|
+
stats(query?: PodStatsQuery): Promise<PodStatsReport[]>;
|
|
32
|
+
/** Remove all stopped pods. */
|
|
33
|
+
prune(): Promise<PodPruneReport>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pods.d.ts","sourceRoot":"","sources":["../../src/api/pods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,OAAO;;gBAEN,SAAS,EAAE,SAAS;IAIhC,4CAA4C;IACtC,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAOzD,6DAA6D;IACvD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAQ/D,yDAAyD;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAO3D,kDAAkD;IAC5C,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,WAAW,CAAC;IAQvB,qCAAqC;IAC/B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAOtD,6DAA6D;IACvD,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,aAAa,CAAC;IAQzB,uCAAuC;IACjC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO1D,gDAAgD;IAC1C,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,aAAa,CAAC;IAQzB,qCAAqC;IAC/B,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAOtD,uCAAuC;IACjC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO1D,sDAAsD;IAChD,GAAG,CACP,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,YAAY,CAAC;IAQxB,uEAAuE;IACjE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMhD,8DAA8D;IACxD,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAO7D,+BAA+B;IACzB,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC;CAMvC"}
|
package/esm/api/pods.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createPodmanError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class PodsApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create a new pod from the given spec. */
|
|
9
|
+
async create(spec) {
|
|
10
|
+
const path = "/pods/create";
|
|
11
|
+
const { status, json } = await this.#t.request("POST", path, spec);
|
|
12
|
+
if (status !== 201)
|
|
13
|
+
throw createPodmanError(status, json, "POST", path);
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
/** Inspect a pod. Returns `null` if the pod is not found. */
|
|
17
|
+
async inspect(nameOrId) {
|
|
18
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/json`;
|
|
19
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
20
|
+
if (status === 404)
|
|
21
|
+
return null;
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "GET", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** List pods, optionally filtered by the given query. */
|
|
27
|
+
async list(query) {
|
|
28
|
+
const path = `/pods/json${buildQuery(query)}`;
|
|
29
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
30
|
+
if (status !== 200)
|
|
31
|
+
throw createPodmanError(status, json, "GET", path);
|
|
32
|
+
return (json ?? []);
|
|
33
|
+
}
|
|
34
|
+
/** Remove a pod and optionally its containers. */
|
|
35
|
+
async remove(nameOrId, query) {
|
|
36
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
37
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
38
|
+
if (status !== 200)
|
|
39
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
40
|
+
return json;
|
|
41
|
+
}
|
|
42
|
+
/** Start all containers in a pod. */
|
|
43
|
+
async start(nameOrId) {
|
|
44
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/start`;
|
|
45
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
46
|
+
if (status !== 200 && status !== 304)
|
|
47
|
+
throw createPodmanError(status, json, "POST", path);
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
/** Stop all containers in a pod with an optional timeout. */
|
|
51
|
+
async stop(nameOrId, query) {
|
|
52
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/stop${buildQuery(query)}`;
|
|
53
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
54
|
+
if (status !== 200 && status !== 304)
|
|
55
|
+
throw createPodmanError(status, json, "POST", path);
|
|
56
|
+
return json;
|
|
57
|
+
}
|
|
58
|
+
/** Restart all containers in a pod. */
|
|
59
|
+
async restart(nameOrId) {
|
|
60
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/restart`;
|
|
61
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
62
|
+
if (status !== 200)
|
|
63
|
+
throw createPodmanError(status, json, "POST", path);
|
|
64
|
+
return json;
|
|
65
|
+
}
|
|
66
|
+
/** Send a signal to all containers in a pod. */
|
|
67
|
+
async kill(nameOrId, query) {
|
|
68
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/kill${buildQuery(query)}`;
|
|
69
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
70
|
+
if (status !== 200)
|
|
71
|
+
throw createPodmanError(status, json, "POST", path);
|
|
72
|
+
return json;
|
|
73
|
+
}
|
|
74
|
+
/** Pause all containers in a pod. */
|
|
75
|
+
async pause(nameOrId) {
|
|
76
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/pause`;
|
|
77
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
78
|
+
if (status !== 200)
|
|
79
|
+
throw createPodmanError(status, json, "POST", path);
|
|
80
|
+
return json;
|
|
81
|
+
}
|
|
82
|
+
/** Unpause all containers in a pod. */
|
|
83
|
+
async unpause(nameOrId) {
|
|
84
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/unpause`;
|
|
85
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
86
|
+
if (status !== 200)
|
|
87
|
+
throw createPodmanError(status, json, "POST", path);
|
|
88
|
+
return json;
|
|
89
|
+
}
|
|
90
|
+
/** List processes running in the pod's containers. */
|
|
91
|
+
async top(nameOrId, query) {
|
|
92
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/top${buildQuery(query)}`;
|
|
93
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
94
|
+
if (status !== 200)
|
|
95
|
+
throw createPodmanError(status, json, "GET", path);
|
|
96
|
+
return json;
|
|
97
|
+
}
|
|
98
|
+
/** Check if a pod exists. Returns `true` on 204, `false` otherwise. */
|
|
99
|
+
async exists(nameOrId) {
|
|
100
|
+
const path = `/pods/${encodeURIComponent(nameOrId)}/exists`;
|
|
101
|
+
const { status } = await this.#t.request("GET", path);
|
|
102
|
+
return status === 204;
|
|
103
|
+
}
|
|
104
|
+
/** Get resource usage statistics for the pod's containers. */
|
|
105
|
+
async stats(query) {
|
|
106
|
+
const path = `/pods/stats${buildQuery(query)}`;
|
|
107
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
108
|
+
if (status !== 200)
|
|
109
|
+
throw createPodmanError(status, json, "GET", path);
|
|
110
|
+
return (json ?? []);
|
|
111
|
+
}
|
|
112
|
+
/** Remove all stopped pods. */
|
|
113
|
+
async prune() {
|
|
114
|
+
const path = "/pods/prune";
|
|
115
|
+
const { status, json } = await this.#t.request("POST", path);
|
|
116
|
+
if (status !== 200)
|
|
117
|
+
throw createPodmanError(status, json, "POST", path);
|
|
118
|
+
return json;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { ListQuadlet, QuadletRemoveAllQuery, QuadletRemoveQuery, QuadletInstallQuery, QuadletListQuery, QuadletRemoveReport } from "../types/api.js";
|
|
3
|
+
export type QuadletInstallReport = {
|
|
4
|
+
InstalledQuadlets?: Record<string, string>;
|
|
5
|
+
QuadletErrors?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare class QuadletsApi {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(transport: Transport);
|
|
10
|
+
/** Install quadlet files from a tar archive. */
|
|
11
|
+
install(body: ReadableStream<Uint8Array>, query?: QuadletInstallQuery): Promise<QuadletInstallReport>;
|
|
12
|
+
/** Remove one or more quadlets. */
|
|
13
|
+
removeAll(query?: QuadletRemoveAllQuery): Promise<QuadletRemoveReport>;
|
|
14
|
+
/** Remove a quadlet by name. */
|
|
15
|
+
remove(name: string, query?: QuadletRemoveQuery): Promise<QuadletRemoveReport>;
|
|
16
|
+
/** Check if a quadlet exists. Returns `true` on 204, `false` otherwise. */
|
|
17
|
+
exists(name: string): Promise<boolean>;
|
|
18
|
+
/** Get the contents of a quadlet file. */
|
|
19
|
+
file(name: string): Promise<string>;
|
|
20
|
+
/** List all quadlets. */
|
|
21
|
+
list(query?: QuadletListQuery): Promise<ListQuadlet[]>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=quadlets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadlets.d.ts","sourceRoot":"","sources":["../../src/api/quadlets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAGF,qBAAa,WAAW;;gBAEV,SAAS,EAAE,SAAS;IAIhC,gDAAgD;IAC1C,OAAO,CACX,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,KAAK,CAAC,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAShC,mCAAmC;IAC7B,SAAS,CAAC,KAAK,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,gCAAgC;IAC1B,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IAQ/B,2EAA2E;IACrE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM5C,0CAA0C;IACpC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOzC,yBAAyB;IACnB,IAAI,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAM7D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class QuadletsApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Install quadlet files from a tar archive. */
|
|
9
|
+
async install(body, query) {
|
|
10
|
+
const path = `/quadlets${buildQuery(query)}`;
|
|
11
|
+
const res = await this.#t.requestRaw("POST", path, body, {
|
|
12
|
+
"Content-Type": "application/x-tar",
|
|
13
|
+
});
|
|
14
|
+
if (res.status !== 200)
|
|
15
|
+
await throwRawError(res, "POST", path);
|
|
16
|
+
return (await res.json());
|
|
17
|
+
}
|
|
18
|
+
/** Remove one or more quadlets. */
|
|
19
|
+
async removeAll(query) {
|
|
20
|
+
const path = `/quadlets${buildQuery(query)}`;
|
|
21
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
22
|
+
if (status !== 200)
|
|
23
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
24
|
+
return json;
|
|
25
|
+
}
|
|
26
|
+
/** Remove a quadlet by name. */
|
|
27
|
+
async remove(name, query) {
|
|
28
|
+
const path = `/quadlets/${encodeURIComponent(name)}${buildQuery(query)}`;
|
|
29
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
30
|
+
if (status !== 200)
|
|
31
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
32
|
+
return json;
|
|
33
|
+
}
|
|
34
|
+
/** Check if a quadlet exists. Returns `true` on 204, `false` otherwise. */
|
|
35
|
+
async exists(name) {
|
|
36
|
+
const path = `/quadlets/${encodeURIComponent(name)}/exists`;
|
|
37
|
+
const { status } = await this.#t.request("GET", path);
|
|
38
|
+
return status === 204;
|
|
39
|
+
}
|
|
40
|
+
/** Get the contents of a quadlet file. */
|
|
41
|
+
async file(name) {
|
|
42
|
+
const path = `/quadlets/${encodeURIComponent(name)}/file`;
|
|
43
|
+
const res = await this.#t.requestRaw("GET", path);
|
|
44
|
+
if (res.status !== 200)
|
|
45
|
+
await throwRawError(res, "GET", path);
|
|
46
|
+
return await res.text();
|
|
47
|
+
}
|
|
48
|
+
/** List all quadlets. */
|
|
49
|
+
async list(query) {
|
|
50
|
+
const path = `/quadlets/json${buildQuery(query)}`;
|
|
51
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
52
|
+
if (status !== 200)
|
|
53
|
+
throw createPodmanError(status, json, "GET", path);
|
|
54
|
+
return (json ?? []);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { SecretCreateQuery, SecretCreateReport, SecretRemoveQuery, SecretInfoReport, SecretInspectQuery, SecretListQuery } from "../types/api.js";
|
|
3
|
+
export declare class SecretsApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Create a new secret from the given data string. */
|
|
7
|
+
create(data: string, query: SecretCreateQuery): Promise<SecretCreateReport>;
|
|
8
|
+
/** Inspect a secret. Returns `null` if the secret is not found. */
|
|
9
|
+
inspect(nameOrId: string, query?: SecretInspectQuery): Promise<SecretInfoReport | null>;
|
|
10
|
+
/** List secrets, optionally filtered by the given query. */
|
|
11
|
+
list(query?: SecretListQuery): Promise<SecretInfoReport[]>;
|
|
12
|
+
/** Remove a secret. */
|
|
13
|
+
remove(nameOrId: string, query?: SecretRemoveQuery): Promise<void>;
|
|
14
|
+
/** Check if a secret exists. Returns `true` on 204, `false` otherwise. */
|
|
15
|
+
exists(nameOrId: string): Promise<boolean>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/api/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,UAAU;;gBAET,SAAS,EAAE,SAAS;IAIhC,sDAAsD;IAChD,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAS9B,mEAAmE;IAC7D,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,kBAAkB,GACzB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IASnC,4DAA4D;IACtD,IAAI,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAOhE,uBAAuB;IACjB,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC;IAOhB,0EAA0E;IACpE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAKjD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createPodmanError, throwRawError } from "../types/errors.js";
|
|
2
|
+
import { buildQuery } from "../internal/query.js";
|
|
3
|
+
export class SecretsApi {
|
|
4
|
+
#t;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.#t = transport;
|
|
7
|
+
}
|
|
8
|
+
/** Create a new secret from the given data string. */
|
|
9
|
+
async create(data, query) {
|
|
10
|
+
const path = `/secrets/create${buildQuery(query)}`;
|
|
11
|
+
const res = await this.#t.requestRaw("POST", path, data, {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
});
|
|
14
|
+
if (res.status !== 200 && res.status !== 201)
|
|
15
|
+
await throwRawError(res, "POST", path);
|
|
16
|
+
return (await res.json());
|
|
17
|
+
}
|
|
18
|
+
/** Inspect a secret. Returns `null` if the secret is not found. */
|
|
19
|
+
async inspect(nameOrId, query) {
|
|
20
|
+
const path = `/secrets/${encodeURIComponent(nameOrId)}/json${buildQuery(query)}`;
|
|
21
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
22
|
+
if (status === 404)
|
|
23
|
+
return null;
|
|
24
|
+
if (status !== 200)
|
|
25
|
+
throw createPodmanError(status, json, "GET", path);
|
|
26
|
+
return json;
|
|
27
|
+
}
|
|
28
|
+
/** List secrets, optionally filtered by the given query. */
|
|
29
|
+
async list(query) {
|
|
30
|
+
const path = `/secrets/json${buildQuery(query)}`;
|
|
31
|
+
const { status, json } = await this.#t.request("GET", path);
|
|
32
|
+
if (status !== 200)
|
|
33
|
+
throw createPodmanError(status, json, "GET", path);
|
|
34
|
+
return (json ?? []);
|
|
35
|
+
}
|
|
36
|
+
/** Remove a secret. */
|
|
37
|
+
async remove(nameOrId, query) {
|
|
38
|
+
const path = `/secrets/${encodeURIComponent(nameOrId)}${buildQuery(query)}`;
|
|
39
|
+
const { status, json } = await this.#t.request("DELETE", path);
|
|
40
|
+
if (status !== 204)
|
|
41
|
+
throw createPodmanError(status, json, "DELETE", path);
|
|
42
|
+
}
|
|
43
|
+
/** Check if a secret exists. Returns `true` on 204, `false` otherwise. */
|
|
44
|
+
async exists(nameOrId) {
|
|
45
|
+
const path = `/secrets/${encodeURIComponent(nameOrId)}/exists`;
|
|
46
|
+
const { status } = await this.#t.request("GET", path);
|
|
47
|
+
return status === 204;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Transport } from "../transport.js";
|
|
2
|
+
import type { LibpodInfo, SystemComponentVersion, SystemDfReport, SystemCheckQuery, SystemCheckReport, SystemEventsQuery, SystemPruneReport } from "../types/api.js";
|
|
3
|
+
export declare class SystemApi {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
/** Return information about the Podman host. */
|
|
7
|
+
info(): Promise<LibpodInfo>;
|
|
8
|
+
/** Return component version information for the Podman service. */
|
|
9
|
+
version(): Promise<SystemComponentVersion>;
|
|
10
|
+
/** Ping the Podman service. Returns `true` if reachable. */
|
|
11
|
+
ping(): Promise<boolean>;
|
|
12
|
+
/** Prune unused data (containers, images, volumes, networks). */
|
|
13
|
+
prune(): Promise<SystemPruneReport>;
|
|
14
|
+
/** Return disk usage information (containers, images, volumes). */
|
|
15
|
+
df(): Promise<SystemDfReport>;
|
|
16
|
+
/** Stream system events as raw bytes. */
|
|
17
|
+
events(query?: SystemEventsQuery): Promise<ReadableStream<Uint8Array>>;
|
|
18
|
+
/** Stream system events as parsed JSON objects. */
|
|
19
|
+
parsedEvents(query?: SystemEventsQuery): AsyncGenerator<Record<string, unknown>>;
|
|
20
|
+
/** Run a consistency check on container storage. */
|
|
21
|
+
check(query?: SystemCheckQuery): Promise<SystemCheckReport>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/api/system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,KAAK,EACV,UAAU,EACV,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,SAAS;;gBAER,SAAS,EAAE,SAAS;IAIhC,gDAAgD;IAC1C,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAOjC,mEAAmE;IAC7D,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAOhD,4DAA4D;IACtD,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAO9B,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAOzC,mEAAmE;IAC7D,EAAE,IAAI,OAAO,CAAC,cAAc,CAAC;IAOnC,yCAAyC;IACnC,MAAM,CACV,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAKtC,mDAAmD;IAC5C,YAAY,CACjB,KAAK,CAAC,EAAE,iBAAiB,GACxB,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAkC1C,oDAAoD;IAC9C,KAAK,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAMlE"}
|