@origincloud/billing 0.0.0-stage → 0.13.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,590 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/billing/v1beta1/billing_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 BillingAccountService.
16
+ *
17
+ * Billing accounts, which project each one pays for, and how they are paid.
18
+ */
19
+ export class BillingAccountClient {
20
+ /**
21
+ * The endpoint the client sends its calls to, which also serves the
22
+ * operations its methods answer with.
23
+ */
24
+ readonly service: Service;
25
+
26
+ /** A client of BillingAccountService that sends its calls through `client`. */
27
+ constructor(client: Client) {
28
+ this.service = client.service("billing", false);
29
+ }
30
+
31
+ /**
32
+ * Returns a billing account. Needs `admin.billing_account.get` on the
33
+ * organization.
34
+ */
35
+ async getBillingAccount(request: GetBillingAccountRequest, options?: CallOptions): Promise<BillingAccount> {
36
+ const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
37
+ return this.service.call<BillingAccount>(
38
+ {
39
+ method: "GET",
40
+ path: `/v1beta1/${p0}`,
41
+ query: query(request, ["name"]),
42
+ idempotent: true,
43
+ },
44
+ options,
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Lists an organization's billing accounts, oldest first. Needs
50
+ * `admin.billing_account.list` on the organization.
51
+ */
52
+ async listBillingAccounts(request: ListBillingAccountsRequest, options?: CallOptions): Promise<ListBillingAccountsResponse> {
53
+ const p0 = pathValue("parent", request.parent, "organizations/*");
54
+ return this.service.call<ListBillingAccountsResponse>(
55
+ {
56
+ method: "GET",
57
+ path: `/v1beta1/${p0}/billingAccounts`,
58
+ query: query(request, ["parent"]),
59
+ idempotent: true,
60
+ },
61
+ options,
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Iterates over everything listBillingAccounts lists from the request's page on,
67
+ * fetching the next page as the loop reaches it. A page that fails ends
68
+ * the iteration with its error.
69
+ */
70
+ async *allBillingAccounts(request: ListBillingAccountsRequest, options?: CallOptions): AsyncGenerator<BillingAccount, void, undefined> {
71
+ for (let page = request; ; ) {
72
+ const response = await this.listBillingAccounts(page, options);
73
+ yield* response.billingAccounts ?? [];
74
+ if (!response.nextPageToken) return;
75
+ page = { ...page, pageToken: response.nextPageToken };
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Creates a billing account with its profile: `displayName`,
81
+ * `billingAddress`, `invoiceEmail` and `contactPerson` are required,
82
+ * and `vatId` too for a billing address outside Germany. The account
83
+ * has no payment method yet: until one is verified, the projects linked
84
+ * to it can't create billable resources. Creating it grants nobody a
85
+ * role: whoever can create billing accounts can use it. Needs
86
+ * `admin.billing_account.create` on the organization.
87
+ */
88
+ async createBillingAccount(request: CreateBillingAccountRequest, options?: CallOptions): Promise<BillingAccount> {
89
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
90
+ const p0 = pathValue("parent", request.parent, "organizations/*");
91
+ return this.service.call<BillingAccount>(
92
+ {
93
+ method: "POST",
94
+ path: `/v1beta1/${p0}/billingAccounts`,
95
+ body: request.billingAccount,
96
+ query: query(request, ["parent", "billingAccount"]),
97
+ idempotent: true,
98
+ },
99
+ options,
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Changes a billing account's `displayName` or its profile. The profile
105
+ * fields named in `updateMask` are replaced and the others kept; once
106
+ * the update is applied, the account must have a whole profile
107
+ * (`billingAddress`, `invoiceEmail`, `contactPerson`, and `vatId`
108
+ * for a billing address outside Germany), or the update is refused. Needs
109
+ * `admin.billing_account.update` on the organization.
110
+ */
111
+ async updateBillingAccount(request: UpdateBillingAccountRequest, options?: CallOptions): Promise<BillingAccount> {
112
+ const p0 = pathValue("billingAccount.name", request.billingAccount?.name, "organizations/*/billingAccounts/*");
113
+ return this.service.call<BillingAccount>(
114
+ {
115
+ method: "PATCH",
116
+ path: `/v1beta1/${p0}`,
117
+ body: request.billingAccount,
118
+ query: query(request, ["billingAccount.name", "billingAccount"]),
119
+ },
120
+ options,
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Deletes a billing account. Refused as a `CONFLICT` for the
126
+ * organization's default billing account, while a project is linked to
127
+ * the account (link it to another account first), and while the account
128
+ * has a spend limit (remove it first). Needs
129
+ * `admin.billing_account.delete` on the organization.
130
+ */
131
+ async deleteBillingAccount(request: DeleteBillingAccountRequest, options?: CallOptions): Promise<Empty> {
132
+ const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
133
+ return this.service.call<Empty>(
134
+ {
135
+ method: "DELETE",
136
+ path: `/v1beta1/${p0}`,
137
+ query: query(request, ["name"]),
138
+ },
139
+ options,
140
+ );
141
+ }
142
+
143
+ /**
144
+ * Starts adding a payment method to a billing account, and returns the
145
+ * payment provider's page to open in a browser: the payment details are
146
+ * entered there and never pass through this API. Once that page is done,
147
+ * call ConfirmPaymentMethodSetup. Starting again replaces a setup that
148
+ * wasn't confirmed. Refused as `INVALID_ARGUMENT` for an account whose
149
+ * `paymentMethod.state` is `NOT_REQUIRED`. Needs
150
+ * `admin.billing_account.update` on the organization.
151
+ */
152
+ async startPaymentMethodSetup(request: StartPaymentMethodSetupRequest, options?: CallOptions): Promise<StartPaymentMethodSetupResponse> {
153
+ const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
154
+ return this.service.call<StartPaymentMethodSetupResponse>(
155
+ {
156
+ method: "POST",
157
+ path: `/v1beta1/${p0}:startPaymentMethodSetup`,
158
+ body: request,
159
+ },
160
+ options,
161
+ );
162
+ }
163
+
164
+ /**
165
+ * Completes the setup StartPaymentMethodSetup started, once its page is
166
+ * done: the payment provider is asked whether it finished, and only a
167
+ * finished setup is recorded. The account's `paymentMethod` is then
168
+ * `VERIFIED`, replacing any earlier one, and its projects can create
169
+ * billable resources. An unfinished or abandoned setup is refused as
170
+ * `INVALID_ARGUMENT` and changes nothing: finish the page, or start
171
+ * again. So is an account with no setup started, which includes a
172
+ * repeat of a confirmation that succeeded: read the account to see
173
+ * whether it did. Needs `admin.billing_account.update` on the
174
+ * organization.
175
+ */
176
+ async confirmPaymentMethodSetup(request: ConfirmPaymentMethodSetupRequest, options?: CallOptions): Promise<BillingAccount> {
177
+ const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
178
+ return this.service.call<BillingAccount>(
179
+ {
180
+ method: "POST",
181
+ path: `/v1beta1/${p0}:confirmPaymentMethodSetup`,
182
+ body: request,
183
+ },
184
+ options,
185
+ );
186
+ }
187
+
188
+ /**
189
+ * Returns which billing account pays for a project. Needs
190
+ * `admin.project.get` on the project.
191
+ */
192
+ async getProjectBillingInfo(request: GetProjectBillingInfoRequest, options?: CallOptions): Promise<ProjectBillingInfo> {
193
+ const p0 = pathValue("name", request.name, "projects/*/billingInfo");
194
+ return this.service.call<ProjectBillingInfo>(
195
+ {
196
+ method: "GET",
197
+ path: `/v1beta1/${p0}`,
198
+ query: query(request, ["name"]),
199
+ idempotent: true,
200
+ },
201
+ options,
202
+ );
203
+ }
204
+
205
+ /**
206
+ * Links a project to another billing account of its organization, which
207
+ * pays for its usage from then on; what it used before stays charged to
208
+ * the account it was linked to then. A project is always linked to one
209
+ * account, so there is nothing to unlink. Needs `admin.project.attach`
210
+ * on the project, which is separate from access to billing accounts.
211
+ */
212
+ async updateProjectBillingInfo(request: UpdateProjectBillingInfoRequest, options?: CallOptions): Promise<ProjectBillingInfo> {
213
+ const p0 = pathValue("projectBillingInfo.name", request.projectBillingInfo?.name, "projects/*/billingInfo");
214
+ return this.service.call<ProjectBillingInfo>(
215
+ {
216
+ method: "PATCH",
217
+ path: `/v1beta1/${p0}`,
218
+ body: request.projectBillingInfo,
219
+ query: query(request, ["projectBillingInfo.name", "projectBillingInfo"]),
220
+ },
221
+ options,
222
+ );
223
+ }
224
+
225
+ /**
226
+ * Lists the projects a billing account pays for, oldest first. Needs
227
+ * `admin.billing_account.get` on the organization.
228
+ */
229
+ async listProjectBillingInfo(request: ListProjectBillingInfoRequest, options?: CallOptions): Promise<ListProjectBillingInfoResponse> {
230
+ const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
231
+ return this.service.call<ListProjectBillingInfoResponse>(
232
+ {
233
+ method: "GET",
234
+ path: `/v1beta1/${p0}/projects`,
235
+ query: query(request, ["name"]),
236
+ idempotent: true,
237
+ },
238
+ options,
239
+ );
240
+ }
241
+
242
+ /**
243
+ * Iterates over everything listProjectBillingInfo lists from the request's page on,
244
+ * fetching the next page as the loop reaches it. A page that fails ends
245
+ * the iteration with its error.
246
+ */
247
+ async *allProjectBillingInfos(request: ListProjectBillingInfoRequest, options?: CallOptions): AsyncGenerator<ProjectBillingInfo, void, undefined> {
248
+ for (let page = request; ; ) {
249
+ const response = await this.listProjectBillingInfo(page, options);
250
+ yield* response.projectBillingInfos ?? [];
251
+ if (!response.nextPageToken) return;
252
+ page = { ...page, pageToken: response.nextPageToken };
253
+ }
254
+ }
255
+
256
+ /** Returns a country a billing address may be in. */
257
+ async getBillingCountry(request: GetBillingCountryRequest, options?: CallOptions): Promise<BillingCountry> {
258
+ const p0 = pathValue("name", request.name, "billingCountries/*");
259
+ return this.service.call<BillingCountry>(
260
+ {
261
+ method: "GET",
262
+ path: `/v1beta1/${p0}`,
263
+ query: query(request, ["name"]),
264
+ idempotent: true,
265
+ },
266
+ options,
267
+ );
268
+ }
269
+
270
+ /**
271
+ * Lists the countries a billing address may be in, in the order a form
272
+ * shows them, and whether each needs a VAT id.
273
+ */
274
+ async listBillingCountries(request: ListBillingCountriesRequest, options?: CallOptions): Promise<ListBillingCountriesResponse> {
275
+ return this.service.call<ListBillingCountriesResponse>(
276
+ {
277
+ method: "GET",
278
+ path: `/v1beta1/billingCountries`,
279
+ query: query(request, []),
280
+ idempotent: true,
281
+ },
282
+ options,
283
+ );
284
+ }
285
+
286
+ /**
287
+ * Iterates over everything listBillingCountries lists from the request's page on,
288
+ * fetching the next page as the loop reaches it. A page that fails ends
289
+ * the iteration with its error.
290
+ */
291
+ async *allBillingCountries(request: ListBillingCountriesRequest, options?: CallOptions): AsyncGenerator<BillingCountry, void, undefined> {
292
+ for (let page = request; ; ) {
293
+ const response = await this.listBillingCountries(page, options);
294
+ yield* response.billingCountries ?? [];
295
+ if (!response.nextPageToken) return;
296
+ page = { ...page, pageToken: response.nextPageToken };
297
+ }
298
+ }
299
+ }
300
+
301
+ /**
302
+ * An organization's billing account: who invoices are issued to, and how
303
+ * its projects' usage is paid.
304
+ */
305
+ export interface BillingAccount {
306
+ /** The billing account's resource name. */
307
+ name?: string;
308
+ /**
309
+ * The billing account's URN, the identifier access policies and the audit
310
+ * log use.
311
+ */
312
+ urn?: string;
313
+ /**
314
+ * The name the console and spend-limit alerts show. Not empty. An
315
+ * organization's default account is called `default` until it is
316
+ * renamed.
317
+ */
318
+ displayName?: string;
319
+ /**
320
+ * Whether this is the organization's default billing account: the one
321
+ * its new projects are linked to. Every organization has exactly one,
322
+ * and it can't be deleted.
323
+ */
324
+ defaultAccount?: boolean;
325
+ /**
326
+ * The postal address invoices are issued to. Required to create an
327
+ * account; unset only on an organization's default account until its
328
+ * profile is set.
329
+ */
330
+ billingAddress?: BillingAddress;
331
+ /**
332
+ * Where invoices are sent. Required to create an account; empty only on
333
+ * an organization's default account until its profile is set.
334
+ */
335
+ invoiceEmail?: string;
336
+ /**
337
+ * The VAT identification number invoices name; empty for none. Required
338
+ * for a billing address outside Germany.
339
+ */
340
+ vatId?: string;
341
+ /**
342
+ * Who invoices are addressed to. Required to create an account; empty
343
+ * only on an organization's default account until its profile is set.
344
+ */
345
+ contactPerson?: string;
346
+ /** How the account is paid. */
347
+ paymentMethod?: PaymentMethod;
348
+ /** When the billing account was created. */
349
+ createTime?: string;
350
+ /**
351
+ * The principal that created the billing account, such as `user:<id>` or
352
+ * `service_account:<id>`.
353
+ */
354
+ creator?: string;
355
+ }
356
+
357
+ /** A postal address invoices are issued to. Every field is required. */
358
+ export interface BillingAddress {
359
+ /** The street and house number. */
360
+ street?: string;
361
+ /** The city. */
362
+ city?: string;
363
+ /** The postal code. */
364
+ postalCode?: string;
365
+ /**
366
+ * The country, as the ISO 3166-1 alpha-2 code of one of the countries
367
+ * ListBillingCountries lists, such as `DE`.
368
+ */
369
+ regionCode?: string;
370
+ }
371
+
372
+ /**
373
+ * How a billing account is paid. Only the payment method's kind and the
374
+ * last digits of a card are shown; the payment details themselves stay
375
+ * with the payment provider.
376
+ */
377
+ export interface PaymentMethod {
378
+ /** Whether the account can pay for usage. */
379
+ state?: PaymentMethod_State;
380
+ /**
381
+ * The verified card's brand, such as `visa`; empty while no payment
382
+ * method is verified, and for one that isn't a card.
383
+ */
384
+ cardBrand?: string;
385
+ /**
386
+ * The verified card's last four digits; empty while no payment method is
387
+ * verified, and for one that isn't a card.
388
+ */
389
+ cardLast4?: string;
390
+ }
391
+
392
+ /** Whether the account can pay for usage. */
393
+ export const PaymentMethod_State = {
394
+ /** Not set. */
395
+ STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
396
+ /**
397
+ * No verified payment method: the projects linked to the account can't
398
+ * create billable resources until one is added with
399
+ * StartPaymentMethodSetup and ConfirmPaymentMethodSetup.
400
+ */
401
+ MISSING: "MISSING",
402
+ /** A payment method is verified, and billable resources can be created. */
403
+ VERIFIED: "VERIFIED",
404
+ /**
405
+ * The account is invoiced by arrangement with the platform's operator:
406
+ * it needs no payment method, and the setup methods are refused.
407
+ */
408
+ NOT_REQUIRED: "NOT_REQUIRED",
409
+ } as const;
410
+
411
+ /** Whether the account can pay for usage. */
412
+ export type PaymentMethod_State = (typeof PaymentMethod_State)[keyof typeof PaymentMethod_State];
413
+
414
+ /** Which billing account pays for a project. */
415
+ export interface ProjectBillingInfo {
416
+ /** The billing info's resource name, `projects/{project}/billingInfo`. */
417
+ name?: string;
418
+ /**
419
+ * The billing account that pays for the project's usage, one of its
420
+ * organization's.
421
+ */
422
+ billingAccount?: string;
423
+ }
424
+
425
+ /** A country a billing address may be in. */
426
+ export interface BillingCountry {
427
+ /** The country's resource name, `billingCountries/{code}`. */
428
+ name?: string;
429
+ /**
430
+ * The ISO 3166-1 alpha-2 code a billing address names it by, such as
431
+ * `DE`.
432
+ */
433
+ regionCode?: string;
434
+ /** The country's name in English. */
435
+ displayName?: string;
436
+ /**
437
+ * Whether a billing account with an address in this country needs a
438
+ * `vatId`. Customers in every country but Germany are invoiced without
439
+ * VAT, as businesses under the reverse-charge rule, which needs one.
440
+ */
441
+ vatIdRequired?: boolean;
442
+ }
443
+
444
+ /** The request for GetBillingAccount. */
445
+ export interface GetBillingAccountRequest {
446
+ /** The billing account to return. */
447
+ name?: string;
448
+ }
449
+
450
+ /** The request for ListBillingAccounts. */
451
+ export interface ListBillingAccountsRequest {
452
+ /**
453
+ * The organization whose billing accounts to list,
454
+ * `organizations/{organization}`.
455
+ */
456
+ parent?: string;
457
+ /**
458
+ * The most billing accounts to return; the server clamps it, and 0 means
459
+ * its default.
460
+ */
461
+ pageSize?: number;
462
+ /** A previous response's `nextPageToken`, for the page after it. */
463
+ pageToken?: string;
464
+ }
465
+
466
+ /** The response for ListBillingAccounts. */
467
+ export interface ListBillingAccountsResponse {
468
+ /** The billing accounts on this page. */
469
+ billingAccounts?: BillingAccount[];
470
+ /** The token for the next page; empty on the last one. */
471
+ nextPageToken?: string;
472
+ }
473
+
474
+ /** The request for CreateBillingAccount. */
475
+ export interface CreateBillingAccountRequest {
476
+ /**
477
+ * The organization to create the billing account in,
478
+ * `organizations/{organization}`.
479
+ */
480
+ parent?: string;
481
+ /** The billing account to create: its `displayName` and profile. */
482
+ billingAccount?: BillingAccount;
483
+ /**
484
+ * A UUID; a repeat with the same id returns the billing account the first
485
+ * request created instead of creating a second one.
486
+ */
487
+ requestId?: string;
488
+ }
489
+
490
+ /** The request for UpdateBillingAccount. */
491
+ export interface UpdateBillingAccountRequest {
492
+ /** The billing account, by its name, with the fields to change. */
493
+ billingAccount?: BillingAccount;
494
+ /**
495
+ * The fields to change: `displayName`, `billingAddress`,
496
+ * `invoiceEmail`, `vatId` and `contactPerson`. `*` is every one of
497
+ * them.
498
+ */
499
+ updateMask?: string;
500
+ }
501
+
502
+ /** The request for DeleteBillingAccount. */
503
+ export interface DeleteBillingAccountRequest {
504
+ /** The billing account to delete. */
505
+ name?: string;
506
+ }
507
+
508
+ /** The request for StartPaymentMethodSetup. */
509
+ export interface StartPaymentMethodSetupRequest {
510
+ /** The billing account to add a payment method to. */
511
+ name?: string;
512
+ }
513
+
514
+ /** The response for StartPaymentMethodSetup. */
515
+ export interface StartPaymentMethodSetupResponse {
516
+ /**
517
+ * The payment provider's page to open in a browser, where the payment
518
+ * details are entered. It returns to the console when done.
519
+ */
520
+ redirectUri?: string;
521
+ }
522
+
523
+ /** The request for ConfirmPaymentMethodSetup. */
524
+ export interface ConfirmPaymentMethodSetupRequest {
525
+ /** The billing account whose setup to complete. */
526
+ name?: string;
527
+ }
528
+
529
+ /** The request for GetProjectBillingInfo. */
530
+ export interface GetProjectBillingInfoRequest {
531
+ /** The billing info to return, `projects/{project}/billingInfo`. */
532
+ name?: string;
533
+ }
534
+
535
+ /** The request for UpdateProjectBillingInfo. */
536
+ export interface UpdateProjectBillingInfoRequest {
537
+ /** The billing info, by its name, with the billing account to link. */
538
+ projectBillingInfo?: ProjectBillingInfo;
539
+ /** The fields to change: `billingAccount`. `*` is the same. */
540
+ updateMask?: string;
541
+ }
542
+
543
+ /** The request for ListProjectBillingInfo. */
544
+ export interface ListProjectBillingInfoRequest {
545
+ /** The billing account whose projects to list. */
546
+ name?: string;
547
+ /**
548
+ * The most projects to return; the server clamps it, and 0 means its
549
+ * default.
550
+ */
551
+ pageSize?: number;
552
+ /** A previous response's `nextPageToken`, for the page after it. */
553
+ pageToken?: string;
554
+ }
555
+
556
+ /** The response for ListProjectBillingInfo. */
557
+ export interface ListProjectBillingInfoResponse {
558
+ /** The billing info of each project on this page. */
559
+ projectBillingInfos?: ProjectBillingInfo[];
560
+ /** The token for the next page; empty on the last one. */
561
+ nextPageToken?: string;
562
+ }
563
+
564
+ /** The request for GetBillingCountry. */
565
+ export interface GetBillingCountryRequest {
566
+ /**
567
+ * The country to return, `billingCountries/{code}`, such as
568
+ * `billingCountries/DE`.
569
+ */
570
+ name?: string;
571
+ }
572
+
573
+ /** The request for ListBillingCountries. */
574
+ export interface ListBillingCountriesRequest {
575
+ /**
576
+ * The most countries to return; the server clamps it, and 0 means its
577
+ * default.
578
+ */
579
+ pageSize?: number;
580
+ /** A previous response's `nextPageToken`, for the page after it. */
581
+ pageToken?: string;
582
+ }
583
+
584
+ /** The response for ListBillingCountries. */
585
+ export interface ListBillingCountriesResponse {
586
+ /** The countries on this page. */
587
+ billingCountries?: BillingCountry[];
588
+ /** The token for the next page; empty on the last one. */
589
+ nextPageToken?: string;
590
+ }