cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/migration_client_example_test.go (about)

     1  // Copyright 2025 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  
    17  package aiplatform_test
    18  
    19  import (
    20  	"context"
    21  
    22  	aiplatform "cloud.google.com/go/aiplatform/apiv1beta1"
    23  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    24  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    25  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    26  	"google.golang.org/api/iterator"
    27  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    28  )
    29  
    30  func ExampleNewMigrationClient() {
    31  	ctx := context.Background()
    32  	// This snippet has been automatically generated and should be regarded as a code template only.
    33  	// It will require modifications to work:
    34  	// - It may require correct/in-range values for request initialization.
    35  	// - It may require specifying regional endpoints when creating the service client as shown in:
    36  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    37  	c, err := aiplatform.NewMigrationClient(ctx)
    38  	if err != nil {
    39  		// TODO: Handle error.
    40  	}
    41  	defer c.Close()
    42  
    43  	// TODO: Use client.
    44  	_ = c
    45  }
    46  
    47  func ExampleNewMigrationRESTClient() {
    48  	ctx := context.Background()
    49  	// This snippet has been automatically generated and should be regarded as a code template only.
    50  	// It will require modifications to work:
    51  	// - It may require correct/in-range values for request initialization.
    52  	// - It may require specifying regional endpoints when creating the service client as shown in:
    53  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    54  	c, err := aiplatform.NewMigrationRESTClient(ctx)
    55  	if err != nil {
    56  		// TODO: Handle error.
    57  	}
    58  	defer c.Close()
    59  
    60  	// TODO: Use client.
    61  	_ = c
    62  }
    63  
    64  func ExampleMigrationClient_BatchMigrateResources() {
    65  	ctx := context.Background()
    66  	// This snippet has been automatically generated and should be regarded as a code template only.
    67  	// It will require modifications to work:
    68  	// - It may require correct/in-range values for request initialization.
    69  	// - It may require specifying regional endpoints when creating the service client as shown in:
    70  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    71  	c, err := aiplatform.NewMigrationClient(ctx)
    72  	if err != nil {
    73  		// TODO: Handle error.
    74  	}
    75  	defer c.Close()
    76  
    77  	req := &aiplatformpb.BatchMigrateResourcesRequest{
    78  		// TODO: Fill request struct fields.
    79  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#BatchMigrateResourcesRequest.
    80  	}
    81  	op, err := c.BatchMigrateResources(ctx, req)
    82  	if err != nil {
    83  		// TODO: Handle error.
    84  	}
    85  
    86  	resp, err := op.Wait(ctx)
    87  	if err != nil {
    88  		// TODO: Handle error.
    89  	}
    90  	// TODO: Use resp.
    91  	_ = resp
    92  }
    93  
    94  func ExampleMigrationClient_SearchMigratableResources() {
    95  	ctx := context.Background()
    96  	// This snippet has been automatically generated and should be regarded as a code template only.
    97  	// It will require modifications to work:
    98  	// - It may require correct/in-range values for request initialization.
    99  	// - It may require specifying regional endpoints when creating the service client as shown in:
   100  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   101  	c, err := aiplatform.NewMigrationClient(ctx)
   102  	if err != nil {
   103  		// TODO: Handle error.
   104  	}
   105  	defer c.Close()
   106  
   107  	req := &aiplatformpb.SearchMigratableResourcesRequest{
   108  		// TODO: Fill request struct fields.
   109  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#SearchMigratableResourcesRequest.
   110  	}
   111  	it := c.SearchMigratableResources(ctx, req)
   112  	for {
   113  		resp, err := it.Next()
   114  		if err == iterator.Done {
   115  			break
   116  		}
   117  		if err != nil {
   118  			// TODO: Handle error.
   119  		}
   120  		// TODO: Use resp.
   121  		_ = resp
   122  
   123  		// If you need to access the underlying RPC response,
   124  		// you can do so by casting the `Response` as below.
   125  		// Otherwise, remove this line. Only populated after
   126  		// first call to Next(). Not safe for concurrent access.
   127  		_ = it.Response.(*aiplatformpb.SearchMigratableResourcesResponse)
   128  	}
   129  }
   130  
   131  func ExampleMigrationClient_GetLocation() {
   132  	ctx := context.Background()
   133  	// This snippet has been automatically generated and should be regarded as a code template only.
   134  	// It will require modifications to work:
   135  	// - It may require correct/in-range values for request initialization.
   136  	// - It may require specifying regional endpoints when creating the service client as shown in:
   137  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   138  	c, err := aiplatform.NewMigrationClient(ctx)
   139  	if err != nil {
   140  		// TODO: Handle error.
   141  	}
   142  	defer c.Close()
   143  
   144  	req := &locationpb.GetLocationRequest{
   145  		// TODO: Fill request struct fields.
   146  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
   147  	}
   148  	resp, err := c.GetLocation(ctx, req)
   149  	if err != nil {
   150  		// TODO: Handle error.
   151  	}
   152  	// TODO: Use resp.
   153  	_ = resp
   154  }
   155  
   156  func ExampleMigrationClient_ListLocations() {
   157  	ctx := context.Background()
   158  	// This snippet has been automatically generated and should be regarded as a code template only.
   159  	// It will require modifications to work:
   160  	// - It may require correct/in-range values for request initialization.
   161  	// - It may require specifying regional endpoints when creating the service client as shown in:
   162  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   163  	c, err := aiplatform.NewMigrationClient(ctx)
   164  	if err != nil {
   165  		// TODO: Handle error.
   166  	}
   167  	defer c.Close()
   168  
   169  	req := &locationpb.ListLocationsRequest{
   170  		// TODO: Fill request struct fields.
   171  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
   172  	}
   173  	it := c.ListLocations(ctx, req)
   174  	for {
   175  		resp, err := it.Next()
   176  		if err == iterator.Done {
   177  			break
   178  		}
   179  		if err != nil {
   180  			// TODO: Handle error.
   181  		}
   182  		// TODO: Use resp.
   183  		_ = resp
   184  
   185  		// If you need to access the underlying RPC response,
   186  		// you can do so by casting the `Response` as below.
   187  		// Otherwise, remove this line. Only populated after
   188  		// first call to Next(). Not safe for concurrent access.
   189  		_ = it.Response.(*locationpb.ListLocationsResponse)
   190  	}
   191  }
   192  
   193  func ExampleMigrationClient_GetIamPolicy() {
   194  	ctx := context.Background()
   195  	// This snippet has been automatically generated and should be regarded as a code template only.
   196  	// It will require modifications to work:
   197  	// - It may require correct/in-range values for request initialization.
   198  	// - It may require specifying regional endpoints when creating the service client as shown in:
   199  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   200  	c, err := aiplatform.NewMigrationClient(ctx)
   201  	if err != nil {
   202  		// TODO: Handle error.
   203  	}
   204  	defer c.Close()
   205  
   206  	req := &iampb.GetIamPolicyRequest{
   207  		// TODO: Fill request struct fields.
   208  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   209  	}
   210  	resp, err := c.GetIamPolicy(ctx, req)
   211  	if err != nil {
   212  		// TODO: Handle error.
   213  	}
   214  	// TODO: Use resp.
   215  	_ = resp
   216  }
   217  
   218  func ExampleMigrationClient_SetIamPolicy() {
   219  	ctx := context.Background()
   220  	// This snippet has been automatically generated and should be regarded as a code template only.
   221  	// It will require modifications to work:
   222  	// - It may require correct/in-range values for request initialization.
   223  	// - It may require specifying regional endpoints when creating the service client as shown in:
   224  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   225  	c, err := aiplatform.NewMigrationClient(ctx)
   226  	if err != nil {
   227  		// TODO: Handle error.
   228  	}
   229  	defer c.Close()
   230  
   231  	req := &iampb.SetIamPolicyRequest{
   232  		// TODO: Fill request struct fields.
   233  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   234  	}
   235  	resp, err := c.SetIamPolicy(ctx, req)
   236  	if err != nil {
   237  		// TODO: Handle error.
   238  	}
   239  	// TODO: Use resp.
   240  	_ = resp
   241  }
   242  
   243  func ExampleMigrationClient_TestIamPermissions() {
   244  	ctx := context.Background()
   245  	// This snippet has been automatically generated and should be regarded as a code template only.
   246  	// It will require modifications to work:
   247  	// - It may require correct/in-range values for request initialization.
   248  	// - It may require specifying regional endpoints when creating the service client as shown in:
   249  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   250  	c, err := aiplatform.NewMigrationClient(ctx)
   251  	if err != nil {
   252  		// TODO: Handle error.
   253  	}
   254  	defer c.Close()
   255  
   256  	req := &iampb.TestIamPermissionsRequest{
   257  		// TODO: Fill request struct fields.
   258  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   259  	}
   260  	resp, err := c.TestIamPermissions(ctx, req)
   261  	if err != nil {
   262  		// TODO: Handle error.
   263  	}
   264  	// TODO: Use resp.
   265  	_ = resp
   266  }
   267  
   268  func ExampleMigrationClient_CancelOperation() {
   269  	ctx := context.Background()
   270  	// This snippet has been automatically generated and should be regarded as a code template only.
   271  	// It will require modifications to work:
   272  	// - It may require correct/in-range values for request initialization.
   273  	// - It may require specifying regional endpoints when creating the service client as shown in:
   274  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   275  	c, err := aiplatform.NewMigrationClient(ctx)
   276  	if err != nil {
   277  		// TODO: Handle error.
   278  	}
   279  	defer c.Close()
   280  
   281  	req := &longrunningpb.CancelOperationRequest{
   282  		// TODO: Fill request struct fields.
   283  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
   284  	}
   285  	err = c.CancelOperation(ctx, req)
   286  	if err != nil {
   287  		// TODO: Handle error.
   288  	}
   289  }
   290  
   291  func ExampleMigrationClient_DeleteOperation() {
   292  	ctx := context.Background()
   293  	// This snippet has been automatically generated and should be regarded as a code template only.
   294  	// It will require modifications to work:
   295  	// - It may require correct/in-range values for request initialization.
   296  	// - It may require specifying regional endpoints when creating the service client as shown in:
   297  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   298  	c, err := aiplatform.NewMigrationClient(ctx)
   299  	if err != nil {
   300  		// TODO: Handle error.
   301  	}
   302  	defer c.Close()
   303  
   304  	req := &longrunningpb.DeleteOperationRequest{
   305  		// TODO: Fill request struct fields.
   306  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
   307  	}
   308  	err = c.DeleteOperation(ctx, req)
   309  	if err != nil {
   310  		// TODO: Handle error.
   311  	}
   312  }
   313  
   314  func ExampleMigrationClient_GetOperation() {
   315  	ctx := context.Background()
   316  	// This snippet has been automatically generated and should be regarded as a code template only.
   317  	// It will require modifications to work:
   318  	// - It may require correct/in-range values for request initialization.
   319  	// - It may require specifying regional endpoints when creating the service client as shown in:
   320  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   321  	c, err := aiplatform.NewMigrationClient(ctx)
   322  	if err != nil {
   323  		// TODO: Handle error.
   324  	}
   325  	defer c.Close()
   326  
   327  	req := &longrunningpb.GetOperationRequest{
   328  		// TODO: Fill request struct fields.
   329  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
   330  	}
   331  	resp, err := c.GetOperation(ctx, req)
   332  	if err != nil {
   333  		// TODO: Handle error.
   334  	}
   335  	// TODO: Use resp.
   336  	_ = resp
   337  }
   338  
   339  func ExampleMigrationClient_ListOperations() {
   340  	ctx := context.Background()
   341  	// This snippet has been automatically generated and should be regarded as a code template only.
   342  	// It will require modifications to work:
   343  	// - It may require correct/in-range values for request initialization.
   344  	// - It may require specifying regional endpoints when creating the service client as shown in:
   345  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   346  	c, err := aiplatform.NewMigrationClient(ctx)
   347  	if err != nil {
   348  		// TODO: Handle error.
   349  	}
   350  	defer c.Close()
   351  
   352  	req := &longrunningpb.ListOperationsRequest{
   353  		// TODO: Fill request struct fields.
   354  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
   355  	}
   356  	it := c.ListOperations(ctx, req)
   357  	for {
   358  		resp, err := it.Next()
   359  		if err == iterator.Done {
   360  			break
   361  		}
   362  		if err != nil {
   363  			// TODO: Handle error.
   364  		}
   365  		// TODO: Use resp.
   366  		_ = resp
   367  
   368  		// If you need to access the underlying RPC response,
   369  		// you can do so by casting the `Response` as below.
   370  		// Otherwise, remove this line. Only populated after
   371  		// first call to Next(). Not safe for concurrent access.
   372  		_ = it.Response.(*longrunningpb.ListOperationsResponse)
   373  	}
   374  }
   375  
   376  func ExampleMigrationClient_WaitOperation() {
   377  	ctx := context.Background()
   378  	// This snippet has been automatically generated and should be regarded as a code template only.
   379  	// It will require modifications to work:
   380  	// - It may require correct/in-range values for request initialization.
   381  	// - It may require specifying regional endpoints when creating the service client as shown in:
   382  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   383  	c, err := aiplatform.NewMigrationClient(ctx)
   384  	if err != nil {
   385  		// TODO: Handle error.
   386  	}
   387  	defer c.Close()
   388  
   389  	req := &longrunningpb.WaitOperationRequest{
   390  		// TODO: Fill request struct fields.
   391  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest.
   392  	}
   393  	resp, err := c.WaitOperation(ctx, req)
   394  	if err != nil {
   395  		// TODO: Handle error.
   396  	}
   397  	// TODO: Use resp.
   398  	_ = resp
   399  }