From 1d12d8991b14a86bf624817102c7af10c285b7b7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:08:15 +0000 Subject: [PATCH] feat: added Sku.geo_taxonomy (#3637) - [ ] Regenerate this pull request now. chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: https://togithub.com/googleapis/googleapis/commit/758f0d1217d9c7fe398aa5efb1057ce4b6409e55 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmcvLk93bEJvdC55YW1sIiwiaCI6Ijc4YmQ4ZjA1ZTEyNzYzNjNlYjE0ZWFlNzBlOTFmZTRiYzIwNzAzYWIifQ== BEGIN_NESTED_COMMIT feat: added Sku.geo_taxonomy fix: more oauth scopes PiperOrigin-RevId: 488493014 Source-Link: https://togithub.com/googleapis/googleapis/commit/8995a8817642b3a209103677012521f953616011 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/adbfce0c0e59b1b38bb8e81ae9a3d0b408e7f7c0 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmcvLk93bEJvdC55YW1sIiwiaCI6ImFkYmZjZTBjMGU1OWIxYjM4YmI4ZTgxYWU5YTNkMGI0MDhlN2Y3YzAifQ== END_NESTED_COMMIT --- .../cloud/billing/v1/cloud_billing.proto | 65 +-- .../cloud/billing/v1/cloud_catalog.proto | 68 ++- .../google-cloud-billing/protos/protos.d.ts | 144 +++++- .../google-cloud-billing/protos/protos.js | 414 ++++++++++++++++-- .../google-cloud-billing/protos/protos.json | 50 ++- .../cloud_billing.create_billing_account.js | 2 +- ...ppet_metadata.google.cloud.billing.v1.json | 6 +- .../src/v1/cloud_billing_client.ts | 40 +- .../src/v1/cloud_catalog_client.ts | 9 +- 9 files changed, 665 insertions(+), 133 deletions(-) diff --git a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto index f0b19d14d13..b98f0fd7c26 100644 --- a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto +++ b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_billing.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -30,10 +29,14 @@ option java_multiple_files = true; option java_outer_classname = "CloudBillingProto"; option java_package = "com.google.cloud.billing.v1"; -// Retrieves GCP Console billing accounts and associates them with projects. +// Retrieves the Google Cloud Console billing accounts and associates them with +// projects. service CloudBilling { option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; // Gets information about a billing account. The current authenticated user // must be a [viewer of the billing @@ -69,15 +72,20 @@ service CloudBilling { option (google.api.method_signature) = "name,account"; } - // Creates a billing account. - // This method can only be used to create - // [billing subaccounts](https://cloud.google.com/billing/docs/concepts) - // by GCP resellers. + // This method creates [billing + // subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + // + // Google Cloud resellers should use the + // Channel Services APIs, + // [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + // and + // [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + // // When creating a subaccount, the current authenticated user must have the - // `billing.accounts.update` IAM permission on the master account, which is + // `billing.accounts.update` IAM permission on the parent account, which is // typically given to billing account // [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - // This method will return an error if the master account has not been + // This method will return an error if the parent account has not been // provisioned as a reseller account. rpc CreateBillingAccount(CreateBillingAccountRequest) returns (BillingAccount) { option (google.api.http) = { @@ -99,9 +107,10 @@ service CloudBilling { } // Gets the billing information for a project. The current authenticated user - // must have [permission to view the - // project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - // ). + // must have the `resourcemanager.projects.get` permission for the project, + // which can be granted by assigning the [Project + // Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + // role. rpc GetProjectBillingInfo(GetProjectBillingInfoRequest) returns (ProjectBillingInfo) { option (google.api.http) = { get: "/v1/{name=projects/*}/billingInfo" @@ -118,7 +127,7 @@ service CloudBilling { // usage charges. // // *Note:* Incurred charges that have not yet been reported in the transaction - // history of the GCP Console might be billed to the new billing + // history of the Google Cloud Console might be billed to the new billing // account, even if the charge occurred before the new billing account was // assigned to the project. // @@ -184,16 +193,20 @@ service CloudBilling { } } -// A billing account in [GCP Console](https://console.cloud.google.com/). -// You can assign a billing account to one or more projects. +// A billing account in the +// [Google Cloud Console](https://console.cloud.google.com/). You can assign a +// billing account to one or more projects. message BillingAccount { - // The resource name of the billing account. The resource name has the form + // Output only. The resource name of the billing account. The resource name has the form // `billingAccounts/{billing_account_id}`. For example, // `billingAccounts/012345-567890-ABCDEF` would be the resource name for // billing account `012345-567890-ABCDEF`. - string name = 1 [(google.api.resource_reference) = { - type: "cloudbilling.googleapis.com/BillingAccount" - }]; + string name = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "cloudbilling.googleapis.com/BillingAccount" + } + ]; // Output only. True if the billing account is open, and will therefore be charged for any // usage on associated projects. False if the billing account is closed, and @@ -201,20 +214,20 @@ message BillingAccount { bool open = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; // The display name given to the billing account, such as `My Billing - // Account`. This name is displayed in the GCP Console. + // Account`. This name is displayed in the Google Cloud Console. string display_name = 3; // If this account is a // [subaccount](https://cloud.google.com/billing/docs/concepts), then this - // will be the resource name of the master billing account that it is being + // will be the resource name of the parent billing account that it is being // resold through. // Otherwise this will be empty. string master_billing_account = 4; } -// Encapsulation of billing information for a GCP Console project. A project -// has at most one associated billing account at a time (but a billing account -// can be assigned to multiple projects). +// Encapsulation of billing information for a Google Cloud Console project. A +// project has at most one associated billing account at a time (but a billing +// account can be assigned to multiple projects). message ProjectBillingInfo { // The resource name for the `ProjectBillingInfo`; has the form // `projects/{project_id}/billingInfo`. For example, the resource name for the @@ -285,7 +298,7 @@ message ListBillingAccountsResponse { message CreateBillingAccountRequest { // Required. The billing account resource to create. // Currently CreateBillingAccount only supports subaccount creation, so - // any created billing accounts must be under a provided master billing + // any created billing accounts must be under a provided parent billing // account. BillingAccount billing_account = 1 [(google.api.field_behavior) = REQUIRED]; } diff --git a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto index 7bc2f14e3b1..f3d46e62708 100644 --- a/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto +++ b/packages/google-cloud-billing/protos/google/cloud/billing/v1/cloud_catalog.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -36,7 +35,10 @@ option objc_class_prefix = "CLDCTLG"; // and SKUs. service CloudCatalog { option (google.api.default_host) = "cloudbilling.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-billing," + "https://www.googleapis.com/auth/cloud-billing.readonly," + "https://www.googleapis.com/auth/cloud-platform"; // Lists all public cloud services. rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { @@ -111,6 +113,9 @@ message Sku { // Identifies the service provider. // This is 'Google' for first party services in Google Cloud Platform. string service_provider_name = 7; + + // The geographic taxonomy for this sku. + GeoTaxonomy geo_taxonomy = 8; } // Represents the category hierarchy of a SKU. @@ -187,6 +192,21 @@ message PricingExpression { // Example: usage_unit of "GiBy" means that usage is specified in "Gibi Byte". string usage_unit = 1; + // The recommended quantity of units for displaying pricing info. When + // displaying pricing info it is recommended to display: + // (unit_price * display_quantity) per display_quantity usage_unit. + // This field does not affect the pricing formula and is for display purposes + // only. + // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and + // the display_quantity is "1000" then the recommended way of displaying the + // pricing info is "0.10 USD per 1000 GB" + double display_quantity = 2; + + // The list of tiered rates for this pricing. The total cost is computed by + // applying each of the tiered rates on usage. This repeated list is sorted + // by ascending order of start_usage_amount. + repeated TierRate tiered_rates = 3; + // The unit of usage in human readable form. // Example: "gibi byte". string usage_unit_description = 4; @@ -205,21 +225,6 @@ message PricingExpression { // start_usage_amount * base_unit_conversion_factor = start_usage_amount in // base_unit. double base_unit_conversion_factor = 7; - - // The recommended quantity of units for displaying pricing info. When - // displaying pricing info it is recommended to display: - // (unit_price * display_quantity) per display_quantity usage_unit. - // This field does not affect the pricing formula and is for display purposes - // only. - // Example: If the unit_price is "0.0001 USD", the usage_unit is "GB" and - // the display_quantity is "1000" then the recommended way of displaying the - // pricing info is "0.10 USD per 1000 GB" - double display_quantity = 2; - - // The list of tiered rates for this pricing. The total cost is computed by - // applying each of the tiered rates on usage. This repeated list is sorted - // by ascending order of start_usage_amount. - repeated TierRate tiered_rates = 3; } // Represents the aggregation level and interval for pricing of a single SKU. @@ -256,6 +261,33 @@ message AggregationInfo { int32 aggregation_count = 3; } +// Encapsulates the geographic taxonomy data for a sku. +message GeoTaxonomy { + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + enum Type { + // The type is not specified. + TYPE_UNSPECIFIED = 0; + + // The sku is global in nature, e.g. a license sku. Global skus are + // available in all regions, and so have an empty region list. + GLOBAL = 1; + + // The sku is available in a specific region, e.g. "us-west2". + REGIONAL = 2; + + // The sku is associated with multiple regions, e.g. "us-west2" and + // "us-east1". + MULTI_REGIONAL = 3; + } + + // The type of Geo Taxonomy: GLOBAL, REGIONAL, or MULTI_REGIONAL. + Type type = 1; + + // The list of regions associated with a sku. Empty for Global skus, which are + // associated with all Google Cloud regions. + repeated string regions = 2; +} + // Request message for `ListServices`. message ListServicesRequest { // Requested page size. Defaults to 5000. diff --git a/packages/google-cloud-billing/protos/protos.d.ts b/packages/google-cloud-billing/protos/protos.d.ts index 478f7a3002a..1f13256deec 100644 --- a/packages/google-cloud-billing/protos/protos.d.ts +++ b/packages/google-cloud-billing/protos/protos.d.ts @@ -1621,6 +1621,9 @@ export namespace google { /** Sku serviceProviderName */ serviceProviderName?: (string|null); + + /** Sku geoTaxonomy */ + geoTaxonomy?: (google.cloud.billing.v1.IGeoTaxonomy|null); } /** Represents a Sku. */ @@ -1653,6 +1656,9 @@ export namespace google { /** Sku serviceProviderName. */ public serviceProviderName: string; + /** Sku geoTaxonomy. */ + public geoTaxonomy?: (google.cloud.billing.v1.IGeoTaxonomy|null); + /** * Creates a new Sku instance using the specified properties. * @param [properties] Properties to set @@ -1973,6 +1979,12 @@ export namespace google { /** PricingExpression usageUnit */ usageUnit?: (string|null); + /** PricingExpression displayQuantity */ + displayQuantity?: (number|null); + + /** PricingExpression tieredRates */ + tieredRates?: (google.cloud.billing.v1.PricingExpression.ITierRate[]|null); + /** PricingExpression usageUnitDescription */ usageUnitDescription?: (string|null); @@ -1984,12 +1996,6 @@ export namespace google { /** PricingExpression baseUnitConversionFactor */ baseUnitConversionFactor?: (number|null); - - /** PricingExpression displayQuantity */ - displayQuantity?: (number|null); - - /** PricingExpression tieredRates */ - tieredRates?: (google.cloud.billing.v1.PricingExpression.ITierRate[]|null); } /** Represents a PricingExpression. */ @@ -2004,6 +2010,12 @@ export namespace google { /** PricingExpression usageUnit. */ public usageUnit: string; + /** PricingExpression displayQuantity. */ + public displayQuantity: number; + + /** PricingExpression tieredRates. */ + public tieredRates: google.cloud.billing.v1.PricingExpression.ITierRate[]; + /** PricingExpression usageUnitDescription. */ public usageUnitDescription: string; @@ -2016,12 +2028,6 @@ export namespace google { /** PricingExpression baseUnitConversionFactor. */ public baseUnitConversionFactor: number; - /** PricingExpression displayQuantity. */ - public displayQuantity: number; - - /** PricingExpression tieredRates. */ - public tieredRates: google.cloud.billing.v1.PricingExpression.ITierRate[]; - /** * Creates a new PricingExpression instance using the specified properties. * @param [properties] Properties to set @@ -2332,6 +2338,120 @@ export namespace google { } } + /** Properties of a GeoTaxonomy. */ + interface IGeoTaxonomy { + + /** GeoTaxonomy type */ + type?: (google.cloud.billing.v1.GeoTaxonomy.Type|keyof typeof google.cloud.billing.v1.GeoTaxonomy.Type|null); + + /** GeoTaxonomy regions */ + regions?: (string[]|null); + } + + /** Represents a GeoTaxonomy. */ + class GeoTaxonomy implements IGeoTaxonomy { + + /** + * Constructs a new GeoTaxonomy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.billing.v1.IGeoTaxonomy); + + /** GeoTaxonomy type. */ + public type: (google.cloud.billing.v1.GeoTaxonomy.Type|keyof typeof google.cloud.billing.v1.GeoTaxonomy.Type); + + /** GeoTaxonomy regions. */ + public regions: string[]; + + /** + * Creates a new GeoTaxonomy instance using the specified properties. + * @param [properties] Properties to set + * @returns GeoTaxonomy instance + */ + public static create(properties?: google.cloud.billing.v1.IGeoTaxonomy): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Encodes the specified GeoTaxonomy message. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @param message GeoTaxonomy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.billing.v1.IGeoTaxonomy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GeoTaxonomy message, length delimited. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @param message GeoTaxonomy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.billing.v1.IGeoTaxonomy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Verifies a GeoTaxonomy message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GeoTaxonomy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeoTaxonomy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.billing.v1.GeoTaxonomy; + + /** + * Creates a plain object from a GeoTaxonomy message. Also converts values to other types if specified. + * @param message GeoTaxonomy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.billing.v1.GeoTaxonomy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeoTaxonomy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GeoTaxonomy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace GeoTaxonomy { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + GLOBAL = 1, + REGIONAL = 2, + MULTI_REGIONAL = 3 + } + } + /** Properties of a ListServicesRequest. */ interface IListServicesRequest { diff --git a/packages/google-cloud-billing/protos/protos.js b/packages/google-cloud-billing/protos/protos.js index faa7d08fa8b..86cd9d40619 100644 --- a/packages/google-cloud-billing/protos/protos.js +++ b/packages/google-cloud-billing/protos/protos.js @@ -3466,6 +3466,7 @@ * @property {Array.|null} [serviceRegions] Sku serviceRegions * @property {Array.|null} [pricingInfo] Sku pricingInfo * @property {string|null} [serviceProviderName] Sku serviceProviderName + * @property {google.cloud.billing.v1.IGeoTaxonomy|null} [geoTaxonomy] Sku geoTaxonomy */ /** @@ -3541,6 +3542,14 @@ */ Sku.prototype.serviceProviderName = ""; + /** + * Sku geoTaxonomy. + * @member {google.cloud.billing.v1.IGeoTaxonomy|null|undefined} geoTaxonomy + * @memberof google.cloud.billing.v1.Sku + * @instance + */ + Sku.prototype.geoTaxonomy = null; + /** * Creates a new Sku instance using the specified properties. * @function create @@ -3581,6 +3590,8 @@ $root.google.cloud.billing.v1.PricingInfo.encode(message.pricingInfo[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.serviceProviderName != null && Object.hasOwnProperty.call(message, "serviceProviderName")) writer.uint32(/* id 7, wireType 2 =*/58).string(message.serviceProviderName); + if (message.geoTaxonomy != null && Object.hasOwnProperty.call(message, "geoTaxonomy")) + $root.google.cloud.billing.v1.GeoTaxonomy.encode(message.geoTaxonomy, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); return writer; }; @@ -3647,6 +3658,10 @@ message.serviceProviderName = reader.string(); break; } + case 8: { + message.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -3715,6 +3730,11 @@ if (message.serviceProviderName != null && message.hasOwnProperty("serviceProviderName")) if (!$util.isString(message.serviceProviderName)) return "serviceProviderName: string expected"; + if (message.geoTaxonomy != null && message.hasOwnProperty("geoTaxonomy")) { + var error = $root.google.cloud.billing.v1.GeoTaxonomy.verify(message.geoTaxonomy); + if (error) + return "geoTaxonomy." + error; + } return null; }; @@ -3760,6 +3780,11 @@ } if (object.serviceProviderName != null) message.serviceProviderName = String(object.serviceProviderName); + if (object.geoTaxonomy != null) { + if (typeof object.geoTaxonomy !== "object") + throw TypeError(".google.cloud.billing.v1.Sku.geoTaxonomy: object expected"); + message.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.fromObject(object.geoTaxonomy); + } return message; }; @@ -3786,6 +3811,7 @@ object.description = ""; object.category = null; object.serviceProviderName = ""; + object.geoTaxonomy = null; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -3807,6 +3833,8 @@ } if (message.serviceProviderName != null && message.hasOwnProperty("serviceProviderName")) object.serviceProviderName = message.serviceProviderName; + if (message.geoTaxonomy != null && message.hasOwnProperty("geoTaxonomy")) + object.geoTaxonomy = $root.google.cloud.billing.v1.GeoTaxonomy.toObject(message.geoTaxonomy, options); return object; }; @@ -4430,12 +4458,12 @@ * @memberof google.cloud.billing.v1 * @interface IPricingExpression * @property {string|null} [usageUnit] PricingExpression usageUnit + * @property {number|null} [displayQuantity] PricingExpression displayQuantity + * @property {Array.|null} [tieredRates] PricingExpression tieredRates * @property {string|null} [usageUnitDescription] PricingExpression usageUnitDescription * @property {string|null} [baseUnit] PricingExpression baseUnit * @property {string|null} [baseUnitDescription] PricingExpression baseUnitDescription * @property {number|null} [baseUnitConversionFactor] PricingExpression baseUnitConversionFactor - * @property {number|null} [displayQuantity] PricingExpression displayQuantity - * @property {Array.|null} [tieredRates] PricingExpression tieredRates */ /** @@ -4462,6 +4490,22 @@ */ PricingExpression.prototype.usageUnit = ""; + /** + * PricingExpression displayQuantity. + * @member {number} displayQuantity + * @memberof google.cloud.billing.v1.PricingExpression + * @instance + */ + PricingExpression.prototype.displayQuantity = 0; + + /** + * PricingExpression tieredRates. + * @member {Array.} tieredRates + * @memberof google.cloud.billing.v1.PricingExpression + * @instance + */ + PricingExpression.prototype.tieredRates = $util.emptyArray; + /** * PricingExpression usageUnitDescription. * @member {string} usageUnitDescription @@ -4494,22 +4538,6 @@ */ PricingExpression.prototype.baseUnitConversionFactor = 0; - /** - * PricingExpression displayQuantity. - * @member {number} displayQuantity - * @memberof google.cloud.billing.v1.PricingExpression - * @instance - */ - PricingExpression.prototype.displayQuantity = 0; - - /** - * PricingExpression tieredRates. - * @member {Array.} tieredRates - * @memberof google.cloud.billing.v1.PricingExpression - * @instance - */ - PricingExpression.prototype.tieredRates = $util.emptyArray; - /** * Creates a new PricingExpression instance using the specified properties. * @function create @@ -4587,6 +4615,16 @@ message.usageUnit = reader.string(); break; } + case 2: { + message.displayQuantity = reader.double(); + break; + } + case 3: { + if (!(message.tieredRates && message.tieredRates.length)) + message.tieredRates = []; + message.tieredRates.push($root.google.cloud.billing.v1.PricingExpression.TierRate.decode(reader, reader.uint32())); + break; + } case 4: { message.usageUnitDescription = reader.string(); break; @@ -4603,16 +4641,6 @@ message.baseUnitConversionFactor = reader.double(); break; } - case 2: { - message.displayQuantity = reader.double(); - break; - } - case 3: { - if (!(message.tieredRates && message.tieredRates.length)) - message.tieredRates = []; - message.tieredRates.push($root.google.cloud.billing.v1.PricingExpression.TierRate.decode(reader, reader.uint32())); - break; - } default: reader.skipType(tag & 7); break; @@ -4651,18 +4679,6 @@ if (message.usageUnit != null && message.hasOwnProperty("usageUnit")) if (!$util.isString(message.usageUnit)) return "usageUnit: string expected"; - if (message.usageUnitDescription != null && message.hasOwnProperty("usageUnitDescription")) - if (!$util.isString(message.usageUnitDescription)) - return "usageUnitDescription: string expected"; - if (message.baseUnit != null && message.hasOwnProperty("baseUnit")) - if (!$util.isString(message.baseUnit)) - return "baseUnit: string expected"; - if (message.baseUnitDescription != null && message.hasOwnProperty("baseUnitDescription")) - if (!$util.isString(message.baseUnitDescription)) - return "baseUnitDescription: string expected"; - if (message.baseUnitConversionFactor != null && message.hasOwnProperty("baseUnitConversionFactor")) - if (typeof message.baseUnitConversionFactor !== "number") - return "baseUnitConversionFactor: number expected"; if (message.displayQuantity != null && message.hasOwnProperty("displayQuantity")) if (typeof message.displayQuantity !== "number") return "displayQuantity: number expected"; @@ -4675,6 +4691,18 @@ return "tieredRates." + error; } } + if (message.usageUnitDescription != null && message.hasOwnProperty("usageUnitDescription")) + if (!$util.isString(message.usageUnitDescription)) + return "usageUnitDescription: string expected"; + if (message.baseUnit != null && message.hasOwnProperty("baseUnit")) + if (!$util.isString(message.baseUnit)) + return "baseUnit: string expected"; + if (message.baseUnitDescription != null && message.hasOwnProperty("baseUnitDescription")) + if (!$util.isString(message.baseUnitDescription)) + return "baseUnitDescription: string expected"; + if (message.baseUnitConversionFactor != null && message.hasOwnProperty("baseUnitConversionFactor")) + if (typeof message.baseUnitConversionFactor !== "number") + return "baseUnitConversionFactor: number expected"; return null; }; @@ -4692,14 +4720,6 @@ var message = new $root.google.cloud.billing.v1.PricingExpression(); if (object.usageUnit != null) message.usageUnit = String(object.usageUnit); - if (object.usageUnitDescription != null) - message.usageUnitDescription = String(object.usageUnitDescription); - if (object.baseUnit != null) - message.baseUnit = String(object.baseUnit); - if (object.baseUnitDescription != null) - message.baseUnitDescription = String(object.baseUnitDescription); - if (object.baseUnitConversionFactor != null) - message.baseUnitConversionFactor = Number(object.baseUnitConversionFactor); if (object.displayQuantity != null) message.displayQuantity = Number(object.displayQuantity); if (object.tieredRates) { @@ -4712,6 +4732,14 @@ message.tieredRates[i] = $root.google.cloud.billing.v1.PricingExpression.TierRate.fromObject(object.tieredRates[i]); } } + if (object.usageUnitDescription != null) + message.usageUnitDescription = String(object.usageUnitDescription); + if (object.baseUnit != null) + message.baseUnit = String(object.baseUnit); + if (object.baseUnitDescription != null) + message.baseUnitDescription = String(object.baseUnitDescription); + if (object.baseUnitConversionFactor != null) + message.baseUnitConversionFactor = Number(object.baseUnitConversionFactor); return message; }; @@ -5349,6 +5377,296 @@ return AggregationInfo; })(); + v1.GeoTaxonomy = (function() { + + /** + * Properties of a GeoTaxonomy. + * @memberof google.cloud.billing.v1 + * @interface IGeoTaxonomy + * @property {google.cloud.billing.v1.GeoTaxonomy.Type|null} [type] GeoTaxonomy type + * @property {Array.|null} [regions] GeoTaxonomy regions + */ + + /** + * Constructs a new GeoTaxonomy. + * @memberof google.cloud.billing.v1 + * @classdesc Represents a GeoTaxonomy. + * @implements IGeoTaxonomy + * @constructor + * @param {google.cloud.billing.v1.IGeoTaxonomy=} [properties] Properties to set + */ + function GeoTaxonomy(properties) { + this.regions = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeoTaxonomy type. + * @member {google.cloud.billing.v1.GeoTaxonomy.Type} type + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + */ + GeoTaxonomy.prototype.type = 0; + + /** + * GeoTaxonomy regions. + * @member {Array.} regions + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + */ + GeoTaxonomy.prototype.regions = $util.emptyArray; + + /** + * Creates a new GeoTaxonomy instance using the specified properties. + * @function create + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy=} [properties] Properties to set + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy instance + */ + GeoTaxonomy.create = function create(properties) { + return new GeoTaxonomy(properties); + }; + + /** + * Encodes the specified GeoTaxonomy message. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @function encode + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy} message GeoTaxonomy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeoTaxonomy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.regions != null && message.regions.length) + for (var i = 0; i < message.regions.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.regions[i]); + return writer; + }; + + /** + * Encodes the specified GeoTaxonomy message, length delimited. Does not implicitly {@link google.cloud.billing.v1.GeoTaxonomy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.IGeoTaxonomy} message GeoTaxonomy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeoTaxonomy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeoTaxonomy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.billing.v1.GeoTaxonomy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + if (!(message.regions && message.regions.length)) + message.regions = []; + message.regions.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GeoTaxonomy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeoTaxonomy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GeoTaxonomy message. + * @function verify + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeoTaxonomy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.regions != null && message.hasOwnProperty("regions")) { + if (!Array.isArray(message.regions)) + return "regions: array expected"; + for (var i = 0; i < message.regions.length; ++i) + if (!$util.isString(message.regions[i])) + return "regions: string[] expected"; + } + return null; + }; + + /** + * Creates a GeoTaxonomy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.billing.v1.GeoTaxonomy} GeoTaxonomy + */ + GeoTaxonomy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.billing.v1.GeoTaxonomy) + return object; + var message = new $root.google.cloud.billing.v1.GeoTaxonomy(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "GLOBAL": + case 1: + message.type = 1; + break; + case "REGIONAL": + case 2: + message.type = 2; + break; + case "MULTI_REGIONAL": + case 3: + message.type = 3; + break; + } + if (object.regions) { + if (!Array.isArray(object.regions)) + throw TypeError(".google.cloud.billing.v1.GeoTaxonomy.regions: array expected"); + message.regions = []; + for (var i = 0; i < object.regions.length; ++i) + message.regions[i] = String(object.regions[i]); + } + return message; + }; + + /** + * Creates a plain object from a GeoTaxonomy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {google.cloud.billing.v1.GeoTaxonomy} message GeoTaxonomy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeoTaxonomy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.regions = []; + if (options.defaults) + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.billing.v1.GeoTaxonomy.Type[message.type] === undefined ? message.type : $root.google.cloud.billing.v1.GeoTaxonomy.Type[message.type] : message.type; + if (message.regions && message.regions.length) { + object.regions = []; + for (var j = 0; j < message.regions.length; ++j) + object.regions[j] = message.regions[j]; + } + return object; + }; + + /** + * Converts this GeoTaxonomy to JSON. + * @function toJSON + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @instance + * @returns {Object.} JSON object + */ + GeoTaxonomy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GeoTaxonomy + * @function getTypeUrl + * @memberof google.cloud.billing.v1.GeoTaxonomy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GeoTaxonomy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.billing.v1.GeoTaxonomy"; + }; + + /** + * Type enum. + * @name google.cloud.billing.v1.GeoTaxonomy.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} GLOBAL=1 GLOBAL value + * @property {number} REGIONAL=2 REGIONAL value + * @property {number} MULTI_REGIONAL=3 MULTI_REGIONAL value + */ + GeoTaxonomy.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "GLOBAL"] = 1; + values[valuesById[2] = "REGIONAL"] = 2; + values[valuesById[3] = "MULTI_REGIONAL"] = 3; + return values; + })(); + + return GeoTaxonomy; + })(); + v1.ListServicesRequest = (function() { /** diff --git a/packages/google-cloud-billing/protos/protos.json b/packages/google-cloud-billing/protos/protos.json index c1e48b8313d..a89fc6d6f3f 100644 --- a/packages/google-cloud-billing/protos/protos.json +++ b/packages/google-cloud-billing/protos/protos.json @@ -19,7 +19,7 @@ "CloudBilling": { "options": { "(google.api.default_host)": "cloudbilling.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-billing,https://www.googleapis.com/auth/cloud-billing.readonly,https://www.googleapis.com/auth/cloud-platform" }, "methods": { "GetBillingAccount": { @@ -220,6 +220,7 @@ "type": "string", "id": 1, "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", "(google.api.resource_reference).type": "cloudbilling.googleapis.com/BillingAccount" } }, @@ -397,7 +398,7 @@ "CloudCatalog": { "options": { "(google.api.default_host)": "cloudbilling.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-billing,https://www.googleapis.com/auth/cloud-billing.readonly,https://www.googleapis.com/auth/cloud-platform" }, "methods": { "ListServices": { @@ -497,6 +498,10 @@ "serviceProviderName": { "type": "string", "id": 7 + }, + "geoTaxonomy": { + "type": "GeoTaxonomy", + "id": 8 } } }, @@ -550,6 +555,15 @@ "type": "string", "id": 1 }, + "displayQuantity": { + "type": "double", + "id": 2 + }, + "tieredRates": { + "rule": "repeated", + "type": "TierRate", + "id": 3 + }, "usageUnitDescription": { "type": "string", "id": 4 @@ -565,15 +579,6 @@ "baseUnitConversionFactor": { "type": "double", "id": 7 - }, - "displayQuantity": { - "type": "double", - "id": 2 - }, - "tieredRates": { - "rule": "repeated", - "type": "TierRate", - "id": 3 } }, "nested": { @@ -623,6 +628,29 @@ } } }, + "GeoTaxonomy": { + "fields": { + "type": { + "type": "Type", + "id": 1 + }, + "regions": { + "rule": "repeated", + "type": "string", + "id": 2 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "GLOBAL": 1, + "REGIONAL": 2, + "MULTI_REGIONAL": 3 + } + } + } + }, "ListServicesRequest": { "fields": { "pageSize": { diff --git a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js index 5924f24b633..06e6462d716 100644 --- a/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js +++ b/packages/google-cloud-billing/samples/generated/v1/cloud_billing.create_billing_account.js @@ -31,7 +31,7 @@ function main(billingAccount) { /** * Required. The billing account resource to create. * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided master billing + * any created billing accounts must be under a provided parent billing * account. */ // const billingAccount = {} diff --git a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json index 1aa2814bffc..f1c5ec85fc3 100644 --- a/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json +++ b/packages/google-cloud-billing/samples/generated/v1/snippet_metadata.google.cloud.billing.v1.json @@ -151,7 +151,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_CreateBillingAccount_async", "title": "CloudBilling createBillingAccount Sample", "origin": "API_DEFINITION", - "description": " Creates a billing account. This method can only be used to create [billing subaccounts](https://cloud.google.com/billing/docs/concepts) by GCP resellers. When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the master account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the master account has not been provisioned as a reseller account.", + "description": " This method creates [billing subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). Google Cloud resellers should use the Channel Services APIs, [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) and [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the parent account, which is typically given to billing account [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the parent account has not been provisioned as a reseller account.", "canonical": true, "file": "cloud_billing.create_billing_account.js", "language": "JAVASCRIPT", @@ -239,7 +239,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_GetProjectBillingInfo_async", "title": "CloudBilling getProjectBillingInfo Sample", "origin": "API_DEFINITION", - "description": " Gets the billing information for a project. The current authenticated user must have [permission to view the project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ).", + "description": " Gets the billing information for a project. The current authenticated user must have the `resourcemanager.projects.get` permission for the project, which can be granted by assigning the [Project Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) role.", "canonical": true, "file": "cloud_billing.get_project_billing_info.js", "language": "JAVASCRIPT", @@ -279,7 +279,7 @@ "regionTag": "cloudbilling_v1_generated_CloudBilling_UpdateProjectBillingInfo_async", "title": "CloudBilling updateProjectBillingInfo Sample", "origin": "API_DEFINITION", - "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the GCP Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", + "description": " Sets or updates the billing account associated with a project. You specify the new billing account by setting the `billing_account_name` in the `ProjectBillingInfo` resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges. *Note:* Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project. The current authenticated user must have ownership privileges for both the [project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](https://cloud.google.com/billing/docs/how-to/billing-access). You can disable billing on the project by setting the `billing_account_name` field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project. Note that associating a project with a *closed* billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an *open* billing account.", "canonical": true, "file": "cloud_billing.update_project_billing_info.js", "language": "JAVASCRIPT", diff --git a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts index 54c42f18eb4..d1c1357644c 100644 --- a/packages/google-cloud-billing/src/v1/cloud_billing_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_billing_client.ts @@ -38,7 +38,8 @@ import * as gapicConfig from './cloud_billing_client_config.json'; const version = require('../../../package.json').version; /** - * Retrieves GCP Console billing accounts and associates them with projects. + * Retrieves the Google Cloud Console billing accounts and associates them with + * projects. * @class * @memberof v1 */ @@ -120,6 +121,9 @@ export class CloudBillingClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -323,7 +327,11 @@ export class CloudBillingClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return ['https://www.googleapis.com/auth/cloud-platform']; + return [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; } getProjectId(): Promise; @@ -541,15 +549,20 @@ export class CloudBillingClient { return this.innerApiCalls.updateBillingAccount(request, options, callback); } /** - * Creates a billing account. - * This method can only be used to create - * [billing subaccounts](https://cloud.google.com/billing/docs/concepts) - * by GCP resellers. + * This method creates [billing + * subaccounts](https://cloud.google.com/billing/docs/concepts#subaccounts). + * + * Google Cloud resellers should use the + * Channel Services APIs, + * [accounts.customers.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers/create) + * and + * [accounts.customers.entitlements.create](https://cloud.google.com/channel/docs/reference/rest/v1/accounts.customers.entitlements/create). + * * When creating a subaccount, the current authenticated user must have the - * `billing.accounts.update` IAM permission on the master account, which is + * `billing.accounts.update` IAM permission on the parent account, which is * typically given to billing account * [administrators](https://cloud.google.com/billing/docs/how-to/billing-access). - * This method will return an error if the master account has not been + * This method will return an error if the parent account has not been * provisioned as a reseller account. * * @param {Object} request @@ -557,7 +570,7 @@ export class CloudBillingClient { * @param {google.cloud.billing.v1.BillingAccount} request.billingAccount * Required. The billing account resource to create. * Currently CreateBillingAccount only supports subaccount creation, so - * any created billing accounts must be under a provided master billing + * any created billing accounts must be under a provided parent billing * account. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. @@ -641,9 +654,10 @@ export class CloudBillingClient { } /** * Gets the billing information for a project. The current authenticated user - * must have [permission to view the - * project](https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo - * ). + * must have the `resourcemanager.projects.get` permission for the project, + * which can be granted by assigning the [Project + * Viewer](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles) + * role. * * @param {Object} request * The request object that will be sent. @@ -744,7 +758,7 @@ export class CloudBillingClient { * usage charges. * * *Note:* Incurred charges that have not yet been reported in the transaction - * history of the GCP Console might be billed to the new billing + * history of the Google Cloud Console might be billed to the new billing * account, even if the charge occurred before the new billing account was * assigned to the project. * diff --git a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts index d000f8e8bc6..779dcfde89a 100644 --- a/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts +++ b/packages/google-cloud-billing/src/v1/cloud_catalog_client.ts @@ -122,6 +122,9 @@ export class CloudCatalogClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -311,7 +314,11 @@ export class CloudCatalogClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return ['https://www.googleapis.com/auth/cloud-platform']; + return [ + 'https://www.googleapis.com/auth/cloud-billing', + 'https://www.googleapis.com/auth/cloud-billing.readonly', + 'https://www.googleapis.com/auth/cloud-platform', + ]; } getProjectId(): Promise;