billing

package
v0.61.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package billing is an auto-generated package for the Cloud Billing API.

Allows developers to manage billing for their Google Cloud Platform projects programmatically.

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

For information about setting deadlines, reusing contexts, and more please visit godoc.org/cloud.google.com/go.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

Types

type BillingAccountIterator

type BillingAccountIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*billingpb.BillingAccount, nextPageToken string, err error)
	// contains filtered or unexported fields
}

BillingAccountIterator manages a stream of *billingpb.BillingAccount.

func (*BillingAccountIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*BillingAccountIterator) PageInfo

func (it *BillingAccountIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type CloudBillingCallOptions

type CloudBillingCallOptions struct {
	GetBillingAccount        []gax.CallOption
	ListBillingAccounts      []gax.CallOption
	UpdateBillingAccount     []gax.CallOption
	CreateBillingAccount     []gax.CallOption
	ListProjectBillingInfo   []gax.CallOption
	GetProjectBillingInfo    []gax.CallOption
	UpdateProjectBillingInfo []gax.CallOption
	GetIamPolicy             []gax.CallOption
	SetIamPolicy             []gax.CallOption
	TestIamPermissions       []gax.CallOption
}

CloudBillingCallOptions contains the retry settings for each method of CloudBillingClient.

type CloudBillingClient

type CloudBillingClient struct {

	// The call options for this service.
	CallOptions *CloudBillingCallOptions
	// contains filtered or unexported fields
}

CloudBillingClient is a client for interacting with Cloud Billing API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewCloudBillingClient

func NewCloudBillingClient(ctx context.Context, opts ...option.ClientOption) (*CloudBillingClient, error)

NewCloudBillingClient creates a new cloud billing client.

Retrieves GCP Console billing accounts and associates them with projects.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}
Output:

func (*CloudBillingClient) Close

func (c *CloudBillingClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*CloudBillingClient) Connection

func (c *CloudBillingClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*CloudBillingClient) CreateBillingAccount

CreateBillingAccount creates a billing account. This method can only be used to create billing subaccounts (at 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 (at 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.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.CreateBillingAccountRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.CreateBillingAccount(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) GetBillingAccount

GetBillingAccount gets information about a billing account. The current authenticated user must be a viewer of the billing account (at https://cloud.google.com/billing/docs/how-to/billing-access).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.GetBillingAccountRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetBillingAccount(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) GetIamPolicy

func (c *CloudBillingClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

GetIamPolicy gets the access control policy for a billing account. The caller must have the billing.accounts.getIamPolicy permission on the account, which is often given to billing account viewers (at https://cloud.google.com/billing/docs/how-to/billing-access).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	iampb "google.golang.org/genproto/googleapis/iam/v1"
)

func main() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.GetIamPolicyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) GetProjectBillingInfo

GetProjectBillingInfo gets the billing information for a project. The current authenticated user must have permission to view the project (at https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.GetProjectBillingInfoRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.GetProjectBillingInfo(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) ListBillingAccounts

ListBillingAccounts lists the billing accounts that the current authenticated user has permission to view (at https://cloud.google.com/billing/docs/how-to/billing-access).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
	"google.golang.org/api/iterator"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.ListBillingAccountsRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListBillingAccounts(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*CloudBillingClient) ListProjectBillingInfo

ListProjectBillingInfo lists the projects associated with a billing account. The current authenticated user must have the billing.resourceAssociations.list IAM permission, which is often given to billing account viewers (at https://cloud.google.com/billing/docs/how-to/billing-access).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
	"google.golang.org/api/iterator"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.ListProjectBillingInfoRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListProjectBillingInfo(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*CloudBillingClient) SetIamPolicy

func (c *CloudBillingClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

SetIamPolicy sets the access control policy for a billing account. Replaces any existing policy. The caller must have the billing.accounts.setIamPolicy permission on the account, which is often given to billing account administrators (at https://cloud.google.com/billing/docs/how-to/billing-access).

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	iampb "google.golang.org/genproto/googleapis/iam/v1"
)

func main() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.SetIamPolicyRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.SetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) TestIamPermissions

TestIamPermissions tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	iampb "google.golang.org/genproto/googleapis/iam/v1"
)

func main() {
	// import iampb "google.golang.org/genproto/googleapis/iam/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &iampb.TestIamPermissionsRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.TestIamPermissions(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) UpdateBillingAccount

UpdateBillingAccount updates a billing account’s fields. Currently the only field that can be edited is display_name. The current authenticated user must have the billing.accounts.update IAM permission, which is typically given to the administrator (at https://cloud.google.com/billing/docs/how-to/billing-access) of the billing account.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.UpdateBillingAccountRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateBillingAccount(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*CloudBillingClient) UpdateProjectBillingInfo

UpdateProjectBillingInfo 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 (at https://cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo) and the billing account (at 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.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"

	ctx := context.Background()
	c, err := billing.NewCloudBillingClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.UpdateProjectBillingInfoRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.UpdateProjectBillingInfo(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

type CloudCatalogCallOptions

type CloudCatalogCallOptions struct {
	ListServices []gax.CallOption
	ListSkus     []gax.CallOption
}

CloudCatalogCallOptions contains the retry settings for each method of CloudCatalogClient.

type CloudCatalogClient

type CloudCatalogClient struct {

	// The call options for this service.
	CallOptions *CloudCatalogCallOptions
	// contains filtered or unexported fields
}

CloudCatalogClient is a client for interacting with Cloud Billing API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewCloudCatalogClient

func NewCloudCatalogClient(ctx context.Context, opts ...option.ClientOption) (*CloudCatalogClient, error)

NewCloudCatalogClient creates a new cloud catalog client.

A catalog of Google Cloud Platform services and SKUs. Provides pricing information and metadata on Google Cloud Platform services and SKUs.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := billing.NewCloudCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use client.
	_ = c
}
Output:

func (*CloudCatalogClient) Close

func (c *CloudCatalogClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*CloudCatalogClient) Connection

func (c *CloudCatalogClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*CloudCatalogClient) ListServices

ListServices lists all public cloud services.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
	"google.golang.org/api/iterator"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := billing.NewCloudCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.ListServicesRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListServices(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

func (*CloudCatalogClient) ListSkus

ListSkus lists all publicly available SKUs for a given cloud service.

Example
package main

import (
	"context"

	billing "cloud.google.com/go/billing/apiv1"
	"google.golang.org/api/iterator"

	billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
)

func main() {
	// import billingpb "google.golang.org/genproto/googleapis/cloud/billing/v1"
	// import "google.golang.org/api/iterator"

	ctx := context.Background()
	c, err := billing.NewCloudCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}

	req := &billingpb.ListSkusRequest{
		// TODO: Fill request struct fields.
	}
	it := c.ListSkus(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}
Output:

type ProjectBillingInfoIterator

type ProjectBillingInfoIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*billingpb.ProjectBillingInfo, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ProjectBillingInfoIterator manages a stream of *billingpb.ProjectBillingInfo.

func (*ProjectBillingInfoIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ProjectBillingInfoIterator) PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type ServiceIterator

type ServiceIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*billingpb.Service, nextPageToken string, err error)
	// contains filtered or unexported fields
}

ServiceIterator manages a stream of *billingpb.Service.

func (*ServiceIterator) Next

func (it *ServiceIterator) Next() (*billingpb.Service, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ServiceIterator) PageInfo

func (it *ServiceIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type SkuIterator

type SkuIterator struct {

	// Response is the raw response for the current page.
	// It must be cast to the RPC response type.
	// Calling Next() or InternalFetch() updates this value.
	Response interface{}

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*billingpb.Sku, nextPageToken string, err error)
	// contains filtered or unexported fields
}

SkuIterator manages a stream of *billingpb.Sku.

func (*SkuIterator) Next

func (it *SkuIterator) Next() (*billingpb.Sku, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*SkuIterator) PageInfo

func (it *SkuIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL