package datapolicies
import "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
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 that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/bigquery/datapolicies/apiv1beta1@latest 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, mentioned above.
req := &datapoliciespb.CreateDataPolicyRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1beta1/datapoliciespb#CreateDataPolicyRequest. } resp, err := c.CreateDataPolicy(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
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.
Index ¶
- func DefaultAuthScopes() []string
- type DataPolicyCallOptions
- type DataPolicyClient
- func NewDataPolicyClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error)
- func NewDataPolicyRESTClient(ctx context.Context, opts ...option.ClientOption) (*DataPolicyClient, error)
- func (c *DataPolicyClient) Close() error
- func (c *DataPolicyClient) Connection() *grpc.ClientConn
- func (c *DataPolicyClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
- func (c *DataPolicyClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, opts ...gax.CallOption) error
- func (c *DataPolicyClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
- func (c *DataPolicyClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *DataPolicyClient) ListDataPolicies(ctx context.Context, req *datapoliciespb.ListDataPoliciesRequest, opts ...gax.CallOption) *DataPolicyIterator
- func (c *DataPolicyClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *DataPolicyClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
- func (c *DataPolicyClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
- type DataPolicyIterator
Examples ¶
- DataPolicyClient.CreateDataPolicy
- DataPolicyClient.DeleteDataPolicy
- DataPolicyClient.GetDataPolicy
- DataPolicyClient.GetIamPolicy
- DataPolicyClient.ListDataPolicies
- DataPolicyClient.ListDataPolicies (All)
- DataPolicyClient.SetIamPolicy
- DataPolicyClient.TestIamPermissions
- DataPolicyClient.UpdateDataPolicy
- NewDataPolicyClient
- NewDataPolicyRESTClient
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type DataPolicyCallOptions ¶
type DataPolicyCallOptions struct { CreateDataPolicy []gax.CallOption UpdateDataPolicy []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.
type 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.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
)
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.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
)
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 ¶
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 ¶
func (c *DataPolicyClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
CreateDataPolicy creates a new data policy under a project with the given dataPolicyId
(used as the display name), policy tag, and data policy type.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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/apiv1beta1/datapoliciespb#CreateDataPolicyRequest.
}
resp, err := c.CreateDataPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DataPolicyClient) DeleteDataPolicy ¶
func (c *DataPolicyClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, opts ...gax.CallOption) error
DeleteDataPolicy deletes the data policy specified by its resource name.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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/apiv1beta1/datapoliciespb#DeleteDataPolicyRequest.
}
err = c.DeleteDataPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*DataPolicyClient) GetDataPolicy ¶
func (c *DataPolicyClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
GetDataPolicy gets the data policy specified by its resource name.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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/apiv1beta1/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.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
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 ¶
func (c *DataPolicyClient) ListDataPolicies(ctx context.Context, req *datapoliciespb.ListDataPoliciesRequest, opts ...gax.CallOption) *DataPolicyIterator
ListDataPolicies list all of the data policies in the specified parent project.
Code:play
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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/apiv1beta1/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
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*datapoliciespb.ListDataPoliciesResponse)
}
}
Example (All)¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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.ListDataPoliciesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/datapolicies/apiv1beta1/datapoliciespb#ListDataPoliciesRequest.
}
for resp, err := range c.ListDataPolicies(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any 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.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
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 ¶
func (c *DataPolicyClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
TestIamPermissions returns the caller’s permission on the specified data policy resource.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
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 ¶
func (c *DataPolicyClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
UpdateDataPolicy updates the metadata for an existing data policy. The target data policy
can be specified by the resource name.
Code:play
Example¶
package main
import (
"context"
datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1beta1"
datapoliciespb "cloud.google.com/go/bigquery/datapolicies/apiv1beta1/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/apiv1beta1/datapoliciespb#UpdateDataPolicyRequest.
}
resp, err := c.UpdateDataPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
type 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) All ¶
func (it *DataPolicyIterator) All() iter.Seq2[*datapoliciespb.DataPolicy, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DataPolicyIterator) Next ¶
func (it *DataPolicyIterator) Next() (*datapoliciespb.DataPolicy, 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 (*DataPolicyIterator) PageInfo ¶
func (it *DataPolicyIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Source Files ¶
auxiliary.go auxiliary_go123.go data_policy_client.go doc.go helpers.go version.go
Directories ¶
Path | Synopsis |
---|---|
datapolicies/apiv1beta1/datapoliciespb |
- Version
- v1.66.2 (latest)
- Published
- Feb 4, 2025
- Platform
- linux/amd64
- Imports
- 27 packages
- Last checked
- 15 hours ago –
Tools for package owners.