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