BigQuery Data Policy API v1 - Package cloud.google.com/go/bigquery/datapolicies/apiv1 (v1.52.0)

Package datapolicies is an auto-generated package for the BigQuery Data Policy API.

Allows users to manage BigQuery data policies.

NOTE: This package is in beta. It is not stable, and may be subject to changes.

General documentation

For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go.

Example usage

To get started with this package, create a client.

ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := datapolicies.NewDataPolicyClient(ctx)
if err != nil {
    // TODO: Handle error.
}
defer c.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client.

ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := datapolicies.NewDataPolicyClient(ctx)
if err != nil {
    // TODO: Handle error.
}
defer c.Close()

req := &datapoliciespb.CreateDataPolicyRequest{
    // TODO: Fill request struct fields.
    // See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#CreateDataPolicyRequest.
}
resp, err := c.CreateDataPolicy(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

Inspecting errors

To see examples of how to inspect errors returned by this package please reference [Inspecting errors](https://pkg.go.dev/cloud.google.com/go#hdr-Inspecting_errors).

Use of Context

The ctx passed to NewDataPolicyClient 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.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

DataPolicyCallOptions

type DataPolicyCallOptions struct {
	CreateDataPolicy   []gax.CallOption
	UpdateDataPolicy   []gax.CallOption
	RenameDataPolicy   []gax.CallOption
	DeleteDataPolicy   []gax.CallOption
	GetDataPolicy      []gax.CallOption
	ListDataPolicies   []gax.CallOption
	GetIamPolicy       []gax.CallOption
	SetIamPolicy       []gax.CallOption
	TestIamPermissions []gax.CallOption
}

DataPolicyCallOptions contains the retry settings for each method of DataPolicyClient.

DataPolicyClient

type DataPolicyClient struct {

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

DataPolicyClient is a client for interacting with BigQuery Data Policy API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Data Policy Service provides APIs for managing the label-policy bindings.

func NewDataPolicyClient

func NewDataPolicyClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error)

NewDataPolicyClient creates a new data policy service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Data Policy Service provides APIs for managing the label-policy bindings.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewDataPolicyRESTClient

func NewDataPolicyRESTClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error)

NewDataPolicyRESTClient creates a new data policy service rest client.

Data Policy Service provides APIs for managing the label-policy bindings.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*DataPolicyClient) Close

func (c *DataPolicyClient) Close() error

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

func (*DataPolicyClient) Connection (deprecated)

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

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*DataPolicyClient) CreateDataPolicy

CreateDataPolicy creates a new data policy under a project with the given dataPolicyId (used as the display name), policy tag, and data policy type.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.CreateDataPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#CreateDataPolicyRequest.
	}
	resp, err := c.CreateDataPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) DeleteDataPolicy

DeleteDataPolicy deletes the data policy specified by its resource name.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.DeleteDataPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#DeleteDataPolicyRequest.
	}
	err = c.DeleteDataPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*DataPolicyClient) GetDataPolicy

GetDataPolicy gets the data policy specified by its resource name.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.GetDataPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#GetDataPolicyRequest.
	}
	resp, err := c.GetDataPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) GetIamPolicy

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

GetIamPolicy gets the IAM policy for the specified data policy.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"

	iampb "cloud.google.com/go/iam/apiv1/iampb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.GetIamPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
	}
	resp, err := c.GetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) ListDataPolicies

ListDataPolicies list all of the data policies in the specified parent project.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
	"google.golang.org/api/iterator"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.ListDataPoliciesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#ListDataPoliciesRequest.
	}
	it := c.ListDataPolicies(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*DataPolicyClient) RenameDataPolicy

RenameDataPolicy renames the id (display name) of the specified data policy.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.RenameDataPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#RenameDataPolicyRequest.
	}
	resp, err := c.RenameDataPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) SetIamPolicy

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

SetIamPolicy sets the IAM policy for the specified data policy.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"

	iampb "cloud.google.com/go/iam/apiv1/iampb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.SetIamPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
	}
	resp, err := c.SetIamPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) TestIamPermissions

TestIamPermissions returns the caller’s permission on the specified data policy resource.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"

	iampb "cloud.google.com/go/iam/apiv1/iampb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &iampb.TestIamPermissionsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
	}
	resp, err := c.TestIamPermissions(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*DataPolicyClient) UpdateDataPolicy

UpdateDataPolicy updates the metadata for an existing data policy. The target data policy can be specified by the resource name.

Example

package main

import (
	"context"

	datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1"
	datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := datapolicies.NewDataPolicyClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &datapoliciespb.UpdateDataPolicyRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1/datapoliciespb#UpdateDataPolicyRequest.
	}
	resp, err := c.UpdateDataPolicy(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

DataPolicyIterator

type DataPolicyIterator 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 []*datapoliciespb.DataPolicy, nextPageToken string, err error)
	// contains filtered or unexported fields
}

DataPolicyIterator manages a stream of *datapoliciespb.DataPolicy.

func (*DataPolicyIterator) 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 (*DataPolicyIterator) PageInfo

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

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