1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17package clouddms 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 "cloud.google.com/go/longrunning" 27 lroauto "cloud.google.com/go/longrunning/autogen" 28 gax "github.com/googleapis/gax-go/v2" 29 "google.golang.org/api/iterator" 30 "google.golang.org/api/option" 31 "google.golang.org/api/option/internaloption" 32 gtransport "google.golang.org/api/transport/grpc" 33 clouddmspb "google.golang.org/genproto/googleapis/cloud/clouddms/v1" 34 longrunningpb "google.golang.org/genproto/googleapis/longrunning" 35 "google.golang.org/grpc" 36 "google.golang.org/grpc/metadata" 37 "google.golang.org/protobuf/proto" 38) 39 40var newDataMigrationClientHook clientHook 41 42// DataMigrationCallOptions contains the retry settings for each method of DataMigrationClient. 43type DataMigrationCallOptions struct { 44 ListMigrationJobs []gax.CallOption 45 GetMigrationJob []gax.CallOption 46 CreateMigrationJob []gax.CallOption 47 UpdateMigrationJob []gax.CallOption 48 DeleteMigrationJob []gax.CallOption 49 StartMigrationJob []gax.CallOption 50 StopMigrationJob []gax.CallOption 51 ResumeMigrationJob []gax.CallOption 52 PromoteMigrationJob []gax.CallOption 53 VerifyMigrationJob []gax.CallOption 54 RestartMigrationJob []gax.CallOption 55 GenerateSshScript []gax.CallOption 56 ListConnectionProfiles []gax.CallOption 57 GetConnectionProfile []gax.CallOption 58 CreateConnectionProfile []gax.CallOption 59 UpdateConnectionProfile []gax.CallOption 60 DeleteConnectionProfile []gax.CallOption 61} 62 63func defaultDataMigrationGRPCClientOptions() []option.ClientOption { 64 return []option.ClientOption{ 65 internaloption.WithDefaultEndpoint("datamigration.googleapis.com:443"), 66 internaloption.WithDefaultMTLSEndpoint("datamigration.mtls.googleapis.com:443"), 67 internaloption.WithDefaultAudience("https://datamigration.googleapis.com/"), 68 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 69 internaloption.EnableJwtWithScope(), 70 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 71 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 72 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 73 } 74} 75 76func defaultDataMigrationCallOptions() *DataMigrationCallOptions { 77 return &DataMigrationCallOptions{ 78 ListMigrationJobs: []gax.CallOption{}, 79 GetMigrationJob: []gax.CallOption{}, 80 CreateMigrationJob: []gax.CallOption{}, 81 UpdateMigrationJob: []gax.CallOption{}, 82 DeleteMigrationJob: []gax.CallOption{}, 83 StartMigrationJob: []gax.CallOption{}, 84 StopMigrationJob: []gax.CallOption{}, 85 ResumeMigrationJob: []gax.CallOption{}, 86 PromoteMigrationJob: []gax.CallOption{}, 87 VerifyMigrationJob: []gax.CallOption{}, 88 RestartMigrationJob: []gax.CallOption{}, 89 GenerateSshScript: []gax.CallOption{}, 90 ListConnectionProfiles: []gax.CallOption{}, 91 GetConnectionProfile: []gax.CallOption{}, 92 CreateConnectionProfile: []gax.CallOption{}, 93 UpdateConnectionProfile: []gax.CallOption{}, 94 DeleteConnectionProfile: []gax.CallOption{}, 95 } 96} 97 98// internalDataMigrationClient is an interface that defines the methods availaible from Database Migration API. 99type internalDataMigrationClient interface { 100 Close() error 101 setGoogleClientInfo(...string) 102 Connection() *grpc.ClientConn 103 ListMigrationJobs(context.Context, *clouddmspb.ListMigrationJobsRequest, ...gax.CallOption) *MigrationJobIterator 104 GetMigrationJob(context.Context, *clouddmspb.GetMigrationJobRequest, ...gax.CallOption) (*clouddmspb.MigrationJob, error) 105 CreateMigrationJob(context.Context, *clouddmspb.CreateMigrationJobRequest, ...gax.CallOption) (*CreateMigrationJobOperation, error) 106 CreateMigrationJobOperation(name string) *CreateMigrationJobOperation 107 UpdateMigrationJob(context.Context, *clouddmspb.UpdateMigrationJobRequest, ...gax.CallOption) (*UpdateMigrationJobOperation, error) 108 UpdateMigrationJobOperation(name string) *UpdateMigrationJobOperation 109 DeleteMigrationJob(context.Context, *clouddmspb.DeleteMigrationJobRequest, ...gax.CallOption) (*DeleteMigrationJobOperation, error) 110 DeleteMigrationJobOperation(name string) *DeleteMigrationJobOperation 111 StartMigrationJob(context.Context, *clouddmspb.StartMigrationJobRequest, ...gax.CallOption) (*StartMigrationJobOperation, error) 112 StartMigrationJobOperation(name string) *StartMigrationJobOperation 113 StopMigrationJob(context.Context, *clouddmspb.StopMigrationJobRequest, ...gax.CallOption) (*StopMigrationJobOperation, error) 114 StopMigrationJobOperation(name string) *StopMigrationJobOperation 115 ResumeMigrationJob(context.Context, *clouddmspb.ResumeMigrationJobRequest, ...gax.CallOption) (*ResumeMigrationJobOperation, error) 116 ResumeMigrationJobOperation(name string) *ResumeMigrationJobOperation 117 PromoteMigrationJob(context.Context, *clouddmspb.PromoteMigrationJobRequest, ...gax.CallOption) (*PromoteMigrationJobOperation, error) 118 PromoteMigrationJobOperation(name string) *PromoteMigrationJobOperation 119 VerifyMigrationJob(context.Context, *clouddmspb.VerifyMigrationJobRequest, ...gax.CallOption) (*VerifyMigrationJobOperation, error) 120 VerifyMigrationJobOperation(name string) *VerifyMigrationJobOperation 121 RestartMigrationJob(context.Context, *clouddmspb.RestartMigrationJobRequest, ...gax.CallOption) (*RestartMigrationJobOperation, error) 122 RestartMigrationJobOperation(name string) *RestartMigrationJobOperation 123 GenerateSshScript(context.Context, *clouddmspb.GenerateSshScriptRequest, ...gax.CallOption) (*clouddmspb.SshScript, error) 124 ListConnectionProfiles(context.Context, *clouddmspb.ListConnectionProfilesRequest, ...gax.CallOption) *ConnectionProfileIterator 125 GetConnectionProfile(context.Context, *clouddmspb.GetConnectionProfileRequest, ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) 126 CreateConnectionProfile(context.Context, *clouddmspb.CreateConnectionProfileRequest, ...gax.CallOption) (*CreateConnectionProfileOperation, error) 127 CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation 128 UpdateConnectionProfile(context.Context, *clouddmspb.UpdateConnectionProfileRequest, ...gax.CallOption) (*UpdateConnectionProfileOperation, error) 129 UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation 130 DeleteConnectionProfile(context.Context, *clouddmspb.DeleteConnectionProfileRequest, ...gax.CallOption) (*DeleteConnectionProfileOperation, error) 131 DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation 132} 133 134// DataMigrationClient is a client for interacting with Database Migration API. 135// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 136// 137// Database Migration service 138type DataMigrationClient struct { 139 // The internal transport-dependent client. 140 internalClient internalDataMigrationClient 141 142 // The call options for this service. 143 CallOptions *DataMigrationCallOptions 144 145 // LROClient is used internally to handle long-running operations. 146 // It is exposed so that its CallOptions can be modified if required. 147 // Users should not Close this client. 148 LROClient *lroauto.OperationsClient 149} 150 151// Wrapper methods routed to the internal client. 152 153// Close closes the connection to the API service. The user should invoke this when 154// the client is no longer required. 155func (c *DataMigrationClient) Close() error { 156 return c.internalClient.Close() 157} 158 159// setGoogleClientInfo sets the name and version of the application in 160// the `x-goog-api-client` header passed on each request. Intended for 161// use by Google-written clients. 162func (c *DataMigrationClient) setGoogleClientInfo(keyval ...string) { 163 c.internalClient.setGoogleClientInfo(keyval...) 164} 165 166// Connection returns a connection to the API service. 167// 168// Deprecated. 169func (c *DataMigrationClient) Connection() *grpc.ClientConn { 170 return c.internalClient.Connection() 171} 172 173// ListMigrationJobs lists migration jobs in a given project and location. 174func (c *DataMigrationClient) ListMigrationJobs(ctx context.Context, req *clouddmspb.ListMigrationJobsRequest, opts ...gax.CallOption) *MigrationJobIterator { 175 return c.internalClient.ListMigrationJobs(ctx, req, opts...) 176} 177 178// GetMigrationJob gets details of a single migration job. 179func (c *DataMigrationClient) GetMigrationJob(ctx context.Context, req *clouddmspb.GetMigrationJobRequest, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 180 return c.internalClient.GetMigrationJob(ctx, req, opts...) 181} 182 183// CreateMigrationJob creates a new migration job in a given project and location. 184func (c *DataMigrationClient) CreateMigrationJob(ctx context.Context, req *clouddmspb.CreateMigrationJobRequest, opts ...gax.CallOption) (*CreateMigrationJobOperation, error) { 185 return c.internalClient.CreateMigrationJob(ctx, req, opts...) 186} 187 188// CreateMigrationJobOperation returns a new CreateMigrationJobOperation from a given name. 189// The name must be that of a previously created CreateMigrationJobOperation, possibly from a different process. 190func (c *DataMigrationClient) CreateMigrationJobOperation(name string) *CreateMigrationJobOperation { 191 return c.internalClient.CreateMigrationJobOperation(name) 192} 193 194// UpdateMigrationJob updates the parameters of a single migration job. 195func (c *DataMigrationClient) UpdateMigrationJob(ctx context.Context, req *clouddmspb.UpdateMigrationJobRequest, opts ...gax.CallOption) (*UpdateMigrationJobOperation, error) { 196 return c.internalClient.UpdateMigrationJob(ctx, req, opts...) 197} 198 199// UpdateMigrationJobOperation returns a new UpdateMigrationJobOperation from a given name. 200// The name must be that of a previously created UpdateMigrationJobOperation, possibly from a different process. 201func (c *DataMigrationClient) UpdateMigrationJobOperation(name string) *UpdateMigrationJobOperation { 202 return c.internalClient.UpdateMigrationJobOperation(name) 203} 204 205// DeleteMigrationJob deletes a single migration job. 206func (c *DataMigrationClient) DeleteMigrationJob(ctx context.Context, req *clouddmspb.DeleteMigrationJobRequest, opts ...gax.CallOption) (*DeleteMigrationJobOperation, error) { 207 return c.internalClient.DeleteMigrationJob(ctx, req, opts...) 208} 209 210// DeleteMigrationJobOperation returns a new DeleteMigrationJobOperation from a given name. 211// The name must be that of a previously created DeleteMigrationJobOperation, possibly from a different process. 212func (c *DataMigrationClient) DeleteMigrationJobOperation(name string) *DeleteMigrationJobOperation { 213 return c.internalClient.DeleteMigrationJobOperation(name) 214} 215 216// StartMigrationJob start an already created migration job. 217func (c *DataMigrationClient) StartMigrationJob(ctx context.Context, req *clouddmspb.StartMigrationJobRequest, opts ...gax.CallOption) (*StartMigrationJobOperation, error) { 218 return c.internalClient.StartMigrationJob(ctx, req, opts...) 219} 220 221// StartMigrationJobOperation returns a new StartMigrationJobOperation from a given name. 222// The name must be that of a previously created StartMigrationJobOperation, possibly from a different process. 223func (c *DataMigrationClient) StartMigrationJobOperation(name string) *StartMigrationJobOperation { 224 return c.internalClient.StartMigrationJobOperation(name) 225} 226 227// StopMigrationJob stops a running migration job. 228func (c *DataMigrationClient) StopMigrationJob(ctx context.Context, req *clouddmspb.StopMigrationJobRequest, opts ...gax.CallOption) (*StopMigrationJobOperation, error) { 229 return c.internalClient.StopMigrationJob(ctx, req, opts...) 230} 231 232// StopMigrationJobOperation returns a new StopMigrationJobOperation from a given name. 233// The name must be that of a previously created StopMigrationJobOperation, possibly from a different process. 234func (c *DataMigrationClient) StopMigrationJobOperation(name string) *StopMigrationJobOperation { 235 return c.internalClient.StopMigrationJobOperation(name) 236} 237 238// ResumeMigrationJob resume a migration job that is currently stopped and is resumable (was 239// stopped during CDC phase). 240func (c *DataMigrationClient) ResumeMigrationJob(ctx context.Context, req *clouddmspb.ResumeMigrationJobRequest, opts ...gax.CallOption) (*ResumeMigrationJobOperation, error) { 241 return c.internalClient.ResumeMigrationJob(ctx, req, opts...) 242} 243 244// ResumeMigrationJobOperation returns a new ResumeMigrationJobOperation from a given name. 245// The name must be that of a previously created ResumeMigrationJobOperation, possibly from a different process. 246func (c *DataMigrationClient) ResumeMigrationJobOperation(name string) *ResumeMigrationJobOperation { 247 return c.internalClient.ResumeMigrationJobOperation(name) 248} 249 250// PromoteMigrationJob promote a migration job, stopping replication to the destination and 251// promoting the destination to be a standalone database. 252func (c *DataMigrationClient) PromoteMigrationJob(ctx context.Context, req *clouddmspb.PromoteMigrationJobRequest, opts ...gax.CallOption) (*PromoteMigrationJobOperation, error) { 253 return c.internalClient.PromoteMigrationJob(ctx, req, opts...) 254} 255 256// PromoteMigrationJobOperation returns a new PromoteMigrationJobOperation from a given name. 257// The name must be that of a previously created PromoteMigrationJobOperation, possibly from a different process. 258func (c *DataMigrationClient) PromoteMigrationJobOperation(name string) *PromoteMigrationJobOperation { 259 return c.internalClient.PromoteMigrationJobOperation(name) 260} 261 262// VerifyMigrationJob verify a migration job, making sure the destination can reach the source 263// and that all configuration and prerequisites are met. 264func (c *DataMigrationClient) VerifyMigrationJob(ctx context.Context, req *clouddmspb.VerifyMigrationJobRequest, opts ...gax.CallOption) (*VerifyMigrationJobOperation, error) { 265 return c.internalClient.VerifyMigrationJob(ctx, req, opts...) 266} 267 268// VerifyMigrationJobOperation returns a new VerifyMigrationJobOperation from a given name. 269// The name must be that of a previously created VerifyMigrationJobOperation, possibly from a different process. 270func (c *DataMigrationClient) VerifyMigrationJobOperation(name string) *VerifyMigrationJobOperation { 271 return c.internalClient.VerifyMigrationJobOperation(name) 272} 273 274// RestartMigrationJob restart a stopped or failed migration job, resetting the destination 275// instance to its original state and starting the migration process from 276// scratch. 277func (c *DataMigrationClient) RestartMigrationJob(ctx context.Context, req *clouddmspb.RestartMigrationJobRequest, opts ...gax.CallOption) (*RestartMigrationJobOperation, error) { 278 return c.internalClient.RestartMigrationJob(ctx, req, opts...) 279} 280 281// RestartMigrationJobOperation returns a new RestartMigrationJobOperation from a given name. 282// The name must be that of a previously created RestartMigrationJobOperation, possibly from a different process. 283func (c *DataMigrationClient) RestartMigrationJobOperation(name string) *RestartMigrationJobOperation { 284 return c.internalClient.RestartMigrationJobOperation(name) 285} 286 287// GenerateSshScript generate a SSH configuration script to configure the reverse SSH 288// connectivity. 289func (c *DataMigrationClient) GenerateSshScript(ctx context.Context, req *clouddmspb.GenerateSshScriptRequest, opts ...gax.CallOption) (*clouddmspb.SshScript, error) { 290 return c.internalClient.GenerateSshScript(ctx, req, opts...) 291} 292 293// ListConnectionProfiles retrieve a list of all connection profiles in a given project and location. 294func (c *DataMigrationClient) ListConnectionProfiles(ctx context.Context, req *clouddmspb.ListConnectionProfilesRequest, opts ...gax.CallOption) *ConnectionProfileIterator { 295 return c.internalClient.ListConnectionProfiles(ctx, req, opts...) 296} 297 298// GetConnectionProfile gets details of a single connection profile. 299func (c *DataMigrationClient) GetConnectionProfile(ctx context.Context, req *clouddmspb.GetConnectionProfileRequest, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 300 return c.internalClient.GetConnectionProfile(ctx, req, opts...) 301} 302 303// CreateConnectionProfile creates a new connection profile in a given project and location. 304func (c *DataMigrationClient) CreateConnectionProfile(ctx context.Context, req *clouddmspb.CreateConnectionProfileRequest, opts ...gax.CallOption) (*CreateConnectionProfileOperation, error) { 305 return c.internalClient.CreateConnectionProfile(ctx, req, opts...) 306} 307 308// CreateConnectionProfileOperation returns a new CreateConnectionProfileOperation from a given name. 309// The name must be that of a previously created CreateConnectionProfileOperation, possibly from a different process. 310func (c *DataMigrationClient) CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation { 311 return c.internalClient.CreateConnectionProfileOperation(name) 312} 313 314// UpdateConnectionProfile update the configuration of a single connection profile. 315func (c *DataMigrationClient) UpdateConnectionProfile(ctx context.Context, req *clouddmspb.UpdateConnectionProfileRequest, opts ...gax.CallOption) (*UpdateConnectionProfileOperation, error) { 316 return c.internalClient.UpdateConnectionProfile(ctx, req, opts...) 317} 318 319// UpdateConnectionProfileOperation returns a new UpdateConnectionProfileOperation from a given name. 320// The name must be that of a previously created UpdateConnectionProfileOperation, possibly from a different process. 321func (c *DataMigrationClient) UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation { 322 return c.internalClient.UpdateConnectionProfileOperation(name) 323} 324 325// DeleteConnectionProfile deletes a single Database Migration Service connection profile. 326// A connection profile can only be deleted if it is not in use by any 327// active migration jobs. 328func (c *DataMigrationClient) DeleteConnectionProfile(ctx context.Context, req *clouddmspb.DeleteConnectionProfileRequest, opts ...gax.CallOption) (*DeleteConnectionProfileOperation, error) { 329 return c.internalClient.DeleteConnectionProfile(ctx, req, opts...) 330} 331 332// DeleteConnectionProfileOperation returns a new DeleteConnectionProfileOperation from a given name. 333// The name must be that of a previously created DeleteConnectionProfileOperation, possibly from a different process. 334func (c *DataMigrationClient) DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation { 335 return c.internalClient.DeleteConnectionProfileOperation(name) 336} 337 338// dataMigrationGRPCClient is a client for interacting with Database Migration API over gRPC transport. 339// 340// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 341type dataMigrationGRPCClient struct { 342 // Connection pool of gRPC connections to the service. 343 connPool gtransport.ConnPool 344 345 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 346 disableDeadlines bool 347 348 // Points back to the CallOptions field of the containing DataMigrationClient 349 CallOptions **DataMigrationCallOptions 350 351 // The gRPC API client. 352 dataMigrationClient clouddmspb.DataMigrationServiceClient 353 354 // LROClient is used internally to handle long-running operations. 355 // It is exposed so that its CallOptions can be modified if required. 356 // Users should not Close this client. 357 LROClient **lroauto.OperationsClient 358 359 // The x-goog-* metadata to be sent with each request. 360 xGoogMetadata metadata.MD 361} 362 363// NewDataMigrationClient creates a new data migration service client based on gRPC. 364// The returned client must be Closed when it is done being used to clean up its underlying connections. 365// 366// Database Migration service 367func NewDataMigrationClient(ctx context.Context, opts ...option.ClientOption) (*DataMigrationClient, error) { 368 clientOpts := defaultDataMigrationGRPCClientOptions() 369 if newDataMigrationClientHook != nil { 370 hookOpts, err := newDataMigrationClientHook(ctx, clientHookParams{}) 371 if err != nil { 372 return nil, err 373 } 374 clientOpts = append(clientOpts, hookOpts...) 375 } 376 377 disableDeadlines, err := checkDisableDeadlines() 378 if err != nil { 379 return nil, err 380 } 381 382 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 383 if err != nil { 384 return nil, err 385 } 386 client := DataMigrationClient{CallOptions: defaultDataMigrationCallOptions()} 387 388 c := &dataMigrationGRPCClient{ 389 connPool: connPool, 390 disableDeadlines: disableDeadlines, 391 dataMigrationClient: clouddmspb.NewDataMigrationServiceClient(connPool), 392 CallOptions: &client.CallOptions, 393 } 394 c.setGoogleClientInfo() 395 396 client.internalClient = c 397 398 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 399 if err != nil { 400 // This error "should not happen", since we are just reusing old connection pool 401 // and never actually need to dial. 402 // If this does happen, we could leak connp. However, we cannot close conn: 403 // If the user invoked the constructor with option.WithGRPCConn, 404 // we would close a connection that's still in use. 405 // TODO: investigate error conditions. 406 return nil, err 407 } 408 c.LROClient = &client.LROClient 409 return &client, nil 410} 411 412// Connection returns a connection to the API service. 413// 414// Deprecated. 415func (c *dataMigrationGRPCClient) Connection() *grpc.ClientConn { 416 return c.connPool.Conn() 417} 418 419// setGoogleClientInfo sets the name and version of the application in 420// the `x-goog-api-client` header passed on each request. Intended for 421// use by Google-written clients. 422func (c *dataMigrationGRPCClient) setGoogleClientInfo(keyval ...string) { 423 kv := append([]string{"gl-go", versionGo()}, keyval...) 424 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 425 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 426} 427 428// Close closes the connection to the API service. The user should invoke this when 429// the client is no longer required. 430func (c *dataMigrationGRPCClient) Close() error { 431 return c.connPool.Close() 432} 433 434func (c *dataMigrationGRPCClient) ListMigrationJobs(ctx context.Context, req *clouddmspb.ListMigrationJobsRequest, opts ...gax.CallOption) *MigrationJobIterator { 435 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 436 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 437 opts = append((*c.CallOptions).ListMigrationJobs[0:len((*c.CallOptions).ListMigrationJobs):len((*c.CallOptions).ListMigrationJobs)], opts...) 438 it := &MigrationJobIterator{} 439 req = proto.Clone(req).(*clouddmspb.ListMigrationJobsRequest) 440 it.InternalFetch = func(pageSize int, pageToken string) ([]*clouddmspb.MigrationJob, string, error) { 441 resp := &clouddmspb.ListMigrationJobsResponse{} 442 if pageToken != "" { 443 req.PageToken = pageToken 444 } 445 if pageSize > math.MaxInt32 { 446 req.PageSize = math.MaxInt32 447 } else if pageSize != 0 { 448 req.PageSize = int32(pageSize) 449 } 450 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 451 var err error 452 resp, err = c.dataMigrationClient.ListMigrationJobs(ctx, req, settings.GRPC...) 453 return err 454 }, opts...) 455 if err != nil { 456 return nil, "", err 457 } 458 459 it.Response = resp 460 return resp.GetMigrationJobs(), resp.GetNextPageToken(), nil 461 } 462 fetch := func(pageSize int, pageToken string) (string, error) { 463 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 464 if err != nil { 465 return "", err 466 } 467 it.items = append(it.items, items...) 468 return nextPageToken, nil 469 } 470 471 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 472 it.pageInfo.MaxSize = int(req.GetPageSize()) 473 it.pageInfo.Token = req.GetPageToken() 474 475 return it 476} 477 478func (c *dataMigrationGRPCClient) GetMigrationJob(ctx context.Context, req *clouddmspb.GetMigrationJobRequest, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 479 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 480 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 481 defer cancel() 482 ctx = cctx 483 } 484 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 485 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 486 opts = append((*c.CallOptions).GetMigrationJob[0:len((*c.CallOptions).GetMigrationJob):len((*c.CallOptions).GetMigrationJob)], opts...) 487 var resp *clouddmspb.MigrationJob 488 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 489 var err error 490 resp, err = c.dataMigrationClient.GetMigrationJob(ctx, req, settings.GRPC...) 491 return err 492 }, opts...) 493 if err != nil { 494 return nil, err 495 } 496 return resp, nil 497} 498 499func (c *dataMigrationGRPCClient) CreateMigrationJob(ctx context.Context, req *clouddmspb.CreateMigrationJobRequest, opts ...gax.CallOption) (*CreateMigrationJobOperation, error) { 500 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 501 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 502 defer cancel() 503 ctx = cctx 504 } 505 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 506 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 507 opts = append((*c.CallOptions).CreateMigrationJob[0:len((*c.CallOptions).CreateMigrationJob):len((*c.CallOptions).CreateMigrationJob)], opts...) 508 var resp *longrunningpb.Operation 509 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 510 var err error 511 resp, err = c.dataMigrationClient.CreateMigrationJob(ctx, req, settings.GRPC...) 512 return err 513 }, opts...) 514 if err != nil { 515 return nil, err 516 } 517 return &CreateMigrationJobOperation{ 518 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 519 }, nil 520} 521 522func (c *dataMigrationGRPCClient) UpdateMigrationJob(ctx context.Context, req *clouddmspb.UpdateMigrationJobRequest, opts ...gax.CallOption) (*UpdateMigrationJobOperation, error) { 523 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 524 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 525 defer cancel() 526 ctx = cctx 527 } 528 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "migration_job.name", url.QueryEscape(req.GetMigrationJob().GetName()))) 529 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 530 opts = append((*c.CallOptions).UpdateMigrationJob[0:len((*c.CallOptions).UpdateMigrationJob):len((*c.CallOptions).UpdateMigrationJob)], opts...) 531 var resp *longrunningpb.Operation 532 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 533 var err error 534 resp, err = c.dataMigrationClient.UpdateMigrationJob(ctx, req, settings.GRPC...) 535 return err 536 }, opts...) 537 if err != nil { 538 return nil, err 539 } 540 return &UpdateMigrationJobOperation{ 541 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 542 }, nil 543} 544 545func (c *dataMigrationGRPCClient) DeleteMigrationJob(ctx context.Context, req *clouddmspb.DeleteMigrationJobRequest, opts ...gax.CallOption) (*DeleteMigrationJobOperation, error) { 546 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 547 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 548 defer cancel() 549 ctx = cctx 550 } 551 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 552 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 553 opts = append((*c.CallOptions).DeleteMigrationJob[0:len((*c.CallOptions).DeleteMigrationJob):len((*c.CallOptions).DeleteMigrationJob)], opts...) 554 var resp *longrunningpb.Operation 555 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 556 var err error 557 resp, err = c.dataMigrationClient.DeleteMigrationJob(ctx, req, settings.GRPC...) 558 return err 559 }, opts...) 560 if err != nil { 561 return nil, err 562 } 563 return &DeleteMigrationJobOperation{ 564 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 565 }, nil 566} 567 568func (c *dataMigrationGRPCClient) StartMigrationJob(ctx context.Context, req *clouddmspb.StartMigrationJobRequest, opts ...gax.CallOption) (*StartMigrationJobOperation, error) { 569 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 570 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 571 defer cancel() 572 ctx = cctx 573 } 574 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 575 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 576 opts = append((*c.CallOptions).StartMigrationJob[0:len((*c.CallOptions).StartMigrationJob):len((*c.CallOptions).StartMigrationJob)], opts...) 577 var resp *longrunningpb.Operation 578 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 579 var err error 580 resp, err = c.dataMigrationClient.StartMigrationJob(ctx, req, settings.GRPC...) 581 return err 582 }, opts...) 583 if err != nil { 584 return nil, err 585 } 586 return &StartMigrationJobOperation{ 587 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 588 }, nil 589} 590 591func (c *dataMigrationGRPCClient) StopMigrationJob(ctx context.Context, req *clouddmspb.StopMigrationJobRequest, opts ...gax.CallOption) (*StopMigrationJobOperation, error) { 592 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 593 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 594 defer cancel() 595 ctx = cctx 596 } 597 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 598 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 599 opts = append((*c.CallOptions).StopMigrationJob[0:len((*c.CallOptions).StopMigrationJob):len((*c.CallOptions).StopMigrationJob)], opts...) 600 var resp *longrunningpb.Operation 601 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 602 var err error 603 resp, err = c.dataMigrationClient.StopMigrationJob(ctx, req, settings.GRPC...) 604 return err 605 }, opts...) 606 if err != nil { 607 return nil, err 608 } 609 return &StopMigrationJobOperation{ 610 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 611 }, nil 612} 613 614func (c *dataMigrationGRPCClient) ResumeMigrationJob(ctx context.Context, req *clouddmspb.ResumeMigrationJobRequest, opts ...gax.CallOption) (*ResumeMigrationJobOperation, error) { 615 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 616 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 617 defer cancel() 618 ctx = cctx 619 } 620 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 621 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 622 opts = append((*c.CallOptions).ResumeMigrationJob[0:len((*c.CallOptions).ResumeMigrationJob):len((*c.CallOptions).ResumeMigrationJob)], opts...) 623 var resp *longrunningpb.Operation 624 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 625 var err error 626 resp, err = c.dataMigrationClient.ResumeMigrationJob(ctx, req, settings.GRPC...) 627 return err 628 }, opts...) 629 if err != nil { 630 return nil, err 631 } 632 return &ResumeMigrationJobOperation{ 633 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 634 }, nil 635} 636 637func (c *dataMigrationGRPCClient) PromoteMigrationJob(ctx context.Context, req *clouddmspb.PromoteMigrationJobRequest, opts ...gax.CallOption) (*PromoteMigrationJobOperation, error) { 638 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 639 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 640 defer cancel() 641 ctx = cctx 642 } 643 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 644 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 645 opts = append((*c.CallOptions).PromoteMigrationJob[0:len((*c.CallOptions).PromoteMigrationJob):len((*c.CallOptions).PromoteMigrationJob)], opts...) 646 var resp *longrunningpb.Operation 647 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 648 var err error 649 resp, err = c.dataMigrationClient.PromoteMigrationJob(ctx, req, settings.GRPC...) 650 return err 651 }, opts...) 652 if err != nil { 653 return nil, err 654 } 655 return &PromoteMigrationJobOperation{ 656 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 657 }, nil 658} 659 660func (c *dataMigrationGRPCClient) VerifyMigrationJob(ctx context.Context, req *clouddmspb.VerifyMigrationJobRequest, opts ...gax.CallOption) (*VerifyMigrationJobOperation, error) { 661 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 662 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 663 defer cancel() 664 ctx = cctx 665 } 666 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 667 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 668 opts = append((*c.CallOptions).VerifyMigrationJob[0:len((*c.CallOptions).VerifyMigrationJob):len((*c.CallOptions).VerifyMigrationJob)], opts...) 669 var resp *longrunningpb.Operation 670 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 671 var err error 672 resp, err = c.dataMigrationClient.VerifyMigrationJob(ctx, req, settings.GRPC...) 673 return err 674 }, opts...) 675 if err != nil { 676 return nil, err 677 } 678 return &VerifyMigrationJobOperation{ 679 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 680 }, nil 681} 682 683func (c *dataMigrationGRPCClient) RestartMigrationJob(ctx context.Context, req *clouddmspb.RestartMigrationJobRequest, opts ...gax.CallOption) (*RestartMigrationJobOperation, error) { 684 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 685 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 686 defer cancel() 687 ctx = cctx 688 } 689 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 690 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 691 opts = append((*c.CallOptions).RestartMigrationJob[0:len((*c.CallOptions).RestartMigrationJob):len((*c.CallOptions).RestartMigrationJob)], opts...) 692 var resp *longrunningpb.Operation 693 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 694 var err error 695 resp, err = c.dataMigrationClient.RestartMigrationJob(ctx, req, settings.GRPC...) 696 return err 697 }, opts...) 698 if err != nil { 699 return nil, err 700 } 701 return &RestartMigrationJobOperation{ 702 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 703 }, nil 704} 705 706func (c *dataMigrationGRPCClient) GenerateSshScript(ctx context.Context, req *clouddmspb.GenerateSshScriptRequest, opts ...gax.CallOption) (*clouddmspb.SshScript, error) { 707 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 708 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 709 defer cancel() 710 ctx = cctx 711 } 712 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "migration_job", url.QueryEscape(req.GetMigrationJob()))) 713 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 714 opts = append((*c.CallOptions).GenerateSshScript[0:len((*c.CallOptions).GenerateSshScript):len((*c.CallOptions).GenerateSshScript)], opts...) 715 var resp *clouddmspb.SshScript 716 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 717 var err error 718 resp, err = c.dataMigrationClient.GenerateSshScript(ctx, req, settings.GRPC...) 719 return err 720 }, opts...) 721 if err != nil { 722 return nil, err 723 } 724 return resp, nil 725} 726 727func (c *dataMigrationGRPCClient) ListConnectionProfiles(ctx context.Context, req *clouddmspb.ListConnectionProfilesRequest, opts ...gax.CallOption) *ConnectionProfileIterator { 728 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 729 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 730 opts = append((*c.CallOptions).ListConnectionProfiles[0:len((*c.CallOptions).ListConnectionProfiles):len((*c.CallOptions).ListConnectionProfiles)], opts...) 731 it := &ConnectionProfileIterator{} 732 req = proto.Clone(req).(*clouddmspb.ListConnectionProfilesRequest) 733 it.InternalFetch = func(pageSize int, pageToken string) ([]*clouddmspb.ConnectionProfile, string, error) { 734 resp := &clouddmspb.ListConnectionProfilesResponse{} 735 if pageToken != "" { 736 req.PageToken = pageToken 737 } 738 if pageSize > math.MaxInt32 { 739 req.PageSize = math.MaxInt32 740 } else if pageSize != 0 { 741 req.PageSize = int32(pageSize) 742 } 743 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 744 var err error 745 resp, err = c.dataMigrationClient.ListConnectionProfiles(ctx, req, settings.GRPC...) 746 return err 747 }, opts...) 748 if err != nil { 749 return nil, "", err 750 } 751 752 it.Response = resp 753 return resp.GetConnectionProfiles(), resp.GetNextPageToken(), nil 754 } 755 fetch := func(pageSize int, pageToken string) (string, error) { 756 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 757 if err != nil { 758 return "", err 759 } 760 it.items = append(it.items, items...) 761 return nextPageToken, nil 762 } 763 764 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 765 it.pageInfo.MaxSize = int(req.GetPageSize()) 766 it.pageInfo.Token = req.GetPageToken() 767 768 return it 769} 770 771func (c *dataMigrationGRPCClient) GetConnectionProfile(ctx context.Context, req *clouddmspb.GetConnectionProfileRequest, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 772 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 773 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 774 defer cancel() 775 ctx = cctx 776 } 777 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 778 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 779 opts = append((*c.CallOptions).GetConnectionProfile[0:len((*c.CallOptions).GetConnectionProfile):len((*c.CallOptions).GetConnectionProfile)], opts...) 780 var resp *clouddmspb.ConnectionProfile 781 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 782 var err error 783 resp, err = c.dataMigrationClient.GetConnectionProfile(ctx, req, settings.GRPC...) 784 return err 785 }, opts...) 786 if err != nil { 787 return nil, err 788 } 789 return resp, nil 790} 791 792func (c *dataMigrationGRPCClient) CreateConnectionProfile(ctx context.Context, req *clouddmspb.CreateConnectionProfileRequest, opts ...gax.CallOption) (*CreateConnectionProfileOperation, error) { 793 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 794 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 795 defer cancel() 796 ctx = cctx 797 } 798 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 799 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 800 opts = append((*c.CallOptions).CreateConnectionProfile[0:len((*c.CallOptions).CreateConnectionProfile):len((*c.CallOptions).CreateConnectionProfile)], opts...) 801 var resp *longrunningpb.Operation 802 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 803 var err error 804 resp, err = c.dataMigrationClient.CreateConnectionProfile(ctx, req, settings.GRPC...) 805 return err 806 }, opts...) 807 if err != nil { 808 return nil, err 809 } 810 return &CreateConnectionProfileOperation{ 811 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 812 }, nil 813} 814 815func (c *dataMigrationGRPCClient) UpdateConnectionProfile(ctx context.Context, req *clouddmspb.UpdateConnectionProfileRequest, opts ...gax.CallOption) (*UpdateConnectionProfileOperation, error) { 816 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 817 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 818 defer cancel() 819 ctx = cctx 820 } 821 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "connection_profile.name", url.QueryEscape(req.GetConnectionProfile().GetName()))) 822 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 823 opts = append((*c.CallOptions).UpdateConnectionProfile[0:len((*c.CallOptions).UpdateConnectionProfile):len((*c.CallOptions).UpdateConnectionProfile)], opts...) 824 var resp *longrunningpb.Operation 825 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 826 var err error 827 resp, err = c.dataMigrationClient.UpdateConnectionProfile(ctx, req, settings.GRPC...) 828 return err 829 }, opts...) 830 if err != nil { 831 return nil, err 832 } 833 return &UpdateConnectionProfileOperation{ 834 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 835 }, nil 836} 837 838func (c *dataMigrationGRPCClient) DeleteConnectionProfile(ctx context.Context, req *clouddmspb.DeleteConnectionProfileRequest, opts ...gax.CallOption) (*DeleteConnectionProfileOperation, error) { 839 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 840 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 841 defer cancel() 842 ctx = cctx 843 } 844 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 845 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 846 opts = append((*c.CallOptions).DeleteConnectionProfile[0:len((*c.CallOptions).DeleteConnectionProfile):len((*c.CallOptions).DeleteConnectionProfile)], opts...) 847 var resp *longrunningpb.Operation 848 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 849 var err error 850 resp, err = c.dataMigrationClient.DeleteConnectionProfile(ctx, req, settings.GRPC...) 851 return err 852 }, opts...) 853 if err != nil { 854 return nil, err 855 } 856 return &DeleteConnectionProfileOperation{ 857 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 858 }, nil 859} 860 861// CreateConnectionProfileOperation manages a long-running operation from CreateConnectionProfile. 862type CreateConnectionProfileOperation struct { 863 lro *longrunning.Operation 864} 865 866// CreateConnectionProfileOperation returns a new CreateConnectionProfileOperation from a given name. 867// The name must be that of a previously created CreateConnectionProfileOperation, possibly from a different process. 868func (c *dataMigrationGRPCClient) CreateConnectionProfileOperation(name string) *CreateConnectionProfileOperation { 869 return &CreateConnectionProfileOperation{ 870 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 871 } 872} 873 874// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 875// 876// See documentation of Poll for error-handling information. 877func (op *CreateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 878 var resp clouddmspb.ConnectionProfile 879 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 880 return nil, err 881 } 882 return &resp, nil 883} 884 885// Poll fetches the latest state of the long-running operation. 886// 887// Poll also fetches the latest metadata, which can be retrieved by Metadata. 888// 889// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 890// the operation has completed with failure, the error is returned and op.Done will return true. 891// If Poll succeeds and the operation has completed successfully, 892// op.Done will return true, and the response of the operation is returned. 893// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 894func (op *CreateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 895 var resp clouddmspb.ConnectionProfile 896 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 897 return nil, err 898 } 899 if !op.Done() { 900 return nil, nil 901 } 902 return &resp, nil 903} 904 905// Metadata returns metadata associated with the long-running operation. 906// Metadata itself does not contact the server, but Poll does. 907// To get the latest metadata, call this method after a successful call to Poll. 908// If the metadata is not available, the returned metadata and error are both nil. 909func (op *CreateConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 910 var meta clouddmspb.OperationMetadata 911 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 912 return nil, nil 913 } else if err != nil { 914 return nil, err 915 } 916 return &meta, nil 917} 918 919// Done reports whether the long-running operation has completed. 920func (op *CreateConnectionProfileOperation) Done() bool { 921 return op.lro.Done() 922} 923 924// Name returns the name of the long-running operation. 925// The name is assigned by the server and is unique within the service from which the operation is created. 926func (op *CreateConnectionProfileOperation) Name() string { 927 return op.lro.Name() 928} 929 930// CreateMigrationJobOperation manages a long-running operation from CreateMigrationJob. 931type CreateMigrationJobOperation struct { 932 lro *longrunning.Operation 933} 934 935// CreateMigrationJobOperation returns a new CreateMigrationJobOperation from a given name. 936// The name must be that of a previously created CreateMigrationJobOperation, possibly from a different process. 937func (c *dataMigrationGRPCClient) CreateMigrationJobOperation(name string) *CreateMigrationJobOperation { 938 return &CreateMigrationJobOperation{ 939 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 940 } 941} 942 943// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 944// 945// See documentation of Poll for error-handling information. 946func (op *CreateMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 947 var resp clouddmspb.MigrationJob 948 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 949 return nil, err 950 } 951 return &resp, nil 952} 953 954// Poll fetches the latest state of the long-running operation. 955// 956// Poll also fetches the latest metadata, which can be retrieved by Metadata. 957// 958// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 959// the operation has completed with failure, the error is returned and op.Done will return true. 960// If Poll succeeds and the operation has completed successfully, 961// op.Done will return true, and the response of the operation is returned. 962// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 963func (op *CreateMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 964 var resp clouddmspb.MigrationJob 965 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 966 return nil, err 967 } 968 if !op.Done() { 969 return nil, nil 970 } 971 return &resp, nil 972} 973 974// Metadata returns metadata associated with the long-running operation. 975// Metadata itself does not contact the server, but Poll does. 976// To get the latest metadata, call this method after a successful call to Poll. 977// If the metadata is not available, the returned metadata and error are both nil. 978func (op *CreateMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 979 var meta clouddmspb.OperationMetadata 980 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 981 return nil, nil 982 } else if err != nil { 983 return nil, err 984 } 985 return &meta, nil 986} 987 988// Done reports whether the long-running operation has completed. 989func (op *CreateMigrationJobOperation) Done() bool { 990 return op.lro.Done() 991} 992 993// Name returns the name of the long-running operation. 994// The name is assigned by the server and is unique within the service from which the operation is created. 995func (op *CreateMigrationJobOperation) Name() string { 996 return op.lro.Name() 997} 998 999// DeleteConnectionProfileOperation manages a long-running operation from DeleteConnectionProfile. 1000type DeleteConnectionProfileOperation struct { 1001 lro *longrunning.Operation 1002} 1003 1004// DeleteConnectionProfileOperation returns a new DeleteConnectionProfileOperation from a given name. 1005// The name must be that of a previously created DeleteConnectionProfileOperation, possibly from a different process. 1006func (c *dataMigrationGRPCClient) DeleteConnectionProfileOperation(name string) *DeleteConnectionProfileOperation { 1007 return &DeleteConnectionProfileOperation{ 1008 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1009 } 1010} 1011 1012// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1013// 1014// See documentation of Poll for error-handling information. 1015func (op *DeleteConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { 1016 return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) 1017} 1018 1019// Poll fetches the latest state of the long-running operation. 1020// 1021// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1022// 1023// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1024// the operation has completed with failure, the error is returned and op.Done will return true. 1025// If Poll succeeds and the operation has completed successfully, 1026// op.Done will return true, and the response of the operation is returned. 1027// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1028func (op *DeleteConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { 1029 return op.lro.Poll(ctx, nil, opts...) 1030} 1031 1032// Metadata returns metadata associated with the long-running operation. 1033// Metadata itself does not contact the server, but Poll does. 1034// To get the latest metadata, call this method after a successful call to Poll. 1035// If the metadata is not available, the returned metadata and error are both nil. 1036func (op *DeleteConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1037 var meta clouddmspb.OperationMetadata 1038 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1039 return nil, nil 1040 } else if err != nil { 1041 return nil, err 1042 } 1043 return &meta, nil 1044} 1045 1046// Done reports whether the long-running operation has completed. 1047func (op *DeleteConnectionProfileOperation) Done() bool { 1048 return op.lro.Done() 1049} 1050 1051// Name returns the name of the long-running operation. 1052// The name is assigned by the server and is unique within the service from which the operation is created. 1053func (op *DeleteConnectionProfileOperation) Name() string { 1054 return op.lro.Name() 1055} 1056 1057// DeleteMigrationJobOperation manages a long-running operation from DeleteMigrationJob. 1058type DeleteMigrationJobOperation struct { 1059 lro *longrunning.Operation 1060} 1061 1062// DeleteMigrationJobOperation returns a new DeleteMigrationJobOperation from a given name. 1063// The name must be that of a previously created DeleteMigrationJobOperation, possibly from a different process. 1064func (c *dataMigrationGRPCClient) DeleteMigrationJobOperation(name string) *DeleteMigrationJobOperation { 1065 return &DeleteMigrationJobOperation{ 1066 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1067 } 1068} 1069 1070// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1071// 1072// See documentation of Poll for error-handling information. 1073func (op *DeleteMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { 1074 return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) 1075} 1076 1077// Poll fetches the latest state of the long-running operation. 1078// 1079// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1080// 1081// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1082// the operation has completed with failure, the error is returned and op.Done will return true. 1083// If Poll succeeds and the operation has completed successfully, 1084// op.Done will return true, and the response of the operation is returned. 1085// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1086func (op *DeleteMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { 1087 return op.lro.Poll(ctx, nil, opts...) 1088} 1089 1090// Metadata returns metadata associated with the long-running operation. 1091// Metadata itself does not contact the server, but Poll does. 1092// To get the latest metadata, call this method after a successful call to Poll. 1093// If the metadata is not available, the returned metadata and error are both nil. 1094func (op *DeleteMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1095 var meta clouddmspb.OperationMetadata 1096 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1097 return nil, nil 1098 } else if err != nil { 1099 return nil, err 1100 } 1101 return &meta, nil 1102} 1103 1104// Done reports whether the long-running operation has completed. 1105func (op *DeleteMigrationJobOperation) Done() bool { 1106 return op.lro.Done() 1107} 1108 1109// Name returns the name of the long-running operation. 1110// The name is assigned by the server and is unique within the service from which the operation is created. 1111func (op *DeleteMigrationJobOperation) Name() string { 1112 return op.lro.Name() 1113} 1114 1115// PromoteMigrationJobOperation manages a long-running operation from PromoteMigrationJob. 1116type PromoteMigrationJobOperation struct { 1117 lro *longrunning.Operation 1118} 1119 1120// PromoteMigrationJobOperation returns a new PromoteMigrationJobOperation from a given name. 1121// The name must be that of a previously created PromoteMigrationJobOperation, possibly from a different process. 1122func (c *dataMigrationGRPCClient) PromoteMigrationJobOperation(name string) *PromoteMigrationJobOperation { 1123 return &PromoteMigrationJobOperation{ 1124 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1125 } 1126} 1127 1128// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1129// 1130// See documentation of Poll for error-handling information. 1131func (op *PromoteMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1132 var resp clouddmspb.MigrationJob 1133 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1134 return nil, err 1135 } 1136 return &resp, nil 1137} 1138 1139// Poll fetches the latest state of the long-running operation. 1140// 1141// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1142// 1143// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1144// the operation has completed with failure, the error is returned and op.Done will return true. 1145// If Poll succeeds and the operation has completed successfully, 1146// op.Done will return true, and the response of the operation is returned. 1147// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1148func (op *PromoteMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1149 var resp clouddmspb.MigrationJob 1150 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1151 return nil, err 1152 } 1153 if !op.Done() { 1154 return nil, nil 1155 } 1156 return &resp, nil 1157} 1158 1159// Metadata returns metadata associated with the long-running operation. 1160// Metadata itself does not contact the server, but Poll does. 1161// To get the latest metadata, call this method after a successful call to Poll. 1162// If the metadata is not available, the returned metadata and error are both nil. 1163func (op *PromoteMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1164 var meta clouddmspb.OperationMetadata 1165 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1166 return nil, nil 1167 } else if err != nil { 1168 return nil, err 1169 } 1170 return &meta, nil 1171} 1172 1173// Done reports whether the long-running operation has completed. 1174func (op *PromoteMigrationJobOperation) Done() bool { 1175 return op.lro.Done() 1176} 1177 1178// Name returns the name of the long-running operation. 1179// The name is assigned by the server and is unique within the service from which the operation is created. 1180func (op *PromoteMigrationJobOperation) Name() string { 1181 return op.lro.Name() 1182} 1183 1184// RestartMigrationJobOperation manages a long-running operation from RestartMigrationJob. 1185type RestartMigrationJobOperation struct { 1186 lro *longrunning.Operation 1187} 1188 1189// RestartMigrationJobOperation returns a new RestartMigrationJobOperation from a given name. 1190// The name must be that of a previously created RestartMigrationJobOperation, possibly from a different process. 1191func (c *dataMigrationGRPCClient) RestartMigrationJobOperation(name string) *RestartMigrationJobOperation { 1192 return &RestartMigrationJobOperation{ 1193 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1194 } 1195} 1196 1197// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1198// 1199// See documentation of Poll for error-handling information. 1200func (op *RestartMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1201 var resp clouddmspb.MigrationJob 1202 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1203 return nil, err 1204 } 1205 return &resp, nil 1206} 1207 1208// Poll fetches the latest state of the long-running operation. 1209// 1210// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1211// 1212// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1213// the operation has completed with failure, the error is returned and op.Done will return true. 1214// If Poll succeeds and the operation has completed successfully, 1215// op.Done will return true, and the response of the operation is returned. 1216// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1217func (op *RestartMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1218 var resp clouddmspb.MigrationJob 1219 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1220 return nil, err 1221 } 1222 if !op.Done() { 1223 return nil, nil 1224 } 1225 return &resp, nil 1226} 1227 1228// Metadata returns metadata associated with the long-running operation. 1229// Metadata itself does not contact the server, but Poll does. 1230// To get the latest metadata, call this method after a successful call to Poll. 1231// If the metadata is not available, the returned metadata and error are both nil. 1232func (op *RestartMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1233 var meta clouddmspb.OperationMetadata 1234 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1235 return nil, nil 1236 } else if err != nil { 1237 return nil, err 1238 } 1239 return &meta, nil 1240} 1241 1242// Done reports whether the long-running operation has completed. 1243func (op *RestartMigrationJobOperation) Done() bool { 1244 return op.lro.Done() 1245} 1246 1247// Name returns the name of the long-running operation. 1248// The name is assigned by the server and is unique within the service from which the operation is created. 1249func (op *RestartMigrationJobOperation) Name() string { 1250 return op.lro.Name() 1251} 1252 1253// ResumeMigrationJobOperation manages a long-running operation from ResumeMigrationJob. 1254type ResumeMigrationJobOperation struct { 1255 lro *longrunning.Operation 1256} 1257 1258// ResumeMigrationJobOperation returns a new ResumeMigrationJobOperation from a given name. 1259// The name must be that of a previously created ResumeMigrationJobOperation, possibly from a different process. 1260func (c *dataMigrationGRPCClient) ResumeMigrationJobOperation(name string) *ResumeMigrationJobOperation { 1261 return &ResumeMigrationJobOperation{ 1262 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1263 } 1264} 1265 1266// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1267// 1268// See documentation of Poll for error-handling information. 1269func (op *ResumeMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1270 var resp clouddmspb.MigrationJob 1271 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1272 return nil, err 1273 } 1274 return &resp, nil 1275} 1276 1277// Poll fetches the latest state of the long-running operation. 1278// 1279// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1280// 1281// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1282// the operation has completed with failure, the error is returned and op.Done will return true. 1283// If Poll succeeds and the operation has completed successfully, 1284// op.Done will return true, and the response of the operation is returned. 1285// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1286func (op *ResumeMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1287 var resp clouddmspb.MigrationJob 1288 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1289 return nil, err 1290 } 1291 if !op.Done() { 1292 return nil, nil 1293 } 1294 return &resp, nil 1295} 1296 1297// Metadata returns metadata associated with the long-running operation. 1298// Metadata itself does not contact the server, but Poll does. 1299// To get the latest metadata, call this method after a successful call to Poll. 1300// If the metadata is not available, the returned metadata and error are both nil. 1301func (op *ResumeMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1302 var meta clouddmspb.OperationMetadata 1303 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1304 return nil, nil 1305 } else if err != nil { 1306 return nil, err 1307 } 1308 return &meta, nil 1309} 1310 1311// Done reports whether the long-running operation has completed. 1312func (op *ResumeMigrationJobOperation) Done() bool { 1313 return op.lro.Done() 1314} 1315 1316// Name returns the name of the long-running operation. 1317// The name is assigned by the server and is unique within the service from which the operation is created. 1318func (op *ResumeMigrationJobOperation) Name() string { 1319 return op.lro.Name() 1320} 1321 1322// StartMigrationJobOperation manages a long-running operation from StartMigrationJob. 1323type StartMigrationJobOperation struct { 1324 lro *longrunning.Operation 1325} 1326 1327// StartMigrationJobOperation returns a new StartMigrationJobOperation from a given name. 1328// The name must be that of a previously created StartMigrationJobOperation, possibly from a different process. 1329func (c *dataMigrationGRPCClient) StartMigrationJobOperation(name string) *StartMigrationJobOperation { 1330 return &StartMigrationJobOperation{ 1331 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1332 } 1333} 1334 1335// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1336// 1337// See documentation of Poll for error-handling information. 1338func (op *StartMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1339 var resp clouddmspb.MigrationJob 1340 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1341 return nil, err 1342 } 1343 return &resp, nil 1344} 1345 1346// Poll fetches the latest state of the long-running operation. 1347// 1348// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1349// 1350// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1351// the operation has completed with failure, the error is returned and op.Done will return true. 1352// If Poll succeeds and the operation has completed successfully, 1353// op.Done will return true, and the response of the operation is returned. 1354// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1355func (op *StartMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1356 var resp clouddmspb.MigrationJob 1357 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1358 return nil, err 1359 } 1360 if !op.Done() { 1361 return nil, nil 1362 } 1363 return &resp, nil 1364} 1365 1366// Metadata returns metadata associated with the long-running operation. 1367// Metadata itself does not contact the server, but Poll does. 1368// To get the latest metadata, call this method after a successful call to Poll. 1369// If the metadata is not available, the returned metadata and error are both nil. 1370func (op *StartMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1371 var meta clouddmspb.OperationMetadata 1372 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1373 return nil, nil 1374 } else if err != nil { 1375 return nil, err 1376 } 1377 return &meta, nil 1378} 1379 1380// Done reports whether the long-running operation has completed. 1381func (op *StartMigrationJobOperation) Done() bool { 1382 return op.lro.Done() 1383} 1384 1385// Name returns the name of the long-running operation. 1386// The name is assigned by the server and is unique within the service from which the operation is created. 1387func (op *StartMigrationJobOperation) Name() string { 1388 return op.lro.Name() 1389} 1390 1391// StopMigrationJobOperation manages a long-running operation from StopMigrationJob. 1392type StopMigrationJobOperation struct { 1393 lro *longrunning.Operation 1394} 1395 1396// StopMigrationJobOperation returns a new StopMigrationJobOperation from a given name. 1397// The name must be that of a previously created StopMigrationJobOperation, possibly from a different process. 1398func (c *dataMigrationGRPCClient) StopMigrationJobOperation(name string) *StopMigrationJobOperation { 1399 return &StopMigrationJobOperation{ 1400 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1401 } 1402} 1403 1404// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1405// 1406// See documentation of Poll for error-handling information. 1407func (op *StopMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1408 var resp clouddmspb.MigrationJob 1409 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1410 return nil, err 1411 } 1412 return &resp, nil 1413} 1414 1415// Poll fetches the latest state of the long-running operation. 1416// 1417// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1418// 1419// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1420// the operation has completed with failure, the error is returned and op.Done will return true. 1421// If Poll succeeds and the operation has completed successfully, 1422// op.Done will return true, and the response of the operation is returned. 1423// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1424func (op *StopMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1425 var resp clouddmspb.MigrationJob 1426 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1427 return nil, err 1428 } 1429 if !op.Done() { 1430 return nil, nil 1431 } 1432 return &resp, nil 1433} 1434 1435// Metadata returns metadata associated with the long-running operation. 1436// Metadata itself does not contact the server, but Poll does. 1437// To get the latest metadata, call this method after a successful call to Poll. 1438// If the metadata is not available, the returned metadata and error are both nil. 1439func (op *StopMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1440 var meta clouddmspb.OperationMetadata 1441 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1442 return nil, nil 1443 } else if err != nil { 1444 return nil, err 1445 } 1446 return &meta, nil 1447} 1448 1449// Done reports whether the long-running operation has completed. 1450func (op *StopMigrationJobOperation) Done() bool { 1451 return op.lro.Done() 1452} 1453 1454// Name returns the name of the long-running operation. 1455// The name is assigned by the server and is unique within the service from which the operation is created. 1456func (op *StopMigrationJobOperation) Name() string { 1457 return op.lro.Name() 1458} 1459 1460// UpdateConnectionProfileOperation manages a long-running operation from UpdateConnectionProfile. 1461type UpdateConnectionProfileOperation struct { 1462 lro *longrunning.Operation 1463} 1464 1465// UpdateConnectionProfileOperation returns a new UpdateConnectionProfileOperation from a given name. 1466// The name must be that of a previously created UpdateConnectionProfileOperation, possibly from a different process. 1467func (c *dataMigrationGRPCClient) UpdateConnectionProfileOperation(name string) *UpdateConnectionProfileOperation { 1468 return &UpdateConnectionProfileOperation{ 1469 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1470 } 1471} 1472 1473// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1474// 1475// See documentation of Poll for error-handling information. 1476func (op *UpdateConnectionProfileOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 1477 var resp clouddmspb.ConnectionProfile 1478 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1479 return nil, err 1480 } 1481 return &resp, nil 1482} 1483 1484// Poll fetches the latest state of the long-running operation. 1485// 1486// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1487// 1488// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1489// the operation has completed with failure, the error is returned and op.Done will return true. 1490// If Poll succeeds and the operation has completed successfully, 1491// op.Done will return true, and the response of the operation is returned. 1492// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1493func (op *UpdateConnectionProfileOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.ConnectionProfile, error) { 1494 var resp clouddmspb.ConnectionProfile 1495 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1496 return nil, err 1497 } 1498 if !op.Done() { 1499 return nil, nil 1500 } 1501 return &resp, nil 1502} 1503 1504// Metadata returns metadata associated with the long-running operation. 1505// Metadata itself does not contact the server, but Poll does. 1506// To get the latest metadata, call this method after a successful call to Poll. 1507// If the metadata is not available, the returned metadata and error are both nil. 1508func (op *UpdateConnectionProfileOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1509 var meta clouddmspb.OperationMetadata 1510 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1511 return nil, nil 1512 } else if err != nil { 1513 return nil, err 1514 } 1515 return &meta, nil 1516} 1517 1518// Done reports whether the long-running operation has completed. 1519func (op *UpdateConnectionProfileOperation) Done() bool { 1520 return op.lro.Done() 1521} 1522 1523// Name returns the name of the long-running operation. 1524// The name is assigned by the server and is unique within the service from which the operation is created. 1525func (op *UpdateConnectionProfileOperation) Name() string { 1526 return op.lro.Name() 1527} 1528 1529// UpdateMigrationJobOperation manages a long-running operation from UpdateMigrationJob. 1530type UpdateMigrationJobOperation struct { 1531 lro *longrunning.Operation 1532} 1533 1534// UpdateMigrationJobOperation returns a new UpdateMigrationJobOperation from a given name. 1535// The name must be that of a previously created UpdateMigrationJobOperation, possibly from a different process. 1536func (c *dataMigrationGRPCClient) UpdateMigrationJobOperation(name string) *UpdateMigrationJobOperation { 1537 return &UpdateMigrationJobOperation{ 1538 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1539 } 1540} 1541 1542// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1543// 1544// See documentation of Poll for error-handling information. 1545func (op *UpdateMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1546 var resp clouddmspb.MigrationJob 1547 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1548 return nil, err 1549 } 1550 return &resp, nil 1551} 1552 1553// Poll fetches the latest state of the long-running operation. 1554// 1555// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1556// 1557// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1558// the operation has completed with failure, the error is returned and op.Done will return true. 1559// If Poll succeeds and the operation has completed successfully, 1560// op.Done will return true, and the response of the operation is returned. 1561// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1562func (op *UpdateMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1563 var resp clouddmspb.MigrationJob 1564 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1565 return nil, err 1566 } 1567 if !op.Done() { 1568 return nil, nil 1569 } 1570 return &resp, nil 1571} 1572 1573// Metadata returns metadata associated with the long-running operation. 1574// Metadata itself does not contact the server, but Poll does. 1575// To get the latest metadata, call this method after a successful call to Poll. 1576// If the metadata is not available, the returned metadata and error are both nil. 1577func (op *UpdateMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1578 var meta clouddmspb.OperationMetadata 1579 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1580 return nil, nil 1581 } else if err != nil { 1582 return nil, err 1583 } 1584 return &meta, nil 1585} 1586 1587// Done reports whether the long-running operation has completed. 1588func (op *UpdateMigrationJobOperation) Done() bool { 1589 return op.lro.Done() 1590} 1591 1592// Name returns the name of the long-running operation. 1593// The name is assigned by the server and is unique within the service from which the operation is created. 1594func (op *UpdateMigrationJobOperation) Name() string { 1595 return op.lro.Name() 1596} 1597 1598// VerifyMigrationJobOperation manages a long-running operation from VerifyMigrationJob. 1599type VerifyMigrationJobOperation struct { 1600 lro *longrunning.Operation 1601} 1602 1603// VerifyMigrationJobOperation returns a new VerifyMigrationJobOperation from a given name. 1604// The name must be that of a previously created VerifyMigrationJobOperation, possibly from a different process. 1605func (c *dataMigrationGRPCClient) VerifyMigrationJobOperation(name string) *VerifyMigrationJobOperation { 1606 return &VerifyMigrationJobOperation{ 1607 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1608 } 1609} 1610 1611// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. 1612// 1613// See documentation of Poll for error-handling information. 1614func (op *VerifyMigrationJobOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1615 var resp clouddmspb.MigrationJob 1616 if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { 1617 return nil, err 1618 } 1619 return &resp, nil 1620} 1621 1622// Poll fetches the latest state of the long-running operation. 1623// 1624// Poll also fetches the latest metadata, which can be retrieved by Metadata. 1625// 1626// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and 1627// the operation has completed with failure, the error is returned and op.Done will return true. 1628// If Poll succeeds and the operation has completed successfully, 1629// op.Done will return true, and the response of the operation is returned. 1630// If Poll succeeds and the operation has not completed, the returned response and error are both nil. 1631func (op *VerifyMigrationJobOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*clouddmspb.MigrationJob, error) { 1632 var resp clouddmspb.MigrationJob 1633 if err := op.lro.Poll(ctx, &resp, opts...); err != nil { 1634 return nil, err 1635 } 1636 if !op.Done() { 1637 return nil, nil 1638 } 1639 return &resp, nil 1640} 1641 1642// Metadata returns metadata associated with the long-running operation. 1643// Metadata itself does not contact the server, but Poll does. 1644// To get the latest metadata, call this method after a successful call to Poll. 1645// If the metadata is not available, the returned metadata and error are both nil. 1646func (op *VerifyMigrationJobOperation) Metadata() (*clouddmspb.OperationMetadata, error) { 1647 var meta clouddmspb.OperationMetadata 1648 if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { 1649 return nil, nil 1650 } else if err != nil { 1651 return nil, err 1652 } 1653 return &meta, nil 1654} 1655 1656// Done reports whether the long-running operation has completed. 1657func (op *VerifyMigrationJobOperation) Done() bool { 1658 return op.lro.Done() 1659} 1660 1661// Name returns the name of the long-running operation. 1662// The name is assigned by the server and is unique within the service from which the operation is created. 1663func (op *VerifyMigrationJobOperation) Name() string { 1664 return op.lro.Name() 1665} 1666 1667// ConnectionProfileIterator manages a stream of *clouddmspb.ConnectionProfile. 1668type ConnectionProfileIterator struct { 1669 items []*clouddmspb.ConnectionProfile 1670 pageInfo *iterator.PageInfo 1671 nextFunc func() error 1672 1673 // Response is the raw response for the current page. 1674 // It must be cast to the RPC response type. 1675 // Calling Next() or InternalFetch() updates this value. 1676 Response interface{} 1677 1678 // InternalFetch is for use by the Google Cloud Libraries only. 1679 // It is not part of the stable interface of this package. 1680 // 1681 // InternalFetch returns results from a single call to the underlying RPC. 1682 // The number of results is no greater than pageSize. 1683 // If there are no more results, nextPageToken is empty and err is nil. 1684 InternalFetch func(pageSize int, pageToken string) (results []*clouddmspb.ConnectionProfile, nextPageToken string, err error) 1685} 1686 1687// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1688func (it *ConnectionProfileIterator) PageInfo() *iterator.PageInfo { 1689 return it.pageInfo 1690} 1691 1692// Next returns the next result. Its second return value is iterator.Done if there are no more 1693// results. Once Next returns Done, all subsequent calls will return Done. 1694func (it *ConnectionProfileIterator) Next() (*clouddmspb.ConnectionProfile, error) { 1695 var item *clouddmspb.ConnectionProfile 1696 if err := it.nextFunc(); err != nil { 1697 return item, err 1698 } 1699 item = it.items[0] 1700 it.items = it.items[1:] 1701 return item, nil 1702} 1703 1704func (it *ConnectionProfileIterator) bufLen() int { 1705 return len(it.items) 1706} 1707 1708func (it *ConnectionProfileIterator) takeBuf() interface{} { 1709 b := it.items 1710 it.items = nil 1711 return b 1712} 1713 1714// MigrationJobIterator manages a stream of *clouddmspb.MigrationJob. 1715type MigrationJobIterator struct { 1716 items []*clouddmspb.MigrationJob 1717 pageInfo *iterator.PageInfo 1718 nextFunc func() error 1719 1720 // Response is the raw response for the current page. 1721 // It must be cast to the RPC response type. 1722 // Calling Next() or InternalFetch() updates this value. 1723 Response interface{} 1724 1725 // InternalFetch is for use by the Google Cloud Libraries only. 1726 // It is not part of the stable interface of this package. 1727 // 1728 // InternalFetch returns results from a single call to the underlying RPC. 1729 // The number of results is no greater than pageSize. 1730 // If there are no more results, nextPageToken is empty and err is nil. 1731 InternalFetch func(pageSize int, pageToken string) (results []*clouddmspb.MigrationJob, nextPageToken string, err error) 1732} 1733 1734// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1735func (it *MigrationJobIterator) PageInfo() *iterator.PageInfo { 1736 return it.pageInfo 1737} 1738 1739// Next returns the next result. Its second return value is iterator.Done if there are no more 1740// results. Once Next returns Done, all subsequent calls will return Done. 1741func (it *MigrationJobIterator) Next() (*clouddmspb.MigrationJob, error) { 1742 var item *clouddmspb.MigrationJob 1743 if err := it.nextFunc(); err != nil { 1744 return item, err 1745 } 1746 item = it.items[0] 1747 it.items = it.items[1:] 1748 return item, nil 1749} 1750 1751func (it *MigrationJobIterator) bufLen() int { 1752 return len(it.items) 1753} 1754 1755func (it *MigrationJobIterator) takeBuf() interface{} { 1756 b := it.items 1757 it.items = nil 1758 return b 1759} 1760