| // Copyright 2024 Google LLC |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // https://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // Code generated by protoc-gen-go_gapic. DO NOT EDIT. |
| |
| package datacatalog |
| |
| import ( |
| "bytes" |
| "context" |
| "fmt" |
| "io" |
| "math" |
| "net/http" |
| "net/url" |
| "time" |
| |
| datacatalogpb "cloud.google.com/go/datacatalog/apiv1beta1/datacatalogpb" |
| iampb "cloud.google.com/go/iam/apiv1/iampb" |
| gax "github.com/googleapis/gax-go/v2" |
| "google.golang.org/api/googleapi" |
| "google.golang.org/api/iterator" |
| "google.golang.org/api/option" |
| "google.golang.org/api/option/internaloption" |
| gtransport "google.golang.org/api/transport/grpc" |
| httptransport "google.golang.org/api/transport/http" |
| "google.golang.org/grpc" |
| "google.golang.org/protobuf/encoding/protojson" |
| "google.golang.org/protobuf/proto" |
| ) |
| |
| var newPolicyTagManagerClientHook clientHook |
| |
| // PolicyTagManagerCallOptions contains the retry settings for each method of PolicyTagManagerClient. |
| type PolicyTagManagerCallOptions struct { |
| CreateTaxonomy []gax.CallOption |
| DeleteTaxonomy []gax.CallOption |
| UpdateTaxonomy []gax.CallOption |
| ListTaxonomies []gax.CallOption |
| GetTaxonomy []gax.CallOption |
| CreatePolicyTag []gax.CallOption |
| DeletePolicyTag []gax.CallOption |
| UpdatePolicyTag []gax.CallOption |
| ListPolicyTags []gax.CallOption |
| GetPolicyTag []gax.CallOption |
| GetIamPolicy []gax.CallOption |
| SetIamPolicy []gax.CallOption |
| TestIamPermissions []gax.CallOption |
| } |
| |
| func defaultPolicyTagManagerGRPCClientOptions() []option.ClientOption { |
| return []option.ClientOption{ |
| internaloption.WithDefaultEndpoint("datacatalog.googleapis.com:443"), |
| internaloption.WithDefaultEndpointTemplate("datacatalog.UNIVERSE_DOMAIN:443"), |
| internaloption.WithDefaultMTLSEndpoint("datacatalog.mtls.googleapis.com:443"), |
| internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| internaloption.WithDefaultAudience("https://datacatalog.googleapis.com/"), |
| internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| internaloption.EnableJwtWithScope(), |
| option.WithGRPCDialOption(grpc.WithDefaultCallOptions( |
| grpc.MaxCallRecvMsgSize(math.MaxInt32))), |
| } |
| } |
| |
| func defaultPolicyTagManagerCallOptions() *PolicyTagManagerCallOptions { |
| return &PolicyTagManagerCallOptions{ |
| CreateTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| DeleteTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| UpdateTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| ListTaxonomies: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| CreatePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| DeletePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| UpdatePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| ListPolicyTags: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetPolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetIamPolicy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| SetIamPolicy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| TestIamPermissions: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| } |
| } |
| |
| func defaultPolicyTagManagerRESTCallOptions() *PolicyTagManagerCallOptions { |
| return &PolicyTagManagerCallOptions{ |
| CreateTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| DeleteTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| UpdateTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| ListTaxonomies: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetTaxonomy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| CreatePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| DeletePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| UpdatePolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| ListPolicyTags: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetPolicyTag: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| GetIamPolicy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| SetIamPolicy: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| TestIamPermissions: []gax.CallOption{ |
| gax.WithTimeout(60000 * time.Millisecond), |
| }, |
| } |
| } |
| |
| // internalPolicyTagManagerClient is an interface that defines the methods available from Google Cloud Data Catalog API. |
| type internalPolicyTagManagerClient interface { |
| Close() error |
| setGoogleClientInfo(...string) |
| Connection() *grpc.ClientConn |
| CreateTaxonomy(context.Context, *datacatalogpb.CreateTaxonomyRequest, ...gax.CallOption) (*datacatalogpb.Taxonomy, error) |
| DeleteTaxonomy(context.Context, *datacatalogpb.DeleteTaxonomyRequest, ...gax.CallOption) error |
| UpdateTaxonomy(context.Context, *datacatalogpb.UpdateTaxonomyRequest, ...gax.CallOption) (*datacatalogpb.Taxonomy, error) |
| ListTaxonomies(context.Context, *datacatalogpb.ListTaxonomiesRequest, ...gax.CallOption) *TaxonomyIterator |
| GetTaxonomy(context.Context, *datacatalogpb.GetTaxonomyRequest, ...gax.CallOption) (*datacatalogpb.Taxonomy, error) |
| CreatePolicyTag(context.Context, *datacatalogpb.CreatePolicyTagRequest, ...gax.CallOption) (*datacatalogpb.PolicyTag, error) |
| DeletePolicyTag(context.Context, *datacatalogpb.DeletePolicyTagRequest, ...gax.CallOption) error |
| UpdatePolicyTag(context.Context, *datacatalogpb.UpdatePolicyTagRequest, ...gax.CallOption) (*datacatalogpb.PolicyTag, error) |
| ListPolicyTags(context.Context, *datacatalogpb.ListPolicyTagsRequest, ...gax.CallOption) *PolicyTagIterator |
| GetPolicyTag(context.Context, *datacatalogpb.GetPolicyTagRequest, ...gax.CallOption) (*datacatalogpb.PolicyTag, error) |
| GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) |
| SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) |
| TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) |
| } |
| |
| // PolicyTagManagerClient is a client for interacting with Google Cloud Data Catalog API. |
| // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| // |
| // The policy tag manager API service allows clients to manage their taxonomies |
| // and policy tags. |
| type PolicyTagManagerClient struct { |
| // The internal transport-dependent client. |
| internalClient internalPolicyTagManagerClient |
| |
| // The call options for this service. |
| CallOptions *PolicyTagManagerCallOptions |
| } |
| |
| // Wrapper methods routed to the internal client. |
| |
| // Close closes the connection to the API service. The user should invoke this when |
| // the client is no longer required. |
| func (c *PolicyTagManagerClient) Close() error { |
| return c.internalClient.Close() |
| } |
| |
| // setGoogleClientInfo sets the name and version of the application in |
| // the `x-goog-api-client` header passed on each request. Intended for |
| // use by Google-written clients. |
| func (c *PolicyTagManagerClient) setGoogleClientInfo(keyval ...string) { |
| c.internalClient.setGoogleClientInfo(keyval...) |
| } |
| |
| // Connection returns a connection to the API service. |
| // |
| // Deprecated: Connections are now pooled so this method does not always |
| // return the same resource. |
| func (c *PolicyTagManagerClient) Connection() *grpc.ClientConn { |
| return c.internalClient.Connection() |
| } |
| |
| // CreateTaxonomy creates a taxonomy in the specified project. |
| func (c *PolicyTagManagerClient) CreateTaxonomy(ctx context.Context, req *datacatalogpb.CreateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| return c.internalClient.CreateTaxonomy(ctx, req, opts...) |
| } |
| |
| // DeleteTaxonomy deletes a taxonomy. This operation will also delete all |
| // policy tags in this taxonomy along with their associated policies. |
| func (c *PolicyTagManagerClient) DeleteTaxonomy(ctx context.Context, req *datacatalogpb.DeleteTaxonomyRequest, opts ...gax.CallOption) error { |
| return c.internalClient.DeleteTaxonomy(ctx, req, opts...) |
| } |
| |
| // UpdateTaxonomy updates a taxonomy. |
| func (c *PolicyTagManagerClient) UpdateTaxonomy(ctx context.Context, req *datacatalogpb.UpdateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| return c.internalClient.UpdateTaxonomy(ctx, req, opts...) |
| } |
| |
| // ListTaxonomies lists all taxonomies in a project in a particular location that the caller |
| // has permission to view. |
| func (c *PolicyTagManagerClient) ListTaxonomies(ctx context.Context, req *datacatalogpb.ListTaxonomiesRequest, opts ...gax.CallOption) *TaxonomyIterator { |
| return c.internalClient.ListTaxonomies(ctx, req, opts...) |
| } |
| |
| // GetTaxonomy gets a taxonomy. |
| func (c *PolicyTagManagerClient) GetTaxonomy(ctx context.Context, req *datacatalogpb.GetTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| return c.internalClient.GetTaxonomy(ctx, req, opts...) |
| } |
| |
| // CreatePolicyTag creates a policy tag in the specified taxonomy. |
| func (c *PolicyTagManagerClient) CreatePolicyTag(ctx context.Context, req *datacatalogpb.CreatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| return c.internalClient.CreatePolicyTag(ctx, req, opts...) |
| } |
| |
| // DeletePolicyTag deletes a policy tag. Also deletes all of its descendant policy tags. |
| func (c *PolicyTagManagerClient) DeletePolicyTag(ctx context.Context, req *datacatalogpb.DeletePolicyTagRequest, opts ...gax.CallOption) error { |
| return c.internalClient.DeletePolicyTag(ctx, req, opts...) |
| } |
| |
| // UpdatePolicyTag updates a policy tag. |
| func (c *PolicyTagManagerClient) UpdatePolicyTag(ctx context.Context, req *datacatalogpb.UpdatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| return c.internalClient.UpdatePolicyTag(ctx, req, opts...) |
| } |
| |
| // ListPolicyTags lists all policy tags in a taxonomy. |
| func (c *PolicyTagManagerClient) ListPolicyTags(ctx context.Context, req *datacatalogpb.ListPolicyTagsRequest, opts ...gax.CallOption) *PolicyTagIterator { |
| return c.internalClient.ListPolicyTags(ctx, req, opts...) |
| } |
| |
| // GetPolicyTag gets a policy tag. |
| func (c *PolicyTagManagerClient) GetPolicyTag(ctx context.Context, req *datacatalogpb.GetPolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| return c.internalClient.GetPolicyTag(ctx, req, opts...) |
| } |
| |
| // GetIamPolicy gets the IAM policy for a taxonomy or a policy tag. |
| func (c *PolicyTagManagerClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| return c.internalClient.GetIamPolicy(ctx, req, opts...) |
| } |
| |
| // SetIamPolicy sets the IAM policy for a taxonomy or a policy tag. |
| func (c *PolicyTagManagerClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| return c.internalClient.SetIamPolicy(ctx, req, opts...) |
| } |
| |
| // TestIamPermissions returns the permissions that a caller has on the specified taxonomy or |
| // policy tag. |
| func (c *PolicyTagManagerClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { |
| return c.internalClient.TestIamPermissions(ctx, req, opts...) |
| } |
| |
| // policyTagManagerGRPCClient is a client for interacting with Google Cloud Data Catalog API over gRPC transport. |
| // |
| // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| type policyTagManagerGRPCClient struct { |
| // Connection pool of gRPC connections to the service. |
| connPool gtransport.ConnPool |
| |
| // Points back to the CallOptions field of the containing PolicyTagManagerClient |
| CallOptions **PolicyTagManagerCallOptions |
| |
| // The gRPC API client. |
| policyTagManagerClient datacatalogpb.PolicyTagManagerClient |
| |
| // The x-goog-* metadata to be sent with each request. |
| xGoogHeaders []string |
| } |
| |
| // NewPolicyTagManagerClient creates a new policy tag manager client based on gRPC. |
| // The returned client must be Closed when it is done being used to clean up its underlying connections. |
| // |
| // The policy tag manager API service allows clients to manage their taxonomies |
| // and policy tags. |
| func NewPolicyTagManagerClient(ctx context.Context, opts ...option.ClientOption) (*PolicyTagManagerClient, error) { |
| clientOpts := defaultPolicyTagManagerGRPCClientOptions() |
| if newPolicyTagManagerClientHook != nil { |
| hookOpts, err := newPolicyTagManagerClientHook(ctx, clientHookParams{}) |
| if err != nil { |
| return nil, err |
| } |
| clientOpts = append(clientOpts, hookOpts...) |
| } |
| |
| connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) |
| if err != nil { |
| return nil, err |
| } |
| client := PolicyTagManagerClient{CallOptions: defaultPolicyTagManagerCallOptions()} |
| |
| c := &policyTagManagerGRPCClient{ |
| connPool: connPool, |
| policyTagManagerClient: datacatalogpb.NewPolicyTagManagerClient(connPool), |
| CallOptions: &client.CallOptions, |
| } |
| c.setGoogleClientInfo() |
| |
| client.internalClient = c |
| |
| return &client, nil |
| } |
| |
| // Connection returns a connection to the API service. |
| // |
| // Deprecated: Connections are now pooled so this method does not always |
| // return the same resource. |
| func (c *policyTagManagerGRPCClient) Connection() *grpc.ClientConn { |
| return c.connPool.Conn() |
| } |
| |
| // setGoogleClientInfo sets the name and version of the application in |
| // the `x-goog-api-client` header passed on each request. Intended for |
| // use by Google-written clients. |
| func (c *policyTagManagerGRPCClient) setGoogleClientInfo(keyval ...string) { |
| kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version) |
| c.xGoogHeaders = []string{ |
| "x-goog-api-client", gax.XGoogHeader(kv...), |
| } |
| } |
| |
| // Close closes the connection to the API service. The user should invoke this when |
| // the client is no longer required. |
| func (c *policyTagManagerGRPCClient) Close() error { |
| return c.connPool.Close() |
| } |
| |
| // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. |
| type policyTagManagerRESTClient struct { |
| // The http endpoint to connect to. |
| endpoint string |
| |
| // The http client. |
| httpClient *http.Client |
| |
| // The x-goog-* headers to be sent with each request. |
| xGoogHeaders []string |
| |
| // Points back to the CallOptions field of the containing PolicyTagManagerClient |
| CallOptions **PolicyTagManagerCallOptions |
| } |
| |
| // NewPolicyTagManagerRESTClient creates a new policy tag manager rest client. |
| // |
| // The policy tag manager API service allows clients to manage their taxonomies |
| // and policy tags. |
| func NewPolicyTagManagerRESTClient(ctx context.Context, opts ...option.ClientOption) (*PolicyTagManagerClient, error) { |
| clientOpts := append(defaultPolicyTagManagerRESTClientOptions(), opts...) |
| httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) |
| if err != nil { |
| return nil, err |
| } |
| |
| callOpts := defaultPolicyTagManagerRESTCallOptions() |
| c := &policyTagManagerRESTClient{ |
| endpoint: endpoint, |
| httpClient: httpClient, |
| CallOptions: &callOpts, |
| } |
| c.setGoogleClientInfo() |
| |
| return &PolicyTagManagerClient{internalClient: c, CallOptions: callOpts}, nil |
| } |
| |
| func defaultPolicyTagManagerRESTClientOptions() []option.ClientOption { |
| return []option.ClientOption{ |
| internaloption.WithDefaultEndpoint("https://datacatalog.googleapis.com"), |
| internaloption.WithDefaultEndpointTemplate("https://datacatalog.UNIVERSE_DOMAIN"), |
| internaloption.WithDefaultMTLSEndpoint("https://datacatalog.mtls.googleapis.com"), |
| internaloption.WithDefaultUniverseDomain("googleapis.com"), |
| internaloption.WithDefaultAudience("https://datacatalog.googleapis.com/"), |
| internaloption.WithDefaultScopes(DefaultAuthScopes()...), |
| } |
| } |
| |
| // setGoogleClientInfo sets the name and version of the application in |
| // the `x-goog-api-client` header passed on each request. Intended for |
| // use by Google-written clients. |
| func (c *policyTagManagerRESTClient) setGoogleClientInfo(keyval ...string) { |
| kv := append([]string{"gl-go", gax.GoVersion}, keyval...) |
| kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN") |
| c.xGoogHeaders = []string{ |
| "x-goog-api-client", gax.XGoogHeader(kv...), |
| } |
| } |
| |
| // Close closes the connection to the API service. The user should invoke this when |
| // the client is no longer required. |
| func (c *policyTagManagerRESTClient) Close() error { |
| // Replace httpClient with nil to force cleanup. |
| c.httpClient = nil |
| return nil |
| } |
| |
| // Connection returns a connection to the API service. |
| // |
| // Deprecated: This method always returns nil. |
| func (c *policyTagManagerRESTClient) Connection() *grpc.ClientConn { |
| return nil |
| } |
| func (c *policyTagManagerGRPCClient) CreateTaxonomy(ctx context.Context, req *datacatalogpb.CreateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).CreateTaxonomy[0:len((*c.CallOptions).CreateTaxonomy):len((*c.CallOptions).CreateTaxonomy)], opts...) |
| var resp *datacatalogpb.Taxonomy |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.CreateTaxonomy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) DeleteTaxonomy(ctx context.Context, req *datacatalogpb.DeleteTaxonomyRequest, opts ...gax.CallOption) error { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).DeleteTaxonomy[0:len((*c.CallOptions).DeleteTaxonomy):len((*c.CallOptions).DeleteTaxonomy)], opts...) |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| _, err = c.policyTagManagerClient.DeleteTaxonomy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| return err |
| } |
| |
| func (c *policyTagManagerGRPCClient) UpdateTaxonomy(ctx context.Context, req *datacatalogpb.UpdateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "taxonomy.name", url.QueryEscape(req.GetTaxonomy().GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).UpdateTaxonomy[0:len((*c.CallOptions).UpdateTaxonomy):len((*c.CallOptions).UpdateTaxonomy)], opts...) |
| var resp *datacatalogpb.Taxonomy |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.UpdateTaxonomy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) ListTaxonomies(ctx context.Context, req *datacatalogpb.ListTaxonomiesRequest, opts ...gax.CallOption) *TaxonomyIterator { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).ListTaxonomies[0:len((*c.CallOptions).ListTaxonomies):len((*c.CallOptions).ListTaxonomies)], opts...) |
| it := &TaxonomyIterator{} |
| req = proto.Clone(req).(*datacatalogpb.ListTaxonomiesRequest) |
| it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.Taxonomy, string, error) { |
| resp := &datacatalogpb.ListTaxonomiesResponse{} |
| if pageToken != "" { |
| req.PageToken = pageToken |
| } |
| if pageSize > math.MaxInt32 { |
| req.PageSize = math.MaxInt32 |
| } else if pageSize != 0 { |
| req.PageSize = int32(pageSize) |
| } |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.ListTaxonomies(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, "", err |
| } |
| |
| it.Response = resp |
| return resp.GetTaxonomies(), resp.GetNextPageToken(), nil |
| } |
| fetch := func(pageSize int, pageToken string) (string, error) { |
| items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| if err != nil { |
| return "", err |
| } |
| it.items = append(it.items, items...) |
| return nextPageToken, nil |
| } |
| |
| it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| it.pageInfo.MaxSize = int(req.GetPageSize()) |
| it.pageInfo.Token = req.GetPageToken() |
| |
| return it |
| } |
| |
| func (c *policyTagManagerGRPCClient) GetTaxonomy(ctx context.Context, req *datacatalogpb.GetTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).GetTaxonomy[0:len((*c.CallOptions).GetTaxonomy):len((*c.CallOptions).GetTaxonomy)], opts...) |
| var resp *datacatalogpb.Taxonomy |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.GetTaxonomy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) CreatePolicyTag(ctx context.Context, req *datacatalogpb.CreatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).CreatePolicyTag[0:len((*c.CallOptions).CreatePolicyTag):len((*c.CallOptions).CreatePolicyTag)], opts...) |
| var resp *datacatalogpb.PolicyTag |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.CreatePolicyTag(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) DeletePolicyTag(ctx context.Context, req *datacatalogpb.DeletePolicyTagRequest, opts ...gax.CallOption) error { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).DeletePolicyTag[0:len((*c.CallOptions).DeletePolicyTag):len((*c.CallOptions).DeletePolicyTag)], opts...) |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| _, err = c.policyTagManagerClient.DeletePolicyTag(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| return err |
| } |
| |
| func (c *policyTagManagerGRPCClient) UpdatePolicyTag(ctx context.Context, req *datacatalogpb.UpdatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "policy_tag.name", url.QueryEscape(req.GetPolicyTag().GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).UpdatePolicyTag[0:len((*c.CallOptions).UpdatePolicyTag):len((*c.CallOptions).UpdatePolicyTag)], opts...) |
| var resp *datacatalogpb.PolicyTag |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.UpdatePolicyTag(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) ListPolicyTags(ctx context.Context, req *datacatalogpb.ListPolicyTagsRequest, opts ...gax.CallOption) *PolicyTagIterator { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).ListPolicyTags[0:len((*c.CallOptions).ListPolicyTags):len((*c.CallOptions).ListPolicyTags)], opts...) |
| it := &PolicyTagIterator{} |
| req = proto.Clone(req).(*datacatalogpb.ListPolicyTagsRequest) |
| it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.PolicyTag, string, error) { |
| resp := &datacatalogpb.ListPolicyTagsResponse{} |
| if pageToken != "" { |
| req.PageToken = pageToken |
| } |
| if pageSize > math.MaxInt32 { |
| req.PageSize = math.MaxInt32 |
| } else if pageSize != 0 { |
| req.PageSize = int32(pageSize) |
| } |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.ListPolicyTags(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, "", err |
| } |
| |
| it.Response = resp |
| return resp.GetPolicyTags(), resp.GetNextPageToken(), nil |
| } |
| fetch := func(pageSize int, pageToken string) (string, error) { |
| items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| if err != nil { |
| return "", err |
| } |
| it.items = append(it.items, items...) |
| return nextPageToken, nil |
| } |
| |
| it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| it.pageInfo.MaxSize = int(req.GetPageSize()) |
| it.pageInfo.Token = req.GetPageToken() |
| |
| return it |
| } |
| |
| func (c *policyTagManagerGRPCClient) GetPolicyTag(ctx context.Context, req *datacatalogpb.GetPolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).GetPolicyTag[0:len((*c.CallOptions).GetPolicyTag):len((*c.CallOptions).GetPolicyTag)], opts...) |
| var resp *datacatalogpb.PolicyTag |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.GetPolicyTag(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) |
| var resp *iampb.Policy |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.GetIamPolicy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) |
| var resp *iampb.Policy |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.SetIamPolicy(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| func (c *policyTagManagerGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) |
| opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) |
| var resp *iampb.TestIamPermissionsResponse |
| err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| var err error |
| resp, err = c.policyTagManagerClient.TestIamPermissions(ctx, req, settings.GRPC...) |
| return err |
| }, opts...) |
| if err != nil { |
| return nil, err |
| } |
| return resp, nil |
| } |
| |
| // CreateTaxonomy creates a taxonomy in the specified project. |
| func (c *policyTagManagerRESTClient) CreateTaxonomy(ctx context.Context, req *datacatalogpb.CreateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| body := req.GetTaxonomy() |
| jsonReq, err := m.Marshal(body) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v/taxonomies", req.GetParent()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).CreateTaxonomy[0:len((*c.CallOptions).CreateTaxonomy):len((*c.CallOptions).CreateTaxonomy)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.Taxonomy{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // DeleteTaxonomy deletes a taxonomy. This operation will also delete all |
| // policy tags in this taxonomy along with their associated policies. |
| func (c *policyTagManagerRESTClient) DeleteTaxonomy(ctx context.Context, req *datacatalogpb.DeleteTaxonomyRequest, opts ...gax.CallOption) error { |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| // Returns nil if there is no error, otherwise wraps |
| // the response code and body into a non-nil error |
| return googleapi.CheckResponse(httpRsp) |
| }, opts...) |
| } |
| |
| // UpdateTaxonomy updates a taxonomy. |
| func (c *policyTagManagerRESTClient) UpdateTaxonomy(ctx context.Context, req *datacatalogpb.UpdateTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| body := req.GetTaxonomy() |
| jsonReq, err := m.Marshal(body) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTaxonomy().GetName()) |
| |
| params := url.Values{} |
| if req.GetUpdateMask() != nil { |
| updateMask, err := protojson.Marshal(req.GetUpdateMask()) |
| if err != nil { |
| return nil, err |
| } |
| params.Add("updateMask", string(updateMask[1:len(updateMask)-1])) |
| } |
| |
| baseUrl.RawQuery = params.Encode() |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "taxonomy.name", url.QueryEscape(req.GetTaxonomy().GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).UpdateTaxonomy[0:len((*c.CallOptions).UpdateTaxonomy):len((*c.CallOptions).UpdateTaxonomy)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.Taxonomy{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // ListTaxonomies lists all taxonomies in a project in a particular location that the caller |
| // has permission to view. |
| func (c *policyTagManagerRESTClient) ListTaxonomies(ctx context.Context, req *datacatalogpb.ListTaxonomiesRequest, opts ...gax.CallOption) *TaxonomyIterator { |
| it := &TaxonomyIterator{} |
| req = proto.Clone(req).(*datacatalogpb.ListTaxonomiesRequest) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.Taxonomy, string, error) { |
| resp := &datacatalogpb.ListTaxonomiesResponse{} |
| if pageToken != "" { |
| req.PageToken = pageToken |
| } |
| if pageSize > math.MaxInt32 { |
| req.PageSize = math.MaxInt32 |
| } else if pageSize != 0 { |
| req.PageSize = int32(pageSize) |
| } |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, "", err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v/taxonomies", req.GetParent()) |
| |
| params := url.Values{} |
| if req.GetFilter() != "" { |
| params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) |
| } |
| if req.GetPageSize() != 0 { |
| params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| } |
| if req.GetPageToken() != "" { |
| params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| } |
| |
| baseUrl.RawQuery = params.Encode() |
| |
| // Build HTTP headers from client and context metadata. |
| hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, "", e |
| } |
| it.Response = resp |
| return resp.GetTaxonomies(), resp.GetNextPageToken(), nil |
| } |
| |
| fetch := func(pageSize int, pageToken string) (string, error) { |
| items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| if err != nil { |
| return "", err |
| } |
| it.items = append(it.items, items...) |
| return nextPageToken, nil |
| } |
| |
| it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| it.pageInfo.MaxSize = int(req.GetPageSize()) |
| it.pageInfo.Token = req.GetPageToken() |
| |
| return it |
| } |
| |
| // GetTaxonomy gets a taxonomy. |
| func (c *policyTagManagerRESTClient) GetTaxonomy(ctx context.Context, req *datacatalogpb.GetTaxonomyRequest, opts ...gax.CallOption) (*datacatalogpb.Taxonomy, error) { |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).GetTaxonomy[0:len((*c.CallOptions).GetTaxonomy):len((*c.CallOptions).GetTaxonomy)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.Taxonomy{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // CreatePolicyTag creates a policy tag in the specified taxonomy. |
| func (c *policyTagManagerRESTClient) CreatePolicyTag(ctx context.Context, req *datacatalogpb.CreatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| body := req.GetPolicyTag() |
| jsonReq, err := m.Marshal(body) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v/policyTags", req.GetParent()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).CreatePolicyTag[0:len((*c.CallOptions).CreatePolicyTag):len((*c.CallOptions).CreatePolicyTag)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.PolicyTag{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // DeletePolicyTag deletes a policy tag. Also deletes all of its descendant policy tags. |
| func (c *policyTagManagerRESTClient) DeletePolicyTag(ctx context.Context, req *datacatalogpb.DeletePolicyTagRequest, opts ...gax.CallOption) error { |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| // Returns nil if there is no error, otherwise wraps |
| // the response code and body into a non-nil error |
| return googleapi.CheckResponse(httpRsp) |
| }, opts...) |
| } |
| |
| // UpdatePolicyTag updates a policy tag. |
| func (c *policyTagManagerRESTClient) UpdatePolicyTag(ctx context.Context, req *datacatalogpb.UpdatePolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| body := req.GetPolicyTag() |
| jsonReq, err := m.Marshal(body) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetPolicyTag().GetName()) |
| |
| params := url.Values{} |
| if req.GetUpdateMask() != nil { |
| updateMask, err := protojson.Marshal(req.GetUpdateMask()) |
| if err != nil { |
| return nil, err |
| } |
| params.Add("updateMask", string(updateMask[1:len(updateMask)-1])) |
| } |
| |
| baseUrl.RawQuery = params.Encode() |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "policy_tag.name", url.QueryEscape(req.GetPolicyTag().GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).UpdatePolicyTag[0:len((*c.CallOptions).UpdatePolicyTag):len((*c.CallOptions).UpdatePolicyTag)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.PolicyTag{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // ListPolicyTags lists all policy tags in a taxonomy. |
| func (c *policyTagManagerRESTClient) ListPolicyTags(ctx context.Context, req *datacatalogpb.ListPolicyTagsRequest, opts ...gax.CallOption) *PolicyTagIterator { |
| it := &PolicyTagIterator{} |
| req = proto.Clone(req).(*datacatalogpb.ListPolicyTagsRequest) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| it.InternalFetch = func(pageSize int, pageToken string) ([]*datacatalogpb.PolicyTag, string, error) { |
| resp := &datacatalogpb.ListPolicyTagsResponse{} |
| if pageToken != "" { |
| req.PageToken = pageToken |
| } |
| if pageSize > math.MaxInt32 { |
| req.PageSize = math.MaxInt32 |
| } else if pageSize != 0 { |
| req.PageSize = int32(pageSize) |
| } |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, "", err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v/policyTags", req.GetParent()) |
| |
| params := url.Values{} |
| if req.GetPageSize() != 0 { |
| params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) |
| } |
| if req.GetPageToken() != "" { |
| params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) |
| } |
| |
| baseUrl.RawQuery = params.Encode() |
| |
| // Build HTTP headers from client and context metadata. |
| hds := append(c.xGoogHeaders, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, "", e |
| } |
| it.Response = resp |
| return resp.GetPolicyTags(), resp.GetNextPageToken(), nil |
| } |
| |
| fetch := func(pageSize int, pageToken string) (string, error) { |
| items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) |
| if err != nil { |
| return "", err |
| } |
| it.items = append(it.items, items...) |
| return nextPageToken, nil |
| } |
| |
| it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) |
| it.pageInfo.MaxSize = int(req.GetPageSize()) |
| it.pageInfo.Token = req.GetPageToken() |
| |
| return it |
| } |
| |
| // GetPolicyTag gets a policy tag. |
| func (c *policyTagManagerRESTClient) GetPolicyTag(ctx context.Context, req *datacatalogpb.GetPolicyTagRequest, opts ...gax.CallOption) (*datacatalogpb.PolicyTag, error) { |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).GetPolicyTag[0:len((*c.CallOptions).GetPolicyTag):len((*c.CallOptions).GetPolicyTag)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &datacatalogpb.PolicyTag{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // GetIamPolicy gets the IAM policy for a taxonomy or a policy tag. |
| func (c *policyTagManagerRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| jsonReq, err := m.Marshal(req) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &iampb.Policy{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // SetIamPolicy sets the IAM policy for a taxonomy or a policy tag. |
| func (c *policyTagManagerRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| jsonReq, err := m.Marshal(req) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &iampb.Policy{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |
| |
| // TestIamPermissions returns the permissions that a caller has on the specified taxonomy or |
| // policy tag. |
| func (c *policyTagManagerRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { |
| m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} |
| jsonReq, err := m.Marshal(req) |
| if err != nil { |
| return nil, err |
| } |
| |
| baseUrl, err := url.Parse(c.endpoint) |
| if err != nil { |
| return nil, err |
| } |
| baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource()) |
| |
| // Build HTTP headers from client and context metadata. |
| hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} |
| |
| hds = append(c.xGoogHeaders, hds...) |
| hds = append(hds, "Content-Type", "application/json") |
| headers := gax.BuildHeaders(ctx, hds...) |
| opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) |
| unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} |
| resp := &iampb.TestIamPermissionsResponse{} |
| e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { |
| if settings.Path != "" { |
| baseUrl.Path = settings.Path |
| } |
| httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) |
| if err != nil { |
| return err |
| } |
| httpReq = httpReq.WithContext(ctx) |
| httpReq.Header = headers |
| |
| httpRsp, err := c.httpClient.Do(httpReq) |
| if err != nil { |
| return err |
| } |
| defer httpRsp.Body.Close() |
| |
| if err = googleapi.CheckResponse(httpRsp); err != nil { |
| return err |
| } |
| |
| buf, err := io.ReadAll(httpRsp.Body) |
| if err != nil { |
| return err |
| } |
| |
| if err := unm.Unmarshal(buf, resp); err != nil { |
| return err |
| } |
| |
| return nil |
| }, opts...) |
| if e != nil { |
| return nil, e |
| } |
| return resp, nil |
| } |