xref: /aosp_15_r20/external/googleapis/google/cloud/billing/v1/cloud_billing.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.billing.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/iam/v1/iam_policy.proto";
24import "google/iam/v1/policy.proto";
25import "google/protobuf/field_mask.proto";
26
27option go_package = "cloud.google.com/go/billing/apiv1/billingpb;billingpb";
28option java_multiple_files = true;
29option java_outer_classname = "CloudBillingProto";
30option java_package = "com.google.cloud.billing.v1";
31option (google.api.resource_definition) = {
32  type: "cloudresourcemanager.googleapis.com/Project"
33  pattern: "projects/{project}"
34};
35option (google.api.resource_definition) = {
36  type: "cloudresourcemanager.googleapis.com/Organization"
37  pattern: "organizations/{organization}"
38};
39
40// Retrieves the Google Cloud Console billing accounts and associates them with
41// projects.
42service CloudBilling {
43  option (google.api.default_host) = "cloudbilling.googleapis.com";
44  option (google.api.oauth_scopes) =
45      "https://www.googleapis.com/auth/cloud-billing,"
46      "https://www.googleapis.com/auth/cloud-billing.readonly,"
47      "https://www.googleapis.com/auth/cloud-platform";
48
49  // Gets information about a billing account. The current authenticated user
50  // must be a [viewer of the billing
51  // account](https://cloud.google.com/billing/docs/how-to/billing-access).
52  rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) {
53    option (google.api.http) = {
54      get: "/v1/{name=billingAccounts/*}"
55    };
56    option (google.api.method_signature) = "name";
57  }
58
59  // Lists the billing accounts that the current authenticated user has
60  // permission to
61  // [view](https://cloud.google.com/billing/docs/how-to/billing-access).
62  rpc ListBillingAccounts(ListBillingAccountsRequest)
63      returns (ListBillingAccountsResponse) {
64    option (google.api.http) = {
65      get: "/v1/billingAccounts"
66      additional_bindings {
67        get: "/v1/{parent=organizations/*}/billingAccounts"
68      }
69      additional_bindings { get: "/v1/{parent=billingAccounts/*}/subAccounts" }
70    };
71    option (google.api.method_signature) = "";
72    option (google.api.method_signature) = "parent";
73  }
74
75  // Updates a billing account's fields.
76  // Currently the only field that can be edited is `display_name`.
77  // The current authenticated user must have the `billing.accounts.update`
78  // IAM permission, which is typically given to the
79  // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access)
80  // of the billing account.
81  rpc UpdateBillingAccount(UpdateBillingAccountRequest)
82      returns (BillingAccount) {
83    option (google.api.http) = {
84      patch: "/v1/{name=billingAccounts/*}"
85      body: "account"
86    };
87    option (google.api.method_signature) = "name,account";
88  }
89
90  // This method creates [billing
91  // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).
92  //
93  // Google Cloud resellers should use the
94  // Channel Services APIs,
95  // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create)
96  // and
97  // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create).
98  //
99  // When creating a subaccount, the current authenticated user must have the
100  // `billing.accounts.update` IAM permission on the parent account, which is
101  // typically given to billing account
102  // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
103  // This method will return an error if the parent account has not been
104  // provisioned for subaccounts.
105  rpc CreateBillingAccount(CreateBillingAccountRequest)
106      returns (BillingAccount) {
107    option (google.api.http) = {
108      post: "/v1/billingAccounts"
109      body: "billing_account"
110      additional_bindings {
111        post: "/v1/{parent=organizations/*}/billingAccounts"
112        body: "billing_account"
113      }
114      additional_bindings {
115        post: "/v1/{parent=billingAccounts/*}/subAccounts"
116        body: "billing_account"
117      }
118    };
119    option (google.api.method_signature) = "billing_account";
120    option (google.api.method_signature) = "billing_account,parent";
121  }
122
123  // Lists the projects associated with a billing account. The current
124  // authenticated user must have the `billing.resourceAssociations.list` IAM
125  // permission, which is often given to billing account
126  // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
127  rpc ListProjectBillingInfo(ListProjectBillingInfoRequest)
128      returns (ListProjectBillingInfoResponse) {
129    option (google.api.http) = {
130      get: "/v1/{name=billingAccounts/*}/projects"
131    };
132    option (google.api.method_signature) = "name";
133  }
134
135  // Gets the billing information for a project. The current authenticated user
136  // must have the `resourcemanager.projects.get` permission for the project,
137  // which can be granted by assigning the [Project
138  // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles)
139  // role.
140  rpc GetProjectBillingInfo(GetProjectBillingInfoRequest)
141      returns (ProjectBillingInfo) {
142    option (google.api.http) = {
143      get: "/v1/{name=projects/*}/billingInfo"
144    };
145    option (google.api.method_signature) = "name";
146  }
147
148  // Sets or updates the billing account associated with a project. You specify
149  // the new billing account by setting the `billing_account_name` in the
150  // `ProjectBillingInfo` resource to the resource name of a billing account.
151  // Associating a project with an open billing account enables billing on the
152  // project and allows charges for resource usage. If the project already had a
153  // billing account, this method changes the billing account used for resource
154  // usage charges.
155  //
156  // *Note:* Incurred charges that have not yet been reported in the transaction
157  // history of the Google Cloud Console might be billed to the new billing
158  // account, even if the charge occurred before the new billing account was
159  // assigned to the project.
160  //
161  // The current authenticated user must have ownership privileges for both
162  // the
163  // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
164  // ) and the [billing
165  // account](https://cloud.google.com/billing/docs/how-to/billing-access).
166  //
167  // You can disable billing on the project by setting the
168  // `billing_account_name` field to empty. This action disassociates the
169  // current billing account from the project. Any billable activity of your
170  // in-use services will stop, and your application could stop functioning as
171  // expected. Any unbilled charges to date will be billed to the previously
172  // associated account. The current authenticated user must be either an owner
173  // of the project or an owner of the billing account for the project.
174  //
175  // Note that associating a project with a *closed* billing account will have
176  // much the same effect as disabling billing on the project: any paid
177  // resources used by the project will be shut down. Thus, unless you wish to
178  // disable billing, you should always call this method with the name of an
179  // *open* billing account.
180  rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest)
181      returns (ProjectBillingInfo) {
182    option (google.api.http) = {
183      put: "/v1/{name=projects/*}/billingInfo"
184      body: "project_billing_info"
185    };
186    option (google.api.method_signature) = "name,project_billing_info";
187  }
188
189  // Gets the access control policy for a billing account.
190  // The caller must have the `billing.accounts.getIamPolicy` permission on the
191  // account, which is often given to billing account
192  // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
193  rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest)
194      returns (google.iam.v1.Policy) {
195    option (google.api.http) = {
196      get: "/v1/{resource=billingAccounts/*}:getIamPolicy"
197    };
198    option (google.api.method_signature) = "resource";
199  }
200
201  // Sets the access control policy for a billing account. Replaces any existing
202  // policy.
203  // The caller must have the `billing.accounts.setIamPolicy` permission on the
204  // account, which is often given to billing account
205  // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
206  rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest)
207      returns (google.iam.v1.Policy) {
208    option (google.api.http) = {
209      post: "/v1/{resource=billingAccounts/*}:setIamPolicy"
210      body: "*"
211    };
212    option (google.api.method_signature) = "resource,policy";
213  }
214
215  // Tests the access control policy for a billing account. This method takes
216  // the resource and a set of permissions as input and returns the subset of
217  // the input permissions that the caller is allowed for that resource.
218  rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest)
219      returns (google.iam.v1.TestIamPermissionsResponse) {
220    option (google.api.http) = {
221      post: "/v1/{resource=billingAccounts/*}:testIamPermissions"
222      body: "*"
223    };
224    option (google.api.method_signature) = "resource,permissions";
225  }
226
227  // Changes which parent organization a billing account belongs to.
228  rpc MoveBillingAccount(MoveBillingAccountRequest) returns (BillingAccount) {
229    option (google.api.http) = {
230      post: "/v1/{name=billingAccounts/*}:move"
231      body: "*"
232      additional_bindings {
233        get: "/v1/{destination_parent=organizations/*}/{name=billingAccounts/*}:move"
234      }
235    };
236  }
237}
238
239// A billing account in the
240// [Google Cloud Console](https://console.cloud.google.com/). You can assign a
241// billing account to one or more projects.
242message BillingAccount {
243  option (google.api.resource) = {
244    type: "cloudbilling.googleapis.com/BillingAccount"
245    pattern: "billingAccounts/{billing_account}"
246    pattern: "organizations/{organization}/billingAccounts/{billing_account}"
247    plural: "billingAccounts"
248    singular: "billingAccount"
249  };
250
251  // Output only. The resource name of the billing account. The resource name
252  // has the form `billingAccounts/{billing_account_id}`. For example,
253  // `billingAccounts/012345-567890-ABCDEF` would be the resource name for
254  // billing account `012345-567890-ABCDEF`.
255  string name = 1 [
256    (google.api.field_behavior) = OUTPUT_ONLY,
257    (google.api.resource_reference) = {
258      type: "cloudbilling.googleapis.com/BillingAccount"
259    }
260  ];
261
262  // Output only. True if the billing account is open, and will therefore be
263  // charged for any usage on associated projects. False if the billing account
264  // is closed, and therefore projects associated with it are unable to use paid
265  // services.
266  bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
267
268  // The display name given to the billing account, such as `My Billing
269  // Account`. This name is displayed in the Google Cloud Console.
270  string display_name = 3;
271
272  // If this account is a
273  // [subaccount](https://cloud.google.com/billing/docs/concepts), then this
274  // will be the resource name of the parent billing account that it is being
275  // resold through.
276  // Otherwise this will be empty.
277  string master_billing_account = 4;
278
279  // Output only. The billing account's parent resource identifier.
280  // Use the `MoveBillingAccount` method to update the account's parent resource
281  // if it is a organization.
282  // Format:
283  //   - `organizations/{organization_id}`, for example,
284  //     `organizations/12345678`
285  //   - `billingAccounts/{billing_account_id}`, for example,
286  //     `billingAccounts/012345-567890-ABCDEF`
287  string parent = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
288}
289
290// Encapsulation of billing information for a Google Cloud Console project. A
291// project has at most one associated billing account at a time (but a billing
292// account can be assigned to multiple projects).
293message ProjectBillingInfo {
294  option (google.api.resource) = {
295    type: "cloudbilling.googleapis.com/ProjectBillingInfo"
296    pattern: "projects/{project}/billingInfo"
297  };
298
299  // Output only. The resource name for the `ProjectBillingInfo`; has the form
300  // `projects/{project_id}/billingInfo`. For example, the resource name for the
301  // billing information for project `tokyo-rain-123` would be
302  // `projects/tokyo-rain-123/billingInfo`.
303  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
304
305  // Output only. The ID of the project that this `ProjectBillingInfo`
306  // represents, such as `tokyo-rain-123`. This is a convenience field so that
307  // you don't need to parse the `name` field to obtain a project ID.
308  string project_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
309
310  // The resource name of the billing account associated with the project, if
311  // any. For example, `billingAccounts/012345-567890-ABCDEF`.
312  string billing_account_name = 3;
313
314  // Output only. True if the project is associated with an open billing
315  // account, to which usage on the project is charged. False if the project is
316  // associated with a closed billing account, or no billing account at all, and
317  // therefore cannot use paid services.
318  bool billing_enabled = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
319}
320
321// Request message for `GetBillingAccount`.
322message GetBillingAccountRequest {
323  // Required. The resource name of the billing account to retrieve. For
324  // example, `billingAccounts/012345-567890-ABCDEF`.
325  string name = 1 [
326    (google.api.field_behavior) = REQUIRED,
327    (google.api.resource_reference) = {
328      type: "cloudbilling.googleapis.com/BillingAccount"
329    }
330  ];
331}
332
333// Request message for `ListBillingAccounts`.
334message ListBillingAccountsRequest {
335  // Requested page size. The maximum page size is 100; this is also the
336  // default.
337  int32 page_size = 1;
338
339  // A token identifying a page of results to return. This should be a
340  // `next_page_token` value returned from a previous `ListBillingAccounts`
341  // call. If unspecified, the first page of results is returned.
342  string page_token = 2;
343
344  // Options for how to filter the returned billing accounts.
345  // This only supports filtering for
346  // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a
347  // single provided parent billing account.
348  // (for example,
349  // `master_billing_account=billingAccounts/012345-678901-ABCDEF`).
350  // Boolean algebra and other fields are not currently supported.
351  string filter = 3;
352
353  // Optional. The parent resource to list billing accounts from.
354  // Format:
355  //   - `organizations/{organization_id}`, for example,
356  //     `organizations/12345678`
357  //   - `billingAccounts/{billing_account_id}`, for example,
358  //     `billingAccounts/012345-567890-ABCDEF`
359  string parent = 4 [(google.api.field_behavior) = OPTIONAL];
360}
361
362// Response message for `ListBillingAccounts`.
363message ListBillingAccountsResponse {
364  // A list of billing accounts.
365  repeated BillingAccount billing_accounts = 1;
366
367  // A token to retrieve the next page of results. To retrieve the next page,
368  // call `ListBillingAccounts` again with the `page_token` field set to this
369  // value. This field is empty if there are no more results to retrieve.
370  string next_page_token = 2;
371}
372
373// Request message for `CreateBillingAccount`.
374message CreateBillingAccountRequest {
375  // Required. The billing account resource to create.
376  // Currently CreateBillingAccount only supports subaccount creation, so
377  // any created billing accounts must be under a provided parent billing
378  // account.
379  BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED];
380
381  // Optional. The parent to create a billing account from.
382  // Format:
383  //   - `billingAccounts/{billing_account_id}`, for example,
384  //      `billingAccounts/012345-567890-ABCDEF`
385  string parent = 2 [(google.api.field_behavior) = OPTIONAL];
386}
387
388// Request message for `UpdateBillingAccount`.
389message UpdateBillingAccountRequest {
390  // Required. The name of the billing account resource to be updated.
391  string name = 1 [
392    (google.api.field_behavior) = REQUIRED,
393    (google.api.resource_reference) = {
394      type: "cloudbilling.googleapis.com/BillingAccount"
395    }
396  ];
397
398  // Required. The billing account resource to replace the resource on the
399  // server.
400  BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED];
401
402  // The update mask applied to the resource.
403  // Only "display_name" is currently supported.
404  google.protobuf.FieldMask update_mask = 3;
405}
406
407// Request message for `ListProjectBillingInfo`.
408message ListProjectBillingInfoRequest {
409  // Required. The resource name of the billing account associated with the
410  // projects that you want to list. For example,
411  // `billingAccounts/012345-567890-ABCDEF`.
412  string name = 1 [
413    (google.api.field_behavior) = REQUIRED,
414    (google.api.resource_reference) = {
415      type: "cloudbilling.googleapis.com/BillingAccount"
416    }
417  ];
418
419  // Requested page size. The maximum page size is 100; this is also the
420  // default.
421  int32 page_size = 2;
422
423  // A token identifying a page of results to be returned. This should be a
424  // `next_page_token` value returned from a previous `ListProjectBillingInfo`
425  // call. If unspecified, the first page of results is returned.
426  string page_token = 3;
427}
428
429// Request message for `ListProjectBillingInfoResponse`.
430message ListProjectBillingInfoResponse {
431  // A list of `ProjectBillingInfo` resources representing the projects
432  // associated with the billing account.
433  repeated ProjectBillingInfo project_billing_info = 1;
434
435  // A token to retrieve the next page of results. To retrieve the next page,
436  // call `ListProjectBillingInfo` again with the `page_token` field set to this
437  // value. This field is empty if there are no more results to retrieve.
438  string next_page_token = 2;
439}
440
441// Request message for `GetProjectBillingInfo`.
442message GetProjectBillingInfoRequest {
443  // Required. The resource name of the project for which billing information is
444  // retrieved. For example, `projects/tokyo-rain-123`.
445  string name = 1 [
446    (google.api.field_behavior) = REQUIRED,
447    (google.api.resource_reference) = {
448      type: "cloudresourcemanager.googleapis.com/Project"
449    }
450  ];
451}
452
453// Request message for `UpdateProjectBillingInfo`.
454message UpdateProjectBillingInfoRequest {
455  // Required. The resource name of the project associated with the billing
456  // information that you want to update. For example,
457  // `projects/tokyo-rain-123`.
458  string name = 1 [(google.api.field_behavior) = REQUIRED];
459
460  // The new billing information for the project. Output-only fields are
461  // ignored; thus, you can leave empty all fields except
462  // `billing_account_name`.
463  ProjectBillingInfo project_billing_info = 2;
464}
465
466// Request message for `MoveBillingAccount` RPC.
467message MoveBillingAccountRequest {
468  // Required. The resource name of the billing account to move.
469  // Must be of the form `billingAccounts/{billing_account_id}`.
470  // The specified billing account cannot be a subaccount, since a subaccount
471  // always belongs to the same organization as its parent account.
472  string name = 1 [
473    (google.api.field_behavior) = REQUIRED,
474    (google.api.resource_reference) = {
475      type: "cloudbilling.googleapis.com/BillingAccount"
476    }
477  ];
478
479  // Required. The resource name of the Organization to move
480  // the billing account under.
481  // Must be of the form `organizations/{organization_id}`.
482  string destination_parent = 2 [
483    (google.api.field_behavior) = REQUIRED,
484    (google.api.resource_reference) = {
485      type: "cloudresourcemanager.googleapis.com/Organization"
486    }
487  ];
488}
489