Documentation ¶
Overview ¶
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
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 (c *DataPolicyClient) Close() error
- func (c *DataPolicyClient) Connection() *grpc.ClientConndeprecated
- func (c *DataPolicyClient) CreateDataPolicy(ctx context.Context, req *datapoliciespb.CreateDataPolicyRequest, ...) (*datapoliciespb.DataPolicy, error)
- func (c *DataPolicyClient) DeleteDataPolicy(ctx context.Context, req *datapoliciespb.DeleteDataPolicyRequest, ...) error
- func (c *DataPolicyClient) GetDataPolicy(ctx context.Context, req *datapoliciespb.GetDataPolicyRequest, ...) (*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, ...) *DataPolicyIterator
- func (c *DataPolicyClient) RenameDataPolicy(ctx context.Context, req *datapoliciespb.RenameDataPolicyRequest, ...) (*datapoliciespb.DataPolicy, error)
- 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, ...) (*iampb.TestIamPermissionsResponse, error)
- func (c *DataPolicyClient) UpdateDataPolicy(ctx context.Context, req *datapoliciespb.UpdateDataPolicyRequest, ...) (*datapoliciespb.DataPolicy, error)
- type DataPolicyIterator
Examples ¶
- DataPolicyClient.CreateDataPolicy
- DataPolicyClient.DeleteDataPolicy
- DataPolicyClient.GetDataPolicy
- DataPolicyClient.GetIamPolicy
- DataPolicyClient.ListDataPolicies
- DataPolicyClient.RenameDataPolicy
- DataPolicyClient.SetIamPolicy
- DataPolicyClient.TestIamPermissions
- DataPolicyClient.UpdateDataPolicy
- NewDataPolicyClient
- NewDataPolicyRESTClient
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 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.
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.
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 }
Output:
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 }
Output:
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 ¶
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.
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 }
Output:
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.
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. } }
Output:
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.
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 }
Output:
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 "google.golang.org/genproto/googleapis/iam/v1" ) 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/google.golang.org/genproto/googleapis/iam/v1#GetIamPolicyRequest. } resp, err := c.GetIamPolicy(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
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.
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 } }
Output:
func (*DataPolicyClient) RenameDataPolicy ¶
func (c *DataPolicyClient) RenameDataPolicy(ctx context.Context, req *datapoliciespb.RenameDataPolicyRequest, opts ...gax.CallOption) (*datapoliciespb.DataPolicy, error)
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 }
Output:
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 "google.golang.org/genproto/googleapis/iam/v1" ) 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/google.golang.org/genproto/googleapis/iam/v1#SetIamPolicyRequest. } resp, err := c.SetIamPolicy(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
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.
Example ¶
package main import ( "context" datapolicies "cloud.google.com/go/bigquery/datapolicies/apiv1" iampb "google.golang.org/genproto/googleapis/iam/v1" ) 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/google.golang.org/genproto/googleapis/iam/v1#TestIamPermissionsRequest. } resp, err := c.TestIamPermissions(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }
Output:
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.
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 }
Output:
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) 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.