diff --git a/dataproc/apiv1beta2/ListClusters_smoke_test.go b/dataproc/apiv1beta2/ListClusters_smoke_test.go deleted file mode 100644 index 87a0e76fb95..00000000000 --- a/dataproc/apiv1beta2/ListClusters_smoke_test.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by gapic-generator. DO NOT EDIT. - -package dataproc - -import ( - "context" - "fmt" - "strconv" - "testing" - "time" - - "cloud.google.com/go/internal/testutil" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -var _ = fmt.Sprintf -var _ = iterator.Done -var _ = strconv.FormatUint -var _ = time.Now - -func TestClusterControllerSmoke(t *testing.T) { - if testing.Short() { - t.Skip("skipping smoke test in short mode") - } - ctx := context.Background() - ts := testutil.TokenSource(ctx, DefaultAuthScopes()...) - if ts == nil { - t.Skip("Integration tests skipped. See CONTRIBUTING.md for details") - } - - projectId := testutil.ProjID() - _ = projectId - - c, err := NewClusterControllerClient(ctx, option.WithTokenSource(ts)) - if err != nil { - t.Fatal(err) - } - - var projectId2 string = projectId - var region string = "global" - var request = &dataprocpb.ListClustersRequest{ - ProjectId: projectId2, - Region: region, - } - - iter := c.ListClusters(ctx, request) - if _, err := iter.Next(); err != nil && err != iterator.Done { - t.Error(err) - } -} diff --git a/dataproc/apiv1beta2/autoscaling_policy_client.go b/dataproc/apiv1beta2/autoscaling_policy_client.go deleted file mode 100644 index d843092655e..00000000000 --- a/dataproc/apiv1beta2/autoscaling_policy_client.go +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/option/internaloption" - gtransport "google.golang.org/api/transport/grpc" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" - "google.golang.org/protobuf/proto" -) - -var newAutoscalingPolicyClientHook clientHook - -// AutoscalingPolicyCallOptions contains the retry settings for each method of AutoscalingPolicyClient. -type AutoscalingPolicyCallOptions struct { - CreateAutoscalingPolicy []gax.CallOption - UpdateAutoscalingPolicy []gax.CallOption - GetAutoscalingPolicy []gax.CallOption - ListAutoscalingPolicies []gax.CallOption - DeleteAutoscalingPolicy []gax.CallOption -} - -func defaultAutoscalingPolicyGRPCClientOptions() []option.ClientOption { - return []option.ClientOption{ - internaloption.WithDefaultEndpoint("dataproc.googleapis.com:443"), - internaloption.WithDefaultMTLSEndpoint("dataproc.mtls.googleapis.com:443"), - internaloption.WithDefaultAudience("https://dataproc.googleapis.com/"), - internaloption.WithDefaultScopes(DefaultAuthScopes()...), - internaloption.EnableJwtWithScope(), - option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultAutoscalingPolicyCallOptions() *AutoscalingPolicyCallOptions { - return &AutoscalingPolicyCallOptions{ - CreateAutoscalingPolicy: []gax.CallOption{}, - UpdateAutoscalingPolicy: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - GetAutoscalingPolicy: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - ListAutoscalingPolicies: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - DeleteAutoscalingPolicy: []gax.CallOption{}, - } -} - -// internalAutoscalingPolicyClient is an interface that defines the methods availaible from Cloud Dataproc API. -type internalAutoscalingPolicyClient interface { - Close() error - setGoogleClientInfo(...string) - Connection() *grpc.ClientConn - CreateAutoscalingPolicy(context.Context, *dataprocpb.CreateAutoscalingPolicyRequest, ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) - UpdateAutoscalingPolicy(context.Context, *dataprocpb.UpdateAutoscalingPolicyRequest, ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) - GetAutoscalingPolicy(context.Context, *dataprocpb.GetAutoscalingPolicyRequest, ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) - ListAutoscalingPolicies(context.Context, *dataprocpb.ListAutoscalingPoliciesRequest, ...gax.CallOption) *AutoscalingPolicyIterator - DeleteAutoscalingPolicy(context.Context, *dataprocpb.DeleteAutoscalingPolicyRequest, ...gax.CallOption) error -} - -// AutoscalingPolicyClient is a client for interacting with Cloud Dataproc API. -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -// -// The API interface for managing autoscaling policies in the -// Cloud Dataproc API. -type AutoscalingPolicyClient struct { - // The internal transport-dependent client. - internalClient internalAutoscalingPolicyClient - - // The call options for this service. - CallOptions *AutoscalingPolicyCallOptions -} - -// Wrapper methods routed to the internal client. - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *AutoscalingPolicyClient) Close() error { - return c.internalClient.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *AutoscalingPolicyClient) setGoogleClientInfo(keyval ...string) { - c.internalClient.setGoogleClientInfo(keyval...) -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *AutoscalingPolicyClient) Connection() *grpc.ClientConn { - return c.internalClient.Connection() -} - -// CreateAutoscalingPolicy creates new autoscaling policy. -func (c *AutoscalingPolicyClient) CreateAutoscalingPolicy(ctx context.Context, req *dataprocpb.CreateAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - return c.internalClient.CreateAutoscalingPolicy(ctx, req, opts...) -} - -// UpdateAutoscalingPolicy updates (replaces) autoscaling policy. -// -// Disabled check for update_mask, because all updates will be full -// replacements. -func (c *AutoscalingPolicyClient) UpdateAutoscalingPolicy(ctx context.Context, req *dataprocpb.UpdateAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - return c.internalClient.UpdateAutoscalingPolicy(ctx, req, opts...) -} - -// GetAutoscalingPolicy retrieves autoscaling policy. -func (c *AutoscalingPolicyClient) GetAutoscalingPolicy(ctx context.Context, req *dataprocpb.GetAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - return c.internalClient.GetAutoscalingPolicy(ctx, req, opts...) -} - -// ListAutoscalingPolicies lists autoscaling policies in the project. -func (c *AutoscalingPolicyClient) ListAutoscalingPolicies(ctx context.Context, req *dataprocpb.ListAutoscalingPoliciesRequest, opts ...gax.CallOption) *AutoscalingPolicyIterator { - return c.internalClient.ListAutoscalingPolicies(ctx, req, opts...) -} - -// DeleteAutoscalingPolicy deletes an autoscaling policy. It is an error to delete an autoscaling -// policy that is in use by one or more clusters. -func (c *AutoscalingPolicyClient) DeleteAutoscalingPolicy(ctx context.Context, req *dataprocpb.DeleteAutoscalingPolicyRequest, opts ...gax.CallOption) error { - return c.internalClient.DeleteAutoscalingPolicy(ctx, req, opts...) -} - -// autoscalingPolicyGRPCClient is a client for interacting with Cloud Dataproc API over gRPC transport. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type autoscalingPolicyGRPCClient struct { - // Connection pool of gRPC connections to the service. - connPool gtransport.ConnPool - - // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE - disableDeadlines bool - - // Points back to the CallOptions field of the containing AutoscalingPolicyClient - CallOptions **AutoscalingPolicyCallOptions - - // The gRPC API client. - autoscalingPolicyClient dataprocpb.AutoscalingPolicyServiceClient - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewAutoscalingPolicyClient creates a new autoscaling policy service client based on gRPC. -// The returned client must be Closed when it is done being used to clean up its underlying connections. -// -// The API interface for managing autoscaling policies in the -// Cloud Dataproc API. -func NewAutoscalingPolicyClient(ctx context.Context, opts ...option.ClientOption) (*AutoscalingPolicyClient, error) { - clientOpts := defaultAutoscalingPolicyGRPCClientOptions() - if newAutoscalingPolicyClientHook != nil { - hookOpts, err := newAutoscalingPolicyClientHook(ctx, clientHookParams{}) - if err != nil { - return nil, err - } - clientOpts = append(clientOpts, hookOpts...) - } - - disableDeadlines, err := checkDisableDeadlines() - if err != nil { - return nil, err - } - - connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) - if err != nil { - return nil, err - } - client := AutoscalingPolicyClient{CallOptions: defaultAutoscalingPolicyCallOptions()} - - c := &autoscalingPolicyGRPCClient{ - connPool: connPool, - disableDeadlines: disableDeadlines, - autoscalingPolicyClient: dataprocpb.NewAutoscalingPolicyServiceClient(connPool), - CallOptions: &client.CallOptions, - } - c.setGoogleClientInfo() - - client.internalClient = c - - return &client, nil -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *autoscalingPolicyGRPCClient) Connection() *grpc.ClientConn { - return c.connPool.Conn() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *autoscalingPolicyGRPCClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *autoscalingPolicyGRPCClient) Close() error { - return c.connPool.Close() -} - -func (c *autoscalingPolicyGRPCClient) CreateAutoscalingPolicy(ctx context.Context, req *dataprocpb.CreateAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).CreateAutoscalingPolicy[0:len((*c.CallOptions).CreateAutoscalingPolicy):len((*c.CallOptions).CreateAutoscalingPolicy)], opts...) - var resp *dataprocpb.AutoscalingPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.autoscalingPolicyClient.CreateAutoscalingPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *autoscalingPolicyGRPCClient) UpdateAutoscalingPolicy(ctx context.Context, req *dataprocpb.UpdateAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "policy.name", url.QueryEscape(req.GetPolicy().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).UpdateAutoscalingPolicy[0:len((*c.CallOptions).UpdateAutoscalingPolicy):len((*c.CallOptions).UpdateAutoscalingPolicy)], opts...) - var resp *dataprocpb.AutoscalingPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.autoscalingPolicyClient.UpdateAutoscalingPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *autoscalingPolicyGRPCClient) GetAutoscalingPolicy(ctx context.Context, req *dataprocpb.GetAutoscalingPolicyRequest, opts ...gax.CallOption) (*dataprocpb.AutoscalingPolicy, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).GetAutoscalingPolicy[0:len((*c.CallOptions).GetAutoscalingPolicy):len((*c.CallOptions).GetAutoscalingPolicy)], opts...) - var resp *dataprocpb.AutoscalingPolicy - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.autoscalingPolicyClient.GetAutoscalingPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *autoscalingPolicyGRPCClient) ListAutoscalingPolicies(ctx context.Context, req *dataprocpb.ListAutoscalingPoliciesRequest, opts ...gax.CallOption) *AutoscalingPolicyIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).ListAutoscalingPolicies[0:len((*c.CallOptions).ListAutoscalingPolicies):len((*c.CallOptions).ListAutoscalingPolicies)], opts...) - it := &AutoscalingPolicyIterator{} - req = proto.Clone(req).(*dataprocpb.ListAutoscalingPoliciesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*dataprocpb.AutoscalingPolicy, string, error) { - resp := &dataprocpb.ListAutoscalingPoliciesResponse{} - 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.autoscalingPolicyClient.ListAutoscalingPolicies(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - - it.Response = resp - return resp.GetPolicies(), 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 *autoscalingPolicyGRPCClient) DeleteAutoscalingPolicy(ctx context.Context, req *dataprocpb.DeleteAutoscalingPolicyRequest, opts ...gax.CallOption) error { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).DeleteAutoscalingPolicy[0:len((*c.CallOptions).DeleteAutoscalingPolicy):len((*c.CallOptions).DeleteAutoscalingPolicy)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.autoscalingPolicyClient.DeleteAutoscalingPolicy(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// AutoscalingPolicyIterator manages a stream of *dataprocpb.AutoscalingPolicy. -type AutoscalingPolicyIterator struct { - items []*dataprocpb.AutoscalingPolicy - 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 []*dataprocpb.AutoscalingPolicy, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *AutoscalingPolicyIterator) 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 *AutoscalingPolicyIterator) Next() (*dataprocpb.AutoscalingPolicy, error) { - var item *dataprocpb.AutoscalingPolicy - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *AutoscalingPolicyIterator) bufLen() int { - return len(it.items) -} - -func (it *AutoscalingPolicyIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/dataproc/apiv1beta2/autoscaling_policy_client_example_test.go b/dataproc/apiv1beta2/autoscaling_policy_client_example_test.go deleted file mode 100644 index a6d1262f67f..00000000000 --- a/dataproc/apiv1beta2/autoscaling_policy_client_example_test.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc_test - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func ExampleNewAutoscalingPolicyClient() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - // TODO: Use client. - _ = c -} - -func ExampleAutoscalingPolicyClient_CreateAutoscalingPolicy() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateAutoscalingPolicyRequest. - } - resp, err := c.CreateAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleAutoscalingPolicyClient_UpdateAutoscalingPolicy() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateAutoscalingPolicyRequest. - } - resp, err := c.UpdateAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleAutoscalingPolicyClient_GetAutoscalingPolicy() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetAutoscalingPolicyRequest. - } - resp, err := c.GetAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleAutoscalingPolicyClient_ListAutoscalingPolicies() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListAutoscalingPoliciesRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListAutoscalingPoliciesRequest. - } - it := c.ListAutoscalingPolicies(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -func ExampleAutoscalingPolicyClient_DeleteAutoscalingPolicy() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteAutoscalingPolicyRequest. - } - err = c.DeleteAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } -} diff --git a/dataproc/apiv1beta2/cluster_controller_client.go b/dataproc/apiv1beta2/cluster_controller_client.go deleted file mode 100644 index 73ef01ad0a4..00000000000 --- a/dataproc/apiv1beta2/cluster_controller_client.go +++ /dev/null @@ -1,817 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "cloud.google.com/go/longrunning" - lroauto "cloud.google.com/go/longrunning/autogen" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/option/internaloption" - gtransport "google.golang.org/api/transport/grpc" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" - 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" -) - -var newClusterControllerClientHook clientHook - -// ClusterControllerCallOptions contains the retry settings for each method of ClusterControllerClient. -type ClusterControllerCallOptions struct { - CreateCluster []gax.CallOption - UpdateCluster []gax.CallOption - DeleteCluster []gax.CallOption - GetCluster []gax.CallOption - ListClusters []gax.CallOption - DiagnoseCluster []gax.CallOption -} - -func defaultClusterControllerGRPCClientOptions() []option.ClientOption { - return []option.ClientOption{ - internaloption.WithDefaultEndpoint("dataproc.googleapis.com:443"), - internaloption.WithDefaultMTLSEndpoint("dataproc.mtls.googleapis.com:443"), - internaloption.WithDefaultAudience("https://dataproc.googleapis.com/"), - internaloption.WithDefaultScopes(DefaultAuthScopes()...), - internaloption.EnableJwtWithScope(), - option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultClusterControllerCallOptions() *ClusterControllerCallOptions { - return &ClusterControllerCallOptions{ - CreateCluster: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - UpdateCluster: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - DeleteCluster: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - GetCluster: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Internal, - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - ListClusters: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Internal, - codes.DeadlineExceeded, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - DiagnoseCluster: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - } -} - -// internalClusterControllerClient is an interface that defines the methods availaible from Cloud Dataproc API. -type internalClusterControllerClient interface { - Close() error - setGoogleClientInfo(...string) - Connection() *grpc.ClientConn - CreateCluster(context.Context, *dataprocpb.CreateClusterRequest, ...gax.CallOption) (*CreateClusterOperation, error) - CreateClusterOperation(name string) *CreateClusterOperation - UpdateCluster(context.Context, *dataprocpb.UpdateClusterRequest, ...gax.CallOption) (*UpdateClusterOperation, error) - UpdateClusterOperation(name string) *UpdateClusterOperation - DeleteCluster(context.Context, *dataprocpb.DeleteClusterRequest, ...gax.CallOption) (*DeleteClusterOperation, error) - DeleteClusterOperation(name string) *DeleteClusterOperation - GetCluster(context.Context, *dataprocpb.GetClusterRequest, ...gax.CallOption) (*dataprocpb.Cluster, error) - ListClusters(context.Context, *dataprocpb.ListClustersRequest, ...gax.CallOption) *ClusterIterator - DiagnoseCluster(context.Context, *dataprocpb.DiagnoseClusterRequest, ...gax.CallOption) (*DiagnoseClusterOperation, error) - DiagnoseClusterOperation(name string) *DiagnoseClusterOperation -} - -// ClusterControllerClient is a client for interacting with Cloud Dataproc API. -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -// -// The ClusterControllerService provides methods to manage clusters -// of Compute Engine instances. -type ClusterControllerClient struct { - // The internal transport-dependent client. - internalClient internalClusterControllerClient - - // The call options for this service. - CallOptions *ClusterControllerCallOptions - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient *lroauto.OperationsClient -} - -// Wrapper methods routed to the internal client. - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *ClusterControllerClient) Close() error { - return c.internalClient.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *ClusterControllerClient) setGoogleClientInfo(keyval ...string) { - c.internalClient.setGoogleClientInfo(keyval...) -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *ClusterControllerClient) Connection() *grpc.ClientConn { - return c.internalClient.Connection() -} - -// CreateCluster creates a cluster in a project. The returned -// Operation.metadata will be -// ClusterOperationMetadata. -func (c *ClusterControllerClient) CreateCluster(ctx context.Context, req *dataprocpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) { - return c.internalClient.CreateCluster(ctx, req, opts...) -} - -// CreateClusterOperation returns a new CreateClusterOperation from a given name. -// The name must be that of a previously created CreateClusterOperation, possibly from a different process. -func (c *ClusterControllerClient) CreateClusterOperation(name string) *CreateClusterOperation { - return c.internalClient.CreateClusterOperation(name) -} - -// UpdateCluster updates a cluster in a project. The returned -// Operation.metadata will be -// ClusterOperationMetadata. -func (c *ClusterControllerClient) UpdateCluster(ctx context.Context, req *dataprocpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) { - return c.internalClient.UpdateCluster(ctx, req, opts...) -} - -// UpdateClusterOperation returns a new UpdateClusterOperation from a given name. -// The name must be that of a previously created UpdateClusterOperation, possibly from a different process. -func (c *ClusterControllerClient) UpdateClusterOperation(name string) *UpdateClusterOperation { - return c.internalClient.UpdateClusterOperation(name) -} - -// DeleteCluster deletes a cluster in a project. The returned -// Operation.metadata will be -// ClusterOperationMetadata. -func (c *ClusterControllerClient) DeleteCluster(ctx context.Context, req *dataprocpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) { - return c.internalClient.DeleteCluster(ctx, req, opts...) -} - -// DeleteClusterOperation returns a new DeleteClusterOperation from a given name. -// The name must be that of a previously created DeleteClusterOperation, possibly from a different process. -func (c *ClusterControllerClient) DeleteClusterOperation(name string) *DeleteClusterOperation { - return c.internalClient.DeleteClusterOperation(name) -} - -// GetCluster gets the resource representation for a cluster in a project. -func (c *ClusterControllerClient) GetCluster(ctx context.Context, req *dataprocpb.GetClusterRequest, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - return c.internalClient.GetCluster(ctx, req, opts...) -} - -// ListClusters lists all regions/{region}/clusters in a project alphabetically. -func (c *ClusterControllerClient) ListClusters(ctx context.Context, req *dataprocpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator { - return c.internalClient.ListClusters(ctx, req, opts...) -} - -// DiagnoseCluster gets cluster diagnostic information. The returned -// Operation.metadata will be -// ClusterOperationMetadata. -// After the operation completes, -// Operation.response -// contains -// Empty. -func (c *ClusterControllerClient) DiagnoseCluster(ctx context.Context, req *dataprocpb.DiagnoseClusterRequest, opts ...gax.CallOption) (*DiagnoseClusterOperation, error) { - return c.internalClient.DiagnoseCluster(ctx, req, opts...) -} - -// DiagnoseClusterOperation returns a new DiagnoseClusterOperation from a given name. -// The name must be that of a previously created DiagnoseClusterOperation, possibly from a different process. -func (c *ClusterControllerClient) DiagnoseClusterOperation(name string) *DiagnoseClusterOperation { - return c.internalClient.DiagnoseClusterOperation(name) -} - -// clusterControllerGRPCClient is a client for interacting with Cloud Dataproc API over gRPC transport. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type clusterControllerGRPCClient struct { - // Connection pool of gRPC connections to the service. - connPool gtransport.ConnPool - - // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE - disableDeadlines bool - - // Points back to the CallOptions field of the containing ClusterControllerClient - CallOptions **ClusterControllerCallOptions - - // The gRPC API client. - clusterControllerClient dataprocpb.ClusterControllerClient - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient **lroauto.OperationsClient - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewClusterControllerClient creates a new cluster controller client based on gRPC. -// The returned client must be Closed when it is done being used to clean up its underlying connections. -// -// The ClusterControllerService provides methods to manage clusters -// of Compute Engine instances. -func NewClusterControllerClient(ctx context.Context, opts ...option.ClientOption) (*ClusterControllerClient, error) { - clientOpts := defaultClusterControllerGRPCClientOptions() - if newClusterControllerClientHook != nil { - hookOpts, err := newClusterControllerClientHook(ctx, clientHookParams{}) - if err != nil { - return nil, err - } - clientOpts = append(clientOpts, hookOpts...) - } - - disableDeadlines, err := checkDisableDeadlines() - if err != nil { - return nil, err - } - - connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) - if err != nil { - return nil, err - } - client := ClusterControllerClient{CallOptions: defaultClusterControllerCallOptions()} - - c := &clusterControllerGRPCClient{ - connPool: connPool, - disableDeadlines: disableDeadlines, - clusterControllerClient: dataprocpb.NewClusterControllerClient(connPool), - CallOptions: &client.CallOptions, - } - c.setGoogleClientInfo() - - client.internalClient = c - - client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) - if err != nil { - // This error "should not happen", since we are just reusing old connection pool - // and never actually need to dial. - // If this does happen, we could leak connp. However, we cannot close conn: - // If the user invoked the constructor with option.WithGRPCConn, - // we would close a connection that's still in use. - // TODO: investigate error conditions. - return nil, err - } - c.LROClient = &client.LROClient - return &client, nil -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *clusterControllerGRPCClient) Connection() *grpc.ClientConn { - return c.connPool.Conn() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *clusterControllerGRPCClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *clusterControllerGRPCClient) Close() error { - return c.connPool.Close() -} - -func (c *clusterControllerGRPCClient) CreateCluster(ctx context.Context, req *dataprocpb.CreateClusterRequest, opts ...gax.CallOption) (*CreateClusterOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).CreateCluster[0:len((*c.CallOptions).CreateCluster):len((*c.CallOptions).CreateCluster)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.clusterControllerClient.CreateCluster(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &CreateClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *clusterControllerGRPCClient) UpdateCluster(ctx context.Context, req *dataprocpb.UpdateClusterRequest, opts ...gax.CallOption) (*UpdateClusterOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "cluster_name", url.QueryEscape(req.GetClusterName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).UpdateCluster[0:len((*c.CallOptions).UpdateCluster):len((*c.CallOptions).UpdateCluster)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.clusterControllerClient.UpdateCluster(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &UpdateClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *clusterControllerGRPCClient) DeleteCluster(ctx context.Context, req *dataprocpb.DeleteClusterRequest, opts ...gax.CallOption) (*DeleteClusterOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "cluster_name", url.QueryEscape(req.GetClusterName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).DeleteCluster[0:len((*c.CallOptions).DeleteCluster):len((*c.CallOptions).DeleteCluster)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.clusterControllerClient.DeleteCluster(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &DeleteClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *clusterControllerGRPCClient) GetCluster(ctx context.Context, req *dataprocpb.GetClusterRequest, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "cluster_name", url.QueryEscape(req.GetClusterName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).GetCluster[0:len((*c.CallOptions).GetCluster):len((*c.CallOptions).GetCluster)], opts...) - var resp *dataprocpb.Cluster - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.clusterControllerClient.GetCluster(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *clusterControllerGRPCClient) ListClusters(ctx context.Context, req *dataprocpb.ListClustersRequest, opts ...gax.CallOption) *ClusterIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).ListClusters[0:len((*c.CallOptions).ListClusters):len((*c.CallOptions).ListClusters)], opts...) - it := &ClusterIterator{} - req = proto.Clone(req).(*dataprocpb.ListClustersRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*dataprocpb.Cluster, string, error) { - resp := &dataprocpb.ListClustersResponse{} - 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.clusterControllerClient.ListClusters(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - - it.Response = resp - return resp.GetClusters(), 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 *clusterControllerGRPCClient) DiagnoseCluster(ctx context.Context, req *dataprocpb.DiagnoseClusterRequest, opts ...gax.CallOption) (*DiagnoseClusterOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 300000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "cluster_name", url.QueryEscape(req.GetClusterName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).DiagnoseCluster[0:len((*c.CallOptions).DiagnoseCluster):len((*c.CallOptions).DiagnoseCluster)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.clusterControllerClient.DiagnoseCluster(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &DiagnoseClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -// CreateClusterOperation manages a long-running operation from CreateCluster. -type CreateClusterOperation struct { - lro *longrunning.Operation -} - -// CreateClusterOperation returns a new CreateClusterOperation from a given name. -// The name must be that of a previously created CreateClusterOperation, possibly from a different process. -func (c *clusterControllerGRPCClient) CreateClusterOperation(name string) *CreateClusterOperation { - return &CreateClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *CreateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - var resp dataprocpb.Cluster - if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { - return nil, err - } - return &resp, nil -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *CreateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - var resp dataprocpb.Cluster - if err := op.lro.Poll(ctx, &resp, opts...); err != nil { - return nil, err - } - if !op.Done() { - return nil, nil - } - return &resp, nil -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *CreateClusterOperation) Metadata() (*dataprocpb.ClusterOperationMetadata, error) { - var meta dataprocpb.ClusterOperationMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *CreateClusterOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *CreateClusterOperation) Name() string { - return op.lro.Name() -} - -// DeleteClusterOperation manages a long-running operation from DeleteCluster. -type DeleteClusterOperation struct { - lro *longrunning.Operation -} - -// DeleteClusterOperation returns a new DeleteClusterOperation from a given name. -// The name must be that of a previously created DeleteClusterOperation, possibly from a different process. -func (c *clusterControllerGRPCClient) DeleteClusterOperation(name string) *DeleteClusterOperation { - return &DeleteClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *DeleteClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *DeleteClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Poll(ctx, nil, opts...) -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *DeleteClusterOperation) Metadata() (*dataprocpb.ClusterOperationMetadata, error) { - var meta dataprocpb.ClusterOperationMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *DeleteClusterOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *DeleteClusterOperation) Name() string { - return op.lro.Name() -} - -// DiagnoseClusterOperation manages a long-running operation from DiagnoseCluster. -type DiagnoseClusterOperation struct { - lro *longrunning.Operation -} - -// DiagnoseClusterOperation returns a new DiagnoseClusterOperation from a given name. -// The name must be that of a previously created DiagnoseClusterOperation, possibly from a different process. -func (c *clusterControllerGRPCClient) DiagnoseClusterOperation(name string) *DiagnoseClusterOperation { - return &DiagnoseClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *DiagnoseClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *DiagnoseClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Poll(ctx, nil, opts...) -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *DiagnoseClusterOperation) Metadata() (*dataprocpb.ClusterOperationMetadata, error) { - var meta dataprocpb.ClusterOperationMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *DiagnoseClusterOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *DiagnoseClusterOperation) Name() string { - return op.lro.Name() -} - -// UpdateClusterOperation manages a long-running operation from UpdateCluster. -type UpdateClusterOperation struct { - lro *longrunning.Operation -} - -// UpdateClusterOperation returns a new UpdateClusterOperation from a given name. -// The name must be that of a previously created UpdateClusterOperation, possibly from a different process. -func (c *clusterControllerGRPCClient) UpdateClusterOperation(name string) *UpdateClusterOperation { - return &UpdateClusterOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *UpdateClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - var resp dataprocpb.Cluster - if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { - return nil, err - } - return &resp, nil -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *UpdateClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Cluster, error) { - var resp dataprocpb.Cluster - if err := op.lro.Poll(ctx, &resp, opts...); err != nil { - return nil, err - } - if !op.Done() { - return nil, nil - } - return &resp, nil -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *UpdateClusterOperation) Metadata() (*dataprocpb.ClusterOperationMetadata, error) { - var meta dataprocpb.ClusterOperationMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *UpdateClusterOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *UpdateClusterOperation) Name() string { - return op.lro.Name() -} - -// ClusterIterator manages a stream of *dataprocpb.Cluster. -type ClusterIterator struct { - items []*dataprocpb.Cluster - 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 []*dataprocpb.Cluster, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *ClusterIterator) 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 *ClusterIterator) Next() (*dataprocpb.Cluster, error) { - var item *dataprocpb.Cluster - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *ClusterIterator) bufLen() int { - return len(it.items) -} - -func (it *ClusterIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/dataproc/apiv1beta2/cluster_controller_client_example_test.go b/dataproc/apiv1beta2/cluster_controller_client_example_test.go deleted file mode 100644 index 27d3aeb5a7c..00000000000 --- a/dataproc/apiv1beta2/cluster_controller_client_example_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc_test - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func ExampleNewClusterControllerClient() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - // TODO: Use client. - _ = c -} - -func ExampleClusterControllerClient_CreateCluster() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateClusterRequest. - } - op, err := c.CreateCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleClusterControllerClient_UpdateCluster() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateClusterRequest. - } - op, err := c.UpdateCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleClusterControllerClient_DeleteCluster() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteClusterRequest. - } - op, err := c.DeleteCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -func ExampleClusterControllerClient_GetCluster() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetClusterRequest. - } - resp, err := c.GetCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleClusterControllerClient_ListClusters() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListClustersRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListClustersRequest. - } - it := c.ListClusters(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -func ExampleClusterControllerClient_DiagnoseCluster() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DiagnoseClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DiagnoseClusterRequest. - } - op, err := c.DiagnoseCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} diff --git a/dataproc/apiv1beta2/doc.go b/dataproc/apiv1beta2/doc.go deleted file mode 100644 index 82c091676a7..00000000000 --- a/dataproc/apiv1beta2/doc.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -// Package dataproc is an auto-generated package for the -// Cloud Dataproc API. -// -// Manages Hadoop-based clusters and jobs on Google Cloud Platform. -// -// NOTE: This package is in beta. It is not stable, and may be subject to changes. -// -// Example usage -// -// To get started with this package, create a client. -// ctx := context.Background() -// c, err := dataproc.NewAutoscalingPolicyClient(ctx) -// if err != nil { -// // TODO: Handle error. -// } -// defer c.Close() -// -// The client will use your default application credentials. Clients should be reused instead of created as needed. -// The methods of Client are safe for concurrent use by multiple goroutines. -// The returned client must be Closed when it is done being used. -// -// Using the Client -// -// The following is an example of making an API call with the newly created client. -// -// ctx := context.Background() -// c, err := dataproc.NewAutoscalingPolicyClient(ctx) -// if err != nil { -// // TODO: Handle error. -// } -// defer c.Close() -// -// req := &dataprocpb.CreateAutoscalingPolicyRequest{ -// // TODO: Fill request struct fields. -// // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateAutoscalingPolicyRequest. -// } -// resp, err := c.CreateAutoscalingPolicy(ctx, req) -// if err != nil { -// // TODO: Handle error. -// } -// // TODO: Use resp. -// _ = resp -// -// Use of Context -// -// The ctx passed to NewClient is used for authentication requests and -// for creating the underlying connection, but is not used for subsequent calls. -// Individual methods on the client use the ctx given to them. -// -// To close the open connection, use the Close() method. -// -// For information about setting deadlines, reusing contexts, and more -// please visit https://pkg.go.dev/cloud.google.com/go. -package dataproc // import "cloud.google.com/go/dataproc/apiv1beta2" - -import ( - "context" - "os" - "runtime" - "strconv" - "strings" - "unicode" - - "google.golang.org/api/option" - "google.golang.org/grpc/metadata" -) - -// For more information on implementing a client constructor hook, see -// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. -type clientHookParams struct{} -type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) - -const versionClient = "20210821" - -func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { - out, _ := metadata.FromOutgoingContext(ctx) - out = out.Copy() - for _, md := range mds { - for k, v := range md { - out[k] = append(out[k], v...) - } - } - return metadata.NewOutgoingContext(ctx, out) -} - -func checkDisableDeadlines() (bool, error) { - raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") - if !ok { - return false, nil - } - - b, err := strconv.ParseBool(raw) - return b, err -} - -// DefaultAuthScopes reports the default set of authentication scopes to use with this package. -func DefaultAuthScopes() []string { - return []string{ - "https://www.googleapis.com/auth/cloud-platform", - } -} - -// versionGo returns the Go runtime version. The returned string -// has no whitespace, suitable for reporting in header. -func versionGo() string { - const develPrefix = "devel +" - - s := runtime.Version() - if strings.HasPrefix(s, develPrefix) { - s = s[len(develPrefix):] - if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { - s = s[:p] - } - return s - } - - notSemverRune := func(r rune) bool { - return !strings.ContainsRune("0123456789.", r) - } - - if strings.HasPrefix(s, "go1") { - s = s[2:] - var prerelease string - if p := strings.IndexFunc(s, notSemverRune); p >= 0 { - s, prerelease = s[:p], s[p:] - } - if strings.HasSuffix(s, ".") { - s += "0" - } else if strings.Count(s, ".") < 2 { - s += ".0" - } - if prerelease != "" { - s += "-" + prerelease - } - return s - } - return "UNKNOWN" -} diff --git a/dataproc/apiv1beta2/gapic_metadata.json b/dataproc/apiv1beta2/gapic_metadata.json deleted file mode 100644 index 2669636f437..00000000000 --- a/dataproc/apiv1beta2/gapic_metadata.json +++ /dev/null @@ -1,170 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", - "language": "go", - "protoPackage": "google.cloud.dataproc.v1beta2", - "libraryPackage": "cloud.google.com/go/dataproc/apiv1beta2", - "services": { - "AutoscalingPolicyService": { - "clients": { - "grpc": { - "libraryClient": "AutoscalingPolicyClient", - "rpcs": { - "CreateAutoscalingPolicy": { - "methods": [ - "CreateAutoscalingPolicy" - ] - }, - "DeleteAutoscalingPolicy": { - "methods": [ - "DeleteAutoscalingPolicy" - ] - }, - "GetAutoscalingPolicy": { - "methods": [ - "GetAutoscalingPolicy" - ] - }, - "ListAutoscalingPolicies": { - "methods": [ - "ListAutoscalingPolicies" - ] - }, - "UpdateAutoscalingPolicy": { - "methods": [ - "UpdateAutoscalingPolicy" - ] - } - } - } - } - }, - "ClusterController": { - "clients": { - "grpc": { - "libraryClient": "ClusterControllerClient", - "rpcs": { - "CreateCluster": { - "methods": [ - "CreateCluster" - ] - }, - "DeleteCluster": { - "methods": [ - "DeleteCluster" - ] - }, - "DiagnoseCluster": { - "methods": [ - "DiagnoseCluster" - ] - }, - "GetCluster": { - "methods": [ - "GetCluster" - ] - }, - "ListClusters": { - "methods": [ - "ListClusters" - ] - }, - "UpdateCluster": { - "methods": [ - "UpdateCluster" - ] - } - } - } - } - }, - "JobController": { - "clients": { - "grpc": { - "libraryClient": "JobControllerClient", - "rpcs": { - "CancelJob": { - "methods": [ - "CancelJob" - ] - }, - "DeleteJob": { - "methods": [ - "DeleteJob" - ] - }, - "GetJob": { - "methods": [ - "GetJob" - ] - }, - "ListJobs": { - "methods": [ - "ListJobs" - ] - }, - "SubmitJob": { - "methods": [ - "SubmitJob" - ] - }, - "SubmitJobAsOperation": { - "methods": [ - "SubmitJobAsOperation" - ] - }, - "UpdateJob": { - "methods": [ - "UpdateJob" - ] - } - } - } - } - }, - "WorkflowTemplateService": { - "clients": { - "grpc": { - "libraryClient": "WorkflowTemplateClient", - "rpcs": { - "CreateWorkflowTemplate": { - "methods": [ - "CreateWorkflowTemplate" - ] - }, - "DeleteWorkflowTemplate": { - "methods": [ - "DeleteWorkflowTemplate" - ] - }, - "GetWorkflowTemplate": { - "methods": [ - "GetWorkflowTemplate" - ] - }, - "InstantiateInlineWorkflowTemplate": { - "methods": [ - "InstantiateInlineWorkflowTemplate" - ] - }, - "InstantiateWorkflowTemplate": { - "methods": [ - "InstantiateWorkflowTemplate" - ] - }, - "ListWorkflowTemplates": { - "methods": [ - "ListWorkflowTemplates" - ] - }, - "UpdateWorkflowTemplate": { - "methods": [ - "UpdateWorkflowTemplate" - ] - } - } - } - } - } - } -} diff --git a/dataproc/apiv1beta2/job_controller_client.go b/dataproc/apiv1beta2/job_controller_client.go deleted file mode 100644 index c85c2084bc4..00000000000 --- a/dataproc/apiv1beta2/job_controller_client.go +++ /dev/null @@ -1,633 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "cloud.google.com/go/longrunning" - lroauto "cloud.google.com/go/longrunning/autogen" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/option/internaloption" - gtransport "google.golang.org/api/transport/grpc" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" - 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" -) - -var newJobControllerClientHook clientHook - -// JobControllerCallOptions contains the retry settings for each method of JobControllerClient. -type JobControllerCallOptions struct { - SubmitJob []gax.CallOption - SubmitJobAsOperation []gax.CallOption - GetJob []gax.CallOption - ListJobs []gax.CallOption - UpdateJob []gax.CallOption - CancelJob []gax.CallOption - DeleteJob []gax.CallOption -} - -func defaultJobControllerGRPCClientOptions() []option.ClientOption { - return []option.ClientOption{ - internaloption.WithDefaultEndpoint("dataproc.googleapis.com:443"), - internaloption.WithDefaultMTLSEndpoint("dataproc.mtls.googleapis.com:443"), - internaloption.WithDefaultAudience("https://dataproc.googleapis.com/"), - internaloption.WithDefaultScopes(DefaultAuthScopes()...), - internaloption.EnableJwtWithScope(), - option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultJobControllerCallOptions() *JobControllerCallOptions { - return &JobControllerCallOptions{ - SubmitJob: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - SubmitJobAsOperation: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - GetJob: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Internal, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - ListJobs: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Internal, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - UpdateJob: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - CancelJob: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Internal, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - DeleteJob: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - } -} - -// internalJobControllerClient is an interface that defines the methods availaible from Cloud Dataproc API. -type internalJobControllerClient interface { - Close() error - setGoogleClientInfo(...string) - Connection() *grpc.ClientConn - SubmitJob(context.Context, *dataprocpb.SubmitJobRequest, ...gax.CallOption) (*dataprocpb.Job, error) - SubmitJobAsOperation(context.Context, *dataprocpb.SubmitJobRequest, ...gax.CallOption) (*SubmitJobAsOperationOperation, error) - SubmitJobAsOperationOperation(name string) *SubmitJobAsOperationOperation - GetJob(context.Context, *dataprocpb.GetJobRequest, ...gax.CallOption) (*dataprocpb.Job, error) - ListJobs(context.Context, *dataprocpb.ListJobsRequest, ...gax.CallOption) *JobIterator - UpdateJob(context.Context, *dataprocpb.UpdateJobRequest, ...gax.CallOption) (*dataprocpb.Job, error) - CancelJob(context.Context, *dataprocpb.CancelJobRequest, ...gax.CallOption) (*dataprocpb.Job, error) - DeleteJob(context.Context, *dataprocpb.DeleteJobRequest, ...gax.CallOption) error -} - -// JobControllerClient is a client for interacting with Cloud Dataproc API. -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -// -// The JobController provides methods to manage jobs. -type JobControllerClient struct { - // The internal transport-dependent client. - internalClient internalJobControllerClient - - // The call options for this service. - CallOptions *JobControllerCallOptions - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient *lroauto.OperationsClient -} - -// Wrapper methods routed to the internal client. - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *JobControllerClient) Close() error { - return c.internalClient.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *JobControllerClient) setGoogleClientInfo(keyval ...string) { - c.internalClient.setGoogleClientInfo(keyval...) -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *JobControllerClient) Connection() *grpc.ClientConn { - return c.internalClient.Connection() -} - -// SubmitJob submits a job to a cluster. -func (c *JobControllerClient) SubmitJob(ctx context.Context, req *dataprocpb.SubmitJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - return c.internalClient.SubmitJob(ctx, req, opts...) -} - -// SubmitJobAsOperation submits job to a cluster. -func (c *JobControllerClient) SubmitJobAsOperation(ctx context.Context, req *dataprocpb.SubmitJobRequest, opts ...gax.CallOption) (*SubmitJobAsOperationOperation, error) { - return c.internalClient.SubmitJobAsOperation(ctx, req, opts...) -} - -// SubmitJobAsOperationOperation returns a new SubmitJobAsOperationOperation from a given name. -// The name must be that of a previously created SubmitJobAsOperationOperation, possibly from a different process. -func (c *JobControllerClient) SubmitJobAsOperationOperation(name string) *SubmitJobAsOperationOperation { - return c.internalClient.SubmitJobAsOperationOperation(name) -} - -// GetJob gets the resource representation for a job in a project. -func (c *JobControllerClient) GetJob(ctx context.Context, req *dataprocpb.GetJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - return c.internalClient.GetJob(ctx, req, opts...) -} - -// ListJobs lists regions/{region}/jobs in a project. -func (c *JobControllerClient) ListJobs(ctx context.Context, req *dataprocpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { - return c.internalClient.ListJobs(ctx, req, opts...) -} - -// UpdateJob updates a job in a project. -func (c *JobControllerClient) UpdateJob(ctx context.Context, req *dataprocpb.UpdateJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - return c.internalClient.UpdateJob(ctx, req, opts...) -} - -// CancelJob starts a job cancellation request. To access the job resource -// after cancellation, call -// regions/{region}/jobs.list -// or -// regions/{region}/jobs.get. -func (c *JobControllerClient) CancelJob(ctx context.Context, req *dataprocpb.CancelJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - return c.internalClient.CancelJob(ctx, req, opts...) -} - -// DeleteJob deletes the job from the project. If the job is active, the delete fails, -// and the response returns FAILED_PRECONDITION. -func (c *JobControllerClient) DeleteJob(ctx context.Context, req *dataprocpb.DeleteJobRequest, opts ...gax.CallOption) error { - return c.internalClient.DeleteJob(ctx, req, opts...) -} - -// jobControllerGRPCClient is a client for interacting with Cloud Dataproc API over gRPC transport. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type jobControllerGRPCClient struct { - // Connection pool of gRPC connections to the service. - connPool gtransport.ConnPool - - // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE - disableDeadlines bool - - // Points back to the CallOptions field of the containing JobControllerClient - CallOptions **JobControllerCallOptions - - // The gRPC API client. - jobControllerClient dataprocpb.JobControllerClient - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient **lroauto.OperationsClient - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewJobControllerClient creates a new job controller client based on gRPC. -// The returned client must be Closed when it is done being used to clean up its underlying connections. -// -// The JobController provides methods to manage jobs. -func NewJobControllerClient(ctx context.Context, opts ...option.ClientOption) (*JobControllerClient, error) { - clientOpts := defaultJobControllerGRPCClientOptions() - if newJobControllerClientHook != nil { - hookOpts, err := newJobControllerClientHook(ctx, clientHookParams{}) - if err != nil { - return nil, err - } - clientOpts = append(clientOpts, hookOpts...) - } - - disableDeadlines, err := checkDisableDeadlines() - if err != nil { - return nil, err - } - - connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) - if err != nil { - return nil, err - } - client := JobControllerClient{CallOptions: defaultJobControllerCallOptions()} - - c := &jobControllerGRPCClient{ - connPool: connPool, - disableDeadlines: disableDeadlines, - jobControllerClient: dataprocpb.NewJobControllerClient(connPool), - CallOptions: &client.CallOptions, - } - c.setGoogleClientInfo() - - client.internalClient = c - - client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) - if err != nil { - // This error "should not happen", since we are just reusing old connection pool - // and never actually need to dial. - // If this does happen, we could leak connp. However, we cannot close conn: - // If the user invoked the constructor with option.WithGRPCConn, - // we would close a connection that's still in use. - // TODO: investigate error conditions. - return nil, err - } - c.LROClient = &client.LROClient - return &client, nil -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *jobControllerGRPCClient) Connection() *grpc.ClientConn { - return c.connPool.Conn() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *jobControllerGRPCClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *jobControllerGRPCClient) Close() error { - return c.connPool.Close() -} - -func (c *jobControllerGRPCClient) SubmitJob(ctx context.Context, req *dataprocpb.SubmitJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).SubmitJob[0:len((*c.CallOptions).SubmitJob):len((*c.CallOptions).SubmitJob)], opts...) - var resp *dataprocpb.Job - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.jobControllerClient.SubmitJob(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *jobControllerGRPCClient) SubmitJobAsOperation(ctx context.Context, req *dataprocpb.SubmitJobRequest, opts ...gax.CallOption) (*SubmitJobAsOperationOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).SubmitJobAsOperation[0:len((*c.CallOptions).SubmitJobAsOperation):len((*c.CallOptions).SubmitJobAsOperation)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.jobControllerClient.SubmitJobAsOperation(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &SubmitJobAsOperationOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *jobControllerGRPCClient) GetJob(ctx context.Context, req *dataprocpb.GetJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "job_id", url.QueryEscape(req.GetJobId()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).GetJob[0:len((*c.CallOptions).GetJob):len((*c.CallOptions).GetJob)], opts...) - var resp *dataprocpb.Job - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.jobControllerClient.GetJob(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *jobControllerGRPCClient) ListJobs(ctx context.Context, req *dataprocpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).ListJobs[0:len((*c.CallOptions).ListJobs):len((*c.CallOptions).ListJobs)], opts...) - it := &JobIterator{} - req = proto.Clone(req).(*dataprocpb.ListJobsRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*dataprocpb.Job, string, error) { - resp := &dataprocpb.ListJobsResponse{} - 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.jobControllerClient.ListJobs(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - - it.Response = resp - return resp.GetJobs(), 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 *jobControllerGRPCClient) UpdateJob(ctx context.Context, req *dataprocpb.UpdateJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "job_id", url.QueryEscape(req.GetJobId()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).UpdateJob[0:len((*c.CallOptions).UpdateJob):len((*c.CallOptions).UpdateJob)], opts...) - var resp *dataprocpb.Job - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.jobControllerClient.UpdateJob(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *jobControllerGRPCClient) CancelJob(ctx context.Context, req *dataprocpb.CancelJobRequest, opts ...gax.CallOption) (*dataprocpb.Job, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "job_id", url.QueryEscape(req.GetJobId()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).CancelJob[0:len((*c.CallOptions).CancelJob):len((*c.CallOptions).CancelJob)], opts...) - var resp *dataprocpb.Job - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.jobControllerClient.CancelJob(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *jobControllerGRPCClient) DeleteJob(ctx context.Context, req *dataprocpb.DeleteJobRequest, opts ...gax.CallOption) error { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 900000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v", "project_id", url.QueryEscape(req.GetProjectId()), "region", url.QueryEscape(req.GetRegion()), "job_id", url.QueryEscape(req.GetJobId()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).DeleteJob[0:len((*c.CallOptions).DeleteJob):len((*c.CallOptions).DeleteJob)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.jobControllerClient.DeleteJob(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// SubmitJobAsOperationOperation manages a long-running operation from SubmitJobAsOperation. -type SubmitJobAsOperationOperation struct { - lro *longrunning.Operation -} - -// SubmitJobAsOperationOperation returns a new SubmitJobAsOperationOperation from a given name. -// The name must be that of a previously created SubmitJobAsOperationOperation, possibly from a different process. -func (c *jobControllerGRPCClient) SubmitJobAsOperationOperation(name string) *SubmitJobAsOperationOperation { - return &SubmitJobAsOperationOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *SubmitJobAsOperationOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Job, error) { - var resp dataprocpb.Job - if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { - return nil, err - } - return &resp, nil -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *SubmitJobAsOperationOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*dataprocpb.Job, error) { - var resp dataprocpb.Job - if err := op.lro.Poll(ctx, &resp, opts...); err != nil { - return nil, err - } - if !op.Done() { - return nil, nil - } - return &resp, nil -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *SubmitJobAsOperationOperation) Metadata() (*dataprocpb.JobMetadata, error) { - var meta dataprocpb.JobMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *SubmitJobAsOperationOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *SubmitJobAsOperationOperation) Name() string { - return op.lro.Name() -} - -// JobIterator manages a stream of *dataprocpb.Job. -type JobIterator struct { - items []*dataprocpb.Job - 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 []*dataprocpb.Job, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *JobIterator) 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 *JobIterator) Next() (*dataprocpb.Job, error) { - var item *dataprocpb.Job - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *JobIterator) bufLen() int { - return len(it.items) -} - -func (it *JobIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/dataproc/apiv1beta2/job_controller_client_example_test.go b/dataproc/apiv1beta2/job_controller_client_example_test.go deleted file mode 100644 index 80260210faa..00000000000 --- a/dataproc/apiv1beta2/job_controller_client_example_test.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc_test - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func ExampleNewJobControllerClient() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - // TODO: Use client. - _ = c -} - -func ExampleJobControllerClient_SubmitJob() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.SubmitJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#SubmitJobRequest. - } - resp, err := c.SubmitJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleJobControllerClient_SubmitJobAsOperation() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.SubmitJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#SubmitJobRequest. - } - op, err := c.SubmitJobAsOperation(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleJobControllerClient_GetJob() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetJobRequest. - } - resp, err := c.GetJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleJobControllerClient_ListJobs() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListJobsRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListJobsRequest. - } - it := c.ListJobs(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -func ExampleJobControllerClient_UpdateJob() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateJobRequest. - } - resp, err := c.UpdateJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleJobControllerClient_CancelJob() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CancelJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CancelJobRequest. - } - resp, err := c.CancelJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleJobControllerClient_DeleteJob() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteJobRequest. - } - err = c.DeleteJob(ctx, req) - if err != nil { - // TODO: Handle error. - } -} diff --git a/dataproc/apiv1beta2/longrunning.go b/dataproc/apiv1beta2/longrunning.go deleted file mode 100644 index e715254b382..00000000000 --- a/dataproc/apiv1beta2/longrunning.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dataproc - -import ( - "context" - - gax "github.com/googleapis/gax-go/v2" -) - -// Cancel starts asynchronous cancellation on a long-running operation. -// The server makes a best effort to cancel the operation, but success is not guaranteed. -// Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation -// completed despite cancellation. On successful cancellation, the operation is not deleted; -// instead, op.Poll returns an error with code Canceled. -func (op *InstantiateInlineWorkflowTemplateOperation) Cancel(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Cancel(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *InstantiateInlineWorkflowTemplateOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} - -// Cancel starts asynchronous cancellation on a long-running operation. -// The server makes a best effort to cancel the operation, but success is not guaranteed. -// Clients can use Poll or other methods to check whether the cancellation succeeded or whether the operation -// completed despite cancellation. On successful cancellation, the operation is not deleted; -// instead, op.Poll returns an error with code Canceled. -func (op *InstantiateWorkflowTemplateOperation) Cancel(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Cancel(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *InstantiateWorkflowTemplateOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *CreateClusterOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *DeleteClusterOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *DiagnoseClusterOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} - -// Delete deletes a long-running operation. -// This method indicates that the client is no longer interested in the operation result. -// It does not cancel the operation. -func (op *UpdateClusterOperation) Delete(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Delete(ctx, opts...) -} diff --git a/dataproc/apiv1beta2/mock_test.go b/dataproc/apiv1beta2/mock_test.go deleted file mode 100644 index 7ce3789f166..00000000000 --- a/dataproc/apiv1beta2/mock_test.go +++ /dev/null @@ -1,2177 +0,0 @@ -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by gapic-generator. DO NOT EDIT. - -package dataproc - -import ( - "context" - "flag" - "fmt" - "io" - "log" - "net" - "os" - "strings" - "testing" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - emptypb "github.com/golang/protobuf/ptypes/empty" - "google.golang.org/api/option" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" - longrunningpb "google.golang.org/genproto/googleapis/longrunning" - field_maskpb "google.golang.org/genproto/protobuf/field_mask" - - status "google.golang.org/genproto/googleapis/rpc/status" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" - - gstatus "google.golang.org/grpc/status" -) - -var _ = io.EOF -var _ = ptypes.MarshalAny -var _ status.Status - -type mockAutoscalingPolicyServer struct { - // Embed for forward compatibility. - // Tests will keep working if more methods are added - // in the future. - dataprocpb.AutoscalingPolicyServiceServer - - reqs []proto.Message - - // If set, all calls return this error. - err error - - // responses to return if err == nil - resps []proto.Message -} - -func (s *mockAutoscalingPolicyServer) CreateAutoscalingPolicy(ctx context.Context, req *dataprocpb.CreateAutoscalingPolicyRequest) (*dataprocpb.AutoscalingPolicy, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.AutoscalingPolicy), nil -} - -func (s *mockAutoscalingPolicyServer) UpdateAutoscalingPolicy(ctx context.Context, req *dataprocpb.UpdateAutoscalingPolicyRequest) (*dataprocpb.AutoscalingPolicy, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.AutoscalingPolicy), nil -} - -func (s *mockAutoscalingPolicyServer) GetAutoscalingPolicy(ctx context.Context, req *dataprocpb.GetAutoscalingPolicyRequest) (*dataprocpb.AutoscalingPolicy, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.AutoscalingPolicy), nil -} - -func (s *mockAutoscalingPolicyServer) ListAutoscalingPolicies(ctx context.Context, req *dataprocpb.ListAutoscalingPoliciesRequest) (*dataprocpb.ListAutoscalingPoliciesResponse, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.ListAutoscalingPoliciesResponse), nil -} - -func (s *mockAutoscalingPolicyServer) DeleteAutoscalingPolicy(ctx context.Context, req *dataprocpb.DeleteAutoscalingPolicyRequest) (*emptypb.Empty, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*emptypb.Empty), nil -} - -type mockClusterControllerServer struct { - // Embed for forward compatibility. - // Tests will keep working if more methods are added - // in the future. - dataprocpb.ClusterControllerServer - - reqs []proto.Message - - // If set, all calls return this error. - err error - - // responses to return if err == nil - resps []proto.Message -} - -func (s *mockClusterControllerServer) CreateCluster(ctx context.Context, req *dataprocpb.CreateClusterRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -func (s *mockClusterControllerServer) UpdateCluster(ctx context.Context, req *dataprocpb.UpdateClusterRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -func (s *mockClusterControllerServer) DeleteCluster(ctx context.Context, req *dataprocpb.DeleteClusterRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -func (s *mockClusterControllerServer) GetCluster(ctx context.Context, req *dataprocpb.GetClusterRequest) (*dataprocpb.Cluster, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.Cluster), nil -} - -func (s *mockClusterControllerServer) ListClusters(ctx context.Context, req *dataprocpb.ListClustersRequest) (*dataprocpb.ListClustersResponse, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.ListClustersResponse), nil -} - -func (s *mockClusterControllerServer) DiagnoseCluster(ctx context.Context, req *dataprocpb.DiagnoseClusterRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -type mockJobControllerServer struct { - // Embed for forward compatibility. - // Tests will keep working if more methods are added - // in the future. - dataprocpb.JobControllerServer - - reqs []proto.Message - - // If set, all calls return this error. - err error - - // responses to return if err == nil - resps []proto.Message -} - -func (s *mockJobControllerServer) SubmitJob(ctx context.Context, req *dataprocpb.SubmitJobRequest) (*dataprocpb.Job, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.Job), nil -} - -func (s *mockJobControllerServer) GetJob(ctx context.Context, req *dataprocpb.GetJobRequest) (*dataprocpb.Job, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.Job), nil -} - -func (s *mockJobControllerServer) ListJobs(ctx context.Context, req *dataprocpb.ListJobsRequest) (*dataprocpb.ListJobsResponse, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.ListJobsResponse), nil -} - -func (s *mockJobControllerServer) UpdateJob(ctx context.Context, req *dataprocpb.UpdateJobRequest) (*dataprocpb.Job, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.Job), nil -} - -func (s *mockJobControllerServer) CancelJob(ctx context.Context, req *dataprocpb.CancelJobRequest) (*dataprocpb.Job, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.Job), nil -} - -func (s *mockJobControllerServer) DeleteJob(ctx context.Context, req *dataprocpb.DeleteJobRequest) (*emptypb.Empty, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*emptypb.Empty), nil -} - -type mockWorkflowTemplateServer struct { - // Embed for forward compatibility. - // Tests will keep working if more methods are added - // in the future. - dataprocpb.WorkflowTemplateServiceServer - - reqs []proto.Message - - // If set, all calls return this error. - err error - - // responses to return if err == nil - resps []proto.Message -} - -func (s *mockWorkflowTemplateServer) CreateWorkflowTemplate(ctx context.Context, req *dataprocpb.CreateWorkflowTemplateRequest) (*dataprocpb.WorkflowTemplate, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.WorkflowTemplate), nil -} - -func (s *mockWorkflowTemplateServer) GetWorkflowTemplate(ctx context.Context, req *dataprocpb.GetWorkflowTemplateRequest) (*dataprocpb.WorkflowTemplate, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.WorkflowTemplate), nil -} - -func (s *mockWorkflowTemplateServer) InstantiateWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateWorkflowTemplateRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -func (s *mockWorkflowTemplateServer) InstantiateInlineWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateInlineWorkflowTemplateRequest) (*longrunningpb.Operation, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*longrunningpb.Operation), nil -} - -func (s *mockWorkflowTemplateServer) UpdateWorkflowTemplate(ctx context.Context, req *dataprocpb.UpdateWorkflowTemplateRequest) (*dataprocpb.WorkflowTemplate, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.WorkflowTemplate), nil -} - -func (s *mockWorkflowTemplateServer) ListWorkflowTemplates(ctx context.Context, req *dataprocpb.ListWorkflowTemplatesRequest) (*dataprocpb.ListWorkflowTemplatesResponse, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*dataprocpb.ListWorkflowTemplatesResponse), nil -} - -func (s *mockWorkflowTemplateServer) DeleteWorkflowTemplate(ctx context.Context, req *dataprocpb.DeleteWorkflowTemplateRequest) (*emptypb.Empty, error) { - md, _ := metadata.FromIncomingContext(ctx) - if xg := md["x-goog-api-client"]; len(xg) == 0 || !strings.Contains(xg[0], "gl-go/") { - return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg) - } - s.reqs = append(s.reqs, req) - if s.err != nil { - return nil, s.err - } - return s.resps[0].(*emptypb.Empty), nil -} - -// clientOpt is the option tests should use to connect to the test server. -// It is initialized by TestMain. -var clientOpt option.ClientOption - -var ( - mockAutoscalingPolicy mockAutoscalingPolicyServer - mockClusterController mockClusterControllerServer - mockJobController mockJobControllerServer - mockWorkflowTemplate mockWorkflowTemplateServer -) - -func TestMain(m *testing.M) { - flag.Parse() - - serv := grpc.NewServer() - dataprocpb.RegisterAutoscalingPolicyServiceServer(serv, &mockAutoscalingPolicy) - dataprocpb.RegisterClusterControllerServer(serv, &mockClusterController) - dataprocpb.RegisterJobControllerServer(serv, &mockJobController) - dataprocpb.RegisterWorkflowTemplateServiceServer(serv, &mockWorkflowTemplate) - - lis, err := net.Listen("tcp", "localhost:0") - if err != nil { - log.Fatal(err) - } - go serv.Serve(lis) - - conn, err := grpc.Dial(lis.Addr().String(), grpc.WithInsecure()) - if err != nil { - log.Fatal(err) - } - clientOpt = option.WithGRPCConn(conn) - - os.Exit(m.Run()) -} - -func TestAutoscalingPolicyServiceCreateAutoscalingPolicy(t *testing.T) { - var id string = "id3355" - var name string = "name3373707" - var expectedResponse = &dataprocpb.AutoscalingPolicy{ - Id: id, - Name: name, - } - - mockAutoscalingPolicy.err = nil - mockAutoscalingPolicy.reqs = nil - - mockAutoscalingPolicy.resps = append(mockAutoscalingPolicy.resps[:0], expectedResponse) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var policy *dataprocpb.AutoscalingPolicy = &dataprocpb.AutoscalingPolicy{} - var request = &dataprocpb.CreateAutoscalingPolicyRequest{ - Parent: formattedParent, - Policy: policy, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CreateAutoscalingPolicy(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockAutoscalingPolicy.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestAutoscalingPolicyServiceCreateAutoscalingPolicyError(t *testing.T) { - errCode := codes.PermissionDenied - mockAutoscalingPolicy.err = gstatus.Error(errCode, "test error") - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var policy *dataprocpb.AutoscalingPolicy = &dataprocpb.AutoscalingPolicy{} - var request = &dataprocpb.CreateAutoscalingPolicyRequest{ - Parent: formattedParent, - Policy: policy, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CreateAutoscalingPolicy(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestAutoscalingPolicyServiceUpdateAutoscalingPolicy(t *testing.T) { - var id string = "id3355" - var name string = "name3373707" - var expectedResponse = &dataprocpb.AutoscalingPolicy{ - Id: id, - Name: name, - } - - mockAutoscalingPolicy.err = nil - mockAutoscalingPolicy.reqs = nil - - mockAutoscalingPolicy.resps = append(mockAutoscalingPolicy.resps[:0], expectedResponse) - - var policy *dataprocpb.AutoscalingPolicy = &dataprocpb.AutoscalingPolicy{} - var request = &dataprocpb.UpdateAutoscalingPolicyRequest{ - Policy: policy, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateAutoscalingPolicy(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockAutoscalingPolicy.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestAutoscalingPolicyServiceUpdateAutoscalingPolicyError(t *testing.T) { - errCode := codes.PermissionDenied - mockAutoscalingPolicy.err = gstatus.Error(errCode, "test error") - - var policy *dataprocpb.AutoscalingPolicy = &dataprocpb.AutoscalingPolicy{} - var request = &dataprocpb.UpdateAutoscalingPolicyRequest{ - Policy: policy, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateAutoscalingPolicy(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestAutoscalingPolicyServiceGetAutoscalingPolicy(t *testing.T) { - var id string = "id3355" - var name2 string = "name2-1052831874" - var expectedResponse = &dataprocpb.AutoscalingPolicy{ - Id: id, - Name: name2, - } - - mockAutoscalingPolicy.err = nil - mockAutoscalingPolicy.reqs = nil - - mockAutoscalingPolicy.resps = append(mockAutoscalingPolicy.resps[:0], expectedResponse) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/autoscalingPolicies/%s", "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") - var request = &dataprocpb.GetAutoscalingPolicyRequest{ - Name: formattedName, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetAutoscalingPolicy(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockAutoscalingPolicy.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestAutoscalingPolicyServiceGetAutoscalingPolicyError(t *testing.T) { - errCode := codes.PermissionDenied - mockAutoscalingPolicy.err = gstatus.Error(errCode, "test error") - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/autoscalingPolicies/%s", "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") - var request = &dataprocpb.GetAutoscalingPolicyRequest{ - Name: formattedName, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetAutoscalingPolicy(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestAutoscalingPolicyServiceListAutoscalingPolicies(t *testing.T) { - var nextPageToken string = "" - var policiesElement *dataprocpb.AutoscalingPolicy = &dataprocpb.AutoscalingPolicy{} - var policies = []*dataprocpb.AutoscalingPolicy{policiesElement} - var expectedResponse = &dataprocpb.ListAutoscalingPoliciesResponse{ - NextPageToken: nextPageToken, - Policies: policies, - } - - mockAutoscalingPolicy.err = nil - mockAutoscalingPolicy.reqs = nil - - mockAutoscalingPolicy.resps = append(mockAutoscalingPolicy.resps[:0], expectedResponse) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var request = &dataprocpb.ListAutoscalingPoliciesRequest{ - Parent: formattedParent, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListAutoscalingPolicies(context.Background(), request).Next() - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockAutoscalingPolicy.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - want := (interface{})(expectedResponse.Policies[0]) - got := (interface{})(resp) - var ok bool - - switch want := (want).(type) { - case proto.Message: - ok = proto.Equal(want, got.(proto.Message)) - default: - ok = want == got - } - if !ok { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestAutoscalingPolicyServiceListAutoscalingPoliciesError(t *testing.T) { - errCode := codes.PermissionDenied - mockAutoscalingPolicy.err = gstatus.Error(errCode, "test error") - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var request = &dataprocpb.ListAutoscalingPoliciesRequest{ - Parent: formattedParent, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListAutoscalingPolicies(context.Background(), request).Next() - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestAutoscalingPolicyServiceDeleteAutoscalingPolicy(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockAutoscalingPolicy.err = nil - mockAutoscalingPolicy.reqs = nil - - mockAutoscalingPolicy.resps = append(mockAutoscalingPolicy.resps[:0], expectedResponse) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/autoscalingPolicies/%s", "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") - var request = &dataprocpb.DeleteAutoscalingPolicyRequest{ - Name: formattedName, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteAutoscalingPolicy(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockAutoscalingPolicy.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestAutoscalingPolicyServiceDeleteAutoscalingPolicyError(t *testing.T) { - errCode := codes.PermissionDenied - mockAutoscalingPolicy.err = gstatus.Error(errCode, "test error") - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/autoscalingPolicies/%s", "[PROJECT]", "[REGION]", "[AUTOSCALING_POLICY]") - var request = &dataprocpb.DeleteAutoscalingPolicyRequest{ - Name: formattedName, - } - - c, err := NewAutoscalingPolicyClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteAutoscalingPolicy(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestClusterControllerCreateCluster(t *testing.T) { - var projectId2 string = "projectId2939242356" - var clusterName string = "clusterName-1018081872" - var clusterUuid string = "clusterUuid-1017854240" - var expectedResponse = &dataprocpb.Cluster{ - ProjectId: projectId2, - ClusterName: clusterName, - ClusterUuid: clusterUuid, - } - - mockClusterController.err = nil - mockClusterController.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var cluster *dataprocpb.Cluster = &dataprocpb.Cluster{} - var request = &dataprocpb.CreateClusterRequest{ - ProjectId: projectId, - Region: region, - Cluster: cluster, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.CreateCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - resp, err := respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestClusterControllerCreateClusterError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = nil - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var cluster *dataprocpb.Cluster = &dataprocpb.Cluster{} - var request = &dataprocpb.CreateClusterRequest{ - ProjectId: projectId, - Region: region, - Cluster: cluster, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.CreateCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - resp, err := respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestClusterControllerUpdateCluster(t *testing.T) { - var projectId2 string = "projectId2939242356" - var clusterName2 string = "clusterName2875867491" - var clusterUuid string = "clusterUuid-1017854240" - var expectedResponse = &dataprocpb.Cluster{ - ProjectId: projectId2, - ClusterName: clusterName2, - ClusterUuid: clusterUuid, - } - - mockClusterController.err = nil - mockClusterController.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var cluster *dataprocpb.Cluster = &dataprocpb.Cluster{} - var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{} - var request = &dataprocpb.UpdateClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - Cluster: cluster, - UpdateMask: updateMask, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.UpdateCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - resp, err := respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestClusterControllerUpdateClusterError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = nil - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var cluster *dataprocpb.Cluster = &dataprocpb.Cluster{} - var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{} - var request = &dataprocpb.UpdateClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - Cluster: cluster, - UpdateMask: updateMask, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.UpdateCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - resp, err := respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestClusterControllerDeleteCluster(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockClusterController.err = nil - mockClusterController.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.DeleteClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.DeleteCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestClusterControllerDeleteClusterError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = nil - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.DeleteClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.DeleteCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestClusterControllerGetCluster(t *testing.T) { - var projectId2 string = "projectId2939242356" - var clusterName2 string = "clusterName2875867491" - var clusterUuid string = "clusterUuid-1017854240" - var expectedResponse = &dataprocpb.Cluster{ - ProjectId: projectId2, - ClusterName: clusterName2, - ClusterUuid: clusterUuid, - } - - mockClusterController.err = nil - mockClusterController.reqs = nil - - mockClusterController.resps = append(mockClusterController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.GetClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetCluster(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestClusterControllerGetClusterError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.GetClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetCluster(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestClusterControllerListClusters(t *testing.T) { - var nextPageToken string = "" - var clustersElement *dataprocpb.Cluster = &dataprocpb.Cluster{} - var clusters = []*dataprocpb.Cluster{clustersElement} - var expectedResponse = &dataprocpb.ListClustersResponse{ - NextPageToken: nextPageToken, - Clusters: clusters, - } - - mockClusterController.err = nil - mockClusterController.reqs = nil - - mockClusterController.resps = append(mockClusterController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var request = &dataprocpb.ListClustersRequest{ - ProjectId: projectId, - Region: region, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListClusters(context.Background(), request).Next() - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - want := (interface{})(expectedResponse.Clusters[0]) - got := (interface{})(resp) - var ok bool - - switch want := (want).(type) { - case proto.Message: - ok = proto.Equal(want, got.(proto.Message)) - default: - ok = want == got - } - if !ok { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestClusterControllerListClustersError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var request = &dataprocpb.ListClustersRequest{ - ProjectId: projectId, - Region: region, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListClusters(context.Background(), request).Next() - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestClusterControllerDiagnoseCluster(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockClusterController.err = nil - mockClusterController.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.DiagnoseClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.DiagnoseCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockClusterController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestClusterControllerDiagnoseClusterError(t *testing.T) { - errCode := codes.PermissionDenied - mockClusterController.err = nil - mockClusterController.resps = append(mockClusterController.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var clusterName string = "clusterName-1018081872" - var request = &dataprocpb.DiagnoseClusterRequest{ - ProjectId: projectId, - Region: region, - ClusterName: clusterName, - } - - c, err := NewClusterControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.DiagnoseCluster(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestJobControllerSubmitJob(t *testing.T) { - var submittedBy string = "submittedBy-2047729125" - var driverOutputResourceUri string = "driverOutputResourceUri-542229086" - var driverControlFilesUri string = "driverControlFilesUri207057643" - var jobUuid string = "jobUuid-1615012099" - var expectedResponse = &dataprocpb.Job{ - SubmittedBy: submittedBy, - DriverOutputResourceUri: driverOutputResourceUri, - DriverControlFilesUri: driverControlFilesUri, - JobUuid: jobUuid, - } - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var job *dataprocpb.Job = &dataprocpb.Job{} - var request = &dataprocpb.SubmitJobRequest{ - ProjectId: projectId, - Region: region, - Job: job, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.SubmitJob(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestJobControllerSubmitJobError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var job *dataprocpb.Job = &dataprocpb.Job{} - var request = &dataprocpb.SubmitJobRequest{ - ProjectId: projectId, - Region: region, - Job: job, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.SubmitJob(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestJobControllerGetJob(t *testing.T) { - var submittedBy string = "submittedBy-2047729125" - var driverOutputResourceUri string = "driverOutputResourceUri-542229086" - var driverControlFilesUri string = "driverControlFilesUri207057643" - var jobUuid string = "jobUuid-1615012099" - var expectedResponse = &dataprocpb.Job{ - SubmittedBy: submittedBy, - DriverOutputResourceUri: driverOutputResourceUri, - DriverControlFilesUri: driverControlFilesUri, - JobUuid: jobUuid, - } - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.GetJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetJob(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestJobControllerGetJobError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.GetJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetJob(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestJobControllerListJobs(t *testing.T) { - var nextPageToken string = "" - var jobsElement *dataprocpb.Job = &dataprocpb.Job{} - var jobs = []*dataprocpb.Job{jobsElement} - var expectedResponse = &dataprocpb.ListJobsResponse{ - NextPageToken: nextPageToken, - Jobs: jobs, - } - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var request = &dataprocpb.ListJobsRequest{ - ProjectId: projectId, - Region: region, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListJobs(context.Background(), request).Next() - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - want := (interface{})(expectedResponse.Jobs[0]) - got := (interface{})(resp) - var ok bool - - switch want := (want).(type) { - case proto.Message: - ok = proto.Equal(want, got.(proto.Message)) - default: - ok = want == got - } - if !ok { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestJobControllerListJobsError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var request = &dataprocpb.ListJobsRequest{ - ProjectId: projectId, - Region: region, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListJobs(context.Background(), request).Next() - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestJobControllerUpdateJob(t *testing.T) { - var submittedBy string = "submittedBy-2047729125" - var driverOutputResourceUri string = "driverOutputResourceUri-542229086" - var driverControlFilesUri string = "driverControlFilesUri207057643" - var jobUuid string = "jobUuid-1615012099" - var expectedResponse = &dataprocpb.Job{ - SubmittedBy: submittedBy, - DriverOutputResourceUri: driverOutputResourceUri, - DriverControlFilesUri: driverControlFilesUri, - JobUuid: jobUuid, - } - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var job *dataprocpb.Job = &dataprocpb.Job{} - var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{} - var request = &dataprocpb.UpdateJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - Job: job, - UpdateMask: updateMask, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateJob(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestJobControllerUpdateJobError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var job *dataprocpb.Job = &dataprocpb.Job{} - var updateMask *field_maskpb.FieldMask = &field_maskpb.FieldMask{} - var request = &dataprocpb.UpdateJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - Job: job, - UpdateMask: updateMask, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateJob(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestJobControllerCancelJob(t *testing.T) { - var submittedBy string = "submittedBy-2047729125" - var driverOutputResourceUri string = "driverOutputResourceUri-542229086" - var driverControlFilesUri string = "driverControlFilesUri207057643" - var jobUuid string = "jobUuid-1615012099" - var expectedResponse = &dataprocpb.Job{ - SubmittedBy: submittedBy, - DriverOutputResourceUri: driverOutputResourceUri, - DriverControlFilesUri: driverControlFilesUri, - JobUuid: jobUuid, - } - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.CancelJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CancelJob(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestJobControllerCancelJobError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.CancelJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CancelJob(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestJobControllerDeleteJob(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockJobController.err = nil - mockJobController.reqs = nil - - mockJobController.resps = append(mockJobController.resps[:0], expectedResponse) - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.DeleteJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteJob(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockJobController.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestJobControllerDeleteJobError(t *testing.T) { - errCode := codes.PermissionDenied - mockJobController.err = gstatus.Error(errCode, "test error") - - var projectId string = "projectId-1969970175" - var region string = "region-934795532" - var jobId string = "jobId-1154752291" - var request = &dataprocpb.DeleteJobRequest{ - ProjectId: projectId, - Region: region, - JobId: jobId, - } - - c, err := NewJobControllerClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteJob(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestWorkflowTemplateServiceCreateWorkflowTemplate(t *testing.T) { - var id string = "id3355" - var name string = "name3373707" - var version int32 = 351608024 - var expectedResponse = &dataprocpb.WorkflowTemplate{ - Id: id, - Name: name, - Version: version, - } - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], expectedResponse) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.CreateWorkflowTemplateRequest{ - Parent: formattedParent, - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CreateWorkflowTemplate(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestWorkflowTemplateServiceCreateWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = gstatus.Error(errCode, "test error") - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.CreateWorkflowTemplateRequest{ - Parent: formattedParent, - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.CreateWorkflowTemplate(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestWorkflowTemplateServiceGetWorkflowTemplate(t *testing.T) { - var id string = "id3355" - var name2 string = "name2-1052831874" - var version int32 = 351608024 - var expectedResponse = &dataprocpb.WorkflowTemplate{ - Id: id, - Name: name2, - Version: version, - } - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], expectedResponse) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.GetWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetWorkflowTemplate(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestWorkflowTemplateServiceGetWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = gstatus.Error(errCode, "test error") - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.GetWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.GetWorkflowTemplate(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestWorkflowTemplateServiceInstantiateWorkflowTemplate(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.InstantiateWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.InstantiateWorkflowTemplate(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestWorkflowTemplateServiceInstantiateWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.InstantiateWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.InstantiateWorkflowTemplate(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestWorkflowTemplateServiceInstantiateInlineWorkflowTemplate(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - any, err := ptypes.MarshalAny(expectedResponse) - if err != nil { - t.Fatal(err) - } - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Response{Response: any}, - }) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.InstantiateInlineWorkflowTemplateRequest{ - Parent: formattedParent, - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.InstantiateInlineWorkflowTemplate(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestWorkflowTemplateServiceInstantiateInlineWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], &longrunningpb.Operation{ - Name: "longrunning-test", - Done: true, - Result: &longrunningpb.Operation_Error{ - Error: &status.Status{ - Code: int32(errCode), - Message: "test error", - }, - }, - }) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.InstantiateInlineWorkflowTemplateRequest{ - Parent: formattedParent, - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - respLRO, err := c.InstantiateInlineWorkflowTemplate(context.Background(), request) - if err != nil { - t.Fatal(err) - } - err = respLRO.Wait(context.Background()) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} -func TestWorkflowTemplateServiceUpdateWorkflowTemplate(t *testing.T) { - var id string = "id3355" - var name string = "name3373707" - var version int32 = 351608024 - var expectedResponse = &dataprocpb.WorkflowTemplate{ - Id: id, - Name: name, - Version: version, - } - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], expectedResponse) - - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.UpdateWorkflowTemplateRequest{ - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateWorkflowTemplate(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - if want, got := expectedResponse, resp; !proto.Equal(want, got) { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestWorkflowTemplateServiceUpdateWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = gstatus.Error(errCode, "test error") - - var template *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var request = &dataprocpb.UpdateWorkflowTemplateRequest{ - Template: template, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.UpdateWorkflowTemplate(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestWorkflowTemplateServiceListWorkflowTemplates(t *testing.T) { - var nextPageToken string = "" - var templatesElement *dataprocpb.WorkflowTemplate = &dataprocpb.WorkflowTemplate{} - var templates = []*dataprocpb.WorkflowTemplate{templatesElement} - var expectedResponse = &dataprocpb.ListWorkflowTemplatesResponse{ - NextPageToken: nextPageToken, - Templates: templates, - } - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], expectedResponse) - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var request = &dataprocpb.ListWorkflowTemplatesRequest{ - Parent: formattedParent, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListWorkflowTemplates(context.Background(), request).Next() - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - - want := (interface{})(expectedResponse.Templates[0]) - got := (interface{})(resp) - var ok bool - - switch want := (want).(type) { - case proto.Message: - ok = proto.Equal(want, got.(proto.Message)) - default: - ok = want == got - } - if !ok { - t.Errorf("wrong response %q, want %q)", got, want) - } -} - -func TestWorkflowTemplateServiceListWorkflowTemplatesError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = gstatus.Error(errCode, "test error") - - var formattedParent string = fmt.Sprintf("projects/%s/regions/%s", "[PROJECT]", "[REGION]") - var request = &dataprocpb.ListWorkflowTemplatesRequest{ - Parent: formattedParent, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - resp, err := c.ListWorkflowTemplates(context.Background(), request).Next() - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } - _ = resp -} -func TestWorkflowTemplateServiceDeleteWorkflowTemplate(t *testing.T) { - var expectedResponse *emptypb.Empty = &emptypb.Empty{} - - mockWorkflowTemplate.err = nil - mockWorkflowTemplate.reqs = nil - - mockWorkflowTemplate.resps = append(mockWorkflowTemplate.resps[:0], expectedResponse) - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.DeleteWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteWorkflowTemplate(context.Background(), request) - - if err != nil { - t.Fatal(err) - } - - if want, got := request, mockWorkflowTemplate.reqs[0]; !proto.Equal(want, got) { - t.Errorf("wrong request %q, want %q", got, want) - } - -} - -func TestWorkflowTemplateServiceDeleteWorkflowTemplateError(t *testing.T) { - errCode := codes.PermissionDenied - mockWorkflowTemplate.err = gstatus.Error(errCode, "test error") - - var formattedName string = fmt.Sprintf("projects/%s/regions/%s/workflowTemplates/%s", "[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]") - var request = &dataprocpb.DeleteWorkflowTemplateRequest{ - Name: formattedName, - } - - c, err := NewWorkflowTemplateClient(context.Background(), clientOpt) - if err != nil { - t.Fatal(err) - } - - err = c.DeleteWorkflowTemplate(context.Background(), request) - - if st, ok := gstatus.FromError(err); !ok { - t.Errorf("got error %v, expected grpc error", err) - } else if c := st.Code(); c != errCode { - t.Errorf("got error code %q, want %q", c, errCode) - } -} diff --git a/dataproc/apiv1beta2/workflow_template_client.go b/dataproc/apiv1beta2/workflow_template_client.go deleted file mode 100644 index 4265af2fb5f..00000000000 --- a/dataproc/apiv1beta2/workflow_template_client.go +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc - -import ( - "context" - "fmt" - "math" - "net/url" - "time" - - "cloud.google.com/go/longrunning" - lroauto "cloud.google.com/go/longrunning/autogen" - gax "github.com/googleapis/gax-go/v2" - "google.golang.org/api/iterator" - "google.golang.org/api/option" - "google.golang.org/api/option/internaloption" - gtransport "google.golang.org/api/transport/grpc" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" - 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" -) - -var newWorkflowTemplateClientHook clientHook - -// WorkflowTemplateCallOptions contains the retry settings for each method of WorkflowTemplateClient. -type WorkflowTemplateCallOptions struct { - CreateWorkflowTemplate []gax.CallOption - GetWorkflowTemplate []gax.CallOption - InstantiateWorkflowTemplate []gax.CallOption - InstantiateInlineWorkflowTemplate []gax.CallOption - UpdateWorkflowTemplate []gax.CallOption - ListWorkflowTemplates []gax.CallOption - DeleteWorkflowTemplate []gax.CallOption -} - -func defaultWorkflowTemplateGRPCClientOptions() []option.ClientOption { - return []option.ClientOption{ - internaloption.WithDefaultEndpoint("dataproc.googleapis.com:443"), - internaloption.WithDefaultMTLSEndpoint("dataproc.mtls.googleapis.com:443"), - internaloption.WithDefaultAudience("https://dataproc.googleapis.com/"), - internaloption.WithDefaultScopes(DefaultAuthScopes()...), - internaloption.EnableJwtWithScope(), - option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), - option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), - } -} - -func defaultWorkflowTemplateCallOptions() *WorkflowTemplateCallOptions { - return &WorkflowTemplateCallOptions{ - CreateWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - GetWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Internal, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - InstantiateWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - InstantiateInlineWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - UpdateWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - ListWorkflowTemplates: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.DeadlineExceeded, - codes.Internal, - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - DeleteWorkflowTemplate: []gax.CallOption{ - gax.WithRetry(func() gax.Retryer { - return gax.OnCodes([]codes.Code{ - codes.Unavailable, - }, gax.Backoff{ - Initial: 100 * time.Millisecond, - Max: 60000 * time.Millisecond, - Multiplier: 1.30, - }) - }), - }, - } -} - -// internalWorkflowTemplateClient is an interface that defines the methods availaible from Cloud Dataproc API. -type internalWorkflowTemplateClient interface { - Close() error - setGoogleClientInfo(...string) - Connection() *grpc.ClientConn - CreateWorkflowTemplate(context.Context, *dataprocpb.CreateWorkflowTemplateRequest, ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) - GetWorkflowTemplate(context.Context, *dataprocpb.GetWorkflowTemplateRequest, ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) - InstantiateWorkflowTemplate(context.Context, *dataprocpb.InstantiateWorkflowTemplateRequest, ...gax.CallOption) (*InstantiateWorkflowTemplateOperation, error) - InstantiateWorkflowTemplateOperation(name string) *InstantiateWorkflowTemplateOperation - InstantiateInlineWorkflowTemplate(context.Context, *dataprocpb.InstantiateInlineWorkflowTemplateRequest, ...gax.CallOption) (*InstantiateInlineWorkflowTemplateOperation, error) - InstantiateInlineWorkflowTemplateOperation(name string) *InstantiateInlineWorkflowTemplateOperation - UpdateWorkflowTemplate(context.Context, *dataprocpb.UpdateWorkflowTemplateRequest, ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) - ListWorkflowTemplates(context.Context, *dataprocpb.ListWorkflowTemplatesRequest, ...gax.CallOption) *WorkflowTemplateIterator - DeleteWorkflowTemplate(context.Context, *dataprocpb.DeleteWorkflowTemplateRequest, ...gax.CallOption) error -} - -// WorkflowTemplateClient is a client for interacting with Cloud Dataproc API. -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -// -// The API interface for managing Workflow Templates in the -// Dataproc API. -type WorkflowTemplateClient struct { - // The internal transport-dependent client. - internalClient internalWorkflowTemplateClient - - // The call options for this service. - CallOptions *WorkflowTemplateCallOptions - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient *lroauto.OperationsClient -} - -// Wrapper methods routed to the internal client. - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *WorkflowTemplateClient) Close() error { - return c.internalClient.Close() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *WorkflowTemplateClient) setGoogleClientInfo(keyval ...string) { - c.internalClient.setGoogleClientInfo(keyval...) -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *WorkflowTemplateClient) Connection() *grpc.ClientConn { - return c.internalClient.Connection() -} - -// CreateWorkflowTemplate creates new workflow template. -func (c *WorkflowTemplateClient) CreateWorkflowTemplate(ctx context.Context, req *dataprocpb.CreateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - return c.internalClient.CreateWorkflowTemplate(ctx, req, opts...) -} - -// GetWorkflowTemplate retrieves the latest workflow template. -// -// Can retrieve previously instantiated template by specifying optional -// version parameter. -func (c *WorkflowTemplateClient) GetWorkflowTemplate(ctx context.Context, req *dataprocpb.GetWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - return c.internalClient.GetWorkflowTemplate(ctx, req, opts...) -} - -// InstantiateWorkflowTemplate instantiates a template and begins execution. -// -// The returned Operation can be used to track execution of -// workflow by polling -// operations.get. -// The Operation will complete when entire workflow is finished. -// -// The running workflow can be aborted via -// operations.cancel. -// This will cause any inflight jobs to be cancelled and workflow-owned -// clusters to be deleted. -// -// The Operation.metadata will be -// WorkflowMetadata. -// Also see Using -// WorkflowMetadata (at https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). -// -// On successful completion, -// Operation.response will be -// Empty. -func (c *WorkflowTemplateClient) InstantiateWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateWorkflowTemplateOperation, error) { - return c.internalClient.InstantiateWorkflowTemplate(ctx, req, opts...) -} - -// InstantiateWorkflowTemplateOperation returns a new InstantiateWorkflowTemplateOperation from a given name. -// The name must be that of a previously created InstantiateWorkflowTemplateOperation, possibly from a different process. -func (c *WorkflowTemplateClient) InstantiateWorkflowTemplateOperation(name string) *InstantiateWorkflowTemplateOperation { - return c.internalClient.InstantiateWorkflowTemplateOperation(name) -} - -// InstantiateInlineWorkflowTemplate instantiates a template and begins execution. -// -// This method is equivalent to executing the sequence -// CreateWorkflowTemplate, -// InstantiateWorkflowTemplate, -// DeleteWorkflowTemplate. -// -// The returned Operation can be used to track execution of -// workflow by polling -// operations.get. -// The Operation will complete when entire workflow is finished. -// -// The running workflow can be aborted via -// operations.cancel. -// This will cause any inflight jobs to be cancelled and workflow-owned -// clusters to be deleted. -// -// The Operation.metadata will be -// WorkflowMetadata (at https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#workflowmetadata). -// Also see Using -// WorkflowMetadata (at https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowmetadata). -// -// On successful completion, -// Operation.response will be -// Empty. -func (c *WorkflowTemplateClient) InstantiateInlineWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateInlineWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateInlineWorkflowTemplateOperation, error) { - return c.internalClient.InstantiateInlineWorkflowTemplate(ctx, req, opts...) -} - -// InstantiateInlineWorkflowTemplateOperation returns a new InstantiateInlineWorkflowTemplateOperation from a given name. -// The name must be that of a previously created InstantiateInlineWorkflowTemplateOperation, possibly from a different process. -func (c *WorkflowTemplateClient) InstantiateInlineWorkflowTemplateOperation(name string) *InstantiateInlineWorkflowTemplateOperation { - return c.internalClient.InstantiateInlineWorkflowTemplateOperation(name) -} - -// UpdateWorkflowTemplate updates (replaces) workflow template. The updated template -// must contain version that matches the current server version. -func (c *WorkflowTemplateClient) UpdateWorkflowTemplate(ctx context.Context, req *dataprocpb.UpdateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - return c.internalClient.UpdateWorkflowTemplate(ctx, req, opts...) -} - -// ListWorkflowTemplates lists workflows that match the specified filter in the request. -func (c *WorkflowTemplateClient) ListWorkflowTemplates(ctx context.Context, req *dataprocpb.ListWorkflowTemplatesRequest, opts ...gax.CallOption) *WorkflowTemplateIterator { - return c.internalClient.ListWorkflowTemplates(ctx, req, opts...) -} - -// DeleteWorkflowTemplate deletes a workflow template. It does not cancel in-progress workflows. -func (c *WorkflowTemplateClient) DeleteWorkflowTemplate(ctx context.Context, req *dataprocpb.DeleteWorkflowTemplateRequest, opts ...gax.CallOption) error { - return c.internalClient.DeleteWorkflowTemplate(ctx, req, opts...) -} - -// workflowTemplateGRPCClient is a client for interacting with Cloud Dataproc API over gRPC transport. -// -// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type workflowTemplateGRPCClient struct { - // Connection pool of gRPC connections to the service. - connPool gtransport.ConnPool - - // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE - disableDeadlines bool - - // Points back to the CallOptions field of the containing WorkflowTemplateClient - CallOptions **WorkflowTemplateCallOptions - - // The gRPC API client. - workflowTemplateClient dataprocpb.WorkflowTemplateServiceClient - - // LROClient is used internally to handle long-running operations. - // It is exposed so that its CallOptions can be modified if required. - // Users should not Close this client. - LROClient **lroauto.OperationsClient - - // The x-goog-* metadata to be sent with each request. - xGoogMetadata metadata.MD -} - -// NewWorkflowTemplateClient creates a new workflow template service client based on gRPC. -// The returned client must be Closed when it is done being used to clean up its underlying connections. -// -// The API interface for managing Workflow Templates in the -// Dataproc API. -func NewWorkflowTemplateClient(ctx context.Context, opts ...option.ClientOption) (*WorkflowTemplateClient, error) { - clientOpts := defaultWorkflowTemplateGRPCClientOptions() - if newWorkflowTemplateClientHook != nil { - hookOpts, err := newWorkflowTemplateClientHook(ctx, clientHookParams{}) - if err != nil { - return nil, err - } - clientOpts = append(clientOpts, hookOpts...) - } - - disableDeadlines, err := checkDisableDeadlines() - if err != nil { - return nil, err - } - - connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) - if err != nil { - return nil, err - } - client := WorkflowTemplateClient{CallOptions: defaultWorkflowTemplateCallOptions()} - - c := &workflowTemplateGRPCClient{ - connPool: connPool, - disableDeadlines: disableDeadlines, - workflowTemplateClient: dataprocpb.NewWorkflowTemplateServiceClient(connPool), - CallOptions: &client.CallOptions, - } - c.setGoogleClientInfo() - - client.internalClient = c - - client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) - if err != nil { - // This error "should not happen", since we are just reusing old connection pool - // and never actually need to dial. - // If this does happen, we could leak connp. However, we cannot close conn: - // If the user invoked the constructor with option.WithGRPCConn, - // we would close a connection that's still in use. - // TODO: investigate error conditions. - return nil, err - } - c.LROClient = &client.LROClient - return &client, nil -} - -// Connection returns a connection to the API service. -// -// Deprecated. -func (c *workflowTemplateGRPCClient) Connection() *grpc.ClientConn { - return c.connPool.Conn() -} - -// setGoogleClientInfo sets the name and version of the application in -// the `x-goog-api-client` header passed on each request. Intended for -// use by Google-written clients. -func (c *workflowTemplateGRPCClient) setGoogleClientInfo(keyval ...string) { - kv := append([]string{"gl-go", versionGo()}, keyval...) - kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) - c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) -} - -// Close closes the connection to the API service. The user should invoke this when -// the client is no longer required. -func (c *workflowTemplateGRPCClient) Close() error { - return c.connPool.Close() -} - -func (c *workflowTemplateGRPCClient) CreateWorkflowTemplate(ctx context.Context, req *dataprocpb.CreateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).CreateWorkflowTemplate[0:len((*c.CallOptions).CreateWorkflowTemplate):len((*c.CallOptions).CreateWorkflowTemplate)], opts...) - var resp *dataprocpb.WorkflowTemplate - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.workflowTemplateClient.CreateWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *workflowTemplateGRPCClient) GetWorkflowTemplate(ctx context.Context, req *dataprocpb.GetWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).GetWorkflowTemplate[0:len((*c.CallOptions).GetWorkflowTemplate):len((*c.CallOptions).GetWorkflowTemplate)], opts...) - var resp *dataprocpb.WorkflowTemplate - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.workflowTemplateClient.GetWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *workflowTemplateGRPCClient) InstantiateWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateWorkflowTemplateOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).InstantiateWorkflowTemplate[0:len((*c.CallOptions).InstantiateWorkflowTemplate):len((*c.CallOptions).InstantiateWorkflowTemplate)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.workflowTemplateClient.InstantiateWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &InstantiateWorkflowTemplateOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *workflowTemplateGRPCClient) InstantiateInlineWorkflowTemplate(ctx context.Context, req *dataprocpb.InstantiateInlineWorkflowTemplateRequest, opts ...gax.CallOption) (*InstantiateInlineWorkflowTemplateOperation, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).InstantiateInlineWorkflowTemplate[0:len((*c.CallOptions).InstantiateInlineWorkflowTemplate):len((*c.CallOptions).InstantiateInlineWorkflowTemplate)], opts...) - var resp *longrunningpb.Operation - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.workflowTemplateClient.InstantiateInlineWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return &InstantiateInlineWorkflowTemplateOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, resp), - }, nil -} - -func (c *workflowTemplateGRPCClient) UpdateWorkflowTemplate(ctx context.Context, req *dataprocpb.UpdateWorkflowTemplateRequest, opts ...gax.CallOption) (*dataprocpb.WorkflowTemplate, error) { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*time.Millisecond) - defer cancel() - ctx = cctx - } - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "template.name", url.QueryEscape(req.GetTemplate().GetName()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).UpdateWorkflowTemplate[0:len((*c.CallOptions).UpdateWorkflowTemplate):len((*c.CallOptions).UpdateWorkflowTemplate)], opts...) - var resp *dataprocpb.WorkflowTemplate - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - resp, err = c.workflowTemplateClient.UpdateWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, err - } - return resp, nil -} - -func (c *workflowTemplateGRPCClient) ListWorkflowTemplates(ctx context.Context, req *dataprocpb.ListWorkflowTemplatesRequest, opts ...gax.CallOption) *WorkflowTemplateIterator { - md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) - ctx = insertMetadata(ctx, c.xGoogMetadata, md) - opts = append((*c.CallOptions).ListWorkflowTemplates[0:len((*c.CallOptions).ListWorkflowTemplates):len((*c.CallOptions).ListWorkflowTemplates)], opts...) - it := &WorkflowTemplateIterator{} - req = proto.Clone(req).(*dataprocpb.ListWorkflowTemplatesRequest) - it.InternalFetch = func(pageSize int, pageToken string) ([]*dataprocpb.WorkflowTemplate, string, error) { - resp := &dataprocpb.ListWorkflowTemplatesResponse{} - 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.workflowTemplateClient.ListWorkflowTemplates(ctx, req, settings.GRPC...) - return err - }, opts...) - if err != nil { - return nil, "", err - } - - it.Response = resp - return resp.GetTemplates(), 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 *workflowTemplateGRPCClient) DeleteWorkflowTemplate(ctx context.Context, req *dataprocpb.DeleteWorkflowTemplateRequest, opts ...gax.CallOption) error { - if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 600000*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) - opts = append((*c.CallOptions).DeleteWorkflowTemplate[0:len((*c.CallOptions).DeleteWorkflowTemplate):len((*c.CallOptions).DeleteWorkflowTemplate)], opts...) - err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { - var err error - _, err = c.workflowTemplateClient.DeleteWorkflowTemplate(ctx, req, settings.GRPC...) - return err - }, opts...) - return err -} - -// InstantiateInlineWorkflowTemplateOperation manages a long-running operation from InstantiateInlineWorkflowTemplate. -type InstantiateInlineWorkflowTemplateOperation struct { - lro *longrunning.Operation -} - -// InstantiateInlineWorkflowTemplateOperation returns a new InstantiateInlineWorkflowTemplateOperation from a given name. -// The name must be that of a previously created InstantiateInlineWorkflowTemplateOperation, possibly from a different process. -func (c *workflowTemplateGRPCClient) InstantiateInlineWorkflowTemplateOperation(name string) *InstantiateInlineWorkflowTemplateOperation { - return &InstantiateInlineWorkflowTemplateOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *InstantiateInlineWorkflowTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *InstantiateInlineWorkflowTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Poll(ctx, nil, opts...) -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *InstantiateInlineWorkflowTemplateOperation) Metadata() (*dataprocpb.WorkflowMetadata, error) { - var meta dataprocpb.WorkflowMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *InstantiateInlineWorkflowTemplateOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *InstantiateInlineWorkflowTemplateOperation) Name() string { - return op.lro.Name() -} - -// InstantiateWorkflowTemplateOperation manages a long-running operation from InstantiateWorkflowTemplate. -type InstantiateWorkflowTemplateOperation struct { - lro *longrunning.Operation -} - -// InstantiateWorkflowTemplateOperation returns a new InstantiateWorkflowTemplateOperation from a given name. -// The name must be that of a previously created InstantiateWorkflowTemplateOperation, possibly from a different process. -func (c *workflowTemplateGRPCClient) InstantiateWorkflowTemplateOperation(name string) *InstantiateWorkflowTemplateOperation { - return &InstantiateWorkflowTemplateOperation{ - lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), - } -} - -// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. -// -// See documentation of Poll for error-handling information. -func (op *InstantiateWorkflowTemplateOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) -} - -// Poll fetches the latest state of the long-running operation. -// -// Poll also fetches the latest metadata, which can be retrieved by Metadata. -// -// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and -// the operation has completed with failure, the error is returned and op.Done will return true. -// If Poll succeeds and the operation has completed successfully, -// op.Done will return true, and the response of the operation is returned. -// If Poll succeeds and the operation has not completed, the returned response and error are both nil. -func (op *InstantiateWorkflowTemplateOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { - return op.lro.Poll(ctx, nil, opts...) -} - -// Metadata returns metadata associated with the long-running operation. -// Metadata itself does not contact the server, but Poll does. -// To get the latest metadata, call this method after a successful call to Poll. -// If the metadata is not available, the returned metadata and error are both nil. -func (op *InstantiateWorkflowTemplateOperation) Metadata() (*dataprocpb.WorkflowMetadata, error) { - var meta dataprocpb.WorkflowMetadata - if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { - return nil, nil - } else if err != nil { - return nil, err - } - return &meta, nil -} - -// Done reports whether the long-running operation has completed. -func (op *InstantiateWorkflowTemplateOperation) Done() bool { - return op.lro.Done() -} - -// Name returns the name of the long-running operation. -// The name is assigned by the server and is unique within the service from which the operation is created. -func (op *InstantiateWorkflowTemplateOperation) Name() string { - return op.lro.Name() -} - -// WorkflowTemplateIterator manages a stream of *dataprocpb.WorkflowTemplate. -type WorkflowTemplateIterator struct { - items []*dataprocpb.WorkflowTemplate - 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 []*dataprocpb.WorkflowTemplate, nextPageToken string, err error) -} - -// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. -func (it *WorkflowTemplateIterator) 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 *WorkflowTemplateIterator) Next() (*dataprocpb.WorkflowTemplate, error) { - var item *dataprocpb.WorkflowTemplate - if err := it.nextFunc(); err != nil { - return item, err - } - item = it.items[0] - it.items = it.items[1:] - return item, nil -} - -func (it *WorkflowTemplateIterator) bufLen() int { - return len(it.items) -} - -func (it *WorkflowTemplateIterator) takeBuf() interface{} { - b := it.items - it.items = nil - return b -} diff --git a/dataproc/apiv1beta2/workflow_template_client_example_test.go b/dataproc/apiv1beta2/workflow_template_client_example_test.go deleted file mode 100644 index 647e1f68d13..00000000000 --- a/dataproc/apiv1beta2/workflow_template_client_example_test.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go_gapic. DO NOT EDIT. - -package dataproc_test - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func ExampleNewWorkflowTemplateClient() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - // TODO: Use client. - _ = c -} - -func ExampleWorkflowTemplateClient_CreateWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateWorkflowTemplateRequest. - } - resp, err := c.CreateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleWorkflowTemplateClient_GetWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetWorkflowTemplateRequest. - } - resp, err := c.GetWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleWorkflowTemplateClient_InstantiateWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.InstantiateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#InstantiateWorkflowTemplateRequest. - } - op, err := c.InstantiateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -func ExampleWorkflowTemplateClient_InstantiateInlineWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.InstantiateInlineWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#InstantiateInlineWorkflowTemplateRequest. - } - op, err := c.InstantiateInlineWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -func ExampleWorkflowTemplateClient_UpdateWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateWorkflowTemplateRequest. - } - resp, err := c.UpdateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -func ExampleWorkflowTemplateClient_ListWorkflowTemplates() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListWorkflowTemplatesRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListWorkflowTemplatesRequest. - } - it := c.ListWorkflowTemplates(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -func ExampleWorkflowTemplateClient_DeleteWorkflowTemplate() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteWorkflowTemplateRequest. - } - err = c.DeleteWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } -} diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 5d5f843eeab..fc9dc2cb61e 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -388,14 +388,6 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "dataproc_v1.yaml", releaseLevel: "ga", }, - { - inputDirectoryPath: "google/cloud/dataproc/v1beta2", - pkg: "dataproc", - importPath: "cloud.google.com/go/dataproc/apiv1beta2", - gRPCServiceConfigPath: "dataproc_grpc_service_config.json", - apiServiceConfigPath: "dataproc_v1beta2.yaml", - releaseLevel: "beta", - }, { inputDirectoryPath: "google/cloud/kms/v1", pkg: "kms", diff --git a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/CreateAutoscalingPolicy/main.go b/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/CreateAutoscalingPolicy/main.go deleted file mode 100644 index 067f9b2a560..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/CreateAutoscalingPolicy/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_AutoscalingPolicyService_CreateAutoscalingPolicy_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateAutoscalingPolicyRequest. - } - resp, err := c.CreateAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_AutoscalingPolicyService_CreateAutoscalingPolicy_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/DeleteAutoscalingPolicy/main.go b/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/DeleteAutoscalingPolicy/main.go deleted file mode 100644 index e2c611a0af4..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/DeleteAutoscalingPolicy/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_AutoscalingPolicyService_DeleteAutoscalingPolicy_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteAutoscalingPolicyRequest. - } - err = c.DeleteAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_AutoscalingPolicyService_DeleteAutoscalingPolicy_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/GetAutoscalingPolicy/main.go b/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/GetAutoscalingPolicy/main.go deleted file mode 100644 index c9568d6654b..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/GetAutoscalingPolicy/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_AutoscalingPolicyService_GetAutoscalingPolicy_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetAutoscalingPolicyRequest. - } - resp, err := c.GetAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_AutoscalingPolicyService_GetAutoscalingPolicy_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/ListAutoscalingPolicies/main.go b/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/ListAutoscalingPolicies/main.go deleted file mode 100644 index 68718f0cc27..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/ListAutoscalingPolicies/main.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_AutoscalingPolicyService_ListAutoscalingPolicies_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListAutoscalingPoliciesRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListAutoscalingPoliciesRequest. - } - it := c.ListAutoscalingPolicies(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -// [END dataproc_v1beta2_generated_AutoscalingPolicyService_ListAutoscalingPolicies_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/UpdateAutoscalingPolicy/main.go b/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/UpdateAutoscalingPolicy/main.go deleted file mode 100644 index 21999f6312d..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/AutoscalingPolicyClient/UpdateAutoscalingPolicy/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_AutoscalingPolicyService_UpdateAutoscalingPolicy_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewAutoscalingPolicyClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateAutoscalingPolicyRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateAutoscalingPolicyRequest. - } - resp, err := c.UpdateAutoscalingPolicy(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_AutoscalingPolicyService_UpdateAutoscalingPolicy_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/CreateCluster/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/CreateCluster/main.go deleted file mode 100644 index f11cb6882d0..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/CreateCluster/main.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_CreateCluster_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateClusterRequest. - } - op, err := c.CreateCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_ClusterController_CreateCluster_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DeleteCluster/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DeleteCluster/main.go deleted file mode 100644 index ca69fdab458..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DeleteCluster/main.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_DeleteCluster_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteClusterRequest. - } - op, err := c.DeleteCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_ClusterController_DeleteCluster_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DiagnoseCluster/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DiagnoseCluster/main.go deleted file mode 100644 index 0d776dbf63e..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/DiagnoseCluster/main.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_DiagnoseCluster_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DiagnoseClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DiagnoseClusterRequest. - } - op, err := c.DiagnoseCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_ClusterController_DiagnoseCluster_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/GetCluster/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/GetCluster/main.go deleted file mode 100644 index 0a1a4d473eb..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/GetCluster/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_GetCluster_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetClusterRequest. - } - resp, err := c.GetCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_ClusterController_GetCluster_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/ListClusters/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/ListClusters/main.go deleted file mode 100644 index 06ff203bee6..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/ListClusters/main.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_ListClusters_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListClustersRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListClustersRequest. - } - it := c.ListClusters(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -// [END dataproc_v1beta2_generated_ClusterController_ListClusters_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/UpdateCluster/main.go b/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/UpdateCluster/main.go deleted file mode 100644 index d4ab807b26f..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/ClusterControllerClient/UpdateCluster/main.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_ClusterController_UpdateCluster_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewClusterControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateClusterRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateClusterRequest. - } - op, err := c.UpdateCluster(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_ClusterController_UpdateCluster_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/CancelJob/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/CancelJob/main.go deleted file mode 100644 index cf989c69f86..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/CancelJob/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_CancelJob_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CancelJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CancelJobRequest. - } - resp, err := c.CancelJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_JobController_CancelJob_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/DeleteJob/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/DeleteJob/main.go deleted file mode 100644 index 4ec6e81eb40..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/DeleteJob/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_DeleteJob_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteJobRequest. - } - err = c.DeleteJob(ctx, req) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_JobController_DeleteJob_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/GetJob/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/GetJob/main.go deleted file mode 100644 index 0f18aeb3db5..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/GetJob/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_GetJob_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetJobRequest. - } - resp, err := c.GetJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_JobController_GetJob_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/ListJobs/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/ListJobs/main.go deleted file mode 100644 index 35bec8cd66b..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/ListJobs/main.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_ListJobs_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListJobsRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListJobsRequest. - } - it := c.ListJobs(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -// [END dataproc_v1beta2_generated_JobController_ListJobs_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJob/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJob/main.go deleted file mode 100644 index a9d91393d4a..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJob/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_SubmitJob_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.SubmitJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#SubmitJobRequest. - } - resp, err := c.SubmitJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_JobController_SubmitJob_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJobAsOperation/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJobAsOperation/main.go deleted file mode 100644 index 87689ed8909..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/SubmitJobAsOperation/main.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_SubmitJobAsOperation_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.SubmitJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#SubmitJobRequest. - } - op, err := c.SubmitJobAsOperation(ctx, req) - if err != nil { - // TODO: Handle error. - } - - resp, err := op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_JobController_SubmitJobAsOperation_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/UpdateJob/main.go b/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/UpdateJob/main.go deleted file mode 100644 index c110c94b355..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/JobControllerClient/UpdateJob/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_JobController_UpdateJob_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewJobControllerClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateJobRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateJobRequest. - } - resp, err := c.UpdateJob(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_JobController_UpdateJob_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/CreateWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/CreateWorkflowTemplate/main.go deleted file mode 100644 index 08539deb893..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/CreateWorkflowTemplate/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_CreateWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.CreateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#CreateWorkflowTemplateRequest. - } - resp, err := c.CreateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_CreateWorkflowTemplate_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/DeleteWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/DeleteWorkflowTemplate/main.go deleted file mode 100644 index f1144df56cd..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/DeleteWorkflowTemplate/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_DeleteWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.DeleteWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#DeleteWorkflowTemplateRequest. - } - err = c.DeleteWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_DeleteWorkflowTemplate_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/GetWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/GetWorkflowTemplate/main.go deleted file mode 100644 index 4846563031a..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/GetWorkflowTemplate/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_GetWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.GetWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#GetWorkflowTemplateRequest. - } - resp, err := c.GetWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_GetWorkflowTemplate_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateInlineWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateInlineWorkflowTemplate/main.go deleted file mode 100644 index 2ff23d4200d..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateInlineWorkflowTemplate/main.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_InstantiateInlineWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.InstantiateInlineWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#InstantiateInlineWorkflowTemplateRequest. - } - op, err := c.InstantiateInlineWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_InstantiateInlineWorkflowTemplate_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateWorkflowTemplate/main.go deleted file mode 100644 index c3c35652ee3..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/InstantiateWorkflowTemplate/main.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_InstantiateWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.InstantiateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#InstantiateWorkflowTemplateRequest. - } - op, err := c.InstantiateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - - err = op.Wait(ctx) - if err != nil { - // TODO: Handle error. - } -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_InstantiateWorkflowTemplate_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/ListWorkflowTemplates/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/ListWorkflowTemplates/main.go deleted file mode 100644 index 28fad654999..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/ListWorkflowTemplates/main.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_ListWorkflowTemplates_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - "google.golang.org/api/iterator" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.ListWorkflowTemplatesRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#ListWorkflowTemplatesRequest. - } - it := c.ListWorkflowTemplates(ctx, req) - for { - resp, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp - } -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_ListWorkflowTemplates_sync] diff --git a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/UpdateWorkflowTemplate/main.go b/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/UpdateWorkflowTemplate/main.go deleted file mode 100644 index f45cee9d4e7..00000000000 --- a/internal/generated/snippets/dataproc/apiv1beta2/WorkflowTemplateClient/UpdateWorkflowTemplate/main.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2021 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 dataproc_v1beta2_generated_WorkflowTemplateService_UpdateWorkflowTemplate_sync] - -package main - -import ( - "context" - - dataproc "cloud.google.com/go/dataproc/apiv1beta2" - dataprocpb "google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2" -) - -func main() { - ctx := context.Background() - c, err := dataproc.NewWorkflowTemplateClient(ctx) - if err != nil { - // TODO: Handle error. - } - defer c.Close() - - req := &dataprocpb.UpdateWorkflowTemplateRequest{ - // TODO: Fill request struct fields. - // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/dataproc/v1beta2#UpdateWorkflowTemplateRequest. - } - resp, err := c.UpdateWorkflowTemplate(ctx, req) - if err != nil { - // TODO: Handle error. - } - // TODO: Use resp. - _ = resp -} - -// [END dataproc_v1beta2_generated_WorkflowTemplateService_UpdateWorkflowTemplate_sync]