@origincloud/iam 0.0.0-stage → 0.6.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.
Files changed (38) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +23 -2
  3. package/dist/v1beta1/audit_log.d.ts +136 -0
  4. package/dist/v1beta1/audit_log.d.ts.map +1 -0
  5. package/dist/v1beta1/audit_log.js +77 -0
  6. package/dist/v1beta1/audit_log.js.map +1 -0
  7. package/dist/v1beta1/index.d.ts +7 -0
  8. package/dist/v1beta1/index.d.ts.map +1 -0
  9. package/dist/v1beta1/index.js +8 -0
  10. package/dist/v1beta1/index.js.map +1 -0
  11. package/dist/v1beta1/permission.d.ts +92 -0
  12. package/dist/v1beta1/permission.d.ts.map +1 -0
  13. package/dist/v1beta1/permission.js +63 -0
  14. package/dist/v1beta1/permission.js.map +1 -0
  15. package/dist/v1beta1/role.d.ts +55 -0
  16. package/dist/v1beta1/role.d.ts.map +1 -0
  17. package/dist/v1beta1/role.js +42 -0
  18. package/dist/v1beta1/role.js.map +1 -0
  19. package/dist/v1beta1/role_binding.d.ts +172 -0
  20. package/dist/v1beta1/role_binding.d.ts.map +1 -0
  21. package/dist/v1beta1/role_binding.js +118 -0
  22. package/dist/v1beta1/role_binding.js.map +1 -0
  23. package/dist/v1beta1/service_account.d.ts +146 -0
  24. package/dist/v1beta1/service_account.d.ts.map +1 -0
  25. package/dist/v1beta1/service_account.js +106 -0
  26. package/dist/v1beta1/service_account.js.map +1 -0
  27. package/dist/v1beta1/user.d.ts +50 -0
  28. package/dist/v1beta1/user.d.ts.map +1 -0
  29. package/dist/v1beta1/user.js +36 -0
  30. package/dist/v1beta1/user.js.map +1 -0
  31. package/package.json +40 -4
  32. package/src/v1beta1/audit_log.ts +180 -0
  33. package/src/v1beta1/index.ts +8 -0
  34. package/src/v1beta1/permission.ts +138 -0
  35. package/src/v1beta1/role.ts +87 -0
  36. package/src/v1beta1/role_binding.ts +251 -0
  37. package/src/v1beta1/service_account.ts +225 -0
  38. package/src/v1beta1/user.ts +70 -0
@@ -0,0 +1,251 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/iam/v1beta1/role_binding.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
+
14
+ /**
15
+ * Calls RoleBindingService.
16
+ *
17
+ * Role bindings: each grants one role to one member, in a whole
18
+ * organization or in one of its projects. A member's access is the union
19
+ * of its bindings. Each binding is managed on its own, so creating or
20
+ * deleting one never touches another, whoever made it.
21
+ *
22
+ * A member is written as one of:
23
+ * - `user:{email}`: a user, by the verified email address of their
24
+ * account. A binding holds on to the account, not the address: it
25
+ * follows a later change of address, and is always shown with the
26
+ * account's current one.
27
+ * - `serviceAccount:{service_account}`: a service account of the same
28
+ * organization, by its id.
29
+ *
30
+ * and shown, never accepted, as:
31
+ * - `userId:{user}`: a user by the id of their account, when no verified
32
+ * address can be shown: the account's current address isn't verified, or
33
+ * the caller may only see their own bindings.
34
+ * - `deleted:user:{user}`: a user whose account no longer exists.
35
+ */
36
+ export class RoleBindingClient {
37
+ /**
38
+ * The endpoint the client sends its calls to, which also serves the
39
+ * operations its methods answer with.
40
+ */
41
+ readonly service: Service;
42
+
43
+ /** A client of RoleBindingService that sends its calls through `client`. */
44
+ constructor(client: Client) {
45
+ this.service = client.service("iam", false);
46
+ }
47
+
48
+ /** Returns a role binding. Needs `iam.member.list` on the organization. */
49
+ async getRoleBinding(request: GetRoleBindingRequest, options?: CallOptions): Promise<RoleBinding> {
50
+ const p0 = pathValue("name", request.name, "organizations/*/roleBindings/*");
51
+ return this.service.call<RoleBinding>(
52
+ {
53
+ method: "GET",
54
+ path: `/v1beta1/${p0}`,
55
+ query: query(request, ["name"]),
56
+ idempotent: true,
57
+ },
58
+ options,
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Lists an organization's role bindings, oldest first, optionally only a
64
+ * member's or a project's. Needs `iam.member.list` on the organization.
65
+ * With the parent `organizations/-` it lists the caller's own bindings in
66
+ * every organization and needs no permission; `member` must be empty
67
+ * there.
68
+ */
69
+ async listRoleBindings(request: ListRoleBindingsRequest, options?: CallOptions): Promise<ListRoleBindingsResponse> {
70
+ const p0 = pathValue("parent", request.parent, "organizations/*");
71
+ return this.service.call<ListRoleBindingsResponse>(
72
+ {
73
+ method: "GET",
74
+ path: `/v1beta1/${p0}/roleBindings`,
75
+ query: query(request, ["parent"]),
76
+ idempotent: true,
77
+ },
78
+ options,
79
+ );
80
+ }
81
+
82
+ /**
83
+ * Iterates over everything listRoleBindings lists from the request's page on,
84
+ * fetching the next page as the loop reaches it. A page that fails ends
85
+ * the iteration with its error.
86
+ */
87
+ async *allRoleBindings(request: ListRoleBindingsRequest, options?: CallOptions): AsyncGenerator<RoleBinding, void, undefined> {
88
+ for (let page = request; ; ) {
89
+ const response = await this.listRoleBindings(page, options);
90
+ yield* response.roleBindings ?? [];
91
+ if (!response.nextPageToken) return;
92
+ page = { ...page, pageToken: response.nextPageToken };
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Grants a role to a member. Needs `iam.role.assign` on the
98
+ * organization, for a project binding as well, and every permission of
99
+ * the role at the binding's scope: a permission held on the organization
100
+ * counts for any scope, one held on a project only for that project.
101
+ * Refused with `NOT_FOUND` when no account has `member`'s address as its
102
+ * verified email: nothing is held for an address until its account
103
+ * exists. Refused with `CONFLICT` when the member already holds the role
104
+ * at that scope, and with `BAD_REQUEST` when the member is a deleted
105
+ * service account.
106
+ */
107
+ async createRoleBinding(request: CreateRoleBindingRequest, options?: CallOptions): Promise<RoleBinding> {
108
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
109
+ const p0 = pathValue("parent", request.parent, "organizations/*");
110
+ return this.service.call<RoleBinding>(
111
+ {
112
+ method: "POST",
113
+ path: `/v1beta1/${p0}/roleBindings`,
114
+ body: request.roleBinding,
115
+ query: query(request, ["parent", "roleBinding"]),
116
+ idempotent: true,
117
+ },
118
+ options,
119
+ );
120
+ }
121
+
122
+ /**
123
+ * Removes a role binding. Needs `iam.role.revoke` on the organization
124
+ * and every permission of the role at the binding's scope, as
125
+ * CreateRoleBinding does. Refused with `CONFLICT`, removing nothing,
126
+ * when it is the organization's last organization-wide binding of
127
+ * `roles/owner`: bind another owner first.
128
+ */
129
+ async deleteRoleBinding(request: DeleteRoleBindingRequest, options?: CallOptions): Promise<Empty> {
130
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
131
+ const p0 = pathValue("name", request.name, "organizations/*/roleBindings/*");
132
+ return this.service.call<Empty>(
133
+ {
134
+ method: "DELETE",
135
+ path: `/v1beta1/${p0}`,
136
+ query: query(request, ["name"]),
137
+ idempotent: true,
138
+ },
139
+ options,
140
+ );
141
+ }
142
+ }
143
+
144
+ /**
145
+ * One role granted to one member, organization-wide or in one project. A
146
+ * binding can't be changed: delete it and create another.
147
+ */
148
+ export interface RoleBinding {
149
+ /** The binding's resource name. */
150
+ name?: string;
151
+ /**
152
+ * The binding's URN, the identifier access policies and the audit log
153
+ * use.
154
+ */
155
+ urn?: string;
156
+ /**
157
+ * Who holds the role: `user:{email}` or
158
+ * `serviceAccount:{service_account}`. A user is shown with their
159
+ * account's current verified address, as `userId:{user}` when it has
160
+ * none, or as `deleted:user:{user}` once the account is gone.
161
+ */
162
+ member?: string;
163
+ /** The role granted, `roles/{role}`. */
164
+ role?: string;
165
+ /**
166
+ * The project the binding is limited to, `projects/{project}`, one of
167
+ * the organization's. Empty for a binding on the whole organization,
168
+ * which covers every project in it.
169
+ */
170
+ project?: string;
171
+ /**
172
+ * Who created the binding, written as a member is, or `platform` for a
173
+ * binding the platform made itself. Always `userId:{user}` for a user in
174
+ * a list of the caller's own bindings (`organizations/-`).
175
+ */
176
+ creator?: string;
177
+ /** When the binding was created. */
178
+ createTime?: string;
179
+ }
180
+
181
+ /** The request for GetRoleBinding. */
182
+ export interface GetRoleBindingRequest {
183
+ /** The binding to return. */
184
+ name?: string;
185
+ }
186
+
187
+ /** The request for ListRoleBindings. */
188
+ export interface ListRoleBindingsRequest {
189
+ /**
190
+ * The organization whose bindings to list, `organizations/{organization}`,
191
+ * or `organizations/-` for the caller's own bindings in every
192
+ * organization.
193
+ */
194
+ parent?: string;
195
+ /**
196
+ * Only the bindings of this member, `user:{email}` or
197
+ * `serviceAccount:{service_account}`. Every member's when empty.
198
+ */
199
+ member?: string;
200
+ /**
201
+ * Only the bindings limited to this project, `projects/{project}`. Every
202
+ * binding, organization-wide or not, when empty.
203
+ */
204
+ project?: string;
205
+ /**
206
+ * The most bindings to return; the server clamps it, and 0 means its
207
+ * default.
208
+ */
209
+ pageSize?: number;
210
+ /** A previous response's `nextPageToken`, for the page after it. */
211
+ pageToken?: string;
212
+ }
213
+
214
+ /** The response for ListRoleBindings. */
215
+ export interface ListRoleBindingsResponse {
216
+ /** The bindings on this page. */
217
+ roleBindings?: RoleBinding[];
218
+ /** The token for the next page; empty on the last one. */
219
+ nextPageToken?: string;
220
+ }
221
+
222
+ /** The request for CreateRoleBinding. */
223
+ export interface CreateRoleBindingRequest {
224
+ /**
225
+ * The organization to create the binding in,
226
+ * `organizations/{organization}`.
227
+ */
228
+ parent?: string;
229
+ /**
230
+ * The binding to create: its member and role, and optionally its
231
+ * project.
232
+ */
233
+ roleBinding?: RoleBinding;
234
+ /**
235
+ * A UUID. A repeat of the request with the same `requestId` within a
236
+ * day returns the binding the first request created, as it is now,
237
+ * instead of being refused as a conflict.
238
+ */
239
+ requestId?: string;
240
+ }
241
+
242
+ /** The request for DeleteRoleBinding. */
243
+ export interface DeleteRoleBindingRequest {
244
+ /** The binding to delete. */
245
+ name?: string;
246
+ /**
247
+ * A UUID. A repeat of the request with the same `requestId` within a
248
+ * day succeeds as the first did, instead of answering `NOT_FOUND`.
249
+ */
250
+ requestId?: string;
251
+ }
@@ -0,0 +1,225 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/iam/v1beta1/service_account.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
+
14
+ /**
15
+ * Calls ServiceAccountService.
16
+ *
17
+ * Service accounts: an organization's credentials for software, which
18
+ * authenticate with the OAuth 2.0 client credentials grant and never log
19
+ * in interactively. A new service account holds no role: grant it one with
20
+ * a role binding on its `member`.
21
+ */
22
+ export class ServiceAccountClient {
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 ServiceAccountService that sends its calls through `client`. */
30
+ constructor(client: Client) {
31
+ this.service = client.service("iam", false);
32
+ }
33
+
34
+ /**
35
+ * Returns a service account, deleted or not. Needs
36
+ * `iam.service_account.list` on the organization.
37
+ */
38
+ async getServiceAccount(request: GetServiceAccountRequest, options?: CallOptions): Promise<ServiceAccount> {
39
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*");
40
+ return this.service.call<ServiceAccount>(
41
+ {
42
+ method: "GET",
43
+ path: `/v1beta1/${p0}`,
44
+ query: query(request, ["name"]),
45
+ idempotent: true,
46
+ },
47
+ options,
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Lists an organization's service accounts, oldest first. Deleted ones
53
+ * are listed only when `showDeleted` is set. Needs
54
+ * `iam.service_account.list` on the organization.
55
+ */
56
+ async listServiceAccounts(request: ListServiceAccountsRequest, options?: CallOptions): Promise<ListServiceAccountsResponse> {
57
+ const p0 = pathValue("parent", request.parent, "organizations/*");
58
+ return this.service.call<ListServiceAccountsResponse>(
59
+ {
60
+ method: "GET",
61
+ path: `/v1beta1/${p0}/serviceAccounts`,
62
+ query: query(request, ["parent"]),
63
+ idempotent: true,
64
+ },
65
+ options,
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Iterates over everything listServiceAccounts lists from the request's page on,
71
+ * fetching the next page as the loop reaches it. A page that fails ends
72
+ * the iteration with its error.
73
+ */
74
+ async *allServiceAccounts(request: ListServiceAccountsRequest, options?: CallOptions): AsyncGenerator<ServiceAccount, void, undefined> {
75
+ for (let page = request; ; ) {
76
+ const response = await this.listServiceAccounts(page, options);
77
+ yield* response.serviceAccounts ?? [];
78
+ if (!response.nextPageToken) return;
79
+ page = { ...page, pageToken: response.nextPageToken };
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Creates a service account and its client secret. The response is the
85
+ * only place the secret is ever shown: store it now. Needs
86
+ * `iam.service_account.create` on the organization.
87
+ */
88
+ async createServiceAccount(request: CreateServiceAccountRequest, options?: CallOptions): Promise<ServiceAccount> {
89
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
90
+ const p0 = pathValue("parent", request.parent, "organizations/*");
91
+ return this.service.call<ServiceAccount>(
92
+ {
93
+ method: "POST",
94
+ path: `/v1beta1/${p0}/serviceAccounts`,
95
+ body: request.serviceAccount,
96
+ query: query(request, ["parent", "serviceAccount"]),
97
+ idempotent: true,
98
+ },
99
+ options,
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Deletes a service account for good: its credential is refused from
105
+ * then on, an access token it already holds is refused on its next
106
+ * request, and every role binding it holds, in any organization, is
107
+ * removed. It stays readable as `DELETED`. Deleting a deleted service
108
+ * account succeeds. Needs `iam.service_account.revoke` on the
109
+ * organization.
110
+ */
111
+ async deleteServiceAccount(request: DeleteServiceAccountRequest, options?: CallOptions): Promise<Empty> {
112
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*");
113
+ return this.service.call<Empty>(
114
+ {
115
+ method: "DELETE",
116
+ path: `/v1beta1/${p0}`,
117
+ query: query(request, ["name"]),
118
+ },
119
+ options,
120
+ );
121
+ }
122
+ }
123
+
124
+ /** A credential of an organization for software. */
125
+ export interface ServiceAccount {
126
+ /** The service account's resource name. */
127
+ name?: string;
128
+ /** A name of your own, shown in the console; at most 100 characters. */
129
+ displayName?: string;
130
+ /**
131
+ * The member a role binding names it by,
132
+ * `serviceAccount:{service_account}`.
133
+ */
134
+ member?: string;
135
+ /** The OAuth 2.0 client id it authenticates with. */
136
+ clientId?: string;
137
+ /**
138
+ * The OAuth 2.0 client secret it authenticates with. Set only in the
139
+ * response that created the service account, and empty everywhere else:
140
+ * it can't be read again.
141
+ */
142
+ clientSecret?: string;
143
+ /** Where the service account is in its lifecycle. */
144
+ state?: ServiceAccount_State;
145
+ /**
146
+ * Who created the service account, written as a role binding's member
147
+ * is.
148
+ */
149
+ creator?: string;
150
+ /** When the service account was created. */
151
+ createTime?: string;
152
+ /** When the service account was deleted; unset while it is active. */
153
+ deleteTime?: string;
154
+ }
155
+
156
+ /** Where the service account is in its lifecycle. */
157
+ export const ServiceAccount_State = {
158
+ /** Not set. */
159
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
160
+ /** Its credential is accepted. */
161
+ ACTIVE: "ACTIVE",
162
+ /** Deleted: its credential is refused, and it holds no role binding. */
163
+ DELETED: "DELETED",
164
+ } as const;
165
+
166
+ /** Where the service account is in its lifecycle. */
167
+ export type ServiceAccount_State = (typeof ServiceAccount_State)[keyof typeof ServiceAccount_State];
168
+
169
+ /** The request for GetServiceAccount. */
170
+ export interface GetServiceAccountRequest {
171
+ /** The service account to return. */
172
+ name?: string;
173
+ }
174
+
175
+ /** The request for ListServiceAccounts. */
176
+ export interface ListServiceAccountsRequest {
177
+ /**
178
+ * The organization whose service accounts to list,
179
+ * `organizations/{organization}`.
180
+ */
181
+ parent?: string;
182
+ /**
183
+ * The most service accounts to return; the server clamps it, and 0 means
184
+ * its default.
185
+ */
186
+ pageSize?: number;
187
+ /** A previous response's `nextPageToken`, for the page after it. */
188
+ pageToken?: string;
189
+ /** Whether deleted service accounts are listed too. */
190
+ showDeleted?: boolean;
191
+ }
192
+
193
+ /** The response for ListServiceAccounts. */
194
+ export interface ListServiceAccountsResponse {
195
+ /** The service accounts on this page. */
196
+ serviceAccounts?: ServiceAccount[];
197
+ /** The token for the next page; empty on the last one. */
198
+ nextPageToken?: string;
199
+ }
200
+
201
+ /** The request for CreateServiceAccount. */
202
+ export interface CreateServiceAccountRequest {
203
+ /**
204
+ * The organization to create the service account in,
205
+ * `organizations/{organization}`.
206
+ */
207
+ parent?: string;
208
+ /** The service account to create: its `displayName`. */
209
+ serviceAccount?: ServiceAccount;
210
+ /**
211
+ * A UUID. A repeat of the request with the same `requestId` within a
212
+ * day creates nothing and is refused with `CONFLICT`: the secret went to
213
+ * the first request only. The error's `ErrorInfo` metadata names the
214
+ * service account under `serviceAccount`; delete it and create a new one
215
+ * to get a working secret. The same `requestId` with a different
216
+ * request is refused with `CONFLICT` without that metadata.
217
+ */
218
+ requestId?: string;
219
+ }
220
+
221
+ /** The request for DeleteServiceAccount. */
222
+ export interface DeleteServiceAccountRequest {
223
+ /** The service account to delete. */
224
+ name?: string;
225
+ }
@@ -0,0 +1,70 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/iam/v1beta1/user.proto
3
+
4
+ import { type CallOptions, type Client, type Service, pathValue, query } from "@origincloud/core";
5
+
6
+ /**
7
+ * Calls UserService.
8
+ *
9
+ * The signed-in user. Each user can read only their own profile, by the
10
+ * name `users/me` or by their own id; the role bindings they hold are
11
+ * listed by ListRoleBindings with the parent `organizations/-`.
12
+ */
13
+ export class UserClient {
14
+ /**
15
+ * The endpoint the client sends its calls to, which also serves the
16
+ * operations its methods answer with.
17
+ */
18
+ readonly service: Service;
19
+
20
+ /** A client of UserService that sends its calls through `client`. */
21
+ constructor(client: Client) {
22
+ this.service = client.service("iam", false);
23
+ }
24
+
25
+ /**
26
+ * Returns the caller's own profile. Any other user is `NOT_FOUND`; a
27
+ * service account caller is refused with `BAD_REQUEST`, having no
28
+ * profile.
29
+ */
30
+ async getUser(request: GetUserRequest, options?: CallOptions): Promise<User> {
31
+ const p0 = pathValue("name", request.name, "users/*");
32
+ return this.service.call<User>(
33
+ {
34
+ method: "GET",
35
+ path: `/v1beta1/${p0}`,
36
+ query: query(request, ["name"]),
37
+ idempotent: true,
38
+ },
39
+ options,
40
+ );
41
+ }
42
+ }
43
+
44
+ /** A person who signs in to the platform. */
45
+ export interface User {
46
+ /**
47
+ * The user's resource name, `users/{user}`, with their id; never
48
+ * `users/me`.
49
+ */
50
+ name?: string;
51
+ /**
52
+ * How a role binding shows the user: `user:{email}` once `email` is
53
+ * verified, `userId:{user}` until then.
54
+ */
55
+ member?: string;
56
+ /** The email address the user signs in with. */
57
+ email?: string;
58
+ /** Whether the user has confirmed `email`. */
59
+ emailVerified?: boolean;
60
+ /** The user's given name; empty when they haven't set one. */
61
+ givenName?: string;
62
+ /** The user's family name; empty when they haven't set one. */
63
+ familyName?: string;
64
+ }
65
+
66
+ /** The request for GetUser. */
67
+ export interface GetUserRequest {
68
+ /** The user to return: `users/me`, or the caller's own `users/{user}`. */
69
+ name?: string;
70
+ }