@origincloud/billing 0.0.0-stage → 0.12.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 +202 -0
- package/README.md +24 -2
- package/dist/v1beta1/billing_account.d.ts +387 -0
- package/dist/v1beta1/billing_account.d.ts.map +1 -0
- package/dist/v1beta1/billing_account.js +260 -0
- package/dist/v1beta1/billing_account.js.map +1 -0
- package/dist/v1beta1/cost.d.ts +220 -0
- package/dist/v1beta1/cost.d.ts.map +1 -0
- package/dist/v1beta1/cost.js +107 -0
- package/dist/v1beta1/cost.js.map +1 -0
- package/dist/v1beta1/index.d.ts +5 -0
- package/dist/v1beta1/index.d.ts.map +1 -0
- package/dist/v1beta1/index.js +6 -0
- package/dist/v1beta1/index.js.map +1 -0
- package/dist/v1beta1/price_list.d.ts +93 -0
- package/dist/v1beta1/price_list.d.ts.map +1 -0
- package/dist/v1beta1/price_list.js +38 -0
- package/dist/v1beta1/price_list.js.map +1 -0
- package/dist/v1beta1/spend_limit.d.ts +78 -0
- package/dist/v1beta1/spend_limit.d.ts.map +1 -0
- package/dist/v1beta1/spend_limit.js +53 -0
- package/dist/v1beta1/spend_limit.js.map +1 -0
- package/package.json +40 -4
- package/src/v1beta1/billing_account.ts +590 -0
- package/src/v1beta1/cost.ts +296 -0
- package/src/v1beta1/index.ts +6 -0
- package/src/v1beta1/price_list.ts +113 -0
- package/src/v1beta1/spend_limit.ts +111 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Code generated by the SDK's generator (generator/). DO NOT EDIT.
|
|
2
|
+
// source: origincloud/billing/v1beta1/billing_account.proto
|
|
3
|
+
import { newRequestId, pathValue, query, } from "@origincloud/core";
|
|
4
|
+
/**
|
|
5
|
+
* Calls BillingAccountService.
|
|
6
|
+
*
|
|
7
|
+
* Billing accounts, which project each one pays for, and how they are paid.
|
|
8
|
+
*/
|
|
9
|
+
export class BillingAccountClient {
|
|
10
|
+
/**
|
|
11
|
+
* The endpoint the client sends its calls to, which also serves the
|
|
12
|
+
* operations its methods answer with.
|
|
13
|
+
*/
|
|
14
|
+
service;
|
|
15
|
+
/** A client of BillingAccountService that sends its calls through `client`. */
|
|
16
|
+
constructor(client) {
|
|
17
|
+
this.service = client.service("billing", false);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns a billing account. Needs `admin.billing_account.get` on the
|
|
21
|
+
* organization.
|
|
22
|
+
*/
|
|
23
|
+
async getBillingAccount(request, options) {
|
|
24
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
|
|
25
|
+
return this.service.call({
|
|
26
|
+
method: "GET",
|
|
27
|
+
path: `/v1beta1/${p0}`,
|
|
28
|
+
query: query(request, ["name"]),
|
|
29
|
+
idempotent: true,
|
|
30
|
+
}, options);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Lists an organization's billing accounts, oldest first. Needs
|
|
34
|
+
* `admin.billing_account.list` on the organization.
|
|
35
|
+
*/
|
|
36
|
+
async listBillingAccounts(request, options) {
|
|
37
|
+
const p0 = pathValue("parent", request.parent, "organizations/*");
|
|
38
|
+
return this.service.call({
|
|
39
|
+
method: "GET",
|
|
40
|
+
path: `/v1beta1/${p0}/billingAccounts`,
|
|
41
|
+
query: query(request, ["parent"]),
|
|
42
|
+
idempotent: true,
|
|
43
|
+
}, options);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Iterates over everything listBillingAccounts lists from the request's page on,
|
|
47
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
48
|
+
* the iteration with its error.
|
|
49
|
+
*/
|
|
50
|
+
async *allBillingAccounts(request, options) {
|
|
51
|
+
for (let page = request;;) {
|
|
52
|
+
const response = await this.listBillingAccounts(page, options);
|
|
53
|
+
yield* response.billingAccounts ?? [];
|
|
54
|
+
if (!response.nextPageToken)
|
|
55
|
+
return;
|
|
56
|
+
page = { ...page, pageToken: response.nextPageToken };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a billing account with its profile: `displayName`,
|
|
61
|
+
* `billingAddress`, `invoiceEmail` and `contactPerson` are required,
|
|
62
|
+
* and `vatId` too for a billing address outside Germany. The account
|
|
63
|
+
* has no payment method yet: until one is verified, the projects linked
|
|
64
|
+
* to it can't create billable resources. Creating it grants nobody a
|
|
65
|
+
* role: whoever can create billing accounts can use it. Needs
|
|
66
|
+
* `admin.billing_account.create` on the organization.
|
|
67
|
+
*/
|
|
68
|
+
async createBillingAccount(request, options) {
|
|
69
|
+
if (!request.requestId)
|
|
70
|
+
request = { ...request, requestId: newRequestId() };
|
|
71
|
+
const p0 = pathValue("parent", request.parent, "organizations/*");
|
|
72
|
+
return this.service.call({
|
|
73
|
+
method: "POST",
|
|
74
|
+
path: `/v1beta1/${p0}/billingAccounts`,
|
|
75
|
+
body: request.billingAccount,
|
|
76
|
+
query: query(request, ["parent", "billingAccount"]),
|
|
77
|
+
idempotent: true,
|
|
78
|
+
}, options);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Changes a billing account's `displayName` or its profile. The profile
|
|
82
|
+
* fields named in `updateMask` are replaced and the others kept; once
|
|
83
|
+
* the update is applied, the account must have a whole profile
|
|
84
|
+
* (`billingAddress`, `invoiceEmail`, `contactPerson`, and `vatId`
|
|
85
|
+
* for a billing address outside Germany), or the update is refused. Needs
|
|
86
|
+
* `admin.billing_account.update` on the organization.
|
|
87
|
+
*/
|
|
88
|
+
async updateBillingAccount(request, options) {
|
|
89
|
+
const p0 = pathValue("billingAccount.name", request.billingAccount?.name, "organizations/*/billingAccounts/*");
|
|
90
|
+
return this.service.call({
|
|
91
|
+
method: "PATCH",
|
|
92
|
+
path: `/v1beta1/${p0}`,
|
|
93
|
+
body: request.billingAccount,
|
|
94
|
+
query: query(request, ["billingAccount.name", "billingAccount"]),
|
|
95
|
+
}, options);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Deletes a billing account. Refused as a `CONFLICT` for the
|
|
99
|
+
* organization's default billing account, while a project is linked to
|
|
100
|
+
* the account (link it to another account first), and while the account
|
|
101
|
+
* has a spend limit (remove it first). Needs
|
|
102
|
+
* `admin.billing_account.delete` on the organization.
|
|
103
|
+
*/
|
|
104
|
+
async deleteBillingAccount(request, options) {
|
|
105
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
|
|
106
|
+
return this.service.call({
|
|
107
|
+
method: "DELETE",
|
|
108
|
+
path: `/v1beta1/${p0}`,
|
|
109
|
+
query: query(request, ["name"]),
|
|
110
|
+
}, options);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Starts adding a payment method to a billing account, and returns the
|
|
114
|
+
* payment provider's page to open in a browser: the payment details are
|
|
115
|
+
* entered there and never pass through this API. Once that page is done,
|
|
116
|
+
* call ConfirmPaymentMethodSetup. Starting again replaces a setup that
|
|
117
|
+
* wasn't confirmed. Refused as `INVALID_ARGUMENT` for an account whose
|
|
118
|
+
* `paymentMethod.state` is `NOT_REQUIRED`. Needs
|
|
119
|
+
* `admin.billing_account.update` on the organization.
|
|
120
|
+
*/
|
|
121
|
+
async startPaymentMethodSetup(request, options) {
|
|
122
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
|
|
123
|
+
return this.service.call({
|
|
124
|
+
method: "POST",
|
|
125
|
+
path: `/v1beta1/${p0}:startPaymentMethodSetup`,
|
|
126
|
+
body: request,
|
|
127
|
+
}, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Completes the setup StartPaymentMethodSetup started, once its page is
|
|
131
|
+
* done: the payment provider is asked whether it finished, and only a
|
|
132
|
+
* finished setup is recorded. The account's `paymentMethod` is then
|
|
133
|
+
* `VERIFIED`, replacing any earlier one, and its projects can create
|
|
134
|
+
* billable resources. An unfinished or abandoned setup is refused as
|
|
135
|
+
* `INVALID_ARGUMENT` and changes nothing: finish the page, or start
|
|
136
|
+
* again. So is an account with no setup started, which includes a
|
|
137
|
+
* repeat of a confirmation that succeeded: read the account to see
|
|
138
|
+
* whether it did. Needs `admin.billing_account.update` on the
|
|
139
|
+
* organization.
|
|
140
|
+
*/
|
|
141
|
+
async confirmPaymentMethodSetup(request, options) {
|
|
142
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
|
|
143
|
+
return this.service.call({
|
|
144
|
+
method: "POST",
|
|
145
|
+
path: `/v1beta1/${p0}:confirmPaymentMethodSetup`,
|
|
146
|
+
body: request,
|
|
147
|
+
}, options);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Returns which billing account pays for a project. Needs
|
|
151
|
+
* `admin.project.get` on the project.
|
|
152
|
+
*/
|
|
153
|
+
async getProjectBillingInfo(request, options) {
|
|
154
|
+
const p0 = pathValue("name", request.name, "projects/*/billingInfo");
|
|
155
|
+
return this.service.call({
|
|
156
|
+
method: "GET",
|
|
157
|
+
path: `/v1beta1/${p0}`,
|
|
158
|
+
query: query(request, ["name"]),
|
|
159
|
+
idempotent: true,
|
|
160
|
+
}, options);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Links a project to another billing account of its organization, which
|
|
164
|
+
* pays for its usage from then on; what it used before stays charged to
|
|
165
|
+
* the account it was linked to then. A project is always linked to one
|
|
166
|
+
* account, so there is nothing to unlink. Needs `admin.project.attach`
|
|
167
|
+
* on the project, which is separate from access to billing accounts.
|
|
168
|
+
*/
|
|
169
|
+
async updateProjectBillingInfo(request, options) {
|
|
170
|
+
const p0 = pathValue("projectBillingInfo.name", request.projectBillingInfo?.name, "projects/*/billingInfo");
|
|
171
|
+
return this.service.call({
|
|
172
|
+
method: "PATCH",
|
|
173
|
+
path: `/v1beta1/${p0}`,
|
|
174
|
+
body: request.projectBillingInfo,
|
|
175
|
+
query: query(request, ["projectBillingInfo.name", "projectBillingInfo"]),
|
|
176
|
+
}, options);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Lists the projects a billing account pays for, oldest first. Needs
|
|
180
|
+
* `admin.billing_account.get` on the organization.
|
|
181
|
+
*/
|
|
182
|
+
async listProjectBillingInfo(request, options) {
|
|
183
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*");
|
|
184
|
+
return this.service.call({
|
|
185
|
+
method: "GET",
|
|
186
|
+
path: `/v1beta1/${p0}/projects`,
|
|
187
|
+
query: query(request, ["name"]),
|
|
188
|
+
idempotent: true,
|
|
189
|
+
}, options);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Iterates over everything listProjectBillingInfo lists from the request's page on,
|
|
193
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
194
|
+
* the iteration with its error.
|
|
195
|
+
*/
|
|
196
|
+
async *allProjectBillingInfos(request, options) {
|
|
197
|
+
for (let page = request;;) {
|
|
198
|
+
const response = await this.listProjectBillingInfo(page, options);
|
|
199
|
+
yield* response.projectBillingInfos ?? [];
|
|
200
|
+
if (!response.nextPageToken)
|
|
201
|
+
return;
|
|
202
|
+
page = { ...page, pageToken: response.nextPageToken };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** Returns a country a billing address may be in. */
|
|
206
|
+
async getBillingCountry(request, options) {
|
|
207
|
+
const p0 = pathValue("name", request.name, "billingCountries/*");
|
|
208
|
+
return this.service.call({
|
|
209
|
+
method: "GET",
|
|
210
|
+
path: `/v1beta1/${p0}`,
|
|
211
|
+
query: query(request, ["name"]),
|
|
212
|
+
idempotent: true,
|
|
213
|
+
}, options);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Lists the countries a billing address may be in, in the order a form
|
|
217
|
+
* shows them, and whether each needs a VAT id.
|
|
218
|
+
*/
|
|
219
|
+
async listBillingCountries(request, options) {
|
|
220
|
+
return this.service.call({
|
|
221
|
+
method: "GET",
|
|
222
|
+
path: `/v1beta1/billingCountries`,
|
|
223
|
+
query: query(request, []),
|
|
224
|
+
idempotent: true,
|
|
225
|
+
}, options);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Iterates over everything listBillingCountries lists from the request's page on,
|
|
229
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
230
|
+
* the iteration with its error.
|
|
231
|
+
*/
|
|
232
|
+
async *allBillingCountries(request, options) {
|
|
233
|
+
for (let page = request;;) {
|
|
234
|
+
const response = await this.listBillingCountries(page, options);
|
|
235
|
+
yield* response.billingCountries ?? [];
|
|
236
|
+
if (!response.nextPageToken)
|
|
237
|
+
return;
|
|
238
|
+
page = { ...page, pageToken: response.nextPageToken };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** Whether the account can pay for usage. */
|
|
243
|
+
export const PaymentMethod_State = {
|
|
244
|
+
/** Not set. */
|
|
245
|
+
STATE_UNSPECIFIED: "STATE_UNSPECIFIED",
|
|
246
|
+
/**
|
|
247
|
+
* No verified payment method: the projects linked to the account can't
|
|
248
|
+
* create billable resources until one is added with
|
|
249
|
+
* StartPaymentMethodSetup and ConfirmPaymentMethodSetup.
|
|
250
|
+
*/
|
|
251
|
+
MISSING: "MISSING",
|
|
252
|
+
/** A payment method is verified, and billable resources can be created. */
|
|
253
|
+
VERIFIED: "VERIFIED",
|
|
254
|
+
/**
|
|
255
|
+
* The account is invoiced by arrangement with the platform's operator:
|
|
256
|
+
* it needs no payment method, and the setup methods are refused.
|
|
257
|
+
*/
|
|
258
|
+
NOT_REQUIRED: "NOT_REQUIRED",
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=billing_account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing_account.js","sourceRoot":"","sources":["../../src/v1beta1/billing_account.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,4DAA4D;AAE5D,OAAO,EAKL,YAAY,EACZ,SAAS,EACT,KAAK,GACN,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;OAGG;I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AE,QAAQ,CAAC,aAAa,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;CACF;AA6FD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,eAAe;IACf,iBAAiB,EAAE,mBAAmB;IACtC;;;;OAIG;IACH,OAAO,EAAE,SAAS;IAClB,2EAA2E;IAC3E,QAAQ,EAAE,UAAU;IACpB;;;OAGG;IACH,YAAY,EAAE,cAAc;CACpB,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { type CallOptions, type Client, type Service } from "@origincloud/core";
|
|
2
|
+
/**
|
|
3
|
+
* Calls CostService.
|
|
4
|
+
*
|
|
5
|
+
* Usage and cost: what a project, an organization or a billing account used
|
|
6
|
+
* in a period, and what it costs, as read-only reports.
|
|
7
|
+
*
|
|
8
|
+
* Usage is metered per resource and priced when it is recorded, at the
|
|
9
|
+
* price list's rate then, so a later price change never changes a past
|
|
10
|
+
* cost. A running resource's usage is recorded at least hourly; the last
|
|
11
|
+
* hour can still be missing from a report.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CostClient {
|
|
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 CostService that sends its calls through `client`. */
|
|
20
|
+
constructor(client: Client);
|
|
21
|
+
/**
|
|
22
|
+
* Returns a project's cost in a period, by service and product, in hourly
|
|
23
|
+
* or daily buckets. Needs `admin.usage.list` on the organization.
|
|
24
|
+
*/
|
|
25
|
+
queryProjectCost(request: QueryProjectCostRequest, options?: CallOptions): Promise<CostReport>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns an organization's cost in a period: every project's together,
|
|
28
|
+
* by service and product, and each project's on its own. Needs
|
|
29
|
+
* `admin.usage.list` on the organization, which reads every project's
|
|
30
|
+
* cost in it.
|
|
31
|
+
*/
|
|
32
|
+
queryOrganizationCost(request: QueryOrganizationCostRequest, options?: CallOptions): Promise<OrganizationCostReport>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns what was charged to a billing account in a period, by service
|
|
35
|
+
* and product. A project's cost is charged to the account it was linked
|
|
36
|
+
* to when the usage was recorded, so moving a project moves only its
|
|
37
|
+
* later cost. Its spend limit compares the calendar month's total with
|
|
38
|
+
* `limit`. Needs `admin.spend_limit.get` on the organization.
|
|
39
|
+
*/
|
|
40
|
+
queryBillingAccountCost(request: QueryBillingAccountCostRequest, options?: CallOptions): Promise<CostReport>;
|
|
41
|
+
/**
|
|
42
|
+
* Lists a project's metered usage records that overlap a period, the
|
|
43
|
+
* input its cost is priced from, oldest first. Needs `admin.usage.list`
|
|
44
|
+
* on the organization.
|
|
45
|
+
*/
|
|
46
|
+
queryProjectUsage(request: QueryProjectUsageRequest, options?: CallOptions): Promise<QueryProjectUsageResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Iterates over everything queryProjectUsage lists from the request's page on,
|
|
49
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
50
|
+
* the iteration with its error.
|
|
51
|
+
*/
|
|
52
|
+
allUsageRecords(request: QueryProjectUsageRequest, options?: CallOptions): AsyncGenerator<UsageRecord, void, undefined>;
|
|
53
|
+
}
|
|
54
|
+
/** How finely a report's cost is bucketed. */
|
|
55
|
+
export declare const Granularity: {
|
|
56
|
+
/** Not set: daily. */
|
|
57
|
+
readonly GRANULARITY_UNSPECIFIED: "GRANULARITY_UNSPECIFIED";
|
|
58
|
+
/** One bucket per hour, starting on the hour. */
|
|
59
|
+
readonly HOURLY: "HOURLY";
|
|
60
|
+
/** One bucket per day, starting at midnight UTC. */
|
|
61
|
+
readonly DAILY: "DAILY";
|
|
62
|
+
};
|
|
63
|
+
/** How finely a report's cost is bucketed. */
|
|
64
|
+
export type Granularity = (typeof Granularity)[keyof typeof Granularity];
|
|
65
|
+
/**
|
|
66
|
+
* A cost report: the period's total, by service and, within a service, by
|
|
67
|
+
* product. Every amount is in EUR, before VAT, as a decimal string.
|
|
68
|
+
*/
|
|
69
|
+
export interface CostReport {
|
|
70
|
+
/** The period's total. */
|
|
71
|
+
total?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Each service with any cost in the period, such as `compute`, in name
|
|
74
|
+
* order.
|
|
75
|
+
*/
|
|
76
|
+
services?: ServiceCost[];
|
|
77
|
+
}
|
|
78
|
+
/** One service's cost in a report. */
|
|
79
|
+
export interface ServiceCost {
|
|
80
|
+
/**
|
|
81
|
+
* The service, the first segment of its products' keys, such as
|
|
82
|
+
* `compute`.
|
|
83
|
+
*/
|
|
84
|
+
service?: string;
|
|
85
|
+
/** The service's total. */
|
|
86
|
+
total?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Each of the service's products with any cost in the period, in key
|
|
89
|
+
* order.
|
|
90
|
+
*/
|
|
91
|
+
products?: ProductCost[];
|
|
92
|
+
}
|
|
93
|
+
/** One product's cost in a report. */
|
|
94
|
+
export interface ProductCost {
|
|
95
|
+
/** The product as the price list names it, such as `compute.gp1.core.2`. */
|
|
96
|
+
productKey?: string;
|
|
97
|
+
/** The product's total. */
|
|
98
|
+
total?: string;
|
|
99
|
+
/** The buckets with any cost, oldest first. */
|
|
100
|
+
buckets?: CostBucket[];
|
|
101
|
+
}
|
|
102
|
+
/** The cost of one hour or one day. */
|
|
103
|
+
export interface CostBucket {
|
|
104
|
+
/** When the bucket starts. */
|
|
105
|
+
startTime?: string;
|
|
106
|
+
/** The bucket's cost. */
|
|
107
|
+
amount?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* An organization's cost report: its projects' together, and each
|
|
111
|
+
* project's.
|
|
112
|
+
*/
|
|
113
|
+
export interface OrganizationCostReport {
|
|
114
|
+
/** The period's total of every project. */
|
|
115
|
+
total?: string;
|
|
116
|
+
/** Each service with any cost in the period, over every project. */
|
|
117
|
+
services?: ServiceCost[];
|
|
118
|
+
/**
|
|
119
|
+
* Each project with any cost in the period, in id order, a project
|
|
120
|
+
* deleted since included.
|
|
121
|
+
*/
|
|
122
|
+
projects?: ProjectCost[];
|
|
123
|
+
}
|
|
124
|
+
/** One project's cost in an organization's report, over every service. */
|
|
125
|
+
export interface ProjectCost {
|
|
126
|
+
/** The project, `projects/{project}`. */
|
|
127
|
+
project?: string;
|
|
128
|
+
/** The project's total. */
|
|
129
|
+
total?: string;
|
|
130
|
+
/** The buckets with any cost, oldest first. */
|
|
131
|
+
buckets?: CostBucket[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* One metered interval of one resource: how much of a metric it used from
|
|
135
|
+
* `startTime` to `endTime`.
|
|
136
|
+
*/
|
|
137
|
+
export interface UsageRecord {
|
|
138
|
+
/** The kind of resource, such as `compute.instance`. */
|
|
139
|
+
resourceKind?: string;
|
|
140
|
+
/** The resource's id. */
|
|
141
|
+
resourceId?: string;
|
|
142
|
+
/** What was measured, such as `running_seconds`. */
|
|
143
|
+
metric?: string;
|
|
144
|
+
/**
|
|
145
|
+
* The product the usage is priced as, such as `compute.gp1.core.2`;
|
|
146
|
+
* empty for a kind of resource that has none.
|
|
147
|
+
*/
|
|
148
|
+
productKey?: string;
|
|
149
|
+
/** How much was used, in the metric's unit, as a decimal string. */
|
|
150
|
+
quantity?: string;
|
|
151
|
+
/** When the interval starts. */
|
|
152
|
+
startTime?: string;
|
|
153
|
+
/** When the interval ends. */
|
|
154
|
+
endTime?: string;
|
|
155
|
+
/**
|
|
156
|
+
* The billing account the usage was charged to, the one the project was
|
|
157
|
+
* linked to when it was recorded; empty if it had none.
|
|
158
|
+
*/
|
|
159
|
+
billingAccount?: string;
|
|
160
|
+
}
|
|
161
|
+
/** The request for QueryProjectCost. */
|
|
162
|
+
export interface QueryProjectCostRequest {
|
|
163
|
+
/** The project, `projects/{project}`. */
|
|
164
|
+
project?: string;
|
|
165
|
+
/** The period's start, included. */
|
|
166
|
+
startTime?: string;
|
|
167
|
+
/** The period's end, left out; after `startTime`. */
|
|
168
|
+
endTime?: string;
|
|
169
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
170
|
+
granularity?: Granularity;
|
|
171
|
+
}
|
|
172
|
+
/** The request for QueryOrganizationCost. */
|
|
173
|
+
export interface QueryOrganizationCostRequest {
|
|
174
|
+
/** The organization, `organizations/{organization}`. */
|
|
175
|
+
organization?: string;
|
|
176
|
+
/** The period's start, included. */
|
|
177
|
+
startTime?: string;
|
|
178
|
+
/** The period's end, left out; after `startTime`. */
|
|
179
|
+
endTime?: string;
|
|
180
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
181
|
+
granularity?: Granularity;
|
|
182
|
+
}
|
|
183
|
+
/** The request for QueryBillingAccountCost. */
|
|
184
|
+
export interface QueryBillingAccountCostRequest {
|
|
185
|
+
/** The billing account. */
|
|
186
|
+
billingAccount?: string;
|
|
187
|
+
/** The period's start, included. */
|
|
188
|
+
startTime?: string;
|
|
189
|
+
/** The period's end, left out; after `startTime`. */
|
|
190
|
+
endTime?: string;
|
|
191
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
192
|
+
granularity?: Granularity;
|
|
193
|
+
}
|
|
194
|
+
/** The request for QueryProjectUsage. */
|
|
195
|
+
export interface QueryProjectUsageRequest {
|
|
196
|
+
/** The project, `projects/{project}`. */
|
|
197
|
+
project?: string;
|
|
198
|
+
/** The period's start: records that end after it are listed. */
|
|
199
|
+
startTime?: string;
|
|
200
|
+
/**
|
|
201
|
+
* The period's end: records that start before it are listed; after
|
|
202
|
+
* `startTime`.
|
|
203
|
+
*/
|
|
204
|
+
endTime?: string;
|
|
205
|
+
/**
|
|
206
|
+
* The most records 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
|
+
/** The response for QueryProjectUsage. */
|
|
214
|
+
export interface QueryProjectUsageResponse {
|
|
215
|
+
/** The usage records on this page. */
|
|
216
|
+
usageRecords?: UsageRecord[];
|
|
217
|
+
/** The token for the next page; empty on the last one. */
|
|
218
|
+
nextPageToken?: string;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/v1beta1/cost.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAoB,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACrB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,qEAAqE;gBACzD,MAAM,EAAE,MAAM;IAI1B;;;OAGG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAapG;;;;;OAKG;IACG,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAa1H;;;;;;OAMG;IACG,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAalH;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAarH;;;;OAIG;IACI,eAAe,CAAC,OAAO,EAAE,wBAAwB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC;CAQ/H;AAED,8CAA8C;AAC9C,eAAO,MAAM,WAAW;IACtB,sBAAsB;;IAEtB,iDAAiD;;IAEjD,oDAAoD;;CAE5C,CAAC;AAEX,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GA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AAM,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACxC,sCAAsC;IACtC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Code generated by the SDK's generator (generator/). DO NOT EDIT.
|
|
2
|
+
// source: origincloud/billing/v1beta1/cost.proto
|
|
3
|
+
import { pathValue, query } from "@origincloud/core";
|
|
4
|
+
/**
|
|
5
|
+
* Calls CostService.
|
|
6
|
+
*
|
|
7
|
+
* Usage and cost: what a project, an organization or a billing account used
|
|
8
|
+
* in a period, and what it costs, as read-only reports.
|
|
9
|
+
*
|
|
10
|
+
* Usage is metered per resource and priced when it is recorded, at the
|
|
11
|
+
* price list's rate then, so a later price change never changes a past
|
|
12
|
+
* cost. A running resource's usage is recorded at least hourly; the last
|
|
13
|
+
* hour can still be missing from a report.
|
|
14
|
+
*/
|
|
15
|
+
export class CostClient {
|
|
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 CostService that sends its calls through `client`. */
|
|
22
|
+
constructor(client) {
|
|
23
|
+
this.service = client.service("billing", false);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a project's cost in a period, by service and product, in hourly
|
|
27
|
+
* or daily buckets. Needs `admin.usage.list` on the organization.
|
|
28
|
+
*/
|
|
29
|
+
async queryProjectCost(request, options) {
|
|
30
|
+
const p0 = pathValue("project", request.project, "projects/*");
|
|
31
|
+
return this.service.call({
|
|
32
|
+
method: "GET",
|
|
33
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
34
|
+
query: query(request, ["project"]),
|
|
35
|
+
idempotent: true,
|
|
36
|
+
}, options);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns an organization's cost in a period: every project's together,
|
|
40
|
+
* by service and product, and each project's on its own. Needs
|
|
41
|
+
* `admin.usage.list` on the organization, which reads every project's
|
|
42
|
+
* cost in it.
|
|
43
|
+
*/
|
|
44
|
+
async queryOrganizationCost(request, options) {
|
|
45
|
+
const p0 = pathValue("organization", request.organization, "organizations/*");
|
|
46
|
+
return this.service.call({
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
49
|
+
query: query(request, ["organization"]),
|
|
50
|
+
idempotent: true,
|
|
51
|
+
}, options);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns what was charged to a billing account in a period, by service
|
|
55
|
+
* and product. A project's cost is charged to the account it was linked
|
|
56
|
+
* to when the usage was recorded, so moving a project moves only its
|
|
57
|
+
* later cost. Its spend limit compares the calendar month's total with
|
|
58
|
+
* `limit`. Needs `admin.spend_limit.get` on the organization.
|
|
59
|
+
*/
|
|
60
|
+
async queryBillingAccountCost(request, options) {
|
|
61
|
+
const p0 = pathValue("billingAccount", request.billingAccount, "organizations/*/billingAccounts/*");
|
|
62
|
+
return this.service.call({
|
|
63
|
+
method: "GET",
|
|
64
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
65
|
+
query: query(request, ["billingAccount"]),
|
|
66
|
+
idempotent: true,
|
|
67
|
+
}, options);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Lists a project's metered usage records that overlap a period, the
|
|
71
|
+
* input its cost is priced from, oldest first. Needs `admin.usage.list`
|
|
72
|
+
* on the organization.
|
|
73
|
+
*/
|
|
74
|
+
async queryProjectUsage(request, options) {
|
|
75
|
+
const p0 = pathValue("project", request.project, "projects/*");
|
|
76
|
+
return this.service.call({
|
|
77
|
+
method: "GET",
|
|
78
|
+
path: `/v1beta1/${p0}:queryUsage`,
|
|
79
|
+
query: query(request, ["project"]),
|
|
80
|
+
idempotent: true,
|
|
81
|
+
}, options);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Iterates over everything queryProjectUsage lists from the request's page on,
|
|
85
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
86
|
+
* the iteration with its error.
|
|
87
|
+
*/
|
|
88
|
+
async *allUsageRecords(request, options) {
|
|
89
|
+
for (let page = request;;) {
|
|
90
|
+
const response = await this.queryProjectUsage(page, options);
|
|
91
|
+
yield* response.usageRecords ?? [];
|
|
92
|
+
if (!response.nextPageToken)
|
|
93
|
+
return;
|
|
94
|
+
page = { ...page, pageToken: response.nextPageToken };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** How finely a report's cost is bucketed. */
|
|
99
|
+
export const Granularity = {
|
|
100
|
+
/** Not set: daily. */
|
|
101
|
+
GRANULARITY_UNSPECIFIED: "GRANULARITY_UNSPECIFIED",
|
|
102
|
+
/** One bucket per hour, starting on the hour. */
|
|
103
|
+
HOURLY: "HOURLY",
|
|
104
|
+
/** One bucket per day, starting at midnight UTC. */
|
|
105
|
+
DAILY: "DAILY",
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../src/v1beta1/cost.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,iDAAiD;AAEjD,OAAO,EAA+C,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IACrB;;;OAGG;IACM,OAAO,CAAU;IAE1B,qEAAqE;IACrE,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,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AChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1beta1/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|