cloud.google.com/go/aiplatform@v1.106.0/apiv1/specialist_pool_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 ExampleNewSpecialistPoolClient() {
    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.NewSpecialistPoolClient(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 ExampleSpecialistPoolClient_CreateSpecialistPool() {
    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.NewSpecialistPoolClient(ctx)
    55  	if err != nil {
    56  		// TODO: Handle error.
    57  	}
    58  	defer c.Close()
    59  
    60  	req := &aiplatformpb.CreateSpecialistPoolRequest{
    61  		// TODO: Fill request struct fields.
    62  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#CreateSpecialistPoolRequest.
    63  	}
    64  	op, err := c.CreateSpecialistPool(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 ExampleSpecialistPoolClient_DeleteSpecialistPool() {
    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.NewSpecialistPoolClient(ctx)
    85  	if err != nil {
    86  		// TODO: Handle error.
    87  	}
    88  	defer c.Close()
    89  
    90  	req := &aiplatformpb.DeleteSpecialistPoolRequest{
    91  		// TODO: Fill request struct fields.
    92  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#DeleteSpecialistPoolRequest.
    93  	}
    94  	op, err := c.DeleteSpecialistPool(ctx, req)
    95  	if err != nil {
    96  		// TODO: Handle error.
    97  	}
    98  
    99  	err = op.Wait(ctx)
   100  	if err != nil {
   101  		// TODO: Handle error.
   102  	}
   103  }
   104  
   105  func ExampleSpecialistPoolClient_GetSpecialistPool() {
   106  	ctx := context.Background()
   107  	// This snippet has been automatically generated and should be regarded as a code template only.
   108  	// It will require modifications to work:
   109  	// - It may require correct/in-range values for request initialization.
   110  	// - It may require specifying regional endpoints when creating the service client as shown in:
   111  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   112  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   113  	if err != nil {
   114  		// TODO: Handle error.
   115  	}
   116  	defer c.Close()
   117  
   118  	req := &aiplatformpb.GetSpecialistPoolRequest{
   119  		// TODO: Fill request struct fields.
   120  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#GetSpecialistPoolRequest.
   121  	}
   122  	resp, err := c.GetSpecialistPool(ctx, req)
   123  	if err != nil {
   124  		// TODO: Handle error.
   125  	}
   126  	// TODO: Use resp.
   127  	_ = resp
   128  }
   129  
   130  func ExampleSpecialistPoolClient_ListSpecialistPools() {
   131  	ctx := context.Background()
   132  	// This snippet has been automatically generated and should be regarded as a code template only.
   133  	// It will require modifications to work:
   134  	// - It may require correct/in-range values for request initialization.
   135  	// - It may require specifying regional endpoints when creating the service client as shown in:
   136  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   137  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   138  	if err != nil {
   139  		// TODO: Handle error.
   140  	}
   141  	defer c.Close()
   142  
   143  	req := &aiplatformpb.ListSpecialistPoolsRequest{
   144  		// TODO: Fill request struct fields.
   145  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#ListSpecialistPoolsRequest.
   146  	}
   147  	it := c.ListSpecialistPools(ctx, req)
   148  	for {
   149  		resp, err := it.Next()
   150  		if err == iterator.Done {
   151  			break
   152  		}
   153  		if err != nil {
   154  			// TODO: Handle error.
   155  		}
   156  		// TODO: Use resp.
   157  		_ = resp
   158  
   159  		// If you need to access the underlying RPC response,
   160  		// you can do so by casting the `Response` as below.
   161  		// Otherwise, remove this line. Only populated after
   162  		// first call to Next(). Not safe for concurrent access.
   163  		_ = it.Response.(*aiplatformpb.ListSpecialistPoolsResponse)
   164  	}
   165  }
   166  
   167  func ExampleSpecialistPoolClient_UpdateSpecialistPool() {
   168  	ctx := context.Background()
   169  	// This snippet has been automatically generated and should be regarded as a code template only.
   170  	// It will require modifications to work:
   171  	// - It may require correct/in-range values for request initialization.
   172  	// - It may require specifying regional endpoints when creating the service client as shown in:
   173  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   174  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   175  	if err != nil {
   176  		// TODO: Handle error.
   177  	}
   178  	defer c.Close()
   179  
   180  	req := &aiplatformpb.UpdateSpecialistPoolRequest{
   181  		// TODO: Fill request struct fields.
   182  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1/aiplatformpb#UpdateSpecialistPoolRequest.
   183  	}
   184  	op, err := c.UpdateSpecialistPool(ctx, req)
   185  	if err != nil {
   186  		// TODO: Handle error.
   187  	}
   188  
   189  	resp, err := op.Wait(ctx)
   190  	if err != nil {
   191  		// TODO: Handle error.
   192  	}
   193  	// TODO: Use resp.
   194  	_ = resp
   195  }
   196  
   197  func ExampleSpecialistPoolClient_GetLocation() {
   198  	ctx := context.Background()
   199  	// This snippet has been automatically generated and should be regarded as a code template only.
   200  	// It will require modifications to work:
   201  	// - It may require correct/in-range values for request initialization.
   202  	// - It may require specifying regional endpoints when creating the service client as shown in:
   203  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   204  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   205  	if err != nil {
   206  		// TODO: Handle error.
   207  	}
   208  	defer c.Close()
   209  
   210  	req := &locationpb.GetLocationRequest{
   211  		// TODO: Fill request struct fields.
   212  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
   213  	}
   214  	resp, err := c.GetLocation(ctx, req)
   215  	if err != nil {
   216  		// TODO: Handle error.
   217  	}
   218  	// TODO: Use resp.
   219  	_ = resp
   220  }
   221  
   222  func ExampleSpecialistPoolClient_ListLocations() {
   223  	ctx := context.Background()
   224  	// This snippet has been automatically generated and should be regarded as a code template only.
   225  	// It will require modifications to work:
   226  	// - It may require correct/in-range values for request initialization.
   227  	// - It may require specifying regional endpoints when creating the service client as shown in:
   228  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   229  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   230  	if err != nil {
   231  		// TODO: Handle error.
   232  	}
   233  	defer c.Close()
   234  
   235  	req := &locationpb.ListLocationsRequest{
   236  		// TODO: Fill request struct fields.
   237  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
   238  	}
   239  	it := c.ListLocations(ctx, req)
   240  	for {
   241  		resp, err := it.Next()
   242  		if err == iterator.Done {
   243  			break
   244  		}
   245  		if err != nil {
   246  			// TODO: Handle error.
   247  		}
   248  		// TODO: Use resp.
   249  		_ = resp
   250  
   251  		// If you need to access the underlying RPC response,
   252  		// you can do so by casting the `Response` as below.
   253  		// Otherwise, remove this line. Only populated after
   254  		// first call to Next(). Not safe for concurrent access.
   255  		_ = it.Response.(*locationpb.ListLocationsResponse)
   256  	}
   257  }
   258  
   259  func ExampleSpecialistPoolClient_GetIamPolicy() {
   260  	ctx := context.Background()
   261  	// This snippet has been automatically generated and should be regarded as a code template only.
   262  	// It will require modifications to work:
   263  	// - It may require correct/in-range values for request initialization.
   264  	// - It may require specifying regional endpoints when creating the service client as shown in:
   265  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   266  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   267  	if err != nil {
   268  		// TODO: Handle error.
   269  	}
   270  	defer c.Close()
   271  
   272  	req := &iampb.GetIamPolicyRequest{
   273  		// TODO: Fill request struct fields.
   274  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   275  	}
   276  	resp, err := c.GetIamPolicy(ctx, req)
   277  	if err != nil {
   278  		// TODO: Handle error.
   279  	}
   280  	// TODO: Use resp.
   281  	_ = resp
   282  }
   283  
   284  func ExampleSpecialistPoolClient_SetIamPolicy() {
   285  	ctx := context.Background()
   286  	// This snippet has been automatically generated and should be regarded as a code template only.
   287  	// It will require modifications to work:
   288  	// - It may require correct/in-range values for request initialization.
   289  	// - It may require specifying regional endpoints when creating the service client as shown in:
   290  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   291  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   292  	if err != nil {
   293  		// TODO: Handle error.
   294  	}
   295  	defer c.Close()
   296  
   297  	req := &iampb.SetIamPolicyRequest{
   298  		// TODO: Fill request struct fields.
   299  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   300  	}
   301  	resp, err := c.SetIamPolicy(ctx, req)
   302  	if err != nil {
   303  		// TODO: Handle error.
   304  	}
   305  	// TODO: Use resp.
   306  	_ = resp
   307  }
   308  
   309  func ExampleSpecialistPoolClient_TestIamPermissions() {
   310  	ctx := context.Background()
   311  	// This snippet has been automatically generated and should be regarded as a code template only.
   312  	// It will require modifications to work:
   313  	// - It may require correct/in-range values for request initialization.
   314  	// - It may require specifying regional endpoints when creating the service client as shown in:
   315  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   316  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   317  	if err != nil {
   318  		// TODO: Handle error.
   319  	}
   320  	defer c.Close()
   321  
   322  	req := &iampb.TestIamPermissionsRequest{
   323  		// TODO: Fill request struct fields.
   324  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   325  	}
   326  	resp, err := c.TestIamPermissions(ctx, req)
   327  	if err != nil {
   328  		// TODO: Handle error.
   329  	}
   330  	// TODO: Use resp.
   331  	_ = resp
   332  }
   333  
   334  func ExampleSpecialistPoolClient_CancelOperation() {
   335  	ctx := context.Background()
   336  	// This snippet has been automatically generated and should be regarded as a code template only.
   337  	// It will require modifications to work:
   338  	// - It may require correct/in-range values for request initialization.
   339  	// - It may require specifying regional endpoints when creating the service client as shown in:
   340  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   341  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   342  	if err != nil {
   343  		// TODO: Handle error.
   344  	}
   345  	defer c.Close()
   346  
   347  	req := &longrunningpb.CancelOperationRequest{
   348  		// TODO: Fill request struct fields.
   349  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
   350  	}
   351  	err = c.CancelOperation(ctx, req)
   352  	if err != nil {
   353  		// TODO: Handle error.
   354  	}
   355  }
   356  
   357  func ExampleSpecialistPoolClient_DeleteOperation() {
   358  	ctx := context.Background()
   359  	// This snippet has been automatically generated and should be regarded as a code template only.
   360  	// It will require modifications to work:
   361  	// - It may require correct/in-range values for request initialization.
   362  	// - It may require specifying regional endpoints when creating the service client as shown in:
   363  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   364  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   365  	if err != nil {
   366  		// TODO: Handle error.
   367  	}
   368  	defer c.Close()
   369  
   370  	req := &longrunningpb.DeleteOperationRequest{
   371  		// TODO: Fill request struct fields.
   372  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
   373  	}
   374  	err = c.DeleteOperation(ctx, req)
   375  	if err != nil {
   376  		// TODO: Handle error.
   377  	}
   378  }
   379  
   380  func ExampleSpecialistPoolClient_GetOperation() {
   381  	ctx := context.Background()
   382  	// This snippet has been automatically generated and should be regarded as a code template only.
   383  	// It will require modifications to work:
   384  	// - It may require correct/in-range values for request initialization.
   385  	// - It may require specifying regional endpoints when creating the service client as shown in:
   386  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   387  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   388  	if err != nil {
   389  		// TODO: Handle error.
   390  	}
   391  	defer c.Close()
   392  
   393  	req := &longrunningpb.GetOperationRequest{
   394  		// TODO: Fill request struct fields.
   395  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
   396  	}
   397  	resp, err := c.GetOperation(ctx, req)
   398  	if err != nil {
   399  		// TODO: Handle error.
   400  	}
   401  	// TODO: Use resp.
   402  	_ = resp
   403  }
   404  
   405  func ExampleSpecialistPoolClient_ListOperations() {
   406  	ctx := context.Background()
   407  	// This snippet has been automatically generated and should be regarded as a code template only.
   408  	// It will require modifications to work:
   409  	// - It may require correct/in-range values for request initialization.
   410  	// - It may require specifying regional endpoints when creating the service client as shown in:
   411  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   412  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   413  	if err != nil {
   414  		// TODO: Handle error.
   415  	}
   416  	defer c.Close()
   417  
   418  	req := &longrunningpb.ListOperationsRequest{
   419  		// TODO: Fill request struct fields.
   420  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
   421  	}
   422  	it := c.ListOperations(ctx, req)
   423  	for {
   424  		resp, err := it.Next()
   425  		if err == iterator.Done {
   426  			break
   427  		}
   428  		if err != nil {
   429  			// TODO: Handle error.
   430  		}
   431  		// TODO: Use resp.
   432  		_ = resp
   433  
   434  		// If you need to access the underlying RPC response,
   435  		// you can do so by casting the `Response` as below.
   436  		// Otherwise, remove this line. Only populated after
   437  		// first call to Next(). Not safe for concurrent access.
   438  		_ = it.Response.(*longrunningpb.ListOperationsResponse)
   439  	}
   440  }
   441  
   442  func ExampleSpecialistPoolClient_WaitOperation() {
   443  	ctx := context.Background()
   444  	// This snippet has been automatically generated and should be regarded as a code template only.
   445  	// It will require modifications to work:
   446  	// - It may require correct/in-range values for request initialization.
   447  	// - It may require specifying regional endpoints when creating the service client as shown in:
   448  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   449  	c, err := aiplatform.NewSpecialistPoolClient(ctx)
   450  	if err != nil {
   451  		// TODO: Handle error.
   452  	}
   453  	defer c.Close()
   454  
   455  	req := &longrunningpb.WaitOperationRequest{
   456  		// TODO: Fill request struct fields.
   457  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest.
   458  	}
   459  	resp, err := c.WaitOperation(ctx, req)
   460  	if err != nil {
   461  		// TODO: Handle error.
   462  	}
   463  	// TODO: Use resp.
   464  	_ = resp
   465  }