cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/reasoning_engine_execution_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 ExampleNewReasoningEngineExecutionClient() {
    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.NewReasoningEngineExecutionClient(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 ExampleNewReasoningEngineExecutionRESTClient() {
    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.NewReasoningEngineExecutionRESTClient(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 ExampleReasoningEngineExecutionClient_QueryReasoningEngine() {
    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.NewReasoningEngineExecutionClient(ctx)
    72  	if err != nil {
    73  		// TODO: Handle error.
    74  	}
    75  	defer c.Close()
    76  
    77  	req := &aiplatformpb.QueryReasoningEngineRequest{
    78  		// TODO: Fill request struct fields.
    79  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#QueryReasoningEngineRequest.
    80  	}
    81  	resp, err := c.QueryReasoningEngine(ctx, req)
    82  	if err != nil {
    83  		// TODO: Handle error.
    84  	}
    85  	// TODO: Use resp.
    86  	_ = resp
    87  }
    88  
    89  func ExampleReasoningEngineExecutionClient_GetLocation() {
    90  	ctx := context.Background()
    91  	// This snippet has been automatically generated and should be regarded as a code template only.
    92  	// It will require modifications to work:
    93  	// - It may require correct/in-range values for request initialization.
    94  	// - It may require specifying regional endpoints when creating the service client as shown in:
    95  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
    96  	c, err := aiplatform.NewReasoningEngineExecutionClient(ctx)
    97  	if err != nil {
    98  		// TODO: Handle error.
    99  	}
   100  	defer c.Close()
   101  
   102  	req := &locationpb.GetLocationRequest{
   103  		// TODO: Fill request struct fields.
   104  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
   105  	}
   106  	resp, err := c.GetLocation(ctx, req)
   107  	if err != nil {
   108  		// TODO: Handle error.
   109  	}
   110  	// TODO: Use resp.
   111  	_ = resp
   112  }
   113  
   114  func ExampleReasoningEngineExecutionClient_ListLocations() {
   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.NewReasoningEngineExecutionClient(ctx)
   122  	if err != nil {
   123  		// TODO: Handle error.
   124  	}
   125  	defer c.Close()
   126  
   127  	req := &locationpb.ListLocationsRequest{
   128  		// TODO: Fill request struct fields.
   129  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
   130  	}
   131  	it := c.ListLocations(ctx, req)
   132  	for {
   133  		resp, err := it.Next()
   134  		if err == iterator.Done {
   135  			break
   136  		}
   137  		if err != nil {
   138  			// TODO: Handle error.
   139  		}
   140  		// TODO: Use resp.
   141  		_ = resp
   142  
   143  		// If you need to access the underlying RPC response,
   144  		// you can do so by casting the `Response` as below.
   145  		// Otherwise, remove this line. Only populated after
   146  		// first call to Next(). Not safe for concurrent access.
   147  		_ = it.Response.(*locationpb.ListLocationsResponse)
   148  	}
   149  }
   150  
   151  func ExampleReasoningEngineExecutionClient_GetIamPolicy() {
   152  	ctx := context.Background()
   153  	// This snippet has been automatically generated and should be regarded as a code template only.
   154  	// It will require modifications to work:
   155  	// - It may require correct/in-range values for request initialization.
   156  	// - It may require specifying regional endpoints when creating the service client as shown in:
   157  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   158  	c, err := aiplatform.NewReasoningEngineExecutionClient(ctx)
   159  	if err != nil {
   160  		// TODO: Handle error.
   161  	}
   162  	defer c.Close()
   163  
   164  	req := &iampb.GetIamPolicyRequest{
   165  		// TODO: Fill request struct fields.
   166  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   167  	}
   168  	resp, err := c.GetIamPolicy(ctx, req)
   169  	if err != nil {
   170  		// TODO: Handle error.
   171  	}
   172  	// TODO: Use resp.
   173  	_ = resp
   174  }
   175  
   176  func ExampleReasoningEngineExecutionClient_SetIamPolicy() {
   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.NewReasoningEngineExecutionClient(ctx)
   184  	if err != nil {
   185  		// TODO: Handle error.
   186  	}
   187  	defer c.Close()
   188  
   189  	req := &iampb.SetIamPolicyRequest{
   190  		// TODO: Fill request struct fields.
   191  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   192  	}
   193  	resp, err := c.SetIamPolicy(ctx, req)
   194  	if err != nil {
   195  		// TODO: Handle error.
   196  	}
   197  	// TODO: Use resp.
   198  	_ = resp
   199  }
   200  
   201  func ExampleReasoningEngineExecutionClient_TestIamPermissions() {
   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.NewReasoningEngineExecutionClient(ctx)
   209  	if err != nil {
   210  		// TODO: Handle error.
   211  	}
   212  	defer c.Close()
   213  
   214  	req := &iampb.TestIamPermissionsRequest{
   215  		// TODO: Fill request struct fields.
   216  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   217  	}
   218  	resp, err := c.TestIamPermissions(ctx, req)
   219  	if err != nil {
   220  		// TODO: Handle error.
   221  	}
   222  	// TODO: Use resp.
   223  	_ = resp
   224  }
   225  
   226  func ExampleReasoningEngineExecutionClient_CancelOperation() {
   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.NewReasoningEngineExecutionClient(ctx)
   234  	if err != nil {
   235  		// TODO: Handle error.
   236  	}
   237  	defer c.Close()
   238  
   239  	req := &longrunningpb.CancelOperationRequest{
   240  		// TODO: Fill request struct fields.
   241  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
   242  	}
   243  	err = c.CancelOperation(ctx, req)
   244  	if err != nil {
   245  		// TODO: Handle error.
   246  	}
   247  }
   248  
   249  func ExampleReasoningEngineExecutionClient_DeleteOperation() {
   250  	ctx := context.Background()
   251  	// This snippet has been automatically generated and should be regarded as a code template only.
   252  	// It will require modifications to work:
   253  	// - It may require correct/in-range values for request initialization.
   254  	// - It may require specifying regional endpoints when creating the service client as shown in:
   255  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   256  	c, err := aiplatform.NewReasoningEngineExecutionClient(ctx)
   257  	if err != nil {
   258  		// TODO: Handle error.
   259  	}
   260  	defer c.Close()
   261  
   262  	req := &longrunningpb.DeleteOperationRequest{
   263  		// TODO: Fill request struct fields.
   264  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
   265  	}
   266  	err = c.DeleteOperation(ctx, req)
   267  	if err != nil {
   268  		// TODO: Handle error.
   269  	}
   270  }
   271  
   272  func ExampleReasoningEngineExecutionClient_GetOperation() {
   273  	ctx := context.Background()
   274  	// This snippet has been automatically generated and should be regarded as a code template only.
   275  	// It will require modifications to work:
   276  	// - It may require correct/in-range values for request initialization.
   277  	// - It may require specifying regional endpoints when creating the service client as shown in:
   278  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   279  	c, err := aiplatform.NewReasoningEngineExecutionClient(ctx)
   280  	if err != nil {
   281  		// TODO: Handle error.
   282  	}
   283  	defer c.Close()
   284  
   285  	req := &longrunningpb.GetOperationRequest{
   286  		// TODO: Fill request struct fields.
   287  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
   288  	}
   289  	resp, err := c.GetOperation(ctx, req)
   290  	if err != nil {
   291  		// TODO: Handle error.
   292  	}
   293  	// TODO: Use resp.
   294  	_ = resp
   295  }
   296  
   297  func ExampleReasoningEngineExecutionClient_ListOperations() {
   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.NewReasoningEngineExecutionClient(ctx)
   305  	if err != nil {
   306  		// TODO: Handle error.
   307  	}
   308  	defer c.Close()
   309  
   310  	req := &longrunningpb.ListOperationsRequest{
   311  		// TODO: Fill request struct fields.
   312  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
   313  	}
   314  	it := c.ListOperations(ctx, req)
   315  	for {
   316  		resp, err := it.Next()
   317  		if err == iterator.Done {
   318  			break
   319  		}
   320  		if err != nil {
   321  			// TODO: Handle error.
   322  		}
   323  		// TODO: Use resp.
   324  		_ = resp
   325  
   326  		// If you need to access the underlying RPC response,
   327  		// you can do so by casting the `Response` as below.
   328  		// Otherwise, remove this line. Only populated after
   329  		// first call to Next(). Not safe for concurrent access.
   330  		_ = it.Response.(*longrunningpb.ListOperationsResponse)
   331  	}
   332  }
   333  
   334  func ExampleReasoningEngineExecutionClient_WaitOperation() {
   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.NewReasoningEngineExecutionClient(ctx)
   342  	if err != nil {
   343  		// TODO: Handle error.
   344  	}
   345  	defer c.Close()
   346  
   347  	req := &longrunningpb.WaitOperationRequest{
   348  		// TODO: Fill request struct fields.
   349  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest.
   350  	}
   351  	resp, err := c.WaitOperation(ctx, req)
   352  	if err != nil {
   353  		// TODO: Handle error.
   354  	}
   355  	// TODO: Use resp.
   356  	_ = resp
   357  }