@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.
- 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,296 @@
|
|
|
1
|
+
// Code generated by the SDK's generator (generator/). DO NOT EDIT.
|
|
2
|
+
// source: origincloud/billing/v1beta1/cost.proto
|
|
3
|
+
|
|
4
|
+
import { type CallOptions, type Client, type Service, pathValue, query } from "@origincloud/core";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calls CostService.
|
|
8
|
+
*
|
|
9
|
+
* Usage and cost: what a project, an organization or a billing account used
|
|
10
|
+
* in a period, and what it costs, as read-only reports.
|
|
11
|
+
*
|
|
12
|
+
* Usage is metered per resource and priced when it is recorded, at the
|
|
13
|
+
* price list's rate then, so a later price change never changes a past
|
|
14
|
+
* cost. A running resource's usage is recorded at least hourly; the last
|
|
15
|
+
* hour can still be missing from a report.
|
|
16
|
+
*/
|
|
17
|
+
export class CostClient {
|
|
18
|
+
/**
|
|
19
|
+
* The endpoint the client sends its calls to, which also serves the
|
|
20
|
+
* operations its methods answer with.
|
|
21
|
+
*/
|
|
22
|
+
readonly service: Service;
|
|
23
|
+
|
|
24
|
+
/** A client of CostService that sends its calls through `client`. */
|
|
25
|
+
constructor(client: Client) {
|
|
26
|
+
this.service = client.service("billing", false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns a project's cost in a period, by service and product, in hourly
|
|
31
|
+
* or daily buckets. Needs `admin.usage.list` on the organization.
|
|
32
|
+
*/
|
|
33
|
+
async queryProjectCost(request: QueryProjectCostRequest, options?: CallOptions): Promise<CostReport> {
|
|
34
|
+
const p0 = pathValue("project", request.project, "projects/*");
|
|
35
|
+
return this.service.call<CostReport>(
|
|
36
|
+
{
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
39
|
+
query: query(request, ["project"]),
|
|
40
|
+
idempotent: true,
|
|
41
|
+
},
|
|
42
|
+
options,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Returns an organization's cost in a period: every project's together,
|
|
48
|
+
* by service and product, and each project's on its own. Needs
|
|
49
|
+
* `admin.usage.list` on the organization, which reads every project's
|
|
50
|
+
* cost in it.
|
|
51
|
+
*/
|
|
52
|
+
async queryOrganizationCost(request: QueryOrganizationCostRequest, options?: CallOptions): Promise<OrganizationCostReport> {
|
|
53
|
+
const p0 = pathValue("organization", request.organization, "organizations/*");
|
|
54
|
+
return this.service.call<OrganizationCostReport>(
|
|
55
|
+
{
|
|
56
|
+
method: "GET",
|
|
57
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
58
|
+
query: query(request, ["organization"]),
|
|
59
|
+
idempotent: true,
|
|
60
|
+
},
|
|
61
|
+
options,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns what was charged to a billing account in a period, by service
|
|
67
|
+
* and product. A project's cost is charged to the account it was linked
|
|
68
|
+
* to when the usage was recorded, so moving a project moves only its
|
|
69
|
+
* later cost. Its spend limit compares the calendar month's total with
|
|
70
|
+
* `limit`. Needs `admin.spend_limit.get` on the organization.
|
|
71
|
+
*/
|
|
72
|
+
async queryBillingAccountCost(request: QueryBillingAccountCostRequest, options?: CallOptions): Promise<CostReport> {
|
|
73
|
+
const p0 = pathValue("billingAccount", request.billingAccount, "organizations/*/billingAccounts/*");
|
|
74
|
+
return this.service.call<CostReport>(
|
|
75
|
+
{
|
|
76
|
+
method: "GET",
|
|
77
|
+
path: `/v1beta1/${p0}:queryCost`,
|
|
78
|
+
query: query(request, ["billingAccount"]),
|
|
79
|
+
idempotent: true,
|
|
80
|
+
},
|
|
81
|
+
options,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Lists a project's metered usage records that overlap a period, the
|
|
87
|
+
* input its cost is priced from, oldest first. Needs `admin.usage.list`
|
|
88
|
+
* on the organization.
|
|
89
|
+
*/
|
|
90
|
+
async queryProjectUsage(request: QueryProjectUsageRequest, options?: CallOptions): Promise<QueryProjectUsageResponse> {
|
|
91
|
+
const p0 = pathValue("project", request.project, "projects/*");
|
|
92
|
+
return this.service.call<QueryProjectUsageResponse>(
|
|
93
|
+
{
|
|
94
|
+
method: "GET",
|
|
95
|
+
path: `/v1beta1/${p0}:queryUsage`,
|
|
96
|
+
query: query(request, ["project"]),
|
|
97
|
+
idempotent: true,
|
|
98
|
+
},
|
|
99
|
+
options,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Iterates over everything queryProjectUsage lists from the request's page on,
|
|
105
|
+
* fetching the next page as the loop reaches it. A page that fails ends
|
|
106
|
+
* the iteration with its error.
|
|
107
|
+
*/
|
|
108
|
+
async *allUsageRecords(request: QueryProjectUsageRequest, options?: CallOptions): AsyncGenerator<UsageRecord, void, undefined> {
|
|
109
|
+
for (let page = request; ; ) {
|
|
110
|
+
const response = await this.queryProjectUsage(page, options);
|
|
111
|
+
yield* response.usageRecords ?? [];
|
|
112
|
+
if (!response.nextPageToken) return;
|
|
113
|
+
page = { ...page, pageToken: response.nextPageToken };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** How finely a report's cost is bucketed. */
|
|
119
|
+
export const Granularity = {
|
|
120
|
+
/** Not set: daily. */
|
|
121
|
+
GRANULARITY_UNSPECIFIED: "GRANULARITY_UNSPECIFIED",
|
|
122
|
+
/** One bucket per hour, starting on the hour. */
|
|
123
|
+
HOURLY: "HOURLY",
|
|
124
|
+
/** One bucket per day, starting at midnight UTC. */
|
|
125
|
+
DAILY: "DAILY",
|
|
126
|
+
} as const;
|
|
127
|
+
|
|
128
|
+
/** How finely a report's cost is bucketed. */
|
|
129
|
+
export type Granularity = (typeof Granularity)[keyof typeof Granularity];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* A cost report: the period's total, by service and, within a service, by
|
|
133
|
+
* product. Every amount is in EUR, before VAT, as a decimal string.
|
|
134
|
+
*/
|
|
135
|
+
export interface CostReport {
|
|
136
|
+
/** The period's total. */
|
|
137
|
+
total?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Each service with any cost in the period, such as `compute`, in name
|
|
140
|
+
* order.
|
|
141
|
+
*/
|
|
142
|
+
services?: ServiceCost[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** One service's cost in a report. */
|
|
146
|
+
export interface ServiceCost {
|
|
147
|
+
/**
|
|
148
|
+
* The service, the first segment of its products' keys, such as
|
|
149
|
+
* `compute`.
|
|
150
|
+
*/
|
|
151
|
+
service?: string;
|
|
152
|
+
/** The service's total. */
|
|
153
|
+
total?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Each of the service's products with any cost in the period, in key
|
|
156
|
+
* order.
|
|
157
|
+
*/
|
|
158
|
+
products?: ProductCost[];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** One product's cost in a report. */
|
|
162
|
+
export interface ProductCost {
|
|
163
|
+
/** The product as the price list names it, such as `compute.gp1.core.2`. */
|
|
164
|
+
productKey?: string;
|
|
165
|
+
/** The product's total. */
|
|
166
|
+
total?: string;
|
|
167
|
+
/** The buckets with any cost, oldest first. */
|
|
168
|
+
buckets?: CostBucket[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The cost of one hour or one day. */
|
|
172
|
+
export interface CostBucket {
|
|
173
|
+
/** When the bucket starts. */
|
|
174
|
+
startTime?: string;
|
|
175
|
+
/** The bucket's cost. */
|
|
176
|
+
amount?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* An organization's cost report: its projects' together, and each
|
|
181
|
+
* project's.
|
|
182
|
+
*/
|
|
183
|
+
export interface OrganizationCostReport {
|
|
184
|
+
/** The period's total of every project. */
|
|
185
|
+
total?: string;
|
|
186
|
+
/** Each service with any cost in the period, over every project. */
|
|
187
|
+
services?: ServiceCost[];
|
|
188
|
+
/**
|
|
189
|
+
* Each project with any cost in the period, in id order, a project
|
|
190
|
+
* deleted since included.
|
|
191
|
+
*/
|
|
192
|
+
projects?: ProjectCost[];
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** One project's cost in an organization's report, over every service. */
|
|
196
|
+
export interface ProjectCost {
|
|
197
|
+
/** The project, `projects/{project}`. */
|
|
198
|
+
project?: string;
|
|
199
|
+
/** The project's total. */
|
|
200
|
+
total?: string;
|
|
201
|
+
/** The buckets with any cost, oldest first. */
|
|
202
|
+
buckets?: CostBucket[];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* One metered interval of one resource: how much of a metric it used from
|
|
207
|
+
* `startTime` to `endTime`.
|
|
208
|
+
*/
|
|
209
|
+
export interface UsageRecord {
|
|
210
|
+
/** The kind of resource, such as `compute.instance`. */
|
|
211
|
+
resourceKind?: string;
|
|
212
|
+
/** The resource's id. */
|
|
213
|
+
resourceId?: string;
|
|
214
|
+
/** What was measured, such as `running_seconds`. */
|
|
215
|
+
metric?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The product the usage is priced as, such as `compute.gp1.core.2`;
|
|
218
|
+
* empty for a kind of resource that has none.
|
|
219
|
+
*/
|
|
220
|
+
productKey?: string;
|
|
221
|
+
/** How much was used, in the metric's unit, as a decimal string. */
|
|
222
|
+
quantity?: string;
|
|
223
|
+
/** When the interval starts. */
|
|
224
|
+
startTime?: string;
|
|
225
|
+
/** When the interval ends. */
|
|
226
|
+
endTime?: string;
|
|
227
|
+
/**
|
|
228
|
+
* The billing account the usage was charged to, the one the project was
|
|
229
|
+
* linked to when it was recorded; empty if it had none.
|
|
230
|
+
*/
|
|
231
|
+
billingAccount?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The request for QueryProjectCost. */
|
|
235
|
+
export interface QueryProjectCostRequest {
|
|
236
|
+
/** The project, `projects/{project}`. */
|
|
237
|
+
project?: string;
|
|
238
|
+
/** The period's start, included. */
|
|
239
|
+
startTime?: string;
|
|
240
|
+
/** The period's end, left out; after `startTime`. */
|
|
241
|
+
endTime?: string;
|
|
242
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
243
|
+
granularity?: Granularity;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** The request for QueryOrganizationCost. */
|
|
247
|
+
export interface QueryOrganizationCostRequest {
|
|
248
|
+
/** The organization, `organizations/{organization}`. */
|
|
249
|
+
organization?: string;
|
|
250
|
+
/** The period's start, included. */
|
|
251
|
+
startTime?: string;
|
|
252
|
+
/** The period's end, left out; after `startTime`. */
|
|
253
|
+
endTime?: string;
|
|
254
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
255
|
+
granularity?: Granularity;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** The request for QueryBillingAccountCost. */
|
|
259
|
+
export interface QueryBillingAccountCostRequest {
|
|
260
|
+
/** The billing account. */
|
|
261
|
+
billingAccount?: string;
|
|
262
|
+
/** The period's start, included. */
|
|
263
|
+
startTime?: string;
|
|
264
|
+
/** The period's end, left out; after `startTime`. */
|
|
265
|
+
endTime?: string;
|
|
266
|
+
/** How finely to bucket the cost; daily when unset. */
|
|
267
|
+
granularity?: Granularity;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** The request for QueryProjectUsage. */
|
|
271
|
+
export interface QueryProjectUsageRequest {
|
|
272
|
+
/** The project, `projects/{project}`. */
|
|
273
|
+
project?: string;
|
|
274
|
+
/** The period's start: records that end after it are listed. */
|
|
275
|
+
startTime?: string;
|
|
276
|
+
/**
|
|
277
|
+
* The period's end: records that start before it are listed; after
|
|
278
|
+
* `startTime`.
|
|
279
|
+
*/
|
|
280
|
+
endTime?: string;
|
|
281
|
+
/**
|
|
282
|
+
* The most records to return; the server clamps it, and 0 means its
|
|
283
|
+
* default.
|
|
284
|
+
*/
|
|
285
|
+
pageSize?: number;
|
|
286
|
+
/** A previous response's `nextPageToken`, for the page after it. */
|
|
287
|
+
pageToken?: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** The response for QueryProjectUsage. */
|
|
291
|
+
export interface QueryProjectUsageResponse {
|
|
292
|
+
/** The usage records on this page. */
|
|
293
|
+
usageRecords?: UsageRecord[];
|
|
294
|
+
/** The token for the next page; empty on the last one. */
|
|
295
|
+
nextPageToken?: string;
|
|
296
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Code generated by the SDK's generator (generator/). DO NOT EDIT.
|
|
2
|
+
// source: origincloud/billing/v1beta1/price_list.proto
|
|
3
|
+
|
|
4
|
+
import { type CallOptions, type Client, type Service, query } from "@origincloud/core";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calls PriceListService.
|
|
8
|
+
*
|
|
9
|
+
* The public price list: the list price of every billable product, for
|
|
10
|
+
* anyone to read, websites included. It needs no access token.
|
|
11
|
+
*
|
|
12
|
+
* Unlike the rest of this API, its path has been `/v1/pricing` since before
|
|
13
|
+
* the API was published, and its fields are written in snake case, as
|
|
14
|
+
* websites read them.
|
|
15
|
+
*/
|
|
16
|
+
export class PriceListClient {
|
|
17
|
+
/**
|
|
18
|
+
* The endpoint the client sends its calls to, which also serves the
|
|
19
|
+
* operations its methods answer with.
|
|
20
|
+
*/
|
|
21
|
+
readonly service: Service;
|
|
22
|
+
|
|
23
|
+
/** A client of PriceListService that sends its calls through `client`. */
|
|
24
|
+
constructor(client: Client) {
|
|
25
|
+
this.service = client.service("billing", false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the prices in effect now. The answer carries an `ETag`; a
|
|
30
|
+
* request that sends it back in `If-None-Match` is answered
|
|
31
|
+
* `304 Not Modified`, without a body, while the list is unchanged.
|
|
32
|
+
*/
|
|
33
|
+
async getPriceList(request: GetPriceListRequest, options?: CallOptions): Promise<PriceList> {
|
|
34
|
+
return this.service.call<PriceList>(
|
|
35
|
+
{
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: `/v1/pricing`,
|
|
38
|
+
query: query(request, []),
|
|
39
|
+
idempotent: true,
|
|
40
|
+
},
|
|
41
|
+
options,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The price list. Every amount is in EUR, before VAT, which depends on the
|
|
48
|
+
* customer's country and is added on the invoice.
|
|
49
|
+
*/
|
|
50
|
+
export interface PriceList {
|
|
51
|
+
/** Always `EUR`. */
|
|
52
|
+
currency?: string;
|
|
53
|
+
/** Always true: every amount is net, before VAT. */
|
|
54
|
+
amounts_exclude_vat?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* When a list price was last set, changed, took effect or ended: what a
|
|
57
|
+
* "prices last updated" line shows. Unset only while nothing is priced.
|
|
58
|
+
*/
|
|
59
|
+
last_changed?: string;
|
|
60
|
+
/**
|
|
61
|
+
* One entry per product family with a price in effect, in the platform's
|
|
62
|
+
* catalog order: `compute_instance`, `network_floating_ip`,
|
|
63
|
+
* `network_nat_gateway`, `network_vpc_egress`, `network_vpc_ingress`,
|
|
64
|
+
* `network_vpc_internal`, `storage_volume`, `storage_snapshot`,
|
|
65
|
+
* `observability_custom_metric`, `observability_api_request`,
|
|
66
|
+
* `observability_ingested_sample`.
|
|
67
|
+
*/
|
|
68
|
+
families?: PriceFamily[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** One product family's prices. */
|
|
72
|
+
export interface PriceFamily {
|
|
73
|
+
/** The family, such as `compute_instance`. */
|
|
74
|
+
family?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The family's prices in effect, by product key, numbers compared as
|
|
77
|
+
* numbers: a class's instance types run from smallest to largest.
|
|
78
|
+
*/
|
|
79
|
+
prices?: Price[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The list price of one product. */
|
|
83
|
+
export interface Price {
|
|
84
|
+
/**
|
|
85
|
+
* The product the price bills, as usage and cost reports name it, such
|
|
86
|
+
* as `compute.gp1.core.2`, `storage.gp1` or `network.vpc_egress`.
|
|
87
|
+
*/
|
|
88
|
+
product_key?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The parts of the product key, split out: `instanceType` for an instance,
|
|
91
|
+
* `storageClass` for a volume. Empty for a product that has none.
|
|
92
|
+
*/
|
|
93
|
+
dimensions?: Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* What is counted: `seconds`, `gib_hours`, `gb` (decimal, 10^9 bytes),
|
|
96
|
+
* `metric_months`, `requests` or `samples`.
|
|
97
|
+
*/
|
|
98
|
+
unit_type?: string;
|
|
99
|
+
/**
|
|
100
|
+
* How many of the unit the amount pays for: `3600` seconds is an
|
|
101
|
+
* hourly rate, `1000` requests a rate per thousand.
|
|
102
|
+
*/
|
|
103
|
+
unit_count?: number;
|
|
104
|
+
/** The price of that many units, as a decimal string. */
|
|
105
|
+
amount?: string;
|
|
106
|
+
/** When the price took effect. */
|
|
107
|
+
valid_from?: string;
|
|
108
|
+
/** When the price is to end; unset while no end is scheduled. */
|
|
109
|
+
valid_until?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The request for GetPriceList, which takes nothing. */
|
|
113
|
+
export interface GetPriceListRequest {}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Code generated by the SDK's generator (generator/). DO NOT EDIT.
|
|
2
|
+
// source: origincloud/billing/v1beta1/spend_limit.proto
|
|
3
|
+
|
|
4
|
+
import { type CallOptions, type Client, type Service, pathValue, query } from "@origincloud/core";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calls SpendLimitService.
|
|
8
|
+
*
|
|
9
|
+
* Spend limits: an amount per calendar month for a billing account, and the
|
|
10
|
+
* shares of it at which an alert is emailed. A spend limit only alerts: it
|
|
11
|
+
* never stops or refuses anything.
|
|
12
|
+
*
|
|
13
|
+
* Access to spend limits is granted apart from access to billing accounts:
|
|
14
|
+
* an organization's owner holds it by default.
|
|
15
|
+
*/
|
|
16
|
+
export class SpendLimitClient {
|
|
17
|
+
/**
|
|
18
|
+
* The endpoint the client sends its calls to, which also serves the
|
|
19
|
+
* operations its methods answer with.
|
|
20
|
+
*/
|
|
21
|
+
readonly service: Service;
|
|
22
|
+
|
|
23
|
+
/** A client of SpendLimitService that sends its calls through `client`. */
|
|
24
|
+
constructor(client: Client) {
|
|
25
|
+
this.service = client.service("billing", false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a billing account's spend limit; one that has none has no
|
|
30
|
+
* `limit`. Needs `admin.spend_limit.get` on the organization.
|
|
31
|
+
*/
|
|
32
|
+
async getSpendLimit(request: GetSpendLimitRequest, options?: CallOptions): Promise<SpendLimit> {
|
|
33
|
+
const p0 = pathValue("name", request.name, "organizations/*/billingAccounts/*/spendLimit");
|
|
34
|
+
return this.service.call<SpendLimit>(
|
|
35
|
+
{
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: `/v1beta1/${p0}`,
|
|
38
|
+
query: query(request, ["name"]),
|
|
39
|
+
idempotent: true,
|
|
40
|
+
},
|
|
41
|
+
options,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Sets or removes a billing account's spend limit. The fields named in
|
|
47
|
+
* `updateMask` are replaced and the others kept. A spend limit left
|
|
48
|
+
* without a `limit` is removed, with its thresholds and recipients. Needs
|
|
49
|
+
* `admin.spend_limit.update` on the organization.
|
|
50
|
+
*/
|
|
51
|
+
async updateSpendLimit(request: UpdateSpendLimitRequest, options?: CallOptions): Promise<SpendLimit> {
|
|
52
|
+
const p0 = pathValue("spendLimit.name", request.spendLimit?.name, "organizations/*/billingAccounts/*/spendLimit");
|
|
53
|
+
return this.service.call<SpendLimit>(
|
|
54
|
+
{
|
|
55
|
+
method: "PATCH",
|
|
56
|
+
path: `/v1beta1/${p0}`,
|
|
57
|
+
body: request.spendLimit,
|
|
58
|
+
query: query(request, ["spendLimit.name", "spendLimit"]),
|
|
59
|
+
},
|
|
60
|
+
options,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A billing account's spend limit: the most it means to spend in a calendar
|
|
67
|
+
* month, and when to be told. Each threshold alerts once a month, the first
|
|
68
|
+
* time the month's spend crosses it.
|
|
69
|
+
*/
|
|
70
|
+
export interface SpendLimit {
|
|
71
|
+
/**
|
|
72
|
+
* The spend limit's resource name,
|
|
73
|
+
* `organizations/{organization}/billingAccounts/{billing_account}/spendLimit`.
|
|
74
|
+
*/
|
|
75
|
+
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The amount per calendar month in EUR, before VAT, as a decimal string
|
|
78
|
+
* such as `500.00`; more than zero. Unset means no spend limit.
|
|
79
|
+
*/
|
|
80
|
+
limit?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The percentages of `limit` whose crossing emails an alert, such as `80`
|
|
83
|
+
* and `100`; each from 1 to 32767, so a threshold can lie beyond the
|
|
84
|
+
* limit. Empty while there is no `limit`.
|
|
85
|
+
*/
|
|
86
|
+
alertThresholdsPercent?: number[];
|
|
87
|
+
/**
|
|
88
|
+
* Where alerts are sent. Empty while there is no `limit`, and an alert
|
|
89
|
+
* with no recipient is sent to nobody.
|
|
90
|
+
*/
|
|
91
|
+
notificationEmails?: string[];
|
|
92
|
+
/** When the spend limit was last set; unset while there is none. */
|
|
93
|
+
updateTime?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The request for GetSpendLimit. */
|
|
97
|
+
export interface GetSpendLimitRequest {
|
|
98
|
+
/** The spend limit to return. */
|
|
99
|
+
name?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The request for UpdateSpendLimit. */
|
|
103
|
+
export interface UpdateSpendLimitRequest {
|
|
104
|
+
/** The spend limit, by its name, with the fields to change. */
|
|
105
|
+
spendLimit?: SpendLimit;
|
|
106
|
+
/**
|
|
107
|
+
* The fields to change: `limit`, `alertThresholdsPercent` and
|
|
108
|
+
* `notificationEmails`. `*` is every one of them.
|
|
109
|
+
*/
|
|
110
|
+
updateMask?: string;
|
|
111
|
+
}
|