@origincloud/resourcemanager 0.0.0-stage → 0.3.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.
@@ -0,0 +1,265 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/resourcemanager/v1beta1/project.proto
3
+
4
+ import {
5
+ type CallOptions,
6
+ type Client,
7
+ type Empty,
8
+ type Service,
9
+ newRequestId,
10
+ pathValue,
11
+ query,
12
+ } from "@origincloud/core";
13
+ import type { ProjectQuota } from "./quota.js";
14
+
15
+ /**
16
+ * Calls ProjectService.
17
+ *
18
+ * Projects: the namespace every resource is created in. A project belongs to
19
+ * one organization, and every resource name of the other APIs starts with
20
+ * it, `projects/{project}/...`.
21
+ */
22
+ export class ProjectClient {
23
+ /**
24
+ * The endpoint the client sends its calls to, which also serves the
25
+ * operations its methods answer with.
26
+ */
27
+ readonly service: Service;
28
+
29
+ /** A client of ProjectService that sends its calls through `client`. */
30
+ constructor(client: Client) {
31
+ this.service = client.service("resourcemanager", false);
32
+ }
33
+
34
+ /** Returns a project. */
35
+ async getProject(request: GetProjectRequest, options?: CallOptions): Promise<Project> {
36
+ const p0 = pathValue("name", request.name, "projects/*");
37
+ return this.service.call<Project>(
38
+ {
39
+ method: "GET",
40
+ path: `/v1beta1/${p0}`,
41
+ query: query(request, ["name"]),
42
+ idempotent: true,
43
+ },
44
+ options,
45
+ );
46
+ }
47
+
48
+ /** Lists an organization's projects, oldest first. */
49
+ async listProjects(request: ListProjectsRequest, options?: CallOptions): Promise<ListProjectsResponse> {
50
+ return this.service.call<ListProjectsResponse>(
51
+ {
52
+ method: "GET",
53
+ path: `/v1beta1/projects`,
54
+ query: query(request, []),
55
+ idempotent: true,
56
+ },
57
+ options,
58
+ );
59
+ }
60
+
61
+ /**
62
+ * Iterates over everything listProjects lists from the request's page on,
63
+ * fetching the next page as the loop reaches it. A page that fails ends
64
+ * the iteration with its error.
65
+ */
66
+ async *allProjects(request: ListProjectsRequest, options?: CallOptions): AsyncGenerator<Project, void, undefined> {
67
+ for (let page = request; ; ) {
68
+ const response = await this.listProjects(page, options);
69
+ yield* response.projects ?? [];
70
+ if (!response.nextPageToken) return;
71
+ page = { ...page, pageToken: response.nextPageToken };
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Creates a project in an `ACTIVE` organization, under the id the caller
77
+ * chooses. The caller becomes the project's owner, and the project is
78
+ * billed to the organization's default billing account. An id in use, or
79
+ * used by a project that was deleted, is refused as a `CONFLICT`.
80
+ */
81
+ async createProject(request: CreateProjectRequest, options?: CallOptions): Promise<Project> {
82
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
83
+ return this.service.call<Project>(
84
+ {
85
+ method: "POST",
86
+ path: `/v1beta1/projects`,
87
+ body: request.project,
88
+ query: query(request, ["project"]),
89
+ idempotent: true,
90
+ },
91
+ options,
92
+ );
93
+ }
94
+
95
+ /** Renames a project. */
96
+ async updateProject(request: UpdateProjectRequest, options?: CallOptions): Promise<Project> {
97
+ const p0 = pathValue("project.name", request.project?.name, "projects/*");
98
+ return this.service.call<Project>(
99
+ {
100
+ method: "PATCH",
101
+ path: `/v1beta1/${p0}`,
102
+ body: request.project,
103
+ query: query(request, ["project.name", "project"]),
104
+ },
105
+ options,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Deletes a project. Refused as a `CONFLICT` while the project
111
+ * still has a resource you can delete yourself: an instance that isn't terminated, an image, a key
112
+ * pair, a volume or snapshot that isn't deleted, a NAT gateway, a floating
113
+ * IP, a VPC, or a DNS policy other than its default one. The refusal names
114
+ * every kind left, in the order to delete them. Nothing you can delete
115
+ * yourself is deleted on your behalf. The project's default DNS policy,
116
+ * its quota and every role granted on it go with it; roles granted on the
117
+ * organization stay.
118
+ */
119
+ async deleteProject(request: DeleteProjectRequest, options?: CallOptions): Promise<Empty> {
120
+ const p0 = pathValue("name", request.name, "projects/*");
121
+ return this.service.call<Empty>(
122
+ {
123
+ method: "DELETE",
124
+ path: `/v1beta1/${p0}`,
125
+ query: query(request, ["name"]),
126
+ },
127
+ options,
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Returns a project's quota: the budget of each kind of resource the
133
+ * project may hold, if one is set, and how much of it the project uses.
134
+ */
135
+ async getProjectQuota(request: GetProjectQuotaRequest, options?: CallOptions): Promise<ProjectQuota> {
136
+ const p0 = pathValue("name", request.name, "projects/*/quota");
137
+ return this.service.call<ProjectQuota>(
138
+ {
139
+ method: "GET",
140
+ path: `/v1beta1/${p0}`,
141
+ query: query(request, ["name"]),
142
+ idempotent: true,
143
+ },
144
+ options,
145
+ );
146
+ }
147
+
148
+ /**
149
+ * Sets or removes a project's budgets. A budget named in `updateMask`
150
+ * is set to the value given, or removed when the value is left out.
151
+ */
152
+ async updateProjectQuota(request: UpdateProjectQuotaRequest, options?: CallOptions): Promise<ProjectQuota> {
153
+ const p0 = pathValue("projectQuota.name", request.projectQuota?.name, "projects/*/quota");
154
+ return this.service.call<ProjectQuota>(
155
+ {
156
+ method: "PATCH",
157
+ path: `/v1beta1/${p0}`,
158
+ body: request.projectQuota,
159
+ query: query(request, ["projectQuota.name", "projectQuota"]),
160
+ },
161
+ options,
162
+ );
163
+ }
164
+ }
165
+
166
+ /** A project: the namespace an organization's resources are created in. */
167
+ export interface Project {
168
+ /**
169
+ * The project's resource name, `projects/{project}`. The id, chosen when
170
+ * the project is created, is unique across the platform and never used
171
+ * again, not even after the project is deleted.
172
+ */
173
+ name?: string;
174
+ /**
175
+ * The project's URN, the identifier access policies and the audit log
176
+ * use.
177
+ */
178
+ urn?: string;
179
+ /** The organization the project belongs to, `organizations/{organization}`. */
180
+ organization?: string;
181
+ /** The name the console shows. Not empty. */
182
+ displayName?: string;
183
+ /** When the project was created. */
184
+ createTime?: string;
185
+ /**
186
+ * The principal that created the project, such as `user:<id>` or
187
+ * `service_account:<id>`.
188
+ */
189
+ creator?: string;
190
+ }
191
+
192
+ /** The request for GetProject. */
193
+ export interface GetProjectRequest {
194
+ /** The project to return. */
195
+ name?: string;
196
+ }
197
+
198
+ /** The request for ListProjects. */
199
+ export interface ListProjectsRequest {
200
+ /** The organization whose projects to list, `organizations/{organization}`. */
201
+ organization?: string;
202
+ /**
203
+ * The most projects to return; the server clamps it, and 0 means its
204
+ * default.
205
+ */
206
+ pageSize?: number;
207
+ /** A previous response's `nextPageToken`, for the page after it. */
208
+ pageToken?: string;
209
+ }
210
+
211
+ /** The response for ListProjects. */
212
+ export interface ListProjectsResponse {
213
+ /** The projects on this page. */
214
+ projects?: Project[];
215
+ /** The token for the next page; empty on the last one. */
216
+ nextPageToken?: string;
217
+ }
218
+
219
+ /** The request for CreateProject. */
220
+ export interface CreateProjectRequest {
221
+ /** The project to create: its `organization` and `displayName`. */
222
+ project?: Project;
223
+ /**
224
+ * The project's id, the last segment of its name: 6 to 16 lowercase
225
+ * letters, digits and hyphens, starting with a letter and not ending with
226
+ * a hyphen, such as `acme-prod`.
227
+ */
228
+ projectId?: string;
229
+ /**
230
+ * A UUID; a repeat with the same id returns the project the first request
231
+ * created instead of creating a second one.
232
+ */
233
+ requestId?: string;
234
+ }
235
+
236
+ /** The request for UpdateProject. */
237
+ export interface UpdateProjectRequest {
238
+ /** The project, by its name, with the fields to change. */
239
+ project?: Project;
240
+ /** The fields to change: `displayName`. `*` is the same. */
241
+ updateMask?: string;
242
+ }
243
+
244
+ /** The request for DeleteProject. */
245
+ export interface DeleteProjectRequest {
246
+ /** The project to delete. */
247
+ name?: string;
248
+ }
249
+
250
+ /** The request for GetProjectQuota. */
251
+ export interface GetProjectQuotaRequest {
252
+ /** The quota to return, `projects/{project}/quota`. */
253
+ name?: string;
254
+ }
255
+
256
+ /** The request for UpdateProjectQuota. */
257
+ export interface UpdateProjectQuotaRequest {
258
+ /** The quota, by its name, with the budgets to set. */
259
+ projectQuota?: ProjectQuota;
260
+ /**
261
+ * The budgets to set or remove, such as `maxVcpu`. `*` is every budget:
262
+ * those given are set, the others removed.
263
+ */
264
+ updateMask?: string;
265
+ }
@@ -0,0 +1,73 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/resourcemanager/v1beta1/quota.proto
3
+
4
+ /**
5
+ * An organization's quota: the most of each kind of resource its projects
6
+ * may hold together, and how much of it they use. Creating a resource past a
7
+ * limit is refused.
8
+ */
9
+ export interface OrganizationQuota {
10
+ /** The quota's resource name, `organizations/{organization}/quota`. */
11
+ name?: string;
12
+ /** The most instances that aren't terminated. */
13
+ maxInstances?: string;
14
+ /** The most vCPUs, summed over the instances that aren't terminated. */
15
+ maxVcpu?: string;
16
+ /** The most GiB of volumes that aren't deleted. */
17
+ maxVolumeGib?: string;
18
+ /** The most VPCs. */
19
+ maxVpcs?: string;
20
+ /** The most floating IPs. */
21
+ maxPublicIps?: string;
22
+ /** How much of each limit the organization's projects use together. */
23
+ usage?: QuotaUsage;
24
+ }
25
+
26
+ /**
27
+ * A project's quota: the budgets its owners set for it, and how much of each
28
+ * the project uses. A project without a budget for a kind of resource is
29
+ * bounded by its organization's quota alone; with one, by both. Budgets are
30
+ * not reservations: several projects' budgets may add up to more than the
31
+ * organization's limit.
32
+ */
33
+ export interface ProjectQuota {
34
+ /** The quota's resource name, `projects/{project}/quota`. */
35
+ name?: string;
36
+ /**
37
+ * The most instances that aren't terminated; unset means no budget. Each
38
+ * budget is zero or more, and no more than the organization's limit for
39
+ * the same kind.
40
+ */
41
+ maxInstances?: string;
42
+ /**
43
+ * The most vCPUs, summed over the instances that aren't terminated; unset
44
+ * means no budget.
45
+ */
46
+ maxVcpu?: string;
47
+ /** The most GiB of volumes that aren't deleted; unset means no budget. */
48
+ maxVolumeGib?: string;
49
+ /** The most VPCs; unset means no budget. */
50
+ maxVpcs?: string;
51
+ /** The most floating IPs; unset means no budget. */
52
+ maxPublicIps?: string;
53
+ /** How much of each budget the project uses. */
54
+ usage?: QuotaUsage;
55
+ }
56
+
57
+ /**
58
+ * How many of each kind of resource are held. Counted continuously, so a
59
+ * resource just created or deleted can take up to half a minute to show;
60
+ * a limit is enforced on the exact count.
61
+ */
62
+ export interface QuotaUsage {
63
+ /** Instances that aren't terminated. */
64
+ instances?: string;
65
+ /** vCPUs of the instances that aren't terminated. */
66
+ vcpu?: string;
67
+ /** GiB of volumes that aren't deleted. */
68
+ volumeGib?: string;
69
+ /** VPCs. */
70
+ vpcs?: string;
71
+ /** Floating IPs. */
72
+ publicIps?: string;
73
+ }