From 29df85c40ab64d59e389a980c9ce550077839763 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Mon, 10 May 2021 12:56:33 -0600 Subject: [PATCH] feat(clouddms): start generating apiv1 (#4081) --- clouddms/apiv1/data_migration_client.go | 1531 +++++++++++++++++ .../data_migration_client_example_test.go | 445 +++++ clouddms/apiv1/doc.go | 117 ++ clouddms/apiv1/gapic_metadata.json | 103 ++ internal/.repo-metadata-full.json | 9 + internal/gapicgen/generator/config.go | 9 + 6 files changed, 2214 insertions(+) create mode 100644 clouddms/apiv1/data_migration_client.go create mode 100644 clouddms/apiv1/data_migration_client_example_test.go create mode 100644 clouddms/apiv1/doc.go create mode 100644 clouddms/apiv1/gapic_metadata.json diff --git a/clouddms/apiv1/data_migration_client.go b/clouddms/apiv1/data_migration_client.go new file mode 100644 index 00000000000..b1938f0edb2 --- /dev/null +++ b/clouddms/apiv1/data_migration_client.go @@ -0,0 +1,1531 @@ +// 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 clouddms + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + 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" + clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +var newDataMigrationClientHook clientHook + +// DataMigrationCallOptions contains the retry settings for each method of DataMigrationClient. +type DataMigrationCallOptions struct { + ListMigrationJobs []gax.CallOption + GetMigrationJob []gax.CallOption + CreateMigrationJob []gax.CallOption + UpdateMigrationJob []gax.CallOption + DeleteMigrationJob []gax.CallOption + StartMigrationJob []gax.CallOption + StopMigrationJob []gax.CallOption + ResumeMigrationJob []gax.CallOption + PromoteMigrationJob []gax.CallOption + VerifyMigrationJob []gax.CallOption + RestartMigrationJob []gax.CallOption + GenerateSshScript []gax.CallOption + ListConnectionProfiles []gax.CallOption + GetConnectionProfile []gax.CallOption + CreateConnectionProfile []gax.CallOption + UpdateConnectionProfile []gax.CallOption + DeleteConnectionProfile []gax.CallOption +} + +func defaultDataMigrationClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("datamigration.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("datamigration.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://datamigration.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultDataMigrationCallOptions() *DataMigrationCallOptions { + return &DataMigrationCallOptions{ + ListMigrationJobs: []gax.CallOption{}, + GetMigrationJob: []gax.CallOption{}, + CreateMigrationJob: []gax.CallOption{}, + UpdateMigrationJob: []gax.CallOption{}, + DeleteMigrationJob: []gax.CallOption{}, + StartMigrationJob: []gax.CallOption{}, + StopMigrationJob: []gax.CallOption{}, + ResumeMigrationJob: []gax.CallOption{}, + PromoteMigrationJob: []gax.CallOption{}, + VerifyMigrationJob: []gax.CallOption{}, + RestartMigrationJob: []gax.CallOption{}, + GenerateSshScript: []gax.CallOption{}, + ListConnectionProfiles: []gax.CallOption{}, + GetConnectionProfile: []gax.CallOption{}, + CreateConnectionProfile: []gax.CallOption{}, + UpdateConnectionProfile: []gax.CallOption{}, + DeleteConnectionProfile: []gax.CallOption{}, + } +} + +// DataMigrationClient is a client for interacting with Database Migration API. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type DataMigrationClient 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 + + // The gRPC API client. + dataMigrationClient clouddmspb.DataMigrationServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *DataMigrationCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewDataMigrationClient creates a new data migration service client. +// +// Database Migration service +func NewDataMigrationClient(ctx context.Context, opts ...option.ClientOption) (*DataMigrationClient, error) { + clientOpts := defaultDataMigrationClientOptions() + + if newDataMigrationClientHook != nil { + hookOpts, err := newDataMigrationClientHook(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 + } + c := &DataMigrationClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultDataMigrationCallOptions(), + + dataMigrationClient: clouddmspb.NewDataMigrationServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.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 + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *DataMigrationClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *DataMigrationClient) Close() error { + return c.connPool.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 *DataMigrationClient) 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...)) +} + +// ListMigrationJobs lists migration jobs in a given project and location. +func (c *DataMigrationClient) ListMigrationJobs(ctx context.Context, req *clouddmspb.ListMigrationJobsRequest, opts ...gax.CallOption) *MigrationJobIterator { + 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.ListMigrationJobs[0:len(c.CallOptions.ListMigrationJobs):len(c.CallOptions.ListMigrationJobs)], opts...) + it := &MigrationJobIterator{} + req = proto.Clone(req).(*clouddmspb.ListMigrationJobsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*clouddmspb.MigrationJob, string, error) { + var resp *clouddmspb.ListMigrationJobsResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.ListMigrationJobs(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetMigrationJobs(), 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 +} + +// GetMigrationJob gets details of a single migration job. +func (c *DataMigrationClient) GetMigrationJob(ctx context.Context, req *clouddmspb.GetMigrationJobRequest, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetMigrationJob[0:len(c.CallOptions.GetMigrationJob):len(c.CallOptions.GetMigrationJob)], opts...) + var resp *clouddmspb.MigrationJob + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.GetMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateMigrationJob creates a new migration job in a given project and location. +func (c *DataMigrationClient) CreateMigrationJob(ctx context.Context, req *clouddmspb.CreateMigrationJobRequest, opts ...gax.CallOption) (*CreateMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateMigrationJob[0:len(c.CallOptions.CreateMigrationJob):len(c.CallOptions.CreateMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.CreateMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateMigrationJob updates the parameters of a single migration job. +func (c *DataMigrationClient) UpdateMigrationJob(ctx context.Context, req *clouddmspb.UpdateMigrationJobRequest, opts ...gax.CallOption) (*UpdateMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "migration_job.name", url.QueryEscape(req.GetMigrationJob().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateMigrationJob[0:len(c.CallOptions.UpdateMigrationJob):len(c.CallOptions.UpdateMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.UpdateMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteMigrationJob deletes a single migration job. +func (c *DataMigrationClient) DeleteMigrationJob(ctx context.Context, req *clouddmspb.DeleteMigrationJobRequest, opts ...gax.CallOption) (*DeleteMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteMigrationJob[0:len(c.CallOptions.DeleteMigrationJob):len(c.CallOptions.DeleteMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.DeleteMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// StartMigrationJob start an already created migration job. +func (c *DataMigrationClient) StartMigrationJob(ctx context.Context, req *clouddmspb.StartMigrationJobRequest, opts ...gax.CallOption) (*StartMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.StartMigrationJob[0:len(c.CallOptions.StartMigrationJob):len(c.CallOptions.StartMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.StartMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &StartMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// StopMigrationJob stops a running migration job. +func (c *DataMigrationClient) StopMigrationJob(ctx context.Context, req *clouddmspb.StopMigrationJobRequest, opts ...gax.CallOption) (*StopMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.StopMigrationJob[0:len(c.CallOptions.StopMigrationJob):len(c.CallOptions.StopMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.StopMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &StopMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// ResumeMigrationJob resume a migration job that is currently stopped and is resumable (was +// stopped during CDC phase). +func (c *DataMigrationClient) ResumeMigrationJob(ctx context.Context, req *clouddmspb.ResumeMigrationJobRequest, opts ...gax.CallOption) (*ResumeMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ResumeMigrationJob[0:len(c.CallOptions.ResumeMigrationJob):len(c.CallOptions.ResumeMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.ResumeMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &ResumeMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PromoteMigrationJob promote a migration job, stopping replication to the destination and +// promoting the destination to be a standalone database. +func (c *DataMigrationClient) PromoteMigrationJob(ctx context.Context, req *clouddmspb.PromoteMigrationJobRequest, opts ...gax.CallOption) (*PromoteMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PromoteMigrationJob[0:len(c.CallOptions.PromoteMigrationJob):len(c.CallOptions.PromoteMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.PromoteMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &PromoteMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// VerifyMigrationJob verify a migration job, making sure the destination can reach the source +// and that all configuration and prerequisites are met. +func (c *DataMigrationClient) VerifyMigrationJob(ctx context.Context, req *clouddmspb.VerifyMigrationJobRequest, opts ...gax.CallOption) (*VerifyMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.VerifyMigrationJob[0:len(c.CallOptions.VerifyMigrationJob):len(c.CallOptions.VerifyMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.VerifyMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &VerifyMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// RestartMigrationJob restart a stopped or failed migration job, resetting the destination +// instance to its original state and starting the migration process from +// scratch. +func (c *DataMigrationClient) RestartMigrationJob(ctx context.Context, req *clouddmspb.RestartMigrationJobRequest, opts ...gax.CallOption) (*RestartMigrationJobOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.RestartMigrationJob[0:len(c.CallOptions.RestartMigrationJob):len(c.CallOptions.RestartMigrationJob)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.RestartMigrationJob(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &RestartMigrationJobOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GenerateSshScript generate a SSH configuration script to configure the reverse SSH +// connectivity. +func (c *DataMigrationClient) GenerateSshScript(ctx context.Context, req *clouddmspb.GenerateSshScriptRequest, opts ...gax.CallOption) (*clouddmspb.SshScript, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "migration_job", url.QueryEscape(req.GetMigrationJob()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GenerateSshScript[0:len(c.CallOptions.GenerateSshScript):len(c.CallOptions.GenerateSshScript)], opts...) + var resp *clouddmspb.SshScript + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.GenerateSshScript(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListConnectionProfiles retrieve a list of all connection profiles in a given project and location. +func (c *DataMigrationClient) ListConnectionProfiles(ctx context.Context, req *clouddmspb.ListConnectionProfilesRequest, opts ...gax.CallOption) *ConnectionProfileIterator { + 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.ListConnectionProfiles[0:len(c.CallOptions.ListConnectionProfiles):len(c.CallOptions.ListConnectionProfiles)], opts...) + it := &ConnectionProfileIterator{} + req = proto.Clone(req).(*clouddmspb.ListConnectionProfilesRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*clouddmspb.ConnectionProfile, string, error) { + var resp *clouddmspb.ListConnectionProfilesResponse + req.PageToken = pageToken + if pageSize > math.MaxInt32 { + req.PageSize = math.MaxInt32 + } else { + req.PageSize = int32(pageSize) + } + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.ListConnectionProfiles(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GetConnectionProfiles(), 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 +} + +// GetConnectionProfile gets details of a single connection profile. +func (c *DataMigrationClient) GetConnectionProfile(ctx context.Context, req *clouddmspb.GetConnectionProfileRequest, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetConnectionProfile[0:len(c.CallOptions.GetConnectionProfile):len(c.CallOptions.GetConnectionProfile)], opts...) + var resp *clouddmspb.ConnectionProfile + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.GetConnectionProfile(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateConnectionProfile creates a new connection profile in a given project and location. +func (c *DataMigrationClient) CreateConnectionProfile(ctx context.Context, req *clouddmspb.CreateConnectionProfileRequest, opts ...gax.CallOption) (*CreateConnectionProfileOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateConnectionProfile[0:len(c.CallOptions.CreateConnectionProfile):len(c.CallOptions.CreateConnectionProfile)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.CreateConnectionProfile(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateConnectionProfileOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateConnectionProfile update the configuration of a single connection profile. +func (c *DataMigrationClient) UpdateConnectionProfile(ctx context.Context, req *clouddmspb.UpdateConnectionProfileRequest, opts ...gax.CallOption) (*UpdateConnectionProfileOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "connection_profile.name", url.QueryEscape(req.GetConnectionProfile().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateConnectionProfile[0:len(c.CallOptions.UpdateConnectionProfile):len(c.CallOptions.UpdateConnectionProfile)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.UpdateConnectionProfile(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateConnectionProfileOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteConnectionProfile deletes a single Database Migration Service connection profile. +// A connection profile can only be deleted if it is not in use by any +// active migration jobs. +func (c *DataMigrationClient) DeleteConnectionProfile(ctx context.Context, req *clouddmspb.DeleteConnectionProfileRequest, opts ...gax.CallOption) (*DeleteConnectionProfileOperation, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) + defer cancel() + ctx = cctx + } + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteConnectionProfile[0:len(c.CallOptions.DeleteConnectionProfile):len(c.CallOptions.DeleteConnectionProfile)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.dataMigrationClient.DeleteConnectionProfile(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteConnectionProfileOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// CreateConnectionProfileOperation manages a long-running operation from CreateConnectionProfile. +type CreateConnectionProfileOperation struct { + lro *longrunning.Operation +} + +// CreateConnectionProfileOperation returns a new CreateConnectionProfileOperation from a given name. +// The name must be that of a previously created CreateConnectionProfileOperation, possibly from a different process. +func (c *DataMigrationClient) CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation { + return &CreateConnectionProfileOperation{ + 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 *CreateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { + var resp clouddmspb.ConnectionProfile + 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 *CreateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { + var resp clouddmspb.ConnectionProfile + 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 *CreateConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *CreateConnectionProfileOperation) 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 *CreateConnectionProfileOperation) Name() string { + return op.lro.Name() +} + +// CreateMigrationJobOperation manages a long-running operation from CreateMigrationJob. +type CreateMigrationJobOperation struct { + lro *longrunning.Operation +} + +// CreateMigrationJobOperation returns a new CreateMigrationJobOperation from a given name. +// The name must be that of a previously created CreateMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) CreateMigrationJobOperation(name string) *CreateMigrationJobOperation { + return &CreateMigrationJobOperation{ + 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 *CreateMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *CreateMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *CreateMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *CreateMigrationJobOperation) 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 *CreateMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// DeleteConnectionProfileOperation manages a long-running operation from DeleteConnectionProfile. +type DeleteConnectionProfileOperation struct { + lro *longrunning.Operation +} + +// DeleteConnectionProfileOperation returns a new DeleteConnectionProfileOperation from a given name. +// The name must be that of a previously created DeleteConnectionProfileOperation, possibly from a different process. +func (c *DataMigrationClient) DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation { + return &DeleteConnectionProfileOperation{ + 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 *DeleteConnectionProfileOperation) 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 *DeleteConnectionProfileOperation) 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 *DeleteConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *DeleteConnectionProfileOperation) 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 *DeleteConnectionProfileOperation) Name() string { + return op.lro.Name() +} + +// DeleteMigrationJobOperation manages a long-running operation from DeleteMigrationJob. +type DeleteMigrationJobOperation struct { + lro *longrunning.Operation +} + +// DeleteMigrationJobOperation returns a new DeleteMigrationJobOperation from a given name. +// The name must be that of a previously created DeleteMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) DeleteMigrationJobOperation(name string) *DeleteMigrationJobOperation { + return &DeleteMigrationJobOperation{ + 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 *DeleteMigrationJobOperation) 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 *DeleteMigrationJobOperation) 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 *DeleteMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *DeleteMigrationJobOperation) 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 *DeleteMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// PromoteMigrationJobOperation manages a long-running operation from PromoteMigrationJob. +type PromoteMigrationJobOperation struct { + lro *longrunning.Operation +} + +// PromoteMigrationJobOperation returns a new PromoteMigrationJobOperation from a given name. +// The name must be that of a previously created PromoteMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) PromoteMigrationJobOperation(name string) *PromoteMigrationJobOperation { + return &PromoteMigrationJobOperation{ + 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 *PromoteMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *PromoteMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *PromoteMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *PromoteMigrationJobOperation) 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 *PromoteMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// RestartMigrationJobOperation manages a long-running operation from RestartMigrationJob. +type RestartMigrationJobOperation struct { + lro *longrunning.Operation +} + +// RestartMigrationJobOperation returns a new RestartMigrationJobOperation from a given name. +// The name must be that of a previously created RestartMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) RestartMigrationJobOperation(name string) *RestartMigrationJobOperation { + return &RestartMigrationJobOperation{ + 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 *RestartMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *RestartMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *RestartMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *RestartMigrationJobOperation) 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 *RestartMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// ResumeMigrationJobOperation manages a long-running operation from ResumeMigrationJob. +type ResumeMigrationJobOperation struct { + lro *longrunning.Operation +} + +// ResumeMigrationJobOperation returns a new ResumeMigrationJobOperation from a given name. +// The name must be that of a previously created ResumeMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) ResumeMigrationJobOperation(name string) *ResumeMigrationJobOperation { + return &ResumeMigrationJobOperation{ + 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 *ResumeMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *ResumeMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *ResumeMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *ResumeMigrationJobOperation) 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 *ResumeMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// StartMigrationJobOperation manages a long-running operation from StartMigrationJob. +type StartMigrationJobOperation struct { + lro *longrunning.Operation +} + +// StartMigrationJobOperation returns a new StartMigrationJobOperation from a given name. +// The name must be that of a previously created StartMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) StartMigrationJobOperation(name string) *StartMigrationJobOperation { + return &StartMigrationJobOperation{ + 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 *StartMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *StartMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *StartMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *StartMigrationJobOperation) 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 *StartMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// StopMigrationJobOperation manages a long-running operation from StopMigrationJob. +type StopMigrationJobOperation struct { + lro *longrunning.Operation +} + +// StopMigrationJobOperation returns a new StopMigrationJobOperation from a given name. +// The name must be that of a previously created StopMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) StopMigrationJobOperation(name string) *StopMigrationJobOperation { + return &StopMigrationJobOperation{ + 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 *StopMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *StopMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *StopMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *StopMigrationJobOperation) 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 *StopMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// UpdateConnectionProfileOperation manages a long-running operation from UpdateConnectionProfile. +type UpdateConnectionProfileOperation struct { + lro *longrunning.Operation +} + +// UpdateConnectionProfileOperation returns a new UpdateConnectionProfileOperation from a given name. +// The name must be that of a previously created UpdateConnectionProfileOperation, possibly from a different process. +func (c *DataMigrationClient) UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation { + return &UpdateConnectionProfileOperation{ + 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 *UpdateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { + var resp clouddmspb.ConnectionProfile + 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 *UpdateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { + var resp clouddmspb.ConnectionProfile + 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 *UpdateConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *UpdateConnectionProfileOperation) 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 *UpdateConnectionProfileOperation) Name() string { + return op.lro.Name() +} + +// UpdateMigrationJobOperation manages a long-running operation from UpdateMigrationJob. +type UpdateMigrationJobOperation struct { + lro *longrunning.Operation +} + +// UpdateMigrationJobOperation returns a new UpdateMigrationJobOperation from a given name. +// The name must be that of a previously created UpdateMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) UpdateMigrationJobOperation(name string) *UpdateMigrationJobOperation { + return &UpdateMigrationJobOperation{ + 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 *UpdateMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *UpdateMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *UpdateMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *UpdateMigrationJobOperation) 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 *UpdateMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// VerifyMigrationJobOperation manages a long-running operation from VerifyMigrationJob. +type VerifyMigrationJobOperation struct { + lro *longrunning.Operation +} + +// VerifyMigrationJobOperation returns a new VerifyMigrationJobOperation from a given name. +// The name must be that of a previously created VerifyMigrationJobOperation, possibly from a different process. +func (c *DataMigrationClient) VerifyMigrationJobOperation(name string) *VerifyMigrationJobOperation { + return &VerifyMigrationJobOperation{ + 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 *VerifyMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *VerifyMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { + var resp clouddmspb.MigrationJob + 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 *VerifyMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { + var meta clouddmspb.OperationMetadata + 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 *VerifyMigrationJobOperation) 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 *VerifyMigrationJobOperation) Name() string { + return op.lro.Name() +} + +// ConnectionProfileIterator manages a stream of *clouddmspb.ConnectionProfile. +type ConnectionProfileIterator struct { + items []*clouddmspb.ConnectionProfile + 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 []*clouddmspb.ConnectionProfile, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *ConnectionProfileIterator) 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 *ConnectionProfileIterator) Next() (*clouddmspb.ConnectionProfile, error) { + var item *clouddmspb.ConnectionProfile + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *ConnectionProfileIterator) bufLen() int { + return len(it.items) +} + +func (it *ConnectionProfileIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} + +// MigrationJobIterator manages a stream of *clouddmspb.MigrationJob. +type MigrationJobIterator struct { + items []*clouddmspb.MigrationJob + 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 []*clouddmspb.MigrationJob, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *MigrationJobIterator) 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 *MigrationJobIterator) Next() (*clouddmspb.MigrationJob, error) { + var item *clouddmspb.MigrationJob + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *MigrationJobIterator) bufLen() int { + return len(it.items) +} + +func (it *MigrationJobIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/clouddms/apiv1/data_migration_client_example_test.go b/clouddms/apiv1/data_migration_client_example_test.go new file mode 100644 index 00000000000..32e321fcdaa --- /dev/null +++ b/clouddms/apiv1/data_migration_client_example_test.go @@ -0,0 +1,445 @@ +// 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 clouddms_test + +import ( + "context" + + clouddms "cloud.google.com/go/clouddms/apiv1" + "google.golang.org/api/iterator" + clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" +) + +func ExampleNewDataMigrationClient() { + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleDataMigrationClient_ListMigrationJobs() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.ListMigrationJobsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListMigrationJobs(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleDataMigrationClient_GetMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.GetMigrationJobRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_CreateMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.CreateMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_UpdateMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.UpdateMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_DeleteMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.DeleteMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleDataMigrationClient_StartMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.StartMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.StartMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_StopMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.StopMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.StopMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_ResumeMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.ResumeMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.ResumeMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_PromoteMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.PromoteMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.PromoteMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_VerifyMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.VerifyMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.VerifyMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_RestartMigrationJob() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.RestartMigrationJobRequest{ + // TODO: Fill request struct fields. + } + op, err := c.RestartMigrationJob(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_GenerateSshScript() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.GenerateSshScriptRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GenerateSshScript(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_ListConnectionProfiles() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.ListConnectionProfilesRequest{ + // TODO: Fill request struct fields. + } + it := c.ListConnectionProfiles(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleDataMigrationClient_GetConnectionProfile() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.GetConnectionProfileRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetConnectionProfile(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_CreateConnectionProfile() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.CreateConnectionProfileRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateConnectionProfile(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_UpdateConnectionProfile() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.UpdateConnectionProfileRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateConnectionProfile(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleDataMigrationClient_DeleteConnectionProfile() { + // import clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" + + ctx := context.Background() + c, err := clouddms.NewDataMigrationClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &clouddmspb.DeleteConnectionProfileRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteConnectionProfile(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} diff --git a/clouddms/apiv1/doc.go b/clouddms/apiv1/doc.go new file mode 100644 index 00000000000..aecf84bc7db --- /dev/null +++ b/clouddms/apiv1/doc.go @@ -0,0 +1,117 @@ +// 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 clouddms is an auto-generated package for the +// Database Migration API. +// +// Manage Cloud Database Migration Service resources on Google Cloud +// Platform. +// +// 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 pkg.go.dev/cloud.google.com/go. +package clouddms // import "cloud.google.com/go/clouddms/apiv1" + +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 = "20210510" + +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/clouddms/apiv1/gapic_metadata.json b/clouddms/apiv1/gapic_metadata.json new file mode 100644 index 00000000000..b6b1c33804f --- /dev/null +++ b/clouddms/apiv1/gapic_metadata.json @@ -0,0 +1,103 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", + "language": "go", + "protoPackage": "google.cloud.clouddms.v1", + "libraryPackage": "cloud.google.com/go/clouddms/apiv1", + "services": { + "DataMigrationService": { + "clients": { + "grpc": { + "libraryClient": "DataMigrationClient", + "rpcs": { + "CreateConnectionProfile": { + "methods": [ + "CreateConnectionProfile" + ] + }, + "CreateMigrationJob": { + "methods": [ + "CreateMigrationJob" + ] + }, + "DeleteConnectionProfile": { + "methods": [ + "DeleteConnectionProfile" + ] + }, + "DeleteMigrationJob": { + "methods": [ + "DeleteMigrationJob" + ] + }, + "GenerateSshScript": { + "methods": [ + "GenerateSshScript" + ] + }, + "GetConnectionProfile": { + "methods": [ + "GetConnectionProfile" + ] + }, + "GetMigrationJob": { + "methods": [ + "GetMigrationJob" + ] + }, + "ListConnectionProfiles": { + "methods": [ + "ListConnectionProfiles" + ] + }, + "ListMigrationJobs": { + "methods": [ + "ListMigrationJobs" + ] + }, + "PromoteMigrationJob": { + "methods": [ + "PromoteMigrationJob" + ] + }, + "RestartMigrationJob": { + "methods": [ + "RestartMigrationJob" + ] + }, + "ResumeMigrationJob": { + "methods": [ + "ResumeMigrationJob" + ] + }, + "StartMigrationJob": { + "methods": [ + "StartMigrationJob" + ] + }, + "StopMigrationJob": { + "methods": [ + "StopMigrationJob" + ] + }, + "UpdateConnectionProfile": { + "methods": [ + "UpdateConnectionProfile" + ] + }, + "UpdateMigrationJob": { + "methods": [ + "UpdateMigrationJob" + ] + }, + "VerifyMigrationJob": { + "methods": [ + "VerifyMigrationJob" + ] + } + } + } + } + } + } +} diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 371363c9f22..4f22e0d5a7b 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -269,6 +269,15 @@ "release_level": "ga", "library_type": "" }, + "cloud.google.com/go/clouddms/apiv1": { + "distribution_name": "cloud.google.com/go/clouddms/apiv1", + "description": "Database Migration API", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/clouddms/apiv1", + "release_level": "beta", + "library_type": "" + }, "cloud.google.com/go/cloudtasks/apiv2": { "distribution_name": "cloud.google.com/go/cloudtasks/apiv2", "description": "Cloud Tasks API", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index f0b9241541d..f41342abe97 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1063,6 +1063,15 @@ var microgenGapicConfigs = []*microgenConfig{ // GA after 2021/04/23 releaseLevel: "beta", }, + { + inputDirectoryPath: "google/cloud/clouddms/v1", + pkg: "clouddms", + importPath: "cloud.google.com/go/clouddms/apiv1", + gRPCServiceConfigPath: "google/cloud/clouddms/v1/library_grpc_service_config.json", + apiServiceConfigPath: "google/cloud/clouddms/v1/datamigration_v1.yaml", + // GA after 2021/06/10 + releaseLevel: "beta", + }, // Non-Cloud APIs {