cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/memory_bank_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 ExampleNewMemoryBankClient() {
    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.NewMemoryBankClient(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 ExampleNewMemoryBankRESTClient() {
    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.NewMemoryBankRESTClient(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 ExampleMemoryBankClient_CreateMemory() {
    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.NewMemoryBankClient(ctx)
    72  	if err != nil {
    73  		// TODO: Handle error.
    74  	}
    75  	defer c.Close()
    76  
    77  	req := &aiplatformpb.CreateMemoryRequest{
    78  		// TODO: Fill request struct fields.
    79  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#CreateMemoryRequest.
    80  	}
    81  	op, err := c.CreateMemory(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 ExampleMemoryBankClient_DeleteMemory() {
    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.NewMemoryBankClient(ctx)
   102  	if err != nil {
   103  		// TODO: Handle error.
   104  	}
   105  	defer c.Close()
   106  
   107  	req := &aiplatformpb.DeleteMemoryRequest{
   108  		// TODO: Fill request struct fields.
   109  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#DeleteMemoryRequest.
   110  	}
   111  	op, err := c.DeleteMemory(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 ExampleMemoryBankClient_GenerateMemories() {
   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.NewMemoryBankClient(ctx)
   130  	if err != nil {
   131  		// TODO: Handle error.
   132  	}
   133  	defer c.Close()
   134  
   135  	req := &aiplatformpb.GenerateMemoriesRequest{
   136  		// TODO: Fill request struct fields.
   137  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GenerateMemoriesRequest.
   138  	}
   139  	op, err := c.GenerateMemories(ctx, req)
   140  	if err != nil {
   141  		// TODO: Handle error.
   142  	}
   143  
   144  	resp, err := op.Wait(ctx)
   145  	if err != nil {
   146  		// TODO: Handle error.
   147  	}
   148  	// TODO: Use resp.
   149  	_ = resp
   150  }
   151  
   152  func ExampleMemoryBankClient_GetMemory() {
   153  	ctx := context.Background()
   154  	// This snippet has been automatically generated and should be regarded as a code template only.
   155  	// It will require modifications to work:
   156  	// - It may require correct/in-range values for request initialization.
   157  	// - It may require specifying regional endpoints when creating the service client as shown in:
   158  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   159  	c, err := aiplatform.NewMemoryBankClient(ctx)
   160  	if err != nil {
   161  		// TODO: Handle error.
   162  	}
   163  	defer c.Close()
   164  
   165  	req := &aiplatformpb.GetMemoryRequest{
   166  		// TODO: Fill request struct fields.
   167  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#GetMemoryRequest.
   168  	}
   169  	resp, err := c.GetMemory(ctx, req)
   170  	if err != nil {
   171  		// TODO: Handle error.
   172  	}
   173  	// TODO: Use resp.
   174  	_ = resp
   175  }
   176  
   177  func ExampleMemoryBankClient_ListMemories() {
   178  	ctx := context.Background()
   179  	// This snippet has been automatically generated and should be regarded as a code template only.
   180  	// It will require modifications to work:
   181  	// - It may require correct/in-range values for request initialization.
   182  	// - It may require specifying regional endpoints when creating the service client as shown in:
   183  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   184  	c, err := aiplatform.NewMemoryBankClient(ctx)
   185  	if err != nil {
   186  		// TODO: Handle error.
   187  	}
   188  	defer c.Close()
   189  
   190  	req := &aiplatformpb.ListMemoriesRequest{
   191  		// TODO: Fill request struct fields.
   192  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#ListMemoriesRequest.
   193  	}
   194  	it := c.ListMemories(ctx, req)
   195  	for {
   196  		resp, err := it.Next()
   197  		if err == iterator.Done {
   198  			break
   199  		}
   200  		if err != nil {
   201  			// TODO: Handle error.
   202  		}
   203  		// TODO: Use resp.
   204  		_ = resp
   205  
   206  		// If you need to access the underlying RPC response,
   207  		// you can do so by casting the `Response` as below.
   208  		// Otherwise, remove this line. Only populated after
   209  		// first call to Next(). Not safe for concurrent access.
   210  		_ = it.Response.(*aiplatformpb.ListMemoriesResponse)
   211  	}
   212  }
   213  
   214  func ExampleMemoryBankClient_RetrieveMemories() {
   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.NewMemoryBankClient(ctx)
   222  	if err != nil {
   223  		// TODO: Handle error.
   224  	}
   225  	defer c.Close()
   226  
   227  	req := &aiplatformpb.RetrieveMemoriesRequest{
   228  		// TODO: Fill request struct fields.
   229  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#RetrieveMemoriesRequest.
   230  	}
   231  	resp, err := c.RetrieveMemories(ctx, req)
   232  	if err != nil {
   233  		// TODO: Handle error.
   234  	}
   235  	// TODO: Use resp.
   236  	_ = resp
   237  }
   238  
   239  func ExampleMemoryBankClient_UpdateMemory() {
   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.NewMemoryBankClient(ctx)
   247  	if err != nil {
   248  		// TODO: Handle error.
   249  	}
   250  	defer c.Close()
   251  
   252  	req := &aiplatformpb.UpdateMemoryRequest{
   253  		// TODO: Fill request struct fields.
   254  		// See https://pkg.go.dev/cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb#UpdateMemoryRequest.
   255  	}
   256  	op, err := c.UpdateMemory(ctx, req)
   257  	if err != nil {
   258  		// TODO: Handle error.
   259  	}
   260  
   261  	resp, err := op.Wait(ctx)
   262  	if err != nil {
   263  		// TODO: Handle error.
   264  	}
   265  	// TODO: Use resp.
   266  	_ = resp
   267  }
   268  
   269  func ExampleMemoryBankClient_GetLocation() {
   270  	ctx := context.Background()
   271  	// This snippet has been automatically generated and should be regarded as a code template only.
   272  	// It will require modifications to work:
   273  	// - It may require correct/in-range values for request initialization.
   274  	// - It may require specifying regional endpoints when creating the service client as shown in:
   275  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   276  	c, err := aiplatform.NewMemoryBankClient(ctx)
   277  	if err != nil {
   278  		// TODO: Handle error.
   279  	}
   280  	defer c.Close()
   281  
   282  	req := &locationpb.GetLocationRequest{
   283  		// TODO: Fill request struct fields.
   284  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
   285  	}
   286  	resp, err := c.GetLocation(ctx, req)
   287  	if err != nil {
   288  		// TODO: Handle error.
   289  	}
   290  	// TODO: Use resp.
   291  	_ = resp
   292  }
   293  
   294  func ExampleMemoryBankClient_ListLocations() {
   295  	ctx := context.Background()
   296  	// This snippet has been automatically generated and should be regarded as a code template only.
   297  	// It will require modifications to work:
   298  	// - It may require correct/in-range values for request initialization.
   299  	// - It may require specifying regional endpoints when creating the service client as shown in:
   300  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   301  	c, err := aiplatform.NewMemoryBankClient(ctx)
   302  	if err != nil {
   303  		// TODO: Handle error.
   304  	}
   305  	defer c.Close()
   306  
   307  	req := &locationpb.ListLocationsRequest{
   308  		// TODO: Fill request struct fields.
   309  		// See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
   310  	}
   311  	it := c.ListLocations(ctx, req)
   312  	for {
   313  		resp, err := it.Next()
   314  		if err == iterator.Done {
   315  			break
   316  		}
   317  		if err != nil {
   318  			// TODO: Handle error.
   319  		}
   320  		// TODO: Use resp.
   321  		_ = resp
   322  
   323  		// If you need to access the underlying RPC response,
   324  		// you can do so by casting the `Response` as below.
   325  		// Otherwise, remove this line. Only populated after
   326  		// first call to Next(). Not safe for concurrent access.
   327  		_ = it.Response.(*locationpb.ListLocationsResponse)
   328  	}
   329  }
   330  
   331  func ExampleMemoryBankClient_GetIamPolicy() {
   332  	ctx := context.Background()
   333  	// This snippet has been automatically generated and should be regarded as a code template only.
   334  	// It will require modifications to work:
   335  	// - It may require correct/in-range values for request initialization.
   336  	// - It may require specifying regional endpoints when creating the service client as shown in:
   337  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   338  	c, err := aiplatform.NewMemoryBankClient(ctx)
   339  	if err != nil {
   340  		// TODO: Handle error.
   341  	}
   342  	defer c.Close()
   343  
   344  	req := &iampb.GetIamPolicyRequest{
   345  		// TODO: Fill request struct fields.
   346  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
   347  	}
   348  	resp, err := c.GetIamPolicy(ctx, req)
   349  	if err != nil {
   350  		// TODO: Handle error.
   351  	}
   352  	// TODO: Use resp.
   353  	_ = resp
   354  }
   355  
   356  func ExampleMemoryBankClient_SetIamPolicy() {
   357  	ctx := context.Background()
   358  	// This snippet has been automatically generated and should be regarded as a code template only.
   359  	// It will require modifications to work:
   360  	// - It may require correct/in-range values for request initialization.
   361  	// - It may require specifying regional endpoints when creating the service client as shown in:
   362  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   363  	c, err := aiplatform.NewMemoryBankClient(ctx)
   364  	if err != nil {
   365  		// TODO: Handle error.
   366  	}
   367  	defer c.Close()
   368  
   369  	req := &iampb.SetIamPolicyRequest{
   370  		// TODO: Fill request struct fields.
   371  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
   372  	}
   373  	resp, err := c.SetIamPolicy(ctx, req)
   374  	if err != nil {
   375  		// TODO: Handle error.
   376  	}
   377  	// TODO: Use resp.
   378  	_ = resp
   379  }
   380  
   381  func ExampleMemoryBankClient_TestIamPermissions() {
   382  	ctx := context.Background()
   383  	// This snippet has been automatically generated and should be regarded as a code template only.
   384  	// It will require modifications to work:
   385  	// - It may require correct/in-range values for request initialization.
   386  	// - It may require specifying regional endpoints when creating the service client as shown in:
   387  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   388  	c, err := aiplatform.NewMemoryBankClient(ctx)
   389  	if err != nil {
   390  		// TODO: Handle error.
   391  	}
   392  	defer c.Close()
   393  
   394  	req := &iampb.TestIamPermissionsRequest{
   395  		// TODO: Fill request struct fields.
   396  		// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
   397  	}
   398  	resp, err := c.TestIamPermissions(ctx, req)
   399  	if err != nil {
   400  		// TODO: Handle error.
   401  	}
   402  	// TODO: Use resp.
   403  	_ = resp
   404  }
   405  
   406  func ExampleMemoryBankClient_CancelOperation() {
   407  	ctx := context.Background()
   408  	// This snippet has been automatically generated and should be regarded as a code template only.
   409  	// It will require modifications to work:
   410  	// - It may require correct/in-range values for request initialization.
   411  	// - It may require specifying regional endpoints when creating the service client as shown in:
   412  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   413  	c, err := aiplatform.NewMemoryBankClient(ctx)
   414  	if err != nil {
   415  		// TODO: Handle error.
   416  	}
   417  	defer c.Close()
   418  
   419  	req := &longrunningpb.CancelOperationRequest{
   420  		// TODO: Fill request struct fields.
   421  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
   422  	}
   423  	err = c.CancelOperation(ctx, req)
   424  	if err != nil {
   425  		// TODO: Handle error.
   426  	}
   427  }
   428  
   429  func ExampleMemoryBankClient_DeleteOperation() {
   430  	ctx := context.Background()
   431  	// This snippet has been automatically generated and should be regarded as a code template only.
   432  	// It will require modifications to work:
   433  	// - It may require correct/in-range values for request initialization.
   434  	// - It may require specifying regional endpoints when creating the service client as shown in:
   435  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   436  	c, err := aiplatform.NewMemoryBankClient(ctx)
   437  	if err != nil {
   438  		// TODO: Handle error.
   439  	}
   440  	defer c.Close()
   441  
   442  	req := &longrunningpb.DeleteOperationRequest{
   443  		// TODO: Fill request struct fields.
   444  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
   445  	}
   446  	err = c.DeleteOperation(ctx, req)
   447  	if err != nil {
   448  		// TODO: Handle error.
   449  	}
   450  }
   451  
   452  func ExampleMemoryBankClient_GetOperation() {
   453  	ctx := context.Background()
   454  	// This snippet has been automatically generated and should be regarded as a code template only.
   455  	// It will require modifications to work:
   456  	// - It may require correct/in-range values for request initialization.
   457  	// - It may require specifying regional endpoints when creating the service client as shown in:
   458  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   459  	c, err := aiplatform.NewMemoryBankClient(ctx)
   460  	if err != nil {
   461  		// TODO: Handle error.
   462  	}
   463  	defer c.Close()
   464  
   465  	req := &longrunningpb.GetOperationRequest{
   466  		// TODO: Fill request struct fields.
   467  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
   468  	}
   469  	resp, err := c.GetOperation(ctx, req)
   470  	if err != nil {
   471  		// TODO: Handle error.
   472  	}
   473  	// TODO: Use resp.
   474  	_ = resp
   475  }
   476  
   477  func ExampleMemoryBankClient_ListOperations() {
   478  	ctx := context.Background()
   479  	// This snippet has been automatically generated and should be regarded as a code template only.
   480  	// It will require modifications to work:
   481  	// - It may require correct/in-range values for request initialization.
   482  	// - It may require specifying regional endpoints when creating the service client as shown in:
   483  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   484  	c, err := aiplatform.NewMemoryBankClient(ctx)
   485  	if err != nil {
   486  		// TODO: Handle error.
   487  	}
   488  	defer c.Close()
   489  
   490  	req := &longrunningpb.ListOperationsRequest{
   491  		// TODO: Fill request struct fields.
   492  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
   493  	}
   494  	it := c.ListOperations(ctx, req)
   495  	for {
   496  		resp, err := it.Next()
   497  		if err == iterator.Done {
   498  			break
   499  		}
   500  		if err != nil {
   501  			// TODO: Handle error.
   502  		}
   503  		// TODO: Use resp.
   504  		_ = resp
   505  
   506  		// If you need to access the underlying RPC response,
   507  		// you can do so by casting the `Response` as below.
   508  		// Otherwise, remove this line. Only populated after
   509  		// first call to Next(). Not safe for concurrent access.
   510  		_ = it.Response.(*longrunningpb.ListOperationsResponse)
   511  	}
   512  }
   513  
   514  func ExampleMemoryBankClient_WaitOperation() {
   515  	ctx := context.Background()
   516  	// This snippet has been automatically generated and should be regarded as a code template only.
   517  	// It will require modifications to work:
   518  	// - It may require correct/in-range values for request initialization.
   519  	// - It may require specifying regional endpoints when creating the service client as shown in:
   520  	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
   521  	c, err := aiplatform.NewMemoryBankClient(ctx)
   522  	if err != nil {
   523  		// TODO: Handle error.
   524  	}
   525  	defer c.Close()
   526  
   527  	req := &longrunningpb.WaitOperationRequest{
   528  		// TODO: Fill request struct fields.
   529  		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#WaitOperationRequest.
   530  	}
   531  	resp, err := c.WaitOperation(ctx, req)
   532  	if err != nil {
   533  		// TODO: Handle error.
   534  	}
   535  	// TODO: Use resp.
   536  	_ = resp
   537  }