Пример #1
0
        /// <summary>
        /// Sets or updates the billing account associated with a project. You specifythe 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 theproject and allows charges for resource usage. If the project already had abilling account, this method changes the billing account used for resourceusage charges.*Note:* Incurred charges that have not yet been reported in the transactionhistory of the Google Cloud Console may be billed to the new billingaccount, even if the charge occurred before the new billing account wasassigned 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 [billingaccount](https://support.google.com/cloud/answer/4430947).You can disable billing on the project by setting the`billing_account_name` field to empty. This action disassociates thecurrent billing account from the project. Any billable activity of yourin-use services will stop, and your application could stop functioning asexpected. Any unbilled charges to date will be billed to the previouslyassociated account. The current authenticated user must be either an ownerof the project or an owner of the billing account for the project.Note that associating a project with a *closed* billing account will havemuch the same effect as disabling billing on the project: any paidresources used by the project will be shut down. Thus, unless you wish todisable billing, you should always call this method with the name of an*open* billing account.
        /// Documentation https://developers.google.com/cloudbilling/v1/reference/projects/updateBillingInfo
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Cloudbilling service.</param>
        /// <param name="name">The resource name of the project associated with the billing informationthat you want to update. For example, `projects/tokyo-rain-123`.</param>
        /// <param name="body">A valid Cloudbilling v1 body.</param>
        /// <returns>ProjectBillingInfoResponse</returns>
        public static ProjectBillingInfo UpdateBillingInfo(CloudbillingService service, string name, ProjectBillingInfo body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (name == null)
                {
                    throw new ArgumentNullException(name);
                }

                // Make the request.
                return(service.Projects.UpdateBillingInfo(body, name).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Projects.UpdateBillingInfo failed.", ex);
            }
        }
Пример #2
0
        public CloudbillingService GetCloudbillingService()
        {
            CloudbillingService service = new CloudbillingService(
                new BaseClientService.Initializer()
            {
                HttpClientInitializer = GetGoogleCredential(),
                ApplicationName       = _applicationName
            }
                );

            return(service);
        }