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