diff --git a/dataplex/apiv1/content_client.go b/dataplex/apiv1/content_client.go index 04e989c6f69..dfcf4769570 100644 --- a/dataplex/apiv1/content_client.go +++ b/dataplex/apiv1/content_client.go @@ -21,6 +21,7 @@ import ( "fmt" "math" "net/url" + "time" gax "github.com/googleapis/gax-go/v2" "google.golang.org/api/iterator" @@ -28,7 +29,11 @@ import ( "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" + iampb "google.golang.org/genproto/googleapis/iam/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/proto" ) @@ -37,11 +42,20 @@ var newContentClientHook clientHook // ContentCallOptions contains the retry settings for each method of ContentClient. type ContentCallOptions struct { - CreateContent []gax.CallOption - UpdateContent []gax.CallOption - DeleteContent []gax.CallOption - GetContent []gax.CallOption - ListContent []gax.CallOption + CreateContent []gax.CallOption + UpdateContent []gax.CallOption + DeleteContent []gax.CallOption + GetContent []gax.CallOption + GetIamPolicy []gax.CallOption + SetIamPolicy []gax.CallOption + TestIamPermissions []gax.CallOption + ListContent []gax.CallOption + GetLocation []gax.CallOption + ListLocations []gax.CallOption + CancelOperation []gax.CallOption + DeleteOperation []gax.CallOption + GetOperation []gax.CallOption + ListOperations []gax.CallOption } func defaultContentGRPCClientOptions() []option.ClientOption { @@ -61,8 +75,57 @@ func defaultContentCallOptions() *ContentCallOptions { CreateContent: []gax.CallOption{}, UpdateContent: []gax.CallOption{}, DeleteContent: []gax.CallOption{}, - GetContent: []gax.CallOption{}, - ListContent: []gax.CallOption{}, + GetContent: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetIamPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + SetIamPolicy: []gax.CallOption{}, + TestIamPermissions: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListContent: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetLocation: []gax.CallOption{}, + ListLocations: []gax.CallOption{}, + CancelOperation: []gax.CallOption{}, + DeleteOperation: []gax.CallOption{}, + GetOperation: []gax.CallOption{}, + ListOperations: []gax.CallOption{}, } } @@ -75,7 +138,16 @@ type internalContentClient interface { UpdateContent(context.Context, *dataplexpb.UpdateContentRequest, ...gax.CallOption) (*dataplexpb.Content, error) DeleteContent(context.Context, *dataplexpb.DeleteContentRequest, ...gax.CallOption) error GetContent(context.Context, *dataplexpb.GetContentRequest, ...gax.CallOption) (*dataplexpb.Content, 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) ListContent(context.Context, *dataplexpb.ListContentRequest, ...gax.CallOption) *ContentIterator + GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) + ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator + CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error + DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error + GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) + ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator } // ContentClient is a client for interacting with Cloud Dataplex API. @@ -132,11 +204,74 @@ func (c *ContentClient) GetContent(ctx context.Context, req *dataplexpb.GetConte return c.internalClient.GetContent(ctx, req, opts...) } +// GetIamPolicy gets the access control policy for a contentitem resource. A NOT_FOUND +// error is returned if the resource does not exist. An empty policy is +// returned if the resource exists but does not have a policy set on it. +// +// Caller must have Google IAM dataplex.content.getIamPolicy permission +// on the resource. +func (c *ContentClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.GetIamPolicy(ctx, req, opts...) +} + +// SetIamPolicy sets the access control policy on the specified contentitem resource. +// Replaces any existing policy. +// +// Caller must have Google IAM dataplex.content.setIamPolicy permission +// on the resource. +func (c *ContentClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.SetIamPolicy(ctx, req, opts...) +} + +// TestIamPermissions returns the caller’s permissions on a resource. +// If the resource does not exist, an empty set of +// permissions is returned (a NOT_FOUND error is not returned). +// +// A caller is not required to have Google IAM permission to make this +// request. +// +// Note: This operation is designed to be used for building permission-aware +// UIs and command-line tools, not for authorization checking. This operation +// may “fail open” without warning. +func (c *ContentClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + return c.internalClient.TestIamPermissions(ctx, req, opts...) +} + // ListContent list content. func (c *ContentClient) ListContent(ctx context.Context, req *dataplexpb.ListContentRequest, opts ...gax.CallOption) *ContentIterator { return c.internalClient.ListContent(ctx, req, opts...) } +// GetLocation gets information about a location. +func (c *ContentClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + return c.internalClient.GetLocation(ctx, req, opts...) +} + +// ListLocations lists information about the supported locations for this service. +func (c *ContentClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + return c.internalClient.ListLocations(ctx, req, opts...) +} + +// CancelOperation is a utility method from google.longrunning.Operations. +func (c *ContentClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.CancelOperation(ctx, req, opts...) +} + +// DeleteOperation is a utility method from google.longrunning.Operations. +func (c *ContentClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteOperation(ctx, req, opts...) +} + +// GetOperation is a utility method from google.longrunning.Operations. +func (c *ContentClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + return c.internalClient.GetOperation(ctx, req, opts...) +} + +// ListOperations is a utility method from google.longrunning.Operations. +func (c *ContentClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + return c.internalClient.ListOperations(ctx, req, opts...) +} + // contentGRPCClient is a client for interacting with Cloud Dataplex API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -153,6 +288,10 @@ type contentGRPCClient struct { // The gRPC API client. contentClient dataplexpb.ContentServiceClient + operationsClient longrunningpb.OperationsClient + + locationsClient locationpb.LocationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -187,6 +326,8 @@ func NewContentClient(ctx context.Context, opts ...option.ClientOption) (*Conten disableDeadlines: disableDeadlines, contentClient: dataplexpb.NewContentServiceClient(connPool), CallOptions: &client.CallOptions, + operationsClient: longrunningpb.NewOperationsClient(connPool), + locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() @@ -218,6 +359,11 @@ func (c *contentGRPCClient) Close() error { } func (c *contentGRPCClient) CreateContent(ctx context.Context, req *dataplexpb.CreateContentRequest, opts ...gax.CallOption) (*dataplexpb.Content, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -235,6 +381,11 @@ func (c *contentGRPCClient) CreateContent(ctx context.Context, req *dataplexpb.C } func (c *contentGRPCClient) UpdateContent(ctx context.Context, req *dataplexpb.UpdateContentRequest, opts ...gax.CallOption) (*dataplexpb.Content, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "content.name", url.QueryEscape(req.GetContent().GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -252,6 +403,11 @@ func (c *contentGRPCClient) UpdateContent(ctx context.Context, req *dataplexpb.U } func (c *contentGRPCClient) DeleteContent(ctx context.Context, req *dataplexpb.DeleteContentRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -265,6 +421,11 @@ func (c *contentGRPCClient) DeleteContent(ctx context.Context, req *dataplexpb.D } func (c *contentGRPCClient) GetContent(ctx context.Context, req *dataplexpb.GetContentRequest, opts ...gax.CallOption) (*dataplexpb.Content, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -281,6 +442,72 @@ func (c *contentGRPCClient) GetContent(ctx context.Context, req *dataplexpb.GetC return resp, nil } +func (c *contentGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + 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.contentClient.GetIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *contentGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + 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.contentClient.SetIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *contentGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + 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.contentClient.TestIamPermissions(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + func (c *contentGRPCClient) ListContent(ctx context.Context, req *dataplexpb.ListContentRequest, opts ...gax.CallOption) *ContentIterator { md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) @@ -326,6 +553,156 @@ func (c *contentGRPCClient) ListContent(ctx context.Context, req *dataplexpb.Lis return it } +func (c *contentGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) + var resp *locationpb.Location + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *contentGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) + it := &LocationIterator{} + req = proto.Clone(req).(*locationpb.ListLocationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { + resp := &locationpb.ListLocationsResponse{} + 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.locationsClient.ListLocations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetLocations(), 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 *contentGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *contentGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.DeleteOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *contentGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *contentGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) + it := &OperationIterator{} + req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { + resp := &longrunningpb.ListOperationsResponse{} + 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.operationsClient.ListOperations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetOperations(), 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 +} + // ContentIterator manages a stream of *dataplexpb.Content. type ContentIterator struct { items []*dataplexpb.Content @@ -372,3 +749,97 @@ func (it *ContentIterator) takeBuf() interface{} { it.items = nil return b } + +// LocationIterator manages a stream of *locationpb.Location. +type LocationIterator struct { + items []*locationpb.Location + pageInfo *iterator.PageInfo + nextFunc func() error + + // 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 []*locationpb.Location, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *LocationIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// 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 (it *LocationIterator) Next() (*locationpb.Location, error) { + var item *locationpb.Location + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *LocationIterator) bufLen() int { + return len(it.items) +} + +func (it *LocationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// OperationIterator manages a stream of *longrunningpb.Operation. +type OperationIterator struct { + items []*longrunningpb.Operation + pageInfo *iterator.PageInfo + nextFunc func() error + + // 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 []*longrunningpb.Operation, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *OperationIterator) PageInfo() *iterator.PageInfo { + return it.pageInfo +} + +// 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 (it *OperationIterator) Next() (*longrunningpb.Operation, error) { + var item *longrunningpb.Operation + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *OperationIterator) bufLen() int { + return len(it.items) +} + +func (it *OperationIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/dataplex/apiv1/content_client_example_test.go b/dataplex/apiv1/content_client_example_test.go index 74b6c34bfc1..d5cebaa08ea 100644 --- a/dataplex/apiv1/content_client_example_test.go +++ b/dataplex/apiv1/content_client_example_test.go @@ -22,6 +22,9 @@ import ( dataplex "cloud.google.com/go/dataplex/apiv1" "google.golang.org/api/iterator" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" + iampb "google.golang.org/genproto/googleapis/iam/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func ExampleNewContentClient() { @@ -114,6 +117,66 @@ func ExampleContentClient_GetContent() { _ = resp } +func ExampleContentClient_GetIamPolicy() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + +func ExampleContentClient_SetIamPolicy() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + +func ExampleContentClient_TestIamPermissions() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + func ExampleContentClient_ListContent() { ctx := context.Background() c, err := dataplex.NewContentClient(ctx) @@ -139,3 +202,131 @@ func ExampleContentClient_ListContent() { _ = resp } } + +func ExampleContentClient_GetLocation() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleContentClient_ListLocations() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleContentClient_CancelOperation() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleContentClient_DeleteOperation() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleContentClient_GetOperation() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleContentClient_ListOperations() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} diff --git a/dataplex/apiv1/dataplex_client.go b/dataplex/apiv1/dataplex_client.go index 98ca9f8672d..38ba6f9c5c3 100644 --- a/dataplex/apiv1/dataplex_client.go +++ b/dataplex/apiv1/dataplex_client.go @@ -31,6 +31,7 @@ import ( "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" longrunningpb "google.golang.org/genproto/googleapis/longrunning" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -74,6 +75,12 @@ type CallOptions struct { ListEnvironments []gax.CallOption GetEnvironment []gax.CallOption ListSessions []gax.CallOption + GetLocation []gax.CallOption + ListLocations []gax.CallOption + CancelOperation []gax.CallOption + DeleteOperation []gax.CallOption + GetOperation []gax.CallOption + ListOperations []gax.CallOption } func defaultGRPCClientOptions() []option.ClientOption { @@ -249,9 +256,35 @@ func defaultCallOptions() *CallOptions { CreateEnvironment: []gax.CallOption{}, UpdateEnvironment: []gax.CallOption{}, DeleteEnvironment: []gax.CallOption{}, - ListEnvironments: []gax.CallOption{}, - GetEnvironment: []gax.CallOption{}, - ListSessions: []gax.CallOption{}, + ListEnvironments: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetEnvironment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + ListSessions: []gax.CallOption{}, + GetLocation: []gax.CallOption{}, + ListLocations: []gax.CallOption{}, + CancelOperation: []gax.CallOption{}, + DeleteOperation: []gax.CallOption{}, + GetOperation: []gax.CallOption{}, + ListOperations: []gax.CallOption{}, } } @@ -307,6 +340,12 @@ type internalClient interface { ListEnvironments(context.Context, *dataplexpb.ListEnvironmentsRequest, ...gax.CallOption) *EnvironmentIterator GetEnvironment(context.Context, *dataplexpb.GetEnvironmentRequest, ...gax.CallOption) (*dataplexpb.Environment, error) ListSessions(context.Context, *dataplexpb.ListSessionsRequest, ...gax.CallOption) *SessionIterator + GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) + ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator + CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error + DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error + GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) + ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator } // Client is a client for interacting with Cloud Dataplex API. @@ -314,9 +353,9 @@ type internalClient interface { // // Dataplex service provides data lakes as a service. The primary resources // offered by this service are Lakes, Zones and Assets which collectively allow -// a data adminstrator to organize, manage, secure and catalog data across their -// organization located across cloud projects in a variety of storage systems -// including Cloud Storage and BigQuery. +// a data administrator to organize, manage, secure and catalog data across +// their organization located across cloud projects in a variety of storage +// systems including Cloud Storage and BigQuery. type Client struct { // The internal transport-dependent client. internalClient internalClient @@ -606,6 +645,36 @@ func (c *Client) ListSessions(ctx context.Context, req *dataplexpb.ListSessionsR return c.internalClient.ListSessions(ctx, req, opts...) } +// GetLocation gets information about a location. +func (c *Client) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + return c.internalClient.GetLocation(ctx, req, opts...) +} + +// ListLocations lists information about the supported locations for this service. +func (c *Client) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + return c.internalClient.ListLocations(ctx, req, opts...) +} + +// CancelOperation is a utility method from google.longrunning.Operations. +func (c *Client) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.CancelOperation(ctx, req, opts...) +} + +// DeleteOperation is a utility method from google.longrunning.Operations. +func (c *Client) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteOperation(ctx, req, opts...) +} + +// GetOperation is a utility method from google.longrunning.Operations. +func (c *Client) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + return c.internalClient.GetOperation(ctx, req, opts...) +} + +// ListOperations is a utility method from google.longrunning.Operations. +func (c *Client) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + return c.internalClient.ListOperations(ctx, req, opts...) +} + // gRPCClient is a client for interacting with Cloud Dataplex API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -627,6 +696,10 @@ type gRPCClient struct { // Users should not Close this client. LROClient **lroauto.OperationsClient + operationsClient longrunningpb.OperationsClient + + locationsClient locationpb.LocationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -636,9 +709,9 @@ type gRPCClient struct { // // Dataplex service provides data lakes as a service. The primary resources // offered by this service are Lakes, Zones and Assets which collectively allow -// a data adminstrator to organize, manage, secure and catalog data across their -// organization located across cloud projects in a variety of storage systems -// including Cloud Storage and BigQuery. +// a data administrator to organize, manage, secure and catalog data across +// their organization located across cloud projects in a variety of storage +// systems including Cloud Storage and BigQuery. func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { clientOpts := defaultGRPCClientOptions() if newClientHook != nil { @@ -665,6 +738,8 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error disableDeadlines: disableDeadlines, client: dataplexpb.NewDataplexServiceClient(connPool), CallOptions: &client.CallOptions, + operationsClient: longrunningpb.NewOperationsClient(connPool), + locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() @@ -1483,6 +1558,11 @@ func (c *gRPCClient) CancelJob(ctx context.Context, req *dataplexpb.CancelJobReq } func (c *gRPCClient) CreateEnvironment(ctx context.Context, req *dataplexpb.CreateEnvironmentRequest, opts ...gax.CallOption) (*CreateEnvironmentOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -1502,6 +1582,11 @@ func (c *gRPCClient) CreateEnvironment(ctx context.Context, req *dataplexpb.Crea } func (c *gRPCClient) UpdateEnvironment(ctx context.Context, req *dataplexpb.UpdateEnvironmentRequest, opts ...gax.CallOption) (*UpdateEnvironmentOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "environment.name", url.QueryEscape(req.GetEnvironment().GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -1521,6 +1606,11 @@ func (c *gRPCClient) UpdateEnvironment(ctx context.Context, req *dataplexpb.Upda } func (c *gRPCClient) DeleteEnvironment(ctx context.Context, req *dataplexpb.DeleteEnvironmentRequest, opts ...gax.CallOption) (*DeleteEnvironmentOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -1585,6 +1675,11 @@ func (c *gRPCClient) ListEnvironments(ctx context.Context, req *dataplexpb.ListE } func (c *gRPCClient) GetEnvironment(ctx context.Context, req *dataplexpb.GetEnvironmentRequest, opts ...gax.CallOption) (*dataplexpb.Environment, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) ctx = insertMetadata(ctx, c.xGoogMetadata, md) @@ -1646,6 +1741,156 @@ func (c *gRPCClient) ListSessions(ctx context.Context, req *dataplexpb.ListSessi return it } +func (c *gRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) + var resp *locationpb.Location + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *gRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) + it := &LocationIterator{} + req = proto.Clone(req).(*locationpb.ListLocationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { + resp := &locationpb.ListLocationsResponse{} + 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.locationsClient.ListLocations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetLocations(), 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 *gRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *gRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.DeleteOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *gRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *gRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) + it := &OperationIterator{} + req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { + resp := &longrunningpb.ListOperationsResponse{} + 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.operationsClient.ListOperations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetOperations(), 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 +} + // CreateAssetOperation manages a long-running operation from CreateAsset. type CreateAssetOperation struct { lro *longrunning.Operation diff --git a/dataplex/apiv1/dataplex_client_example_test.go b/dataplex/apiv1/dataplex_client_example_test.go index e7379eaf4bf..16440eb2f2b 100644 --- a/dataplex/apiv1/dataplex_client_example_test.go +++ b/dataplex/apiv1/dataplex_client_example_test.go @@ -22,6 +22,8 @@ import ( dataplex "cloud.google.com/go/dataplex/apiv1" "google.golang.org/api/iterator" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func ExampleNewClient() { @@ -798,3 +800,131 @@ func ExampleClient_ListSessions() { _ = resp } } + +func ExampleClient_GetLocation() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListLocations() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleClient_CancelOperation() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_DeleteOperation() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetOperation() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListOperations() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} diff --git a/dataplex/apiv1/gapic_metadata.json b/dataplex/apiv1/gapic_metadata.json index 79238874335..e1c77a79836 100644 --- a/dataplex/apiv1/gapic_metadata.json +++ b/dataplex/apiv1/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "ContentClient", "rpcs": { + "CancelOperation": { + "methods": [ + "CancelOperation" + ] + }, "CreateContent": { "methods": [ "CreateContent" @@ -20,16 +25,56 @@ "DeleteContent" ] }, + "DeleteOperation": { + "methods": [ + "DeleteOperation" + ] + }, "GetContent": { "methods": [ "GetContent" ] }, + "GetIamPolicy": { + "methods": [ + "GetIamPolicy" + ] + }, + "GetLocation": { + "methods": [ + "GetLocation" + ] + }, + "GetOperation": { + "methods": [ + "GetOperation" + ] + }, "ListContent": { "methods": [ "ListContent" ] }, + "ListLocations": { + "methods": [ + "ListLocations" + ] + }, + "ListOperations": { + "methods": [ + "ListOperations" + ] + }, + "SetIamPolicy": { + "methods": [ + "SetIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "TestIamPermissions" + ] + }, "UpdateContent": { "methods": [ "UpdateContent" @@ -49,6 +94,11 @@ "CancelJob" ] }, + "CancelOperation": { + "methods": [ + "CancelOperation" + ] + }, "CreateAsset": { "methods": [ "CreateAsset" @@ -89,6 +139,11 @@ "DeleteLake" ] }, + "DeleteOperation": { + "methods": [ + "DeleteOperation" + ] + }, "DeleteTask": { "methods": [ "DeleteTask" @@ -119,6 +174,16 @@ "GetLake" ] }, + "GetLocation": { + "methods": [ + "GetLocation" + ] + }, + "GetOperation": { + "methods": [ + "GetOperation" + ] + }, "GetTask": { "methods": [ "GetTask" @@ -159,6 +224,16 @@ "ListLakes" ] }, + "ListLocations": { + "methods": [ + "ListLocations" + ] + }, + "ListOperations": { + "methods": [ + "ListOperations" + ] + }, "ListSessions": { "methods": [ "ListSessions" @@ -213,6 +288,11 @@ "grpc": { "libraryClient": "MetadataClient", "rpcs": { + "CancelOperation": { + "methods": [ + "CancelOperation" + ] + }, "CreateEntity": { "methods": [ "CreateEntity" @@ -228,6 +308,11 @@ "DeleteEntity" ] }, + "DeleteOperation": { + "methods": [ + "DeleteOperation" + ] + }, "DeletePartition": { "methods": [ "DeletePartition" @@ -238,6 +323,16 @@ "GetEntity" ] }, + "GetLocation": { + "methods": [ + "GetLocation" + ] + }, + "GetOperation": { + "methods": [ + "GetOperation" + ] + }, "GetPartition": { "methods": [ "GetPartition" @@ -248,6 +343,16 @@ "ListEntities" ] }, + "ListLocations": { + "methods": [ + "ListLocations" + ] + }, + "ListOperations": { + "methods": [ + "ListOperations" + ] + }, "ListPartitions": { "methods": [ "ListPartitions" diff --git a/dataplex/apiv1/metadata_client.go b/dataplex/apiv1/metadata_client.go index 0c90f399de4..fba7c8b68bb 100644 --- a/dataplex/apiv1/metadata_client.go +++ b/dataplex/apiv1/metadata_client.go @@ -29,6 +29,8 @@ import ( "google.golang.org/api/option/internaloption" gtransport "google.golang.org/api/transport/grpc" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" @@ -48,6 +50,12 @@ type MetadataCallOptions struct { DeletePartition []gax.CallOption GetPartition []gax.CallOption ListPartitions []gax.CallOption + GetLocation []gax.CallOption + ListLocations []gax.CallOption + CancelOperation []gax.CallOption + DeleteOperation []gax.CallOption + GetOperation []gax.CallOption + ListOperations []gax.CallOption } func defaultMetadataGRPCClientOptions() []option.ClientOption { @@ -113,6 +121,12 @@ func defaultMetadataCallOptions() *MetadataCallOptions { }) }), }, + GetLocation: []gax.CallOption{}, + ListLocations: []gax.CallOption{}, + CancelOperation: []gax.CallOption{}, + DeleteOperation: []gax.CallOption{}, + GetOperation: []gax.CallOption{}, + ListOperations: []gax.CallOption{}, } } @@ -130,6 +144,12 @@ type internalMetadataClient interface { DeletePartition(context.Context, *dataplexpb.DeletePartitionRequest, ...gax.CallOption) error GetPartition(context.Context, *dataplexpb.GetPartitionRequest, ...gax.CallOption) (*dataplexpb.Partition, error) ListPartitions(context.Context, *dataplexpb.ListPartitionsRequest, ...gax.CallOption) *PartitionIterator + GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) + ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator + CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error + DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error + GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) + ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator } // MetadataClient is a client for interacting with Cloud Dataplex API. @@ -212,6 +232,36 @@ func (c *MetadataClient) ListPartitions(ctx context.Context, req *dataplexpb.Lis return c.internalClient.ListPartitions(ctx, req, opts...) } +// GetLocation gets information about a location. +func (c *MetadataClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + return c.internalClient.GetLocation(ctx, req, opts...) +} + +// ListLocations lists information about the supported locations for this service. +func (c *MetadataClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + return c.internalClient.ListLocations(ctx, req, opts...) +} + +// CancelOperation is a utility method from google.longrunning.Operations. +func (c *MetadataClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.CancelOperation(ctx, req, opts...) +} + +// DeleteOperation is a utility method from google.longrunning.Operations. +func (c *MetadataClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteOperation(ctx, req, opts...) +} + +// GetOperation is a utility method from google.longrunning.Operations. +func (c *MetadataClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + return c.internalClient.GetOperation(ctx, req, opts...) +} + +// ListOperations is a utility method from google.longrunning.Operations. +func (c *MetadataClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + return c.internalClient.ListOperations(ctx, req, opts...) +} + // metadataGRPCClient is a client for interacting with Cloud Dataplex API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. @@ -228,6 +278,10 @@ type metadataGRPCClient struct { // The gRPC API client. metadataClient dataplexpb.MetadataServiceClient + operationsClient longrunningpb.OperationsClient + + locationsClient locationpb.LocationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -263,6 +317,8 @@ func NewMetadataClient(ctx context.Context, opts ...option.ClientOption) (*Metad disableDeadlines: disableDeadlines, metadataClient: dataplexpb.NewMetadataServiceClient(connPool), CallOptions: &client.CallOptions, + operationsClient: longrunningpb.NewOperationsClient(connPool), + locationsClient: locationpb.NewLocationsClient(connPool), } c.setGoogleClientInfo() @@ -529,6 +585,156 @@ func (c *metadataGRPCClient) ListPartitions(ctx context.Context, req *dataplexpb return it } +func (c *metadataGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) + var resp *locationpb.Location + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *metadataGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) + it := &LocationIterator{} + req = proto.Clone(req).(*locationpb.ListLocationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { + resp := &locationpb.ListLocationsResponse{} + 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.locationsClient.ListLocations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetLocations(), 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 *metadataGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.CancelOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *metadataGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.operationsClient.DeleteOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +func (c *metadataGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *metadataGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) + it := &OperationIterator{} + req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { + resp := &longrunningpb.ListOperationsResponse{} + 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.operationsClient.ListOperations(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetOperations(), 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 +} + // EntityIterator manages a stream of *dataplexpb.Entity. type EntityIterator struct { items []*dataplexpb.Entity diff --git a/dataplex/apiv1/metadata_client_example_test.go b/dataplex/apiv1/metadata_client_example_test.go index 8cdb5ac00a4..ae9dac40b47 100644 --- a/dataplex/apiv1/metadata_client_example_test.go +++ b/dataplex/apiv1/metadata_client_example_test.go @@ -22,6 +22,8 @@ import ( dataplex "cloud.google.com/go/dataplex/apiv1" "google.golang.org/api/iterator" dataplexpb "google.golang.org/genproto/googleapis/cloud/dataplex/v1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" ) func ExampleNewMetadataClient() { @@ -223,3 +225,131 @@ func ExampleMetadataClient_ListPartitions() { _ = resp } } + +func ExampleMetadataClient_GetLocation() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleMetadataClient_ListLocations() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleMetadataClient_CancelOperation() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleMetadataClient_DeleteOperation() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleMetadataClient_GetOperation() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleMetadataClient_ListOperations() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} diff --git a/internal/generated/snippets/dataplex/apiv1/Client/CancelOperation/main.go b/internal/generated/snippets/dataplex/apiv1/Client/CancelOperation/main.go new file mode 100644 index 00000000000..bcec233d486 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/CancelOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_CancelOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_DataplexService_CancelOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/Client/DeleteOperation/main.go b/internal/generated/snippets/dataplex/apiv1/Client/DeleteOperation/main.go new file mode 100644 index 00000000000..a5cdc76baca --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/DeleteOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_DeleteOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_DataplexService_DeleteOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/Client/GetLocation/main.go b/internal/generated/snippets/dataplex/apiv1/Client/GetLocation/main.go new file mode 100644 index 00000000000..145a2dac5a1 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/GetLocation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_GetLocation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_DataplexService_GetLocation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/Client/GetOperation/main.go b/internal/generated/snippets/dataplex/apiv1/Client/GetOperation/main.go new file mode 100644 index 00000000000..24dcb9bee6f --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/GetOperation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_GetOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_DataplexService_GetOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/Client/ListLocations/main.go b/internal/generated/snippets/dataplex/apiv1/Client/ListLocations/main.go new file mode 100644 index 00000000000..2f8e31a52a6 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/ListLocations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_ListLocations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_DataplexService_ListLocations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/Client/ListOperations/main.go b/internal/generated/snippets/dataplex/apiv1/Client/ListOperations/main.go new file mode 100644 index 00000000000..3249909bbf7 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/Client/ListOperations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_DataplexService_ListOperations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_DataplexService_ListOperations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/CancelOperation/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/CancelOperation/main.go new file mode 100644 index 00000000000..133fa345fc2 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/CancelOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_CancelOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_ContentService_CancelOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/DeleteOperation/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/DeleteOperation/main.go new file mode 100644 index 00000000000..7d91a9e108f --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/DeleteOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_DeleteOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_ContentService_DeleteOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/GetIamPolicy/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetIamPolicy/main.go new file mode 100644 index 00000000000..18225cb0ca5 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_GetIamPolicy_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + iampb "google.golang.org/genproto/googleapis/iam/v1" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + +// [END dataplex_v1_generated_ContentService_GetIamPolicy_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/GetLocation/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetLocation/main.go new file mode 100644 index 00000000000..d8c47cf7091 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetLocation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_GetLocation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_ContentService_GetLocation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/GetOperation/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetOperation/main.go new file mode 100644 index 00000000000..1ac3a7c81ed --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/GetOperation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_GetOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_ContentService_GetOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/ListLocations/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/ListLocations/main.go new file mode 100644 index 00000000000..8630f32c386 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/ListLocations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_ListLocations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_ContentService_ListLocations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/ListOperations/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/ListOperations/main.go new file mode 100644 index 00000000000..f736db465fa --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/ListOperations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_ListOperations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_ContentService_ListOperations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/SetIamPolicy/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/SetIamPolicy/main.go new file mode 100644 index 00000000000..1e7b59e9775 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/SetIamPolicy/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_SetIamPolicy_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + iampb "google.golang.org/genproto/googleapis/iam/v1" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + +// [END dataplex_v1_generated_ContentService_SetIamPolicy_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/ContentClient/TestIamPermissions/main.go b/internal/generated/snippets/dataplex/apiv1/ContentClient/TestIamPermissions/main.go new file mode 100644 index 00000000000..0c8e27997d6 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/ContentClient/TestIamPermissions/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_ContentService_TestIamPermissions_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + iampb "google.golang.org/genproto/googleapis/iam/v1" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewContentClient(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 +} + +// [END dataplex_v1_generated_ContentService_TestIamPermissions_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/CancelOperation/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/CancelOperation/main.go new file mode 100644 index 00000000000..8924570fe6c --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/CancelOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_CancelOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.CancelOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#CancelOperationRequest. + } + err = c.CancelOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_MetadataService_CancelOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/DeleteOperation/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/DeleteOperation/main.go new file mode 100644 index 00000000000..05a4b8ce176 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/DeleteOperation/main.go @@ -0,0 +1,46 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_DeleteOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.DeleteOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#DeleteOperationRequest. + } + err = c.DeleteOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +// [END dataplex_v1_generated_MetadataService_DeleteOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetLocation/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetLocation/main.go new file mode 100644 index 00000000000..3c0c66504cc --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetLocation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_GetLocation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.GetLocationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest. + } + resp, err := c.GetLocation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_MetadataService_GetLocation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetOperation/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetOperation/main.go new file mode 100644 index 00000000000..015b381127d --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/GetOperation/main.go @@ -0,0 +1,48 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_GetOperation_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.GetOperationRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#GetOperationRequest. + } + resp, err := c.GetOperation(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +// [END dataplex_v1_generated_MetadataService_GetOperation_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListLocations/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListLocations/main.go new file mode 100644 index 00000000000..a21420b7d4a --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListLocations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_ListLocations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + locationpb "google.golang.org/genproto/googleapis/cloud/location" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &locationpb.ListLocationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest. + } + it := c.ListLocations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_MetadataService_ListLocations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListOperations/main.go b/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListOperations/main.go new file mode 100644 index 00000000000..6ac1f235402 --- /dev/null +++ b/internal/generated/snippets/dataplex/apiv1/MetadataClient/ListOperations/main.go @@ -0,0 +1,55 @@ +// Copyright 2022 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 +// +// http://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 cloud.google.com/go/internal/gapicgen/gensnippets. DO NOT EDIT. + +// [START dataplex_v1_generated_MetadataService_ListOperations_sync] + +package main + +import ( + "context" + + dataplex "cloud.google.com/go/dataplex/apiv1" + "google.golang.org/api/iterator" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" +) + +func main() { + ctx := context.Background() + c, err := dataplex.NewMetadataClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &longrunningpb.ListOperationsRequest{ + // TODO: Fill request struct fields. + // See https://pkg.go.dev/google.golang.org/genproto/googleapis/longrunning#ListOperationsRequest. + } + it := c.ListOperations(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +// [END dataplex_v1_generated_MetadataService_ListOperations_sync] diff --git a/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json b/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json index 2eb2c7a3687..3789c930367 100644 --- a/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json +++ b/internal/generated/snippets/dataplex/apiv1/snippet_metadata.google.cloud.dataplex.v1.json @@ -56,6 +56,51 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_DataplexService_CancelOperation_sync", + "title": "dataplex CancelOperation Sample", + "description": "CancelOperation is a utility method from google.longrunning.Operations.", + "file": "Client/CancelOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.Client.CancelOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.CancelOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.DataplexService.CancelOperation", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_DataplexService_CreateAsset_sync", "title": "dataplex CreateAsset Sample", @@ -424,6 +469,51 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_DataplexService_DeleteOperation_sync", + "title": "dataplex DeleteOperation Sample", + "description": "DeleteOperation is a utility method from google.longrunning.Operations.", + "file": "Client/DeleteOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.Client.DeleteOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.DeleteOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.DataplexService.DeleteOperation", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_DataplexService_DeleteTask_sync", "title": "dataplex DeleteTask Sample", @@ -700,6 +790,98 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_DataplexService_GetLocation_sync", + "title": "dataplex GetLocation Sample", + "description": "GetLocation gets information about a location.", + "file": "Client/GetLocation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.Client.GetLocation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.GetLocationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "locationpb.Location", + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.DataplexService.GetLocation", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_DataplexService_GetOperation_sync", + "title": "dataplex GetOperation Sample", + "description": "GetOperation is a utility method from google.longrunning.Operations.", + "file": "Client/GetOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.Client.GetOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.GetOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "longrunningpb.Operation", + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.DataplexService.GetOperation", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_DataplexService_GetTask_sync", "title": "dataplex GetTask Sample", @@ -1068,6 +1250,98 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_DataplexService_ListLocations_sync", + "title": "dataplex ListLocations Sample", + "description": "ListLocations lists information about the supported locations for this service.", + "file": "Client/ListLocations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.Client.ListLocations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.ListLocationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "LocationIterator", + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.DataplexService.ListLocations", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_DataplexService_ListOperations_sync", + "title": "dataplex ListOperations Sample", + "description": "ListOperations is a utility method from google.longrunning.Operations.", + "file": "Client/ListOperations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.Client.ListOperations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.ListOperationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "OperationIterator", + "client": { + "shortName": "Client", + "fullName": "google.cloud.dataplex.v1.Client" + }, + "method": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.DataplexService.ListOperations", + "service": { + "shortName": "DataplexService", + "fullName": "google.cloud.dataplex.v1.DataplexService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_DataplexService_ListSessions_sync", "title": "dataplex ListSessions Sample", @@ -1482,6 +1756,51 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_ContentService_CancelOperation_sync", + "title": "dataplex CancelOperation Sample", + "description": "CancelOperation is a utility method from google.longrunning.Operations.", + "file": "ContentClient/CancelOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.ContentClient.CancelOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.CancelOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.ContentService.CancelOperation", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_ContentService_CreateContent_sync", "title": "dataplex CreateContent Sample", @@ -1574,10 +1893,55 @@ ] }, { - "regionTag": "dataplex_v1_generated_ContentService_GetContent_sync", - "title": "dataplex GetContent Sample", - "description": "GetContent get a content resource.", - "file": "ContentClient/GetContent/main.go", + "regionTag": "dataplex_v1_generated_ContentService_DeleteOperation_sync", + "title": "dataplex DeleteOperation Sample", + "description": "DeleteOperation is a utility method from google.longrunning.Operations.", + "file": "ContentClient/DeleteOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.ContentClient.DeleteOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.DeleteOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.ContentService.DeleteOperation", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_GetContent_sync", + "title": "dataplex GetContent Sample", + "description": "GetContent get a content resource.", + "file": "ContentClient/GetContent/main.go", "language": "GO", "clientMethod": { "shortName": "GetContent", @@ -1619,6 +1983,144 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_ContentService_GetIamPolicy_sync", + "title": "dataplex GetIamPolicy Sample", + "description": "GetIamPolicy gets the access control policy for a contentitem resource. A NOT_FOUND\nerror is returned if the resource does not exist. An empty policy is\nreturned if the resource exists but does not have a policy set on it.\n\nCaller must have Google IAM dataplex.content.getIamPolicy permission\non the resource.", + "file": "ContentClient/GetIamPolicy/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.dataplex.v1.ContentClient.GetIamPolicy", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "iampb.GetIamPolicyRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "iampb.Policy", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.dataplex.v1.ContentService.GetIamPolicy", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_GetLocation_sync", + "title": "dataplex GetLocation Sample", + "description": "GetLocation gets information about a location.", + "file": "ContentClient/GetLocation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.ContentClient.GetLocation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.GetLocationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "locationpb.Location", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.ContentService.GetLocation", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_GetOperation_sync", + "title": "dataplex GetOperation Sample", + "description": "GetOperation is a utility method from google.longrunning.Operations.", + "file": "ContentClient/GetOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.ContentClient.GetOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.GetOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "longrunningpb.Operation", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.ContentService.GetOperation", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_ContentService_ListContent_sync", "title": "dataplex ListContent Sample", @@ -1665,6 +2167,190 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_ContentService_ListLocations_sync", + "title": "dataplex ListLocations Sample", + "description": "ListLocations lists information about the supported locations for this service.", + "file": "ContentClient/ListLocations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.ContentClient.ListLocations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.ListLocationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "LocationIterator", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.ContentService.ListLocations", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_ListOperations_sync", + "title": "dataplex ListOperations Sample", + "description": "ListOperations is a utility method from google.longrunning.Operations.", + "file": "ContentClient/ListOperations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.ContentClient.ListOperations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.ListOperationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "OperationIterator", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.ContentService.ListOperations", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_SetIamPolicy_sync", + "title": "dataplex SetIamPolicy Sample", + "description": "SetIamPolicy sets the access control policy on the specified contentitem resource.\nReplaces any existing policy.\n\nCaller must have Google IAM dataplex.content.setIamPolicy permission\non the resource.", + "file": "ContentClient/SetIamPolicy/main.go", + "language": "GO", + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.dataplex.v1.ContentClient.SetIamPolicy", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "iampb.SetIamPolicyRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "iampb.Policy", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.dataplex.v1.ContentService.SetIamPolicy", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_ContentService_TestIamPermissions_sync", + "title": "dataplex TestIamPermissions Sample", + "description": "TestIamPermissions returns the caller’s permissions on a resource.\nIf the resource does not exist, an empty set of\npermissions is returned (a NOT_FOUND error is not returned).\n\nA caller is not required to have Google IAM permission to make this\nrequest.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay “fail open” without warning.", + "file": "ContentClient/TestIamPermissions/main.go", + "language": "GO", + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.dataplex.v1.ContentClient.TestIamPermissions", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "iampb.TestIamPermissionsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "iampb.TestIamPermissionsResponse", + "client": { + "shortName": "ContentClient", + "fullName": "google.cloud.dataplex.v1.ContentClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.dataplex.v1.ContentService.TestIamPermissions", + "service": { + "shortName": "ContentService", + "fullName": "google.cloud.dataplex.v1.ContentService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_ContentService_UpdateContent_sync", "title": "dataplex UpdateContent Sample", @@ -1711,6 +2397,51 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_MetadataService_CancelOperation_sync", + "title": "dataplex CancelOperation Sample", + "description": "CancelOperation is a utility method from google.longrunning.Operations.", + "file": "MetadataClient/CancelOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.MetadataClient.CancelOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.CancelOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "CancelOperation", + "fullName": "google.cloud.dataplex.v1.MetadataService.CancelOperation", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_MetadataService_CreateEntity_sync", "title": "dataplex CreateEntity Sample", @@ -1848,6 +2579,51 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_MetadataService_DeleteOperation_sync", + "title": "dataplex DeleteOperation Sample", + "description": "DeleteOperation is a utility method from google.longrunning.Operations.", + "file": "MetadataClient/DeleteOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.MetadataClient.DeleteOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.DeleteOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "DeleteOperation", + "fullName": "google.cloud.dataplex.v1.MetadataService.DeleteOperation", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 45, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_MetadataService_DeletePartition_sync", "title": "dataplex DeletePartition Sample", @@ -1939,6 +2715,98 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_MetadataService_GetLocation_sync", + "title": "dataplex GetLocation Sample", + "description": "GetLocation gets information about a location.", + "file": "MetadataClient/GetLocation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.MetadataClient.GetLocation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.GetLocationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "locationpb.Location", + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "GetLocation", + "fullName": "google.cloud.dataplex.v1.MetadataService.GetLocation", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_MetadataService_GetOperation_sync", + "title": "dataplex GetOperation Sample", + "description": "GetOperation is a utility method from google.longrunning.Operations.", + "file": "MetadataClient/GetOperation/main.go", + "language": "GO", + "clientMethod": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.MetadataClient.GetOperation", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.GetOperationRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "longrunningpb.Operation", + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "GetOperation", + "fullName": "google.cloud.dataplex.v1.MetadataService.GetOperation", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 47, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_MetadataService_GetPartition_sync", "title": "dataplex GetPartition Sample", @@ -2031,6 +2899,98 @@ } ] }, + { + "regionTag": "dataplex_v1_generated_MetadataService_ListLocations_sync", + "title": "dataplex ListLocations Sample", + "description": "ListLocations lists information about the supported locations for this service.", + "file": "MetadataClient/ListLocations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.MetadataClient.ListLocations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "locationpb.ListLocationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "LocationIterator", + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "ListLocations", + "fullName": "google.cloud.dataplex.v1.MetadataService.ListLocations", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, + { + "regionTag": "dataplex_v1_generated_MetadataService_ListOperations_sync", + "title": "dataplex ListOperations Sample", + "description": "ListOperations is a utility method from google.longrunning.Operations.", + "file": "MetadataClient/ListOperations/main.go", + "language": "GO", + "clientMethod": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.MetadataClient.ListOperations", + "parameters": [ + { + "type": "context.Context", + "name": "ctx" + }, + { + "type": "longrunningpb.ListOperationsRequest", + "name": "req" + }, + { + "type": "...gax.CallOption", + "name": "opts" + } + ], + "resultType": "OperationIterator", + "client": { + "shortName": "MetadataClient", + "fullName": "google.cloud.dataplex.v1.MetadataClient" + }, + "method": { + "shortName": "ListOperations", + "fullName": "google.cloud.dataplex.v1.MetadataService.ListOperations", + "service": { + "shortName": "MetadataService", + "fullName": "google.cloud.dataplex.v1.MetadataService" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 18, + "end": 54, + "type": "FULL" + } + ] + }, { "regionTag": "dataplex_v1_generated_MetadataService_ListPartitions_sync", "title": "dataplex ListPartitions Sample",