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