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