@origincloud/iam 0.20.0 → 0.21.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,161 @@
1
+ import { type CallOptions, type Client, type Empty, type Service } from "@origincloud/core";
2
+ /**
3
+ * Calls FederatedCredentialService.
4
+ *
5
+ * Federated credentials: a `WORKLOAD` service account's trust in the OIDC
6
+ * tokens of an identity provider outside Origin Cloud, such as the token
7
+ * GitHub Actions gives every job. Software holding a matching token
8
+ * exchanges it for the service account's access token, so no secret is
9
+ * stored where it runs. A trust policy names the token's issuer and
10
+ * audience exactly, and the claims it must carry. To change one, create
11
+ * the new one and delete the old.
12
+ */
13
+ export declare class FederatedCredentialClient {
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
+ /** A client of FederatedCredentialService that sends its calls through `client`. */
20
+ constructor(client: Client);
21
+ /**
22
+ * Returns a federated credential, deleted or not. Needs
23
+ * `iam.service_account.list` on the organization.
24
+ */
25
+ getFederatedCredential(request: GetFederatedCredentialRequest, options?: CallOptions): Promise<FederatedCredential>;
26
+ /**
27
+ * Lists a service account's federated credentials, oldest first. Deleted
28
+ * ones are listed only when `showDeleted` is set. Needs
29
+ * `iam.service_account.list` on the organization.
30
+ */
31
+ listFederatedCredentials(request: ListFederatedCredentialsRequest, options?: CallOptions): Promise<ListFederatedCredentialsResponse>;
32
+ /**
33
+ * Iterates over everything listFederatedCredentials lists from the request's page on,
34
+ * fetching the next page as the loop reaches it. A page that fails ends
35
+ * the iteration with its error.
36
+ */
37
+ allFederatedCredentials(request: ListFederatedCredentialsRequest, options?: CallOptions): AsyncGenerator<FederatedCredential, void, undefined>;
38
+ /**
39
+ * Creates a federated credential on an active `WORKLOAD` service
40
+ * account. Anyone whose token matches it acts as the service account, so
41
+ * creating one needs `iam.service_account.create` and
42
+ * `iam.service_account.act_as` on the organization: the right to act as
43
+ * the account yourself. Refused with `INVALID_ARGUMENT` when a condition
44
+ * contains `*`, or when no condition names an identity that never
45
+ * changes: `repository_id` or `repository_owner_id` for GitHub Actions'
46
+ * issuer, `sub` for any other.
47
+ */
48
+ createFederatedCredential(request: CreateFederatedCredentialRequest, options?: CallOptions): Promise<FederatedCredential>;
49
+ /**
50
+ * Deletes a federated credential: no token is exchanged for it from then
51
+ * on, and an access token already exchanged for it is refused on its
52
+ * next request. It stays readable as `DELETED`. Deleting a deleted one
53
+ * succeeds. Needs `iam.service_account.revoke` on the organization.
54
+ */
55
+ deleteFederatedCredential(request: DeleteFederatedCredentialRequest, options?: CallOptions): Promise<Empty>;
56
+ }
57
+ /**
58
+ * A `WORKLOAD` service account's trust in an identity provider's OIDC
59
+ * tokens that carry the given claims.
60
+ */
61
+ export interface FederatedCredential {
62
+ /** The federated credential's resource name. */
63
+ name?: string;
64
+ /** A name of your own, shown in the console; at most 100 characters. */
65
+ displayName?: string;
66
+ /**
67
+ * The identity provider whose tokens are trusted: a token's `iss`, matched
68
+ * exactly, an `https` URL that serves
69
+ * `/.well-known/openid-configuration`, such as
70
+ * `https://token.actions.githubusercontent.com`.
71
+ */
72
+ issuer?: string;
73
+ /**
74
+ * The audience a token must be issued for, its `aud`, matched exactly;
75
+ * `https://sts.origincloudapis.eu` when the create leaves it empty.
76
+ */
77
+ audience?: string;
78
+ /**
79
+ * The claims a token must carry, each with exactly this value, such as
80
+ * `repository_id` and `environment` for GitHub Actions. At least one, on
81
+ * an identity that never changes.
82
+ */
83
+ conditions?: Record<string, string>;
84
+ /** Where the federated credential is in its lifecycle. */
85
+ state?: FederatedCredential_State;
86
+ /**
87
+ * Who created the federated credential, written as a role binding's
88
+ * member is.
89
+ */
90
+ creator?: string;
91
+ /** When the federated credential was created. */
92
+ createTime?: string;
93
+ /** When the federated credential was deleted; unset while it is active. */
94
+ deleteTime?: string;
95
+ }
96
+ /** Where the federated credential is in its lifecycle. */
97
+ export declare const FederatedCredential_State: {
98
+ /** Not set. */
99
+ readonly STATE_UNSPECIFIED: "STATE_UNSPECIFIED";
100
+ /** Tokens that match it are exchanged. */
101
+ readonly ACTIVE: "ACTIVE";
102
+ /** Deleted: no token is exchanged for it. */
103
+ readonly DELETED: "DELETED";
104
+ };
105
+ /** Where the federated credential is in its lifecycle. */
106
+ export type FederatedCredential_State = (typeof FederatedCredential_State)[keyof typeof FederatedCredential_State];
107
+ /** The request for GetFederatedCredential. */
108
+ export interface GetFederatedCredentialRequest {
109
+ /** The federated credential to return. */
110
+ name?: string;
111
+ }
112
+ /** The request for ListFederatedCredentials. */
113
+ export interface ListFederatedCredentialsRequest {
114
+ /**
115
+ * The service account whose federated credentials to list,
116
+ * `organizations/{organization}/serviceAccounts/{service_account}`.
117
+ */
118
+ parent?: string;
119
+ /**
120
+ * The most federated credentials to return; the server clamps it, and 0
121
+ * means its default.
122
+ */
123
+ pageSize?: number;
124
+ /** A previous response's `nextPageToken`, for the page after it. */
125
+ pageToken?: string;
126
+ /** Whether deleted federated credentials are listed too. */
127
+ showDeleted?: boolean;
128
+ }
129
+ /** The response for ListFederatedCredentials. */
130
+ export interface ListFederatedCredentialsResponse {
131
+ /** The federated credentials on this page. */
132
+ federatedCredentials?: FederatedCredential[];
133
+ /** The token for the next page; empty on the last one. */
134
+ nextPageToken?: string;
135
+ }
136
+ /** The request for CreateFederatedCredential. */
137
+ export interface CreateFederatedCredentialRequest {
138
+ /**
139
+ * The `WORKLOAD` service account to create the federated credential on,
140
+ * `organizations/{organization}/serviceAccounts/{service_account}`.
141
+ */
142
+ parent?: string;
143
+ /**
144
+ * The federated credential to create: its `displayName`, `issuer`,
145
+ * `conditions`, and optionally its `audience`.
146
+ */
147
+ federatedCredential?: FederatedCredential;
148
+ /**
149
+ * A UUID. A repeat of the request with the same `requestId` within a
150
+ * day returns the federated credential the first request created, as it
151
+ * is now, instead of creating a second. The same `requestId` with a
152
+ * different request is refused with `CONFLICT`.
153
+ */
154
+ requestId?: string;
155
+ }
156
+ /** The request for DeleteFederatedCredential. */
157
+ export interface DeleteFederatedCredentialRequest {
158
+ /** The federated credential to delete. */
159
+ name?: string;
160
+ }
161
+ //# sourceMappingURL=federated_credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"federated_credential.d.ts","sourceRoot":"","sources":["../../src/v1beta1/federated_credential.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,OAAO,EAIb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,qBAAa,yBAAyB;IACpC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,oFAAoF;gBACxE,MAAM,EAAE,MAAM;IAI1B;;;OAGG;IACG,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAazH;;;;OAIG;IACG,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAa1I;;;;OAIG;IACI,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,mBAAmB,EAAE,IAAI,EAAE,SAAS,CAAC;IASrJ;;;;;;;;;OASG;IACG,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAe/H;;;;;OAKG;IACG,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;CAWlH;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACr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,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iDAAiD;AACjD,MAAM,WAAW,gCAAgC;IAC/C,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,112 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/iam/v1beta1/federated_credential.proto
3
+ import { newRequestId, pathValue, query, } from "@origincloud/core";
4
+ /**
5
+ * Calls FederatedCredentialService.
6
+ *
7
+ * Federated credentials: a `WORKLOAD` service account's trust in the OIDC
8
+ * tokens of an identity provider outside Origin Cloud, such as the token
9
+ * GitHub Actions gives every job. Software holding a matching token
10
+ * exchanges it for the service account's access token, so no secret is
11
+ * stored where it runs. A trust policy names the token's issuer and
12
+ * audience exactly, and the claims it must carry. To change one, create
13
+ * the new one and delete the old.
14
+ */
15
+ export class FederatedCredentialClient {
16
+ /**
17
+ * The endpoint the client sends its calls to, which also serves the
18
+ * operations its methods answer with.
19
+ */
20
+ service;
21
+ /** A client of FederatedCredentialService that sends its calls through `client`. */
22
+ constructor(client) {
23
+ this.service = client.service("iam", false);
24
+ }
25
+ /**
26
+ * Returns a federated credential, deleted or not. Needs
27
+ * `iam.service_account.list` on the organization.
28
+ */
29
+ async getFederatedCredential(request, options) {
30
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*/federatedCredentials/*");
31
+ return this.service.call({
32
+ method: "GET",
33
+ path: `/v1beta1/${p0}`,
34
+ query: query(request, ["name"]),
35
+ idempotent: true,
36
+ }, options);
37
+ }
38
+ /**
39
+ * Lists a service account's federated credentials, oldest first. Deleted
40
+ * ones are listed only when `showDeleted` is set. Needs
41
+ * `iam.service_account.list` on the organization.
42
+ */
43
+ async listFederatedCredentials(request, options) {
44
+ const p0 = pathValue("parent", request.parent, "organizations/*/serviceAccounts/*");
45
+ return this.service.call({
46
+ method: "GET",
47
+ path: `/v1beta1/${p0}/federatedCredentials`,
48
+ query: query(request, ["parent"]),
49
+ idempotent: true,
50
+ }, options);
51
+ }
52
+ /**
53
+ * Iterates over everything listFederatedCredentials lists from the request's page on,
54
+ * fetching the next page as the loop reaches it. A page that fails ends
55
+ * the iteration with its error.
56
+ */
57
+ async *allFederatedCredentials(request, options) {
58
+ for (let page = request;;) {
59
+ const response = await this.listFederatedCredentials(page, options);
60
+ yield* response.federatedCredentials ?? [];
61
+ if (!response.nextPageToken)
62
+ return;
63
+ page = { ...page, pageToken: response.nextPageToken };
64
+ }
65
+ }
66
+ /**
67
+ * Creates a federated credential on an active `WORKLOAD` service
68
+ * account. Anyone whose token matches it acts as the service account, so
69
+ * creating one needs `iam.service_account.create` and
70
+ * `iam.service_account.act_as` on the organization: the right to act as
71
+ * the account yourself. Refused with `INVALID_ARGUMENT` when a condition
72
+ * contains `*`, or when no condition names an identity that never
73
+ * changes: `repository_id` or `repository_owner_id` for GitHub Actions'
74
+ * issuer, `sub` for any other.
75
+ */
76
+ async createFederatedCredential(request, options) {
77
+ if (!request.requestId)
78
+ request = { ...request, requestId: newRequestId() };
79
+ const p0 = pathValue("parent", request.parent, "organizations/*/serviceAccounts/*");
80
+ return this.service.call({
81
+ method: "POST",
82
+ path: `/v1beta1/${p0}/federatedCredentials`,
83
+ body: request.federatedCredential,
84
+ query: query(request, ["parent", "federatedCredential"]),
85
+ idempotent: true,
86
+ }, options);
87
+ }
88
+ /**
89
+ * Deletes a federated credential: no token is exchanged for it from then
90
+ * on, and an access token already exchanged for it is refused on its
91
+ * next request. It stays readable as `DELETED`. Deleting a deleted one
92
+ * succeeds. Needs `iam.service_account.revoke` on the organization.
93
+ */
94
+ async deleteFederatedCredential(request, options) {
95
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*/federatedCredentials/*");
96
+ return this.service.call({
97
+ method: "DELETE",
98
+ path: `/v1beta1/${p0}`,
99
+ query: query(request, ["name"]),
100
+ }, options);
101
+ }
102
+ }
103
+ /** Where the federated credential is in its lifecycle. */
104
+ export const FederatedCredential_State = {
105
+ /** Not set. */
106
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
107
+ /** Tokens that match it are exchanged. */
108
+ ACTIVE: "ACTIVE",
109
+ /** Deleted: no token is exchanged for it. */
110
+ DELETED: "DELETED",
111
+ };
112
+ //# sourceMappingURL=federated_credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"federated_credential.js","sourceRoot":"","sources":["../../src/v1beta1/federated_credential.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,6DAA6D;AAE7D,OAAO,EAKL,YAAY,EACZ,SAAS,EACT,KAAK,GACN,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,MAAM,OAAO,yBAAyB;IACpC;;;OAGG;IACM,OAAO,CAAU;IAE1B,oFAAoF;IACpF,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,sBAAsB,CAAC,OAAsC,EAAE,OAAqB;QACxF,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,0DAA0D,CAAC,CAAC;QACvG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;YAC/B,UAAU,EAAE,IAAI;SACjB,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,wBAAwB,CAAC,OAAwC,EAAE,OAAqB;QAC5F,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,OAAO,CA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;IACH,KAAK,CAAC,yBAAyB,CAAC,OAAyC,EAAE,OAAqB;QAC9F,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,0DAA0D,CAAC,CAAC;QACvG,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CACtB;YACE,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;SAChC,EACD,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA0CD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,eAAe;IACf,iBAAiB,EAAE,mBAAmB;IACtC,0CAA0C;IAC1C,MAAM,EAAE,QAAQ;IAChB,6CAA6C;IAC7C,OAAO,EAAE,SAAS;CACV,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./audit_log.js";
2
+ export * from "./federated_credential.js";
2
3
  export * from "./permission.js";
3
4
  export * from "./role.js";
4
5
  export * from "./role_binding.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1beta1/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1beta1/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
@@ -1,5 +1,6 @@
1
1
  // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
2
  export * from "./audit_log.js";
3
+ export * from "./federated_credential.js";
3
4
  export * from "./permission.js";
4
5
  export * from "./role.js";
5
6
  export * from "./role_binding.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1beta1/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1beta1/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@origincloud/iam",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Origin Cloud's IAM service: users, service accounts, roles, role bindings, permissions and the audit log.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/origincloudhq/sdk-typescript#readme",
@@ -34,9 +34,9 @@
34
34
  "!dist/**/*.tsbuildinfo"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@origincloud/core": "^0.20.0"
37
+ "@origincloud/core": "^0.21.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@origincloud/core": "^0.20.0"
40
+ "@origincloud/core": "^0.21.0"
41
41
  }
42
42
  }
@@ -0,0 +1,240 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/iam/v1beta1/federated_credential.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 FederatedCredentialService.
16
+ *
17
+ * Federated credentials: a `WORKLOAD` service account's trust in the OIDC
18
+ * tokens of an identity provider outside Origin Cloud, such as the token
19
+ * GitHub Actions gives every job. Software holding a matching token
20
+ * exchanges it for the service account's access token, so no secret is
21
+ * stored where it runs. A trust policy names the token's issuer and
22
+ * audience exactly, and the claims it must carry. To change one, create
23
+ * the new one and delete the old.
24
+ */
25
+ export class FederatedCredentialClient {
26
+ /**
27
+ * The endpoint the client sends its calls to, which also serves the
28
+ * operations its methods answer with.
29
+ */
30
+ readonly service: Service;
31
+
32
+ /** A client of FederatedCredentialService that sends its calls through `client`. */
33
+ constructor(client: Client) {
34
+ this.service = client.service("iam", false);
35
+ }
36
+
37
+ /**
38
+ * Returns a federated credential, deleted or not. Needs
39
+ * `iam.service_account.list` on the organization.
40
+ */
41
+ async getFederatedCredential(request: GetFederatedCredentialRequest, options?: CallOptions): Promise<FederatedCredential> {
42
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*/federatedCredentials/*");
43
+ return this.service.call<FederatedCredential>(
44
+ {
45
+ method: "GET",
46
+ path: `/v1beta1/${p0}`,
47
+ query: query(request, ["name"]),
48
+ idempotent: true,
49
+ },
50
+ options,
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Lists a service account's federated credentials, oldest first. Deleted
56
+ * ones are listed only when `showDeleted` is set. Needs
57
+ * `iam.service_account.list` on the organization.
58
+ */
59
+ async listFederatedCredentials(request: ListFederatedCredentialsRequest, options?: CallOptions): Promise<ListFederatedCredentialsResponse> {
60
+ const p0 = pathValue("parent", request.parent, "organizations/*/serviceAccounts/*");
61
+ return this.service.call<ListFederatedCredentialsResponse>(
62
+ {
63
+ method: "GET",
64
+ path: `/v1beta1/${p0}/federatedCredentials`,
65
+ query: query(request, ["parent"]),
66
+ idempotent: true,
67
+ },
68
+ options,
69
+ );
70
+ }
71
+
72
+ /**
73
+ * Iterates over everything listFederatedCredentials lists from the request's page on,
74
+ * fetching the next page as the loop reaches it. A page that fails ends
75
+ * the iteration with its error.
76
+ */
77
+ async *allFederatedCredentials(request: ListFederatedCredentialsRequest, options?: CallOptions): AsyncGenerator<FederatedCredential, void, undefined> {
78
+ for (let page = request; ; ) {
79
+ const response = await this.listFederatedCredentials(page, options);
80
+ yield* response.federatedCredentials ?? [];
81
+ if (!response.nextPageToken) return;
82
+ page = { ...page, pageToken: response.nextPageToken };
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Creates a federated credential on an active `WORKLOAD` service
88
+ * account. Anyone whose token matches it acts as the service account, so
89
+ * creating one needs `iam.service_account.create` and
90
+ * `iam.service_account.act_as` on the organization: the right to act as
91
+ * the account yourself. Refused with `INVALID_ARGUMENT` when a condition
92
+ * contains `*`, or when no condition names an identity that never
93
+ * changes: `repository_id` or `repository_owner_id` for GitHub Actions'
94
+ * issuer, `sub` for any other.
95
+ */
96
+ async createFederatedCredential(request: CreateFederatedCredentialRequest, options?: CallOptions): Promise<FederatedCredential> {
97
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
98
+ const p0 = pathValue("parent", request.parent, "organizations/*/serviceAccounts/*");
99
+ return this.service.call<FederatedCredential>(
100
+ {
101
+ method: "POST",
102
+ path: `/v1beta1/${p0}/federatedCredentials`,
103
+ body: request.federatedCredential,
104
+ query: query(request, ["parent", "federatedCredential"]),
105
+ idempotent: true,
106
+ },
107
+ options,
108
+ );
109
+ }
110
+
111
+ /**
112
+ * Deletes a federated credential: no token is exchanged for it from then
113
+ * on, and an access token already exchanged for it is refused on its
114
+ * next request. It stays readable as `DELETED`. Deleting a deleted one
115
+ * succeeds. Needs `iam.service_account.revoke` on the organization.
116
+ */
117
+ async deleteFederatedCredential(request: DeleteFederatedCredentialRequest, options?: CallOptions): Promise<Empty> {
118
+ const p0 = pathValue("name", request.name, "organizations/*/serviceAccounts/*/federatedCredentials/*");
119
+ return this.service.call<Empty>(
120
+ {
121
+ method: "DELETE",
122
+ path: `/v1beta1/${p0}`,
123
+ query: query(request, ["name"]),
124
+ },
125
+ options,
126
+ );
127
+ }
128
+ }
129
+
130
+ /**
131
+ * A `WORKLOAD` service account's trust in an identity provider's OIDC
132
+ * tokens that carry the given claims.
133
+ */
134
+ export interface FederatedCredential {
135
+ /** The federated credential's resource name. */
136
+ name?: string;
137
+ /** A name of your own, shown in the console; at most 100 characters. */
138
+ displayName?: string;
139
+ /**
140
+ * The identity provider whose tokens are trusted: a token's `iss`, matched
141
+ * exactly, an `https` URL that serves
142
+ * `/.well-known/openid-configuration`, such as
143
+ * `https://token.actions.githubusercontent.com`.
144
+ */
145
+ issuer?: string;
146
+ /**
147
+ * The audience a token must be issued for, its `aud`, matched exactly;
148
+ * `https://sts.origincloudapis.eu` when the create leaves it empty.
149
+ */
150
+ audience?: string;
151
+ /**
152
+ * The claims a token must carry, each with exactly this value, such as
153
+ * `repository_id` and `environment` for GitHub Actions. At least one, on
154
+ * an identity that never changes.
155
+ */
156
+ conditions?: Record<string, string>;
157
+ /** Where the federated credential is in its lifecycle. */
158
+ state?: FederatedCredential_State;
159
+ /**
160
+ * Who created the federated credential, written as a role binding's
161
+ * member is.
162
+ */
163
+ creator?: string;
164
+ /** When the federated credential was created. */
165
+ createTime?: string;
166
+ /** When the federated credential was deleted; unset while it is active. */
167
+ deleteTime?: string;
168
+ }
169
+
170
+ /** Where the federated credential is in its lifecycle. */
171
+ export const FederatedCredential_State = {
172
+ /** Not set. */
173
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
174
+ /** Tokens that match it are exchanged. */
175
+ ACTIVE: "ACTIVE",
176
+ /** Deleted: no token is exchanged for it. */
177
+ DELETED: "DELETED",
178
+ } as const;
179
+
180
+ /** Where the federated credential is in its lifecycle. */
181
+ export type FederatedCredential_State = (typeof FederatedCredential_State)[keyof typeof FederatedCredential_State];
182
+
183
+ /** The request for GetFederatedCredential. */
184
+ export interface GetFederatedCredentialRequest {
185
+ /** The federated credential to return. */
186
+ name?: string;
187
+ }
188
+
189
+ /** The request for ListFederatedCredentials. */
190
+ export interface ListFederatedCredentialsRequest {
191
+ /**
192
+ * The service account whose federated credentials to list,
193
+ * `organizations/{organization}/serviceAccounts/{service_account}`.
194
+ */
195
+ parent?: string;
196
+ /**
197
+ * The most federated credentials to return; the server clamps it, and 0
198
+ * means its default.
199
+ */
200
+ pageSize?: number;
201
+ /** A previous response's `nextPageToken`, for the page after it. */
202
+ pageToken?: string;
203
+ /** Whether deleted federated credentials are listed too. */
204
+ showDeleted?: boolean;
205
+ }
206
+
207
+ /** The response for ListFederatedCredentials. */
208
+ export interface ListFederatedCredentialsResponse {
209
+ /** The federated credentials on this page. */
210
+ federatedCredentials?: FederatedCredential[];
211
+ /** The token for the next page; empty on the last one. */
212
+ nextPageToken?: string;
213
+ }
214
+
215
+ /** The request for CreateFederatedCredential. */
216
+ export interface CreateFederatedCredentialRequest {
217
+ /**
218
+ * The `WORKLOAD` service account to create the federated credential on,
219
+ * `organizations/{organization}/serviceAccounts/{service_account}`.
220
+ */
221
+ parent?: string;
222
+ /**
223
+ * The federated credential to create: its `displayName`, `issuer`,
224
+ * `conditions`, and optionally its `audience`.
225
+ */
226
+ federatedCredential?: FederatedCredential;
227
+ /**
228
+ * A UUID. A repeat of the request with the same `requestId` within a
229
+ * day returns the federated credential the first request created, as it
230
+ * is now, instead of creating a second. The same `requestId` with a
231
+ * different request is refused with `CONFLICT`.
232
+ */
233
+ requestId?: string;
234
+ }
235
+
236
+ /** The request for DeleteFederatedCredential. */
237
+ export interface DeleteFederatedCredentialRequest {
238
+ /** The federated credential to delete. */
239
+ name?: string;
240
+ }
@@ -1,6 +1,7 @@
1
1
  // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
2
 
3
3
  export * from "./audit_log.js";
4
+ export * from "./federated_credential.js";
4
5
  export * from "./permission.js";
5
6
  export * from "./role.js";
6
7
  export * from "./role_binding.js";