cloud_billing.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. // Copyright 2022 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. syntax = "proto3";
  15. package google.cloud.billing.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/iam/v1/iam_policy.proto";
  21. import "google/iam/v1/policy.proto";
  22. import "google/protobuf/field_mask.proto";
  23. option go_package = "google.golang.org/genproto/googleapis/cloud/billing/v1;billing";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "CloudBillingProto";
  26. option java_package = "com.google.cloud.billing.v1";
  27. // Retrieves the Google Cloud Console billing accounts and associates them with
  28. // projects.
  29. service CloudBilling {
  30. option (google.api.default_host) = "cloudbilling.googleapis.com";
  31. option (google.api.oauth_scopes) =
  32. "https://www.googleapis.com/auth/cloud-billing,"
  33. "https://www.googleapis.com/auth/cloud-billing.readonly,"
  34. "https://www.googleapis.com/auth/cloud-platform";
  35. // Gets information about a billing account. The current authenticated user
  36. // must be a [viewer of the billing
  37. // account](https://cloud.google.com/billing/docs/how-to/billing-access).
  38. rpc GetBillingAccount(GetBillingAccountRequest) returns (BillingAccount) {
  39. option (google.api.http) = {
  40. get: "/v1/{name=billingAccounts/*}"
  41. };
  42. option (google.api.method_signature) = "name";
  43. }
  44. // Lists the billing accounts that the current authenticated user has
  45. // permission to
  46. // [view](https://cloud.google.com/billing/docs/how-to/billing-access).
  47. rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) {
  48. option (google.api.http) = {
  49. get: "/v1/billingAccounts"
  50. };
  51. option (google.api.method_signature) = "";
  52. }
  53. // Updates a billing account's fields.
  54. // Currently the only field that can be edited is `display_name`.
  55. // The current authenticated user must have the `billing.accounts.update`
  56. // IAM permission, which is typically given to the
  57. // [administrator](https://cloud.google.com/billing/docs/how-to/billing-access)
  58. // of the billing account.
  59. rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (BillingAccount) {
  60. option (google.api.http) = {
  61. patch: "/v1/{name=billingAccounts/*}"
  62. body: "account"
  63. };
  64. option (google.api.method_signature) = "name,account";
  65. }
  66. // This method creates [billing
  67. // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts).
  68. //
  69. // Google Cloud resellers should use the
  70. // Channel Services APIs,
  71. // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create)
  72. // and
  73. // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create).
  74. //
  75. // When creating a subaccount, the current authenticated user must have the
  76. // `billing.accounts.update` IAM permission on the parent account, which is
  77. // typically given to billing account
  78. // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
  79. // This method will return an error if the parent account has not been
  80. // provisioned as a reseller account.
  81. rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) {
  82. option (google.api.http) = {
  83. post: "/v1/billingAccounts"
  84. body: "billing_account"
  85. };
  86. option (google.api.method_signature) = "billing_account";
  87. }
  88. // Lists the projects associated with a billing account. The current
  89. // authenticated user must have the `billing.resourceAssociations.list` IAM
  90. // permission, which is often given to billing account
  91. // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
  92. rpc ListProjectBillingInfo(ListProjectBillingInfoRequest) returns (ListProjectBillingInfoResponse) {
  93. option (google.api.http) = {
  94. get: "/v1/{name=billingAccounts/*}/projects"
  95. };
  96. option (google.api.method_signature) = "name";
  97. }
  98. // Gets the billing information for a project. The current authenticated user
  99. // must have the `resourcemanager.projects.get` permission for the project,
  100. // which can be granted by assigning the [Project
  101. // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles)
  102. // role.
  103. rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) {
  104. option (google.api.http) = {
  105. get: "/v1/{name=projects/*}/billingInfo"
  106. };
  107. option (google.api.method_signature) = "name";
  108. }
  109. // Sets or updates the billing account associated with a project. You specify
  110. // the new billing account by setting the `billing_account_name` in the
  111. // `ProjectBillingInfo` resource to the resource name of a billing account.
  112. // Associating a project with an open billing account enables billing on the
  113. // project and allows charges for resource usage. If the project already had a
  114. // billing account, this method changes the billing account used for resource
  115. // usage charges.
  116. //
  117. // *Note:* Incurred charges that have not yet been reported in the transaction
  118. // history of the Google Cloud Console might be billed to the new billing
  119. // account, even if the charge occurred before the new billing account was
  120. // assigned to the project.
  121. //
  122. // The current authenticated user must have ownership privileges for both the
  123. // [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo
  124. // ) and the [billing
  125. // account](https://cloud.google.com/billing/docs/how-to/billing-access).
  126. //
  127. // You can disable billing on the project by setting the
  128. // `billing_account_name` field to empty. This action disassociates the
  129. // current billing account from the project. Any billable activity of your
  130. // in-use services will stop, and your application could stop functioning as
  131. // expected. Any unbilled charges to date will be billed to the previously
  132. // associated account. The current authenticated user must be either an owner
  133. // of the project or an owner of the billing account for the project.
  134. //
  135. // Note that associating a project with a *closed* billing account will have
  136. // much the same effect as disabling billing on the project: any paid
  137. // resources used by the project will be shut down. Thus, unless you wish to
  138. // disable billing, you should always call this method with the name of an
  139. // *open* billing account.
  140. rpc UpdateProjectBillingInfo(UpdateProjectBillingInfoRequest) returns (ProjectBillingInfo) {
  141. option (google.api.http) = {
  142. put: "/v1/{name=projects/*}/billingInfo"
  143. body: "project_billing_info"
  144. };
  145. option (google.api.method_signature) = "name,project_billing_info";
  146. }
  147. // Gets the access control policy for a billing account.
  148. // The caller must have the `billing.accounts.getIamPolicy` permission on the
  149. // account, which is often given to billing account
  150. // [viewers](https://cloud.google.com/billing/docs/how-to/billing-access).
  151. rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
  152. option (google.api.http) = {
  153. get: "/v1/{resource=billingAccounts/*}:getIamPolicy"
  154. };
  155. option (google.api.method_signature) = "resource";
  156. }
  157. // Sets the access control policy for a billing account. Replaces any existing
  158. // policy.
  159. // The caller must have the `billing.accounts.setIamPolicy` permission on the
  160. // account, which is often given to billing account
  161. // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
  162. rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
  163. option (google.api.http) = {
  164. post: "/v1/{resource=billingAccounts/*}:setIamPolicy"
  165. body: "*"
  166. };
  167. option (google.api.method_signature) = "resource,policy";
  168. }
  169. // Tests the access control policy for a billing account. This method takes
  170. // the resource and a set of permissions as input and returns the subset of
  171. // the input permissions that the caller is allowed for that resource.
  172. rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
  173. option (google.api.http) = {
  174. post: "/v1/{resource=billingAccounts/*}:testIamPermissions"
  175. body: "*"
  176. };
  177. option (google.api.method_signature) = "resource,permissions";
  178. }
  179. }
  180. // A billing account in the
  181. // [Google Cloud Console](https://console.cloud.google.com/). You can assign a
  182. // billing account to one or more projects.
  183. message BillingAccount {
  184. // Output only. The resource name of the billing account. The resource name has the form
  185. // `billingAccounts/{billing_account_id}`. For example,
  186. // `billingAccounts/012345-567890-ABCDEF` would be the resource name for
  187. // billing account `012345-567890-ABCDEF`.
  188. string name = 1 [
  189. (google.api.field_behavior) = OUTPUT_ONLY,
  190. (google.api.resource_reference) = {
  191. type: "cloudbilling.googleapis.com/BillingAccount"
  192. }
  193. ];
  194. // Output only. True if the billing account is open, and will therefore be charged for any
  195. // usage on associated projects. False if the billing account is closed, and
  196. // therefore projects associated with it will be unable to use paid services.
  197. bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  198. // The display name given to the billing account, such as `My Billing
  199. // Account`. This name is displayed in the Google Cloud Console.
  200. string display_name = 3;
  201. // If this account is a
  202. // [subaccount](https://cloud.google.com/billing/docs/concepts), then this
  203. // will be the resource name of the parent billing account that it is being
  204. // resold through.
  205. // Otherwise this will be empty.
  206. string master_billing_account = 4;
  207. }
  208. // Encapsulation of billing information for a Google Cloud Console project. A
  209. // project has at most one associated billing account at a time (but a billing
  210. // account can be assigned to multiple projects).
  211. message ProjectBillingInfo {
  212. // The resource name for the `ProjectBillingInfo`; has the form
  213. // `projects/{project_id}/billingInfo`. For example, the resource name for the
  214. // billing information for project `tokyo-rain-123` would be
  215. // `projects/tokyo-rain-123/billingInfo`. This field is read-only.
  216. string name = 1;
  217. // The ID of the project that this `ProjectBillingInfo` represents, such as
  218. // `tokyo-rain-123`. This is a convenience field so that you don't need to
  219. // parse the `name` field to obtain a project ID. This field is read-only.
  220. string project_id = 2;
  221. // The resource name of the billing account associated with the project, if
  222. // any. For example, `billingAccounts/012345-567890-ABCDEF`.
  223. string billing_account_name = 3;
  224. // True if the project is associated with an open billing account, to which
  225. // usage on the project is charged. False if the project is associated with a
  226. // closed billing account, or no billing account at all, and therefore cannot
  227. // use paid services. This field is read-only.
  228. bool billing_enabled = 4;
  229. }
  230. // Request message for `GetBillingAccount`.
  231. message GetBillingAccountRequest {
  232. // Required. The resource name of the billing account to retrieve. For example,
  233. // `billingAccounts/012345-567890-ABCDEF`.
  234. string name = 1 [
  235. (google.api.field_behavior) = REQUIRED,
  236. (google.api.resource_reference) = {
  237. type: "cloudbilling.googleapis.com/BillingAccount"
  238. }
  239. ];
  240. }
  241. // Request message for `ListBillingAccounts`.
  242. message ListBillingAccountsRequest {
  243. // Requested page size. The maximum page size is 100; this is also the
  244. // default.
  245. int32 page_size = 1;
  246. // A token identifying a page of results to return. This should be a
  247. // `next_page_token` value returned from a previous `ListBillingAccounts`
  248. // call. If unspecified, the first page of results is returned.
  249. string page_token = 2;
  250. // Options for how to filter the returned billing accounts.
  251. // Currently this only supports filtering for
  252. // [subaccounts](https://cloud.google.com/billing/docs/concepts) under a
  253. // single provided reseller billing account.
  254. // (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF").
  255. // Boolean algebra and other fields are not currently supported.
  256. string filter = 3;
  257. }
  258. // Response message for `ListBillingAccounts`.
  259. message ListBillingAccountsResponse {
  260. // A list of billing accounts.
  261. repeated BillingAccount billing_accounts = 1;
  262. // A token to retrieve the next page of results. To retrieve the next page,
  263. // call `ListBillingAccounts` again with the `page_token` field set to this
  264. // value. This field is empty if there are no more results to retrieve.
  265. string next_page_token = 2;
  266. }
  267. // Request message for `CreateBillingAccount`.
  268. message CreateBillingAccountRequest {
  269. // Required. The billing account resource to create.
  270. // Currently CreateBillingAccount only supports subaccount creation, so
  271. // any created billing accounts must be under a provided parent billing
  272. // account.
  273. BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED];
  274. }
  275. // Request message for `UpdateBillingAccount`.
  276. message UpdateBillingAccountRequest {
  277. // Required. The name of the billing account resource to be updated.
  278. string name = 1 [
  279. (google.api.field_behavior) = REQUIRED,
  280. (google.api.resource_reference) = {
  281. type: "cloudbilling.googleapis.com/BillingAccount"
  282. }
  283. ];
  284. // Required. The billing account resource to replace the resource on the server.
  285. BillingAccount account = 2 [(google.api.field_behavior) = REQUIRED];
  286. // The update mask applied to the resource.
  287. // Only "display_name" is currently supported.
  288. google.protobuf.FieldMask update_mask = 3;
  289. }
  290. // Request message for `ListProjectBillingInfo`.
  291. message ListProjectBillingInfoRequest {
  292. // Required. The resource name of the billing account associated with the projects that
  293. // you want to list. For example, `billingAccounts/012345-567890-ABCDEF`.
  294. string name = 1 [
  295. (google.api.field_behavior) = REQUIRED,
  296. (google.api.resource_reference) = {
  297. type: "cloudbilling.googleapis.com/BillingAccount"
  298. }
  299. ];
  300. // Requested page size. The maximum page size is 100; this is also the
  301. // default.
  302. int32 page_size = 2;
  303. // A token identifying a page of results to be returned. This should be a
  304. // `next_page_token` value returned from a previous `ListProjectBillingInfo`
  305. // call. If unspecified, the first page of results is returned.
  306. string page_token = 3;
  307. }
  308. // Request message for `ListProjectBillingInfoResponse`.
  309. message ListProjectBillingInfoResponse {
  310. // A list of `ProjectBillingInfo` resources representing the projects
  311. // associated with the billing account.
  312. repeated ProjectBillingInfo project_billing_info = 1;
  313. // A token to retrieve the next page of results. To retrieve the next page,
  314. // call `ListProjectBillingInfo` again with the `page_token` field set to this
  315. // value. This field is empty if there are no more results to retrieve.
  316. string next_page_token = 2;
  317. }
  318. // Request message for `GetProjectBillingInfo`.
  319. message GetProjectBillingInfoRequest {
  320. // Required. The resource name of the project for which billing information is
  321. // retrieved. For example, `projects/tokyo-rain-123`.
  322. string name = 1 [(google.api.field_behavior) = REQUIRED];
  323. }
  324. // Request message for `UpdateProjectBillingInfo`.
  325. message UpdateProjectBillingInfoRequest {
  326. // Required. The resource name of the project associated with the billing information
  327. // that you want to update. For example, `projects/tokyo-rain-123`.
  328. string name = 1 [(google.api.field_behavior) = REQUIRED];
  329. // The new billing information for the project. Read-only fields are ignored;
  330. // thus, you can leave empty all fields except `billing_account_name`.
  331. ProjectBillingInfo project_billing_info = 2;
  332. }