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