@dockstat/docker 0.1.0 → 0.1.2

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.
@@ -1,87 +0,0 @@
1
- import { BaseModule } from "../base"
2
- import type {
3
- CreateNetworkOptions,
4
- ListNetworksOptions,
5
- NetworkConnectRequest,
6
- NetworkCreateResponse,
7
- NetworkDisconnectRequest,
8
- NetworkInspect,
9
- NetworkPruneResponse,
10
- NetworkSummary,
11
- PruneNetworksOptions,
12
- } from "./types"
13
-
14
- /**
15
- * Networks module for managing Docker networks
16
- */
17
- export class NetworksModule extends BaseModule {
18
- /**
19
- * List networks
20
- * @param options - List options including filters
21
- * @returns Array of network summaries
22
- */
23
- async list(options?: ListNetworksOptions): Promise<NetworkSummary[]> {
24
- const res = await this.request(`/networks`, "GET", undefined, undefined, options)
25
- return (await res.json()) as NetworkSummary[]
26
- }
27
-
28
- /**
29
- * Create a network
30
- * @param config - Network configuration
31
- * @returns Network create response with ID and warnings
32
- */
33
- async create(config: CreateNetworkOptions): Promise<NetworkCreateResponse> {
34
- const res = await this.request("/networks/create", "POST", config)
35
- return (await res.json()) as NetworkCreateResponse
36
- }
37
-
38
- /**
39
- * Inspect a network
40
- * @param id - Network ID or name
41
- * @param options - Inspect options
42
- * @returns Detailed network information
43
- */
44
- async inspect(
45
- id: string,
46
- options?: { verbose?: boolean; scope?: string }
47
- ): Promise<NetworkInspect> {
48
- const res = await this.request(`/networks/${id}`, "GET", undefined, undefined, options)
49
- return (await res.json()) as NetworkInspect
50
- }
51
-
52
- /**
53
- * Remove a network
54
- * @param id - Network ID or name
55
- */
56
- async remove(id: string): Promise<void> {
57
- await this.request(`/networks/${id}`, "DELETE")
58
- }
59
-
60
- /**
61
- * Connect a container to a network
62
- * @param id - Network ID or name
63
- * @param request - Connection request with container and endpoint config
64
- */
65
- async connect(id: string, request: NetworkConnectRequest): Promise<void> {
66
- await this.request(`/networks/${id}/connect`, "POST", request)
67
- }
68
-
69
- /**
70
- * Disconnect a container from a network
71
- * @param id - Network ID or name
72
- * @param request - Disconnection request with container and force option
73
- */
74
- async disconnect(id: string, request: NetworkDisconnectRequest): Promise<void> {
75
- await this.request(`/networks/${id}/disconnect`, "POST", request)
76
- }
77
-
78
- /**
79
- * Remove unused networks
80
- * @param options - Prune options including filters
81
- * @returns Prune response with deleted networks
82
- */
83
- async prune(options?: PruneNetworksOptions): Promise<NetworkPruneResponse> {
84
- const res = await this.request(`/networks/prune`, "POST", undefined, undefined, options)
85
- return (await res.json()) as NetworkPruneResponse
86
- }
87
- }
@@ -1,258 +0,0 @@
1
- // ============================================================================
2
- // Network Types
3
- // ============================================================================
4
-
5
- /**
6
- * Network configuration and state
7
- */
8
- export interface Network {
9
- Name?: string
10
- Id?: string
11
- Created?: number
12
- Scope?: string
13
- Driver?: string
14
- EnableIPv4?: boolean
15
- EnableIPv6?: boolean
16
- IPAM?: IPAM
17
- Internal?: boolean
18
- Attachable?: boolean
19
- Ingress?: boolean
20
- ConfigFrom?: ConfigReference
21
- ConfigOnly?: boolean
22
- Options?: Record<string, string>
23
- Labels?: Record<string, string>
24
- Peers?: PeerInfo[]
25
- }
26
-
27
- /**
28
- * Network summary (extends Network)
29
- */
30
- export interface NetworkSummary extends Network {}
31
-
32
- /**
33
- * Full network inspection details
34
- */
35
- export interface NetworkInspect extends Network {
36
- Containers?: Record<string, EndpointResource>
37
- Services?: Record<string, ServiceInfo>
38
- Status?: NetworkStatus
39
- }
40
-
41
- /**
42
- * Network status information
43
- */
44
- export interface NetworkStatus {
45
- IPAM?: IPAMStatus
46
- }
47
-
48
- /**
49
- * Service information in a network
50
- */
51
- export interface ServiceInfo {
52
- VIP?: string
53
- Ports?: string[]
54
- LocalLBIndex?: number
55
- Tasks?: NetworkTaskInfo[]
56
- }
57
-
58
- /**
59
- * Task information in a network
60
- */
61
- export interface NetworkTaskInfo {
62
- Name?: string
63
- EndpointID?: string
64
- EndpointIP?: string
65
- MacAddress?: string
66
- IPv4Address?: string
67
- IPv6Address?: string
68
- }
69
-
70
- /**
71
- * Config reference for network
72
- */
73
- export interface ConfigReference {
74
- Network?: string
75
- }
76
-
77
- /**
78
- * IPAM configuration
79
- */
80
- export interface IPAM {
81
- Driver?: string
82
- Config?: IPAMConfig[]
83
- Options?: Record<string, string>
84
- }
85
-
86
- /**
87
- * IPAM configuration entry
88
- */
89
- export interface IPAMConfig {
90
- Subnet?: string
91
- IPRange?: string
92
- Gateway?: string
93
- AuxiliaryAddresses?: Record<string, string>
94
- }
95
-
96
- /**
97
- * IPAM status
98
- */
99
- export interface IPAMStatus {
100
- Subnets?: Record<string, SubnetStatus>
101
- }
102
-
103
- /**
104
- * Subnet status
105
- */
106
- export interface SubnetStatus {
107
- IPsInUse?: number
108
- DynamicIPsAvailable?: number
109
- }
110
-
111
- /**
112
- * Endpoint resource information
113
- */
114
- export interface EndpointResource {
115
- Name?: string
116
- EndpointID?: string
117
- MacAddress?: string
118
- IPv4Address?: string
119
- IPv6Address?: string
120
- }
121
-
122
- /**
123
- * Peer information
124
- */
125
- export interface PeerInfo {
126
- Name?: string
127
- IP?: string
128
- }
129
-
130
- /**
131
- * Network create response
132
- */
133
- export interface NetworkCreateResponse {
134
- Id?: string
135
- Warning?: string
136
- }
137
-
138
- /**
139
- * Network connect request
140
- */
141
- export interface NetworkConnectRequest {
142
- Container?: string
143
- EndpointConfig?: EndpointSettings
144
- }
145
-
146
- /**
147
- * Network disconnect request
148
- */
149
- export interface NetworkDisconnectRequest {
150
- Container?: string
151
- Force?: boolean
152
- }
153
-
154
- /**
155
- * Endpoint settings
156
- */
157
- export interface EndpointSettings {
158
- IPAMConfig?: EndpointIPAMConfig
159
- Links?: string[]
160
- Aliases?: string[]
161
- NetworkID?: string
162
- EndpointID?: string
163
- Gateway?: string
164
- IPAddress?: string
165
- IPPrefixLen?: number
166
- IPv6Gateway?: string
167
- GlobalIPv6Address?: string
168
- GlobalIPv6PrefixLen?: number
169
- MacAddress?: string
170
- DriverOpts?: Record<string, string>
171
- }
172
-
173
- /**
174
- * Endpoint IPAM configuration
175
- */
176
- export interface EndpointIPAMConfig {
177
- IPv4Address?: string
178
- IPv6Address?: string
179
- LinkLocalIPs?: string[]
180
- }
181
-
182
- /**
183
- * Network prune response
184
- */
185
- export interface NetworkPruneResponse {
186
- NetworksDeleted?: string[]
187
- }
188
-
189
- // ============================================================================
190
- // Request/Response Types
191
- // ============================================================================
192
-
193
- /**
194
- * List networks options
195
- */
196
- export interface ListNetworksOptions {
197
- filters?: {
198
- dangling?: boolean[]
199
- driver?: string[]
200
- id?: string[]
201
- label?: string[]
202
- name?: string[]
203
- scope?: string[]
204
- type?: string[]
205
- }
206
- }
207
-
208
- /**
209
- * Create network options
210
- */
211
- export interface CreateNetworkOptions {
212
- Name: string
213
- CheckDuplicate?: boolean
214
- Driver?: string
215
- Internal?: boolean
216
- Attachable?: boolean
217
- Ingress?: boolean
218
- IPAM?: IPAM
219
- EnableIPv6?: boolean
220
- Options?: Record<string, string>
221
- Labels?: Record<string, string>
222
- Scope?: string
223
- }
224
-
225
- /**
226
- * Inspect network options
227
- */
228
- export interface InspectNetworkOptions {
229
- verbose?: boolean
230
- scope?: string
231
- }
232
-
233
- /**
234
- * Connect network options
235
- */
236
- export interface ConnectNetworkOptions {
237
- Container?: string
238
- EndpointConfig?: EndpointSettings
239
- }
240
-
241
- /**
242
- * Disconnect network options
243
- */
244
- export interface DisconnectNetworkOptions {
245
- Container?: string
246
- Force?: boolean
247
- }
248
-
249
- /**
250
- * Prune networks options
251
- */
252
- export interface PruneNetworksOptions {
253
- filters?: {
254
- dangling?: boolean[]
255
- label?: string[]
256
- until?: string[]
257
- }
258
- }
@@ -1,48 +0,0 @@
1
- import { BaseModule } from "../base"
2
- import type { ListNodesOptions, NodeResponse, NodeUpdateOptions } from "./types"
3
-
4
- export class NodesModule extends BaseModule {
5
- /**
6
- * List nodes
7
- * @param options Filters to process on the nodes list, encoded as JSON (a Record<string, string[]>).
8
- * @returns NodeResponse[]
9
- */
10
- async list(options?: ListNodesOptions) {
11
- const res = await this.request(`/nodes`, "GET", undefined, undefined, options)
12
- return (await res.json()) as NodeResponse[]
13
- }
14
-
15
- /**
16
- * Inspect a node
17
- * @param id The ID or name of the node
18
- */
19
- async inspect(id: string) {
20
- const res = await this.request(`/nodes/${id}`, "GET")
21
- return (await res.json()) as NodeResponse
22
- }
23
-
24
- /**
25
- *
26
- * @param id The ID or name of the node
27
- * @param force Force remove a node from the swarm (Default: false)
28
- * @returns `true` or throws an DockerError
29
- */
30
- async delete(id: string, force: boolean = false) {
31
- await this.request(`/nodes/${id}`, "DELETE", undefined, undefined, { force })
32
- // No thrown error = sucess
33
- return true
34
- }
35
-
36
- /**
37
- *
38
- * @param id The ID or name of the node
39
- * @param version The version number of the node object being updated. This is required to avoid conflicting writes.
40
- * @param options What to update
41
- * @returns
42
- */
43
- async update(id: string, version: number, options: NodeUpdateOptions) {
44
- await this.request(`/nodes/${id}/update`, "POST", options, undefined, { version })
45
- // No thrown error = sucess
46
- return true
47
- }
48
- }
@@ -1,69 +0,0 @@
1
- type NodeFilters = {
2
- id?: string[]
3
- label?: string[]
4
- membership?: Array<"accepted" | "pending">
5
- name?: string[]
6
- "node.label"?: string[]
7
- role?: Array<"manager" | "worker">
8
- }
9
-
10
- export type ListNodesOptions = {
11
- filters: NodeFilters
12
- }
13
-
14
- export type NodeResponse = {
15
- ID: string
16
- Version: {
17
- Index: number
18
- }
19
- CreatedAt: string
20
- UpdatedAt: string
21
- Spec: {
22
- Name: string
23
- Labels: Record<string, string>
24
- Role: "worker" | "manager"
25
- Availability: "active" | "pause" | "drain"
26
- }
27
- Description: {
28
- Hostname: string
29
- Platform: {
30
- Architecture: string
31
- OS: string
32
- }
33
- Resources: {
34
- NanoCPUs: number
35
- MemoryBytes: number
36
- GenericResources: Array<
37
- | { DiscreteResourceSpec: { Kind: string; Value: number } }
38
- | { NamedResourceSpec: { Kind: string; Value: string } }
39
- >
40
- }
41
- Engine: {
42
- EngineVersion: string
43
- Labels: Record<string, string>
44
- Plugins: Array<{ Type: string; Name: string }>
45
- }
46
- TLSInfo: {
47
- TrustRoot: string
48
- CertIssuerSubject: string
49
- CertIssuerPublicKey: string
50
- }
51
- }
52
- Status: {
53
- State: "unknown" | "down" | "ready" | "disconnected"
54
- Message: string
55
- Addr: string
56
- }
57
- ManagerStatus: {
58
- Leader: boolean
59
- Reachability: "unknown" | "unreachable" | "reachable"
60
- Addr: string
61
- } | null
62
- }
63
-
64
- export type NodeUpdateOptions = {
65
- Name: string
66
- Labels: Record<string, string>
67
- Role: "worker" | "manager"
68
- Availability: "active" | "pause" | "drain"
69
- }
@@ -1,128 +0,0 @@
1
- import { BaseModule } from "../base"
2
- import type {
3
- CreatePluginOptions,
4
- DisablePluginOptions,
5
- EnablePluginOptions,
6
- ListPluginsOptions,
7
- PluginConfig,
8
- PluginPrivilege,
9
- PullPluginOptions,
10
- RemovePluginOptions,
11
- SetPluginOptions,
12
- UpgradePluginOptions,
13
- } from "./types"
14
-
15
- export class PluginsModule extends BaseModule {
16
- /**
17
- * List plugins
18
- * @param options - List options
19
- * @returns Array of plugin configurations
20
- */
21
- async list(options?: ListPluginsOptions): Promise<PluginConfig[]> {
22
- const res = await this.request(`/plugins`, "GET", undefined, undefined, options)
23
- return (await res.json()) as PluginConfig[]
24
- }
25
-
26
- /**
27
- * Get plugin privileges
28
- * @param remote - Remote name or plugin name
29
- * @returns Array of plugin privileges
30
- */
31
- async privileges(remote: string): Promise<PluginPrivilege[]> {
32
- const res = await this.request(`/plugins/privileges`, "GET", undefined, undefined, { remote })
33
- return (await res.json()) as PluginPrivilege[]
34
- }
35
-
36
- /**
37
- * Pull a plugin
38
- * @param options - Pull options
39
- * @returns Plugin configuration
40
- */
41
- async pull(options: PullPluginOptions): Promise<PluginConfig> {
42
- const res = await this.request(`/plugins/pull`, "POST", undefined, undefined, options)
43
- return (await res.json()) as PluginConfig
44
- }
45
-
46
- /**
47
- * Get plugin details
48
- * @param name - Plugin name
49
- * @returns Plugin configuration
50
- */
51
- async inspect(name: string): Promise<PluginConfig> {
52
- const res = await this.request(`/plugins/${name}/json`, "GET")
53
- return (await res.json()) as PluginConfig
54
- }
55
-
56
- /**
57
- * Remove a plugin
58
- * @param name - Plugin name
59
- * @param options - Remove options
60
- */
61
- async remove(name: string, options?: RemovePluginOptions): Promise<void> {
62
- await this.request(`/plugins/${name}`, "DELETE", undefined, undefined, options)
63
- }
64
-
65
- /**
66
- * Enable a plugin
67
- * @param name - Plugin name
68
- * @param options - Enable options
69
- */
70
- async enable(name: string, options?: EnablePluginOptions): Promise<void> {
71
- await this.request(`/plugins/${name}/enable`, "POST", undefined, undefined, options)
72
- }
73
-
74
- /**
75
- * Disable a plugin
76
- * @param name - Plugin name
77
- * @param options - Disable options
78
- */
79
- async disable(name: string, options?: DisablePluginOptions): Promise<void> {
80
- await this.request(`/plugins/${name}/disable`, "POST", undefined, undefined, options)
81
- }
82
-
83
- /**
84
- * Upgrade a plugin
85
- * @param name - Plugin name
86
- * @param options - Upgrade options
87
- * @returns Plugin configuration
88
- */
89
- async upgrade(name: string, options: UpgradePluginOptions): Promise<PluginConfig> {
90
- const res = await this.request(
91
- `/plugins/${name}/upgrade`,
92
- "POST",
93
- undefined,
94
- undefined,
95
- options
96
- )
97
- return (await res.json()) as PluginConfig
98
- }
99
-
100
- /**
101
- * Create a plugin
102
- * @param options - Create options
103
- * @returns Plugin configuration
104
- */
105
- async create(options: CreatePluginOptions): Promise<PluginConfig> {
106
- const res = await this.request(`/plugins/create`, "POST", options.path, undefined, {
107
- name: options.name,
108
- })
109
- return (await res.json()) as PluginConfig
110
- }
111
-
112
- /**
113
- * Push a plugin
114
- * @param name - Plugin name
115
- */
116
- async push(name: string): Promise<void> {
117
- await this.request(`/plugins/${name}/push`, "POST")
118
- }
119
-
120
- /**
121
- * Set plugin settings
122
- * @param name - Plugin name
123
- * @param options - Set options
124
- */
125
- async set(name: string, options: SetPluginOptions): Promise<void> {
126
- await this.request(`/plugins/${name}/set`, "POST", JSON.stringify(options.settings))
127
- }
128
- }
@@ -1,114 +0,0 @@
1
- export type PluginsFilter = {
2
- capability: string[]
3
- enabled: boolean[]
4
- }
5
-
6
- export type PluginDevice = {
7
- Name: string
8
- Description: string
9
- Settable: string[]
10
- Path: string
11
- }
12
-
13
- export type PluginMount = {
14
- Name: string
15
- Description: string
16
- Settable: string[]
17
- Source: string
18
- Destination: string
19
- Type: string
20
- Options: string[]
21
- }
22
-
23
- export type PluginConfig = {
24
- Id: string
25
- Name: string
26
- Enabled: boolean
27
- Settings: {
28
- Mounts: Array<PluginMount>
29
- Env: string[]
30
- Args: string[]
31
- Devices: Array<PluginDevice>
32
- }
33
- PluginReference: string
34
- Config: {
35
- Description: string
36
- Documentation: string
37
- Interface: Array<{
38
- Types: string[]
39
- Socket: string
40
- ProtocolScheme: "" | "moby.plugins.http/v1"
41
- }>
42
- Entrypoint: string[]
43
- WorkDir: string
44
- User: {
45
- UID: number
46
- GID: number
47
- }
48
- Network: {
49
- Type: string
50
- }
51
- Linux: {
52
- Capabilities: string[]
53
- AllowAllDevices: boolean
54
- Devices: Array<PluginDevice>
55
- }
56
- PropagatedMount: string
57
- IpcHost: string
58
- PidHost: string
59
- Mounts: Array<PluginMount>
60
- Env: Array<{
61
- Name: string
62
- Description: string
63
- Settable: string[]
64
- Value: string
65
- }>
66
- Args: Array<{ Name: string; Description: string; Settable: string[]; Value: string[] }>
67
- rootfs: {
68
- type: string
69
- diff_ids: string[]
70
- }
71
- }
72
- }
73
-
74
- export type PluginPrivilege = {
75
- Name: string
76
- Description: string
77
- Value: string[]
78
- }
79
-
80
- export type ListPluginsOptions = {
81
- filters?: PluginsFilter
82
- }
83
-
84
- export type PullPluginOptions = {
85
- remote: string
86
- name?: string
87
- privileges?: PluginPrivilege[]
88
- }
89
-
90
- export type CreatePluginOptions = {
91
- name: string
92
- path: string
93
- }
94
-
95
- export type RemovePluginOptions = {
96
- force?: boolean
97
- }
98
-
99
- export type EnablePluginOptions = {
100
- timeout?: number
101
- }
102
-
103
- export type DisablePluginOptions = {
104
- timeout?: number
105
- }
106
-
107
- export type UpgradePluginOptions = {
108
- remote: string
109
- privileges?: PluginPrivilege[]
110
- }
111
-
112
- export type SetPluginOptions = {
113
- settings: Array<PluginMount | PluginDevice | string[]>
114
- }
@@ -1,5 +0,0 @@
1
- import { BaseModule } from "../base"
2
-
3
- export class SecretsModule extends BaseModule {
4
- list() {}
5
- }
File without changes