next-lxd 1.0.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/LICENSE +21 -0
- package/README.md +780 -0
- package/bun.lock +317 -0
- package/classes/Certificate.ts +43 -0
- package/classes/Certificates.ts +34 -0
- package/classes/Client.ts +142 -0
- package/classes/Cluster.ts +174 -0
- package/classes/Image.ts +114 -0
- package/classes/Images.ts +38 -0
- package/classes/Instance.ts +599 -0
- package/classes/Instances.ts +44 -0
- package/classes/Network.ts +176 -0
- package/classes/Networks.ts +30 -0
- package/classes/Operation.ts +39 -0
- package/classes/Operations.ts +24 -0
- package/classes/Profile.ts +54 -0
- package/classes/Profiles.ts +30 -0
- package/classes/Project.ts +63 -0
- package/classes/Projects.ts +30 -0
- package/classes/Resource.ts +9 -0
- package/classes/StoragePool.ts +160 -0
- package/classes/StoragePools.ts +34 -0
- package/classes/Warnings.ts +39 -0
- package/index.ts +19 -0
- package/lxd-api-source.json +24022 -0
- package/package.json +36 -0
- package/tsconfig.json +21 -0
- package/types/index.d.ts +1087 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdNetworkResponse,
|
|
6
|
+
LxdNetworkPut,
|
|
7
|
+
LxdBaseResponse,
|
|
8
|
+
LxdNetworkLeasesResponse,
|
|
9
|
+
LxdNetworkForwardsPost,
|
|
10
|
+
LxdNetworkForwardPut,
|
|
11
|
+
LxdNetworkForwardsResponse,
|
|
12
|
+
LxdNetworkForwardResponse,
|
|
13
|
+
LxdNetworkACLsPost,
|
|
14
|
+
LxdNetworkACLPut,
|
|
15
|
+
LxdNetworkACLsResponse,
|
|
16
|
+
LxdNetworkACLResponse,
|
|
17
|
+
LxdNetworkPeerPut,
|
|
18
|
+
LxdNetworkPeersResponse,
|
|
19
|
+
LxdNetworkPeerResponse,
|
|
20
|
+
} from "../types";
|
|
21
|
+
|
|
22
|
+
export class Network extends Resource {
|
|
23
|
+
public name: string;
|
|
24
|
+
public type: string;
|
|
25
|
+
public managed: boolean;
|
|
26
|
+
public metadata: LxdNetworkResponse["metadata"];
|
|
27
|
+
|
|
28
|
+
constructor(client: Client, options: LxdNetworkResponse) {
|
|
29
|
+
super(client);
|
|
30
|
+
|
|
31
|
+
this.name = options.metadata.name;
|
|
32
|
+
this.type = options.metadata.type;
|
|
33
|
+
this.managed = options.metadata.managed;
|
|
34
|
+
this.metadata = options.metadata;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async delete(project?: string): Promise<LxdBaseResponse<void>> {
|
|
38
|
+
return this.client.request({
|
|
39
|
+
method: "DELETE",
|
|
40
|
+
path: `/1.0/networks/${this.name}${project ? `?project=${project}` : ""}`,
|
|
41
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async put(data: LxdNetworkPut, project?: string): Promise<LxdBaseResponse<void>> {
|
|
45
|
+
return this.client.request({
|
|
46
|
+
method: "PUT",
|
|
47
|
+
path: `/1.0/networks/${this.name}${project ? `?project=${project}` : ""}`,
|
|
48
|
+
body: data,
|
|
49
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async patch(data: LxdNetworkPut, project?: string): Promise<LxdBaseResponse<void>> {
|
|
53
|
+
return this.client.request({
|
|
54
|
+
method: "PATCH",
|
|
55
|
+
path: `/1.0/networks/${this.name}${project ? `?project=${project}` : ""}`,
|
|
56
|
+
body: data,
|
|
57
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async state(project?: string): Promise<LxdBaseResponse<Record<string, any>>> {
|
|
61
|
+
return this.client.request({
|
|
62
|
+
method: "GET",
|
|
63
|
+
path: `/1.0/networks/${this.name}/state${project ? `?project=${project}` : ""}`,
|
|
64
|
+
}) as Promise<LxdBaseResponse<Record<string, any>>>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async leases(project?: string): Promise<LxdNetworkLeasesResponse> {
|
|
68
|
+
return this.client.request({
|
|
69
|
+
method: "GET",
|
|
70
|
+
path: `/1.0/networks/${this.name}/leases${project ? `?project=${project}` : ""}`,
|
|
71
|
+
}) as Promise<LxdNetworkLeasesResponse>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
forwards = {
|
|
75
|
+
list: async (project?: string): Promise<LxdNetworkForwardsResponse> => {
|
|
76
|
+
return this.client.request({
|
|
77
|
+
path: `/1.0/networks/${this.name}/forwards${project ? `?project=${project}` : ""}`,
|
|
78
|
+
}) as Promise<LxdNetworkForwardsResponse>;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
get: async (listenAddress: string, project?: string): Promise<LxdNetworkForwardResponse> => {
|
|
82
|
+
return this.client.request({
|
|
83
|
+
path: `/1.0/networks/${this.name}/forwards/${listenAddress}${project ? `?project=${project}` : ""}`,
|
|
84
|
+
}) as Promise<LxdNetworkForwardResponse>;
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
post: async (data: LxdNetworkForwardsPost, project?: string): Promise<LxdNetworkForwardResponse> => {
|
|
88
|
+
return this.client.request({
|
|
89
|
+
method: "POST",
|
|
90
|
+
path: `/1.0/networks/${this.name}/forwards${project ? `?project=${project}` : ""}`,
|
|
91
|
+
body: data,
|
|
92
|
+
}) as Promise<LxdNetworkForwardResponse>;
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
put: async (listenAddress: string, data: LxdNetworkForwardPut, project?: string): Promise<LxdNetworkForwardResponse> => {
|
|
96
|
+
return this.client.request({
|
|
97
|
+
method: "PUT",
|
|
98
|
+
path: `/1.0/networks/${this.name}/forwards/${listenAddress}${project ? `?project=${project}` : ""}`,
|
|
99
|
+
body: data,
|
|
100
|
+
}) as Promise<LxdNetworkForwardResponse>;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
delete: async (listenAddress: string, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
104
|
+
return this.client.request({
|
|
105
|
+
method: "DELETE",
|
|
106
|
+
path: `/1.0/networks/${this.name}/forwards/${listenAddress}${project ? `?project=${project}` : ""}`,
|
|
107
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
acls = {
|
|
112
|
+
list: async (project?: string): Promise<LxdNetworkACLsResponse> => {
|
|
113
|
+
return this.client.request({
|
|
114
|
+
path: `/1.0/networks/${this.name}/acls${project ? `?project=${project}` : ""}`,
|
|
115
|
+
}) as Promise<LxdNetworkACLsResponse>;
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
get: async (aclName: string, project?: string): Promise<LxdNetworkACLResponse> => {
|
|
119
|
+
return this.client.request({
|
|
120
|
+
path: `/1.0/networks/${this.name}/acls/${aclName}${project ? `?project=${project}` : ""}`,
|
|
121
|
+
}) as Promise<LxdNetworkACLResponse>;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
post: async (data: LxdNetworkACLsPost, project?: string): Promise<LxdNetworkACLResponse> => {
|
|
125
|
+
return this.client.request({
|
|
126
|
+
method: "POST",
|
|
127
|
+
path: `/1.0/networks/${this.name}/acls${project ? `?project=${project}` : ""}`,
|
|
128
|
+
body: data,
|
|
129
|
+
}) as Promise<LxdNetworkACLResponse>;
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
put: async (aclName: string, data: LxdNetworkACLPut, project?: string): Promise<LxdNetworkACLResponse> => {
|
|
133
|
+
return this.client.request({
|
|
134
|
+
method: "PUT",
|
|
135
|
+
path: `/1.0/networks/${this.name}/acls/${aclName}${project ? `?project=${project}` : ""}`,
|
|
136
|
+
body: data,
|
|
137
|
+
}) as Promise<LxdNetworkACLResponse>;
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
delete: async (aclName: string, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
141
|
+
return this.client.request({
|
|
142
|
+
method: "DELETE",
|
|
143
|
+
path: `/1.0/networks/${this.name}/acls/${aclName}${project ? `?project=${project}` : ""}`,
|
|
144
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
peers = {
|
|
149
|
+
list: async (project?: string): Promise<LxdNetworkPeersResponse> => {
|
|
150
|
+
return this.client.request({
|
|
151
|
+
path: `/1.0/networks/${this.name}/peers${project ? `?project=${project}` : ""}`,
|
|
152
|
+
}) as Promise<LxdNetworkPeersResponse>;
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
get: async (peerName: string, project?: string): Promise<LxdNetworkPeerResponse> => {
|
|
156
|
+
return this.client.request({
|
|
157
|
+
path: `/1.0/networks/${this.name}/peers/${peerName}${project ? `?project=${project}` : ""}`,
|
|
158
|
+
}) as Promise<LxdNetworkPeerResponse>;
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
put: async (peerName: string, data: LxdNetworkPeerPut, project?: string): Promise<LxdNetworkPeerResponse> => {
|
|
162
|
+
return this.client.request({
|
|
163
|
+
method: "PUT",
|
|
164
|
+
path: `/1.0/networks/${this.name}/peers/${peerName}${project ? `?project=${project}` : ""}`,
|
|
165
|
+
body: data,
|
|
166
|
+
}) as Promise<LxdNetworkPeerResponse>;
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
delete: async (peerName: string, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
170
|
+
return this.client.request({
|
|
171
|
+
method: "DELETE",
|
|
172
|
+
path: `/1.0/networks/${this.name}/peers/${peerName}${project ? `?project=${project}` : ""}`,
|
|
173
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Resource } from './Resource';
|
|
2
|
+
import { Network } from './Network';
|
|
3
|
+
|
|
4
|
+
import type { LxdNetworksResponse, LxdNetworkResponse, LxdNetworksPost } from '../types';
|
|
5
|
+
|
|
6
|
+
export class Networks extends Resource {
|
|
7
|
+
async list(project?: string): Promise<LxdNetworksResponse> {
|
|
8
|
+
return this.client.request({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: `/1.0/networks${project ? `?project=${project}` : ''}`
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async get(name: string, project?: string): Promise<Network> {
|
|
15
|
+
const data = (await this.client.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: `/1.0/networks/${name}${project ? `?project=${project}` : ''}`
|
|
18
|
+
})) as LxdNetworkResponse;
|
|
19
|
+
return new Network(this.client, data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async post(config: LxdNetworksPost, project?: string): Promise<Network> {
|
|
23
|
+
await this.client.request({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
path: `/1.0/networks${project ? `?project=${project}` : ''}`,
|
|
26
|
+
body: config
|
|
27
|
+
});
|
|
28
|
+
return this.get(config.name, project);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdOperationResponse,
|
|
6
|
+
LxdBaseResponse,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
export class Operation extends Resource {
|
|
10
|
+
public id: string;
|
|
11
|
+
public metadata: LxdOperationResponse["metadata"];
|
|
12
|
+
|
|
13
|
+
constructor(client: Client, options: LxdOperationResponse) {
|
|
14
|
+
super(client);
|
|
15
|
+
|
|
16
|
+
this.id = options.metadata.id;
|
|
17
|
+
this.metadata = options.metadata;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async wait(timeout?: number): Promise<LxdOperationResponse> {
|
|
21
|
+
const params = timeout !== undefined ? `?timeout=${timeout}` : "";
|
|
22
|
+
return this.client.request({
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: `/1.0/operations/${this.id}/wait${params}`,
|
|
25
|
+
}) as Promise<LxdOperationResponse>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async cancel(): Promise<LxdBaseResponse<void>> {
|
|
29
|
+
return this.client.request({
|
|
30
|
+
method: "DELETE",
|
|
31
|
+
path: `/1.0/operations/${this.id}`,
|
|
32
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
websocketUrl(secret?: string): string {
|
|
36
|
+
const base = `${this.client.url.protocol}//${this.client.url.host}/1.0/operations/${this.id}/websocket`;
|
|
37
|
+
return secret ? `${base}?secret=${secret}` : base;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Operation } from "./Operation";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdOperationsResponse,
|
|
6
|
+
LxdOperationResponse,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
export class Operations extends Resource {
|
|
10
|
+
async list(project?: string): Promise<LxdOperationsResponse> {
|
|
11
|
+
return this.client.request({
|
|
12
|
+
method: "GET",
|
|
13
|
+
path: `/1.0/operations${project ? `?project=${project}` : ""}`,
|
|
14
|
+
}) as Promise<LxdOperationsResponse>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async get(id: string): Promise<Operation> {
|
|
18
|
+
const data = await this.client.request({
|
|
19
|
+
method: "GET",
|
|
20
|
+
path: `/1.0/operations/${id}`,
|
|
21
|
+
}) as LxdOperationResponse;
|
|
22
|
+
return new Operation(this.client, data);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdProfileResponse,
|
|
6
|
+
LxdProfilePut,
|
|
7
|
+
LxdProfilePost,
|
|
8
|
+
LxdBaseResponse,
|
|
9
|
+
} from "../types";
|
|
10
|
+
|
|
11
|
+
export class Profile extends Resource {
|
|
12
|
+
public name: string;
|
|
13
|
+
public description: string;
|
|
14
|
+
public metadata: LxdProfileResponse["metadata"];
|
|
15
|
+
|
|
16
|
+
constructor(client: Client, options: LxdProfileResponse) {
|
|
17
|
+
super(client);
|
|
18
|
+
|
|
19
|
+
this.name = options.metadata.name;
|
|
20
|
+
this.description = options.metadata.description || "";
|
|
21
|
+
this.metadata = options.metadata;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async delete(project?: string): Promise<LxdBaseResponse<void>> {
|
|
25
|
+
return this.client.request({
|
|
26
|
+
method: "DELETE",
|
|
27
|
+
path: `/1.0/profiles/${this.name}${project ? `?project=${project}` : ""}`,
|
|
28
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async put(data: LxdProfilePut, project?: string): Promise<LxdBaseResponse<void>> {
|
|
32
|
+
return this.client.request({
|
|
33
|
+
method: "PUT",
|
|
34
|
+
path: `/1.0/profiles/${this.name}${project ? `?project=${project}` : ""}`,
|
|
35
|
+
body: data,
|
|
36
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async patch(data: LxdProfilePut, project?: string): Promise<LxdBaseResponse<void>> {
|
|
40
|
+
return this.client.request({
|
|
41
|
+
method: "PATCH",
|
|
42
|
+
path: `/1.0/profiles/${this.name}${project ? `?project=${project}` : ""}`,
|
|
43
|
+
body: data,
|
|
44
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async post(data: LxdProfilePost, project?: string): Promise<LxdBaseResponse<void>> {
|
|
48
|
+
return this.client.request({
|
|
49
|
+
method: "POST",
|
|
50
|
+
path: `/1.0/profiles/${this.name}${project ? `?project=${project}` : ""}`,
|
|
51
|
+
body: data,
|
|
52
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Resource } from './Resource';
|
|
2
|
+
import { Profile } from './Profile';
|
|
3
|
+
|
|
4
|
+
import type { LxdProfilesResponse, LxdProfileResponse, LxdProfilesPost } from '../types';
|
|
5
|
+
|
|
6
|
+
export class Profiles extends Resource {
|
|
7
|
+
async list(project?: string): Promise<LxdProfilesResponse> {
|
|
8
|
+
return this.client.request({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: `/1.0/profiles${project ? `?project=${project}` : ''}`
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async get(name: string, project?: string): Promise<Profile> {
|
|
15
|
+
const data = (await this.client.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: `/1.0/profiles/${name}${project ? `?project=${project}` : ''}`
|
|
18
|
+
})) as LxdProfileResponse;
|
|
19
|
+
return new Profile(this.client, data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async post(config: LxdProfilesPost, project?: string): Promise<Profile> {
|
|
23
|
+
await this.client.request({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
path: `/1.0/profiles${project ? `?project=${project}` : ''}`,
|
|
26
|
+
body: config
|
|
27
|
+
});
|
|
28
|
+
return this.get(config.name, project);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdProjectResponse,
|
|
6
|
+
LxdProjectPut,
|
|
7
|
+
LxdProjectPost,
|
|
8
|
+
LxdProjectStateResponse,
|
|
9
|
+
LxdBaseResponse,
|
|
10
|
+
} from "../types";
|
|
11
|
+
|
|
12
|
+
export class Project extends Resource {
|
|
13
|
+
public name: string;
|
|
14
|
+
public description: string;
|
|
15
|
+
public metadata: LxdProjectResponse["metadata"];
|
|
16
|
+
|
|
17
|
+
constructor(client: Client, options: LxdProjectResponse) {
|
|
18
|
+
super(client);
|
|
19
|
+
|
|
20
|
+
this.name = options.metadata.name;
|
|
21
|
+
this.description = options.metadata.description || "";
|
|
22
|
+
this.metadata = options.metadata;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async delete(force?: boolean): Promise<LxdBaseResponse<void>> {
|
|
26
|
+
const params = force ? "?force=1" : "";
|
|
27
|
+
return this.client.request({
|
|
28
|
+
method: "DELETE",
|
|
29
|
+
path: `/1.0/projects/${this.name}${params}`,
|
|
30
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async put(data: LxdProjectPut): Promise<LxdBaseResponse<void>> {
|
|
34
|
+
return this.client.request({
|
|
35
|
+
method: "PUT",
|
|
36
|
+
path: `/1.0/projects/${this.name}`,
|
|
37
|
+
body: data,
|
|
38
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async patch(data: LxdProjectPut): Promise<LxdBaseResponse<void>> {
|
|
42
|
+
return this.client.request({
|
|
43
|
+
method: "PATCH",
|
|
44
|
+
path: `/1.0/projects/${this.name}`,
|
|
45
|
+
body: data,
|
|
46
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async post(data: LxdProjectPost): Promise<LxdBaseResponse<void>> {
|
|
50
|
+
return this.client.request({
|
|
51
|
+
method: "POST",
|
|
52
|
+
path: `/1.0/projects/${this.name}`,
|
|
53
|
+
body: data,
|
|
54
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async state(): Promise<LxdProjectStateResponse> {
|
|
58
|
+
return this.client.request({
|
|
59
|
+
method: "GET",
|
|
60
|
+
path: `/1.0/projects/${this.name}/state`,
|
|
61
|
+
}) as Promise<LxdProjectStateResponse>;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Resource } from './Resource';
|
|
2
|
+
import { Project } from './Project';
|
|
3
|
+
|
|
4
|
+
import type { LxdProjectsResponse, LxdProjectResponse, LxdProjectsPost } from '../types';
|
|
5
|
+
|
|
6
|
+
export class Projects extends Resource {
|
|
7
|
+
async list(project?: string): Promise<LxdProjectsResponse> {
|
|
8
|
+
return this.client.request({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: `/1.0/projects${project ? `?project=${project}` : ''}`
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async get(name: string, project?: string): Promise<Project> {
|
|
15
|
+
const data = (await this.client.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: `/1.0/projects/${name}${project ? `?project=${project}` : ''}`
|
|
18
|
+
})) as LxdProjectResponse;
|
|
19
|
+
return new Project(this.client, data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async post(config: LxdProjectsPost, project?: string): Promise<Project> {
|
|
23
|
+
await this.client.request({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
path: `/1.0/projects${project ? `?project=${project}` : ''}`,
|
|
26
|
+
body: config
|
|
27
|
+
});
|
|
28
|
+
return this.get(config.name, project);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Resource } from "./Resource";
|
|
2
|
+
import { Client } from "./Client";
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdStoragePoolResponse,
|
|
6
|
+
LxdStoragePoolPut,
|
|
7
|
+
LxdBaseResponse,
|
|
8
|
+
LxdStorageVolumesResponse,
|
|
9
|
+
LxdStorageVolumeResponse,
|
|
10
|
+
LxdStorageVolumesPost,
|
|
11
|
+
LxdStorageVolumePut,
|
|
12
|
+
LxdStorageVolumePost,
|
|
13
|
+
LxdStorageVolumeSnapshotsResponse,
|
|
14
|
+
LxdStorageVolumeSnapshotResponse,
|
|
15
|
+
LxdStorageVolumeSnapshotsPost,
|
|
16
|
+
LxdStorageVolumeSnapshotPut,
|
|
17
|
+
LxdStorageVolumeSnapshotPost,
|
|
18
|
+
} from "../types";
|
|
19
|
+
|
|
20
|
+
export class StoragePool extends Resource {
|
|
21
|
+
public name: string;
|
|
22
|
+
public driver: string;
|
|
23
|
+
public metadata: LxdStoragePoolResponse["metadata"];
|
|
24
|
+
|
|
25
|
+
constructor(client: Client, options: LxdStoragePoolResponse) {
|
|
26
|
+
super(client);
|
|
27
|
+
|
|
28
|
+
this.name = options.metadata.name;
|
|
29
|
+
this.driver = options.metadata.driver;
|
|
30
|
+
this.metadata = options.metadata;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async delete(): Promise<LxdBaseResponse<void>> {
|
|
34
|
+
return this.client.request({
|
|
35
|
+
method: "DELETE",
|
|
36
|
+
path: `/1.0/storage-pools/${this.name}`,
|
|
37
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async put(data: LxdStoragePoolPut): Promise<LxdBaseResponse<void>> {
|
|
41
|
+
return this.client.request({
|
|
42
|
+
method: "PUT",
|
|
43
|
+
path: `/1.0/storage-pools/${this.name}`,
|
|
44
|
+
body: data,
|
|
45
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async patch(data: LxdStoragePoolPut): Promise<LxdBaseResponse<void>> {
|
|
49
|
+
return this.client.request({
|
|
50
|
+
method: "PATCH",
|
|
51
|
+
path: `/1.0/storage-pools/${this.name}`,
|
|
52
|
+
body: data,
|
|
53
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async resources() {
|
|
57
|
+
return this.client.request({
|
|
58
|
+
method: "GET",
|
|
59
|
+
path: `/1.0/storage-pools/${this.name}/resources`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
volumes = {
|
|
64
|
+
list: async (project?: string): Promise<LxdStorageVolumesResponse> => {
|
|
65
|
+
return this.client.request({
|
|
66
|
+
path: `/1.0/storage-pools/${this.name}/volumes${project ? `?project=${project}` : ""}`,
|
|
67
|
+
}) as Promise<LxdStorageVolumesResponse>;
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
get: async (type: string, name: string, project?: string): Promise<LxdStorageVolumeResponse> => {
|
|
71
|
+
return this.client.request({
|
|
72
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${name}${project ? `?project=${project}` : ""}`,
|
|
73
|
+
}) as Promise<LxdStorageVolumeResponse>;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
post: async (type: string, data: LxdStorageVolumesPost, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
77
|
+
return this.client.request({
|
|
78
|
+
method: "POST",
|
|
79
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}${project ? `?project=${project}` : ""}`,
|
|
80
|
+
body: data,
|
|
81
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
put: async (type: string, name: string, data: LxdStorageVolumePut, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
85
|
+
return this.client.request({
|
|
86
|
+
method: "PUT",
|
|
87
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${name}${project ? `?project=${project}` : ""}`,
|
|
88
|
+
body: data,
|
|
89
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
patch: async (type: string, name: string, data: LxdStorageVolumePut, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
93
|
+
return this.client.request({
|
|
94
|
+
method: "PATCH",
|
|
95
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${name}${project ? `?project=${project}` : ""}`,
|
|
96
|
+
body: data,
|
|
97
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
delete: async (type: string, name: string, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
101
|
+
return this.client.request({
|
|
102
|
+
method: "DELETE",
|
|
103
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${name}${project ? `?project=${project}` : ""}`,
|
|
104
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
rename: async (type: string, name: string, data: LxdStorageVolumePost, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
108
|
+
return this.client.request({
|
|
109
|
+
method: "POST",
|
|
110
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${name}${project ? `?project=${project}` : ""}`,
|
|
111
|
+
body: data,
|
|
112
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
snapshots: {
|
|
116
|
+
list: async (type: string, volumeName: string, project?: string): Promise<LxdStorageVolumeSnapshotsResponse> => {
|
|
117
|
+
return this.client.request({
|
|
118
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots${project ? `?project=${project}` : ""}`,
|
|
119
|
+
}) as Promise<LxdStorageVolumeSnapshotsResponse>;
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
get: async (type: string, volumeName: string, snapshotName: string, project?: string): Promise<LxdStorageVolumeSnapshotResponse> => {
|
|
123
|
+
return this.client.request({
|
|
124
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots/${snapshotName}${project ? `?project=${project}` : ""}`,
|
|
125
|
+
}) as Promise<LxdStorageVolumeSnapshotResponse>;
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
post: async (type: string, volumeName: string, data: LxdStorageVolumeSnapshotsPost, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
129
|
+
return this.client.request({
|
|
130
|
+
method: "POST",
|
|
131
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots${project ? `?project=${project}` : ""}`,
|
|
132
|
+
body: data,
|
|
133
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
put: async (type: string, volumeName: string, snapshotName: string, data: LxdStorageVolumeSnapshotPut, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
137
|
+
return this.client.request({
|
|
138
|
+
method: "PUT",
|
|
139
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots/${snapshotName}${project ? `?project=${project}` : ""}`,
|
|
140
|
+
body: data,
|
|
141
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
delete: async (type: string, volumeName: string, snapshotName: string, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
145
|
+
return this.client.request({
|
|
146
|
+
method: "DELETE",
|
|
147
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots/${snapshotName}${project ? `?project=${project}` : ""}`,
|
|
148
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
rename: async (type: string, volumeName: string, snapshotName: string, data: LxdStorageVolumeSnapshotPost, project?: string): Promise<LxdBaseResponse<void>> => {
|
|
152
|
+
return this.client.request({
|
|
153
|
+
method: "POST",
|
|
154
|
+
path: `/1.0/storage-pools/${this.name}/volumes/${type}/${volumeName}/snapshots/${snapshotName}${project ? `?project=${project}` : ""}`,
|
|
155
|
+
body: data,
|
|
156
|
+
}) as Promise<LxdBaseResponse<void>>;
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Resource } from './Resource';
|
|
2
|
+
import { StoragePool } from './StoragePool';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
LxdStoragePoolsResponse,
|
|
6
|
+
LxdStoragePoolResponse,
|
|
7
|
+
LxdStoragePoolsPost
|
|
8
|
+
} from '../types';
|
|
9
|
+
|
|
10
|
+
export class StoragePools extends Resource {
|
|
11
|
+
async list(project?: string): Promise<LxdStoragePoolsResponse> {
|
|
12
|
+
return this.client.request({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
path: `/1.0/storage-pools${project ? `?project=${project}` : ''}`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async get(name: string, project?: string): Promise<StoragePool> {
|
|
19
|
+
const data = (await this.client.request({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
path: `/1.0/storage-pools/${name}${project ? `?project=${project}` : ''}`
|
|
22
|
+
})) as LxdStoragePoolResponse;
|
|
23
|
+
return new StoragePool(this.client, data);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async post(config: LxdStoragePoolsPost, project?: string): Promise<StoragePool> {
|
|
27
|
+
await this.client.request({
|
|
28
|
+
method: 'POST',
|
|
29
|
+
path: `/1.0/storage-pools${project ? `?project=${project}` : ''}`,
|
|
30
|
+
body: config
|
|
31
|
+
});
|
|
32
|
+
return this.get(config.name, project);
|
|
33
|
+
}
|
|
34
|
+
}
|