cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/tensorboard_client.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
    18  
    19  import (
    20  	"bytes"
    21  	"context"
    22  	"errors"
    23  	"fmt"
    24  	"log/slog"
    25  	"math"
    26  	"net/http"
    27  	"net/url"
    28  
    29  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    30  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    31  	"cloud.google.com/go/longrunning"
    32  	lroauto "cloud.google.com/go/longrunning/autogen"
    33  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    34  	gax "github.com/googleapis/gax-go/v2"
    35  	"google.golang.org/api/iterator"
    36  	"google.golang.org/api/option"
    37  	"google.golang.org/api/option/internaloption"
    38  	gtransport "google.golang.org/api/transport/grpc"
    39  	httptransport "google.golang.org/api/transport/http"
    40  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    41  	"google.golang.org/grpc"
    42  	"google.golang.org/grpc/metadata"
    43  	"google.golang.org/protobuf/encoding/protojson"
    44  	"google.golang.org/protobuf/proto"
    45  )
    46  
    47  var newTensorboardClientHook clientHook
    48  
    49  // TensorboardCallOptions contains the retry settings for each method of TensorboardClient.
    50  type TensorboardCallOptions struct {
    51  	CreateTensorboard                  []gax.CallOption
    52  	GetTensorboard                     []gax.CallOption
    53  	UpdateTensorboard                  []gax.CallOption
    54  	ListTensorboards                   []gax.CallOption
    55  	DeleteTensorboard                  []gax.CallOption
    56  	ReadTensorboardUsage               []gax.CallOption
    57  	ReadTensorboardSize                []gax.CallOption
    58  	CreateTensorboardExperiment        []gax.CallOption
    59  	GetTensorboardExperiment           []gax.CallOption
    60  	UpdateTensorboardExperiment        []gax.CallOption
    61  	ListTensorboardExperiments         []gax.CallOption
    62  	DeleteTensorboardExperiment        []gax.CallOption
    63  	CreateTensorboardRun               []gax.CallOption
    64  	BatchCreateTensorboardRuns         []gax.CallOption
    65  	GetTensorboardRun                  []gax.CallOption
    66  	UpdateTensorboardRun               []gax.CallOption
    67  	ListTensorboardRuns                []gax.CallOption
    68  	DeleteTensorboardRun               []gax.CallOption
    69  	BatchCreateTensorboardTimeSeries   []gax.CallOption
    70  	CreateTensorboardTimeSeries        []gax.CallOption
    71  	GetTensorboardTimeSeries           []gax.CallOption
    72  	UpdateTensorboardTimeSeries        []gax.CallOption
    73  	ListTensorboardTimeSeries          []gax.CallOption
    74  	DeleteTensorboardTimeSeries        []gax.CallOption
    75  	BatchReadTensorboardTimeSeriesData []gax.CallOption
    76  	ReadTensorboardTimeSeriesData      []gax.CallOption
    77  	ReadTensorboardBlobData            []gax.CallOption
    78  	WriteTensorboardExperimentData     []gax.CallOption
    79  	WriteTensorboardRunData            []gax.CallOption
    80  	ExportTensorboardTimeSeriesData    []gax.CallOption
    81  	GetLocation                        []gax.CallOption
    82  	ListLocations                      []gax.CallOption
    83  	GetIamPolicy                       []gax.CallOption
    84  	SetIamPolicy                       []gax.CallOption
    85  	TestIamPermissions                 []gax.CallOption
    86  	CancelOperation                    []gax.CallOption
    87  	DeleteOperation                    []gax.CallOption
    88  	GetOperation                       []gax.CallOption
    89  	ListOperations                     []gax.CallOption
    90  	WaitOperation                      []gax.CallOption
    91  }
    92  
    93  func defaultTensorboardGRPCClientOptions() []option.ClientOption {
    94  	return []option.ClientOption{
    95  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    96  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    97  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    98  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    99  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   100  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   101  		internaloption.EnableJwtWithScope(),
   102  		internaloption.EnableNewAuthLibrary(),
   103  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
   104  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
   105  	}
   106  }
   107  
   108  func defaultTensorboardCallOptions() *TensorboardCallOptions {
   109  	return &TensorboardCallOptions{
   110  		CreateTensorboard:                  []gax.CallOption{},
   111  		GetTensorboard:                     []gax.CallOption{},
   112  		UpdateTensorboard:                  []gax.CallOption{},
   113  		ListTensorboards:                   []gax.CallOption{},
   114  		DeleteTensorboard:                  []gax.CallOption{},
   115  		ReadTensorboardUsage:               []gax.CallOption{},
   116  		ReadTensorboardSize:                []gax.CallOption{},
   117  		CreateTensorboardExperiment:        []gax.CallOption{},
   118  		GetTensorboardExperiment:           []gax.CallOption{},
   119  		UpdateTensorboardExperiment:        []gax.CallOption{},
   120  		ListTensorboardExperiments:         []gax.CallOption{},
   121  		DeleteTensorboardExperiment:        []gax.CallOption{},
   122  		CreateTensorboardRun:               []gax.CallOption{},
   123  		BatchCreateTensorboardRuns:         []gax.CallOption{},
   124  		GetTensorboardRun:                  []gax.CallOption{},
   125  		UpdateTensorboardRun:               []gax.CallOption{},
   126  		ListTensorboardRuns:                []gax.CallOption{},
   127  		DeleteTensorboardRun:               []gax.CallOption{},
   128  		BatchCreateTensorboardTimeSeries:   []gax.CallOption{},
   129  		CreateTensorboardTimeSeries:        []gax.CallOption{},
   130  		GetTensorboardTimeSeries:           []gax.CallOption{},
   131  		UpdateTensorboardTimeSeries:        []gax.CallOption{},
   132  		ListTensorboardTimeSeries:          []gax.CallOption{},
   133  		DeleteTensorboardTimeSeries:        []gax.CallOption{},
   134  		BatchReadTensorboardTimeSeriesData: []gax.CallOption{},
   135  		ReadTensorboardTimeSeriesData:      []gax.CallOption{},
   136  		ReadTensorboardBlobData:            []gax.CallOption{},
   137  		WriteTensorboardExperimentData:     []gax.CallOption{},
   138  		WriteTensorboardRunData:            []gax.CallOption{},
   139  		ExportTensorboardTimeSeriesData:    []gax.CallOption{},
   140  		GetLocation:                        []gax.CallOption{},
   141  		ListLocations:                      []gax.CallOption{},
   142  		GetIamPolicy:                       []gax.CallOption{},
   143  		SetIamPolicy:                       []gax.CallOption{},
   144  		TestIamPermissions:                 []gax.CallOption{},
   145  		CancelOperation:                    []gax.CallOption{},
   146  		DeleteOperation:                    []gax.CallOption{},
   147  		GetOperation:                       []gax.CallOption{},
   148  		ListOperations:                     []gax.CallOption{},
   149  		WaitOperation:                      []gax.CallOption{},
   150  	}
   151  }
   152  
   153  func defaultTensorboardRESTCallOptions() *TensorboardCallOptions {
   154  	return &TensorboardCallOptions{
   155  		CreateTensorboard:                  []gax.CallOption{},
   156  		GetTensorboard:                     []gax.CallOption{},
   157  		UpdateTensorboard:                  []gax.CallOption{},
   158  		ListTensorboards:                   []gax.CallOption{},
   159  		DeleteTensorboard:                  []gax.CallOption{},
   160  		ReadTensorboardUsage:               []gax.CallOption{},
   161  		ReadTensorboardSize:                []gax.CallOption{},
   162  		CreateTensorboardExperiment:        []gax.CallOption{},
   163  		GetTensorboardExperiment:           []gax.CallOption{},
   164  		UpdateTensorboardExperiment:        []gax.CallOption{},
   165  		ListTensorboardExperiments:         []gax.CallOption{},
   166  		DeleteTensorboardExperiment:        []gax.CallOption{},
   167  		CreateTensorboardRun:               []gax.CallOption{},
   168  		BatchCreateTensorboardRuns:         []gax.CallOption{},
   169  		GetTensorboardRun:                  []gax.CallOption{},
   170  		UpdateTensorboardRun:               []gax.CallOption{},
   171  		ListTensorboardRuns:                []gax.CallOption{},
   172  		DeleteTensorboardRun:               []gax.CallOption{},
   173  		BatchCreateTensorboardTimeSeries:   []gax.CallOption{},
   174  		CreateTensorboardTimeSeries:        []gax.CallOption{},
   175  		GetTensorboardTimeSeries:           []gax.CallOption{},
   176  		UpdateTensorboardTimeSeries:        []gax.CallOption{},
   177  		ListTensorboardTimeSeries:          []gax.CallOption{},
   178  		DeleteTensorboardTimeSeries:        []gax.CallOption{},
   179  		BatchReadTensorboardTimeSeriesData: []gax.CallOption{},
   180  		ReadTensorboardTimeSeriesData:      []gax.CallOption{},
   181  		ReadTensorboardBlobData:            []gax.CallOption{},
   182  		WriteTensorboardExperimentData:     []gax.CallOption{},
   183  		WriteTensorboardRunData:            []gax.CallOption{},
   184  		ExportTensorboardTimeSeriesData:    []gax.CallOption{},
   185  		GetLocation:                        []gax.CallOption{},
   186  		ListLocations:                      []gax.CallOption{},
   187  		GetIamPolicy:                       []gax.CallOption{},
   188  		SetIamPolicy:                       []gax.CallOption{},
   189  		TestIamPermissions:                 []gax.CallOption{},
   190  		CancelOperation:                    []gax.CallOption{},
   191  		DeleteOperation:                    []gax.CallOption{},
   192  		GetOperation:                       []gax.CallOption{},
   193  		ListOperations:                     []gax.CallOption{},
   194  		WaitOperation:                      []gax.CallOption{},
   195  	}
   196  }
   197  
   198  // internalTensorboardClient is an interface that defines the methods available from Vertex AI API.
   199  type internalTensorboardClient interface {
   200  	Close() error
   201  	setGoogleClientInfo(...string)
   202  	Connection() *grpc.ClientConn
   203  	CreateTensorboard(context.Context, *aiplatformpb.CreateTensorboardRequest, ...gax.CallOption) (*CreateTensorboardOperation, error)
   204  	CreateTensorboardOperation(name string) *CreateTensorboardOperation
   205  	GetTensorboard(context.Context, *aiplatformpb.GetTensorboardRequest, ...gax.CallOption) (*aiplatformpb.Tensorboard, error)
   206  	UpdateTensorboard(context.Context, *aiplatformpb.UpdateTensorboardRequest, ...gax.CallOption) (*UpdateTensorboardOperation, error)
   207  	UpdateTensorboardOperation(name string) *UpdateTensorboardOperation
   208  	ListTensorboards(context.Context, *aiplatformpb.ListTensorboardsRequest, ...gax.CallOption) *TensorboardIterator
   209  	DeleteTensorboard(context.Context, *aiplatformpb.DeleteTensorboardRequest, ...gax.CallOption) (*DeleteTensorboardOperation, error)
   210  	DeleteTensorboardOperation(name string) *DeleteTensorboardOperation
   211  	ReadTensorboardUsage(context.Context, *aiplatformpb.ReadTensorboardUsageRequest, ...gax.CallOption) (*aiplatformpb.ReadTensorboardUsageResponse, error)
   212  	ReadTensorboardSize(context.Context, *aiplatformpb.ReadTensorboardSizeRequest, ...gax.CallOption) (*aiplatformpb.ReadTensorboardSizeResponse, error)
   213  	CreateTensorboardExperiment(context.Context, *aiplatformpb.CreateTensorboardExperimentRequest, ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error)
   214  	GetTensorboardExperiment(context.Context, *aiplatformpb.GetTensorboardExperimentRequest, ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error)
   215  	UpdateTensorboardExperiment(context.Context, *aiplatformpb.UpdateTensorboardExperimentRequest, ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error)
   216  	ListTensorboardExperiments(context.Context, *aiplatformpb.ListTensorboardExperimentsRequest, ...gax.CallOption) *TensorboardExperimentIterator
   217  	DeleteTensorboardExperiment(context.Context, *aiplatformpb.DeleteTensorboardExperimentRequest, ...gax.CallOption) (*DeleteTensorboardExperimentOperation, error)
   218  	DeleteTensorboardExperimentOperation(name string) *DeleteTensorboardExperimentOperation
   219  	CreateTensorboardRun(context.Context, *aiplatformpb.CreateTensorboardRunRequest, ...gax.CallOption) (*aiplatformpb.TensorboardRun, error)
   220  	BatchCreateTensorboardRuns(context.Context, *aiplatformpb.BatchCreateTensorboardRunsRequest, ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardRunsResponse, error)
   221  	GetTensorboardRun(context.Context, *aiplatformpb.GetTensorboardRunRequest, ...gax.CallOption) (*aiplatformpb.TensorboardRun, error)
   222  	UpdateTensorboardRun(context.Context, *aiplatformpb.UpdateTensorboardRunRequest, ...gax.CallOption) (*aiplatformpb.TensorboardRun, error)
   223  	ListTensorboardRuns(context.Context, *aiplatformpb.ListTensorboardRunsRequest, ...gax.CallOption) *TensorboardRunIterator
   224  	DeleteTensorboardRun(context.Context, *aiplatformpb.DeleteTensorboardRunRequest, ...gax.CallOption) (*DeleteTensorboardRunOperation, error)
   225  	DeleteTensorboardRunOperation(name string) *DeleteTensorboardRunOperation
   226  	BatchCreateTensorboardTimeSeries(context.Context, *aiplatformpb.BatchCreateTensorboardTimeSeriesRequest, ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardTimeSeriesResponse, error)
   227  	CreateTensorboardTimeSeries(context.Context, *aiplatformpb.CreateTensorboardTimeSeriesRequest, ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error)
   228  	GetTensorboardTimeSeries(context.Context, *aiplatformpb.GetTensorboardTimeSeriesRequest, ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error)
   229  	UpdateTensorboardTimeSeries(context.Context, *aiplatformpb.UpdateTensorboardTimeSeriesRequest, ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error)
   230  	ListTensorboardTimeSeries(context.Context, *aiplatformpb.ListTensorboardTimeSeriesRequest, ...gax.CallOption) *TensorboardTimeSeriesIterator
   231  	DeleteTensorboardTimeSeries(context.Context, *aiplatformpb.DeleteTensorboardTimeSeriesRequest, ...gax.CallOption) (*DeleteTensorboardTimeSeriesOperation, error)
   232  	DeleteTensorboardTimeSeriesOperation(name string) *DeleteTensorboardTimeSeriesOperation
   233  	BatchReadTensorboardTimeSeriesData(context.Context, *aiplatformpb.BatchReadTensorboardTimeSeriesDataRequest, ...gax.CallOption) (*aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse, error)
   234  	ReadTensorboardTimeSeriesData(context.Context, *aiplatformpb.ReadTensorboardTimeSeriesDataRequest, ...gax.CallOption) (*aiplatformpb.ReadTensorboardTimeSeriesDataResponse, error)
   235  	ReadTensorboardBlobData(context.Context, *aiplatformpb.ReadTensorboardBlobDataRequest, ...gax.CallOption) (aiplatformpb.TensorboardService_ReadTensorboardBlobDataClient, error)
   236  	WriteTensorboardExperimentData(context.Context, *aiplatformpb.WriteTensorboardExperimentDataRequest, ...gax.CallOption) (*aiplatformpb.WriteTensorboardExperimentDataResponse, error)
   237  	WriteTensorboardRunData(context.Context, *aiplatformpb.WriteTensorboardRunDataRequest, ...gax.CallOption) (*aiplatformpb.WriteTensorboardRunDataResponse, error)
   238  	ExportTensorboardTimeSeriesData(context.Context, *aiplatformpb.ExportTensorboardTimeSeriesDataRequest, ...gax.CallOption) *TimeSeriesDataPointIterator
   239  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   240  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   241  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   242  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   243  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   244  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   245  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   246  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   247  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   248  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   249  }
   250  
   251  // TensorboardClient is a client for interacting with Vertex AI API.
   252  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   253  //
   254  // TensorboardService
   255  type TensorboardClient struct {
   256  	// The internal transport-dependent client.
   257  	internalClient internalTensorboardClient
   258  
   259  	// The call options for this service.
   260  	CallOptions *TensorboardCallOptions
   261  
   262  	// LROClient is used internally to handle long-running operations.
   263  	// It is exposed so that its CallOptions can be modified if required.
   264  	// Users should not Close this client.
   265  	LROClient *lroauto.OperationsClient
   266  }
   267  
   268  // Wrapper methods routed to the internal client.
   269  
   270  // Close closes the connection to the API service. The user should invoke this when
   271  // the client is no longer required.
   272  func (c *TensorboardClient) Close() error {
   273  	return c.internalClient.Close()
   274  }
   275  
   276  // setGoogleClientInfo sets the name and version of the application in
   277  // the `x-goog-api-client` header passed on each request. Intended for
   278  // use by Google-written clients.
   279  func (c *TensorboardClient) setGoogleClientInfo(keyval ...string) {
   280  	c.internalClient.setGoogleClientInfo(keyval...)
   281  }
   282  
   283  // Connection returns a connection to the API service.
   284  //
   285  // Deprecated: Connections are now pooled so this method does not always
   286  // return the same resource.
   287  func (c *TensorboardClient) Connection() *grpc.ClientConn {
   288  	return c.internalClient.Connection()
   289  }
   290  
   291  // CreateTensorboard creates a Tensorboard.
   292  func (c *TensorboardClient) CreateTensorboard(ctx context.Context, req *aiplatformpb.CreateTensorboardRequest, opts ...gax.CallOption) (*CreateTensorboardOperation, error) {
   293  	return c.internalClient.CreateTensorboard(ctx, req, opts...)
   294  }
   295  
   296  // CreateTensorboardOperation returns a new CreateTensorboardOperation from a given name.
   297  // The name must be that of a previously created CreateTensorboardOperation, possibly from a different process.
   298  func (c *TensorboardClient) CreateTensorboardOperation(name string) *CreateTensorboardOperation {
   299  	return c.internalClient.CreateTensorboardOperation(name)
   300  }
   301  
   302  // GetTensorboard gets a Tensorboard.
   303  func (c *TensorboardClient) GetTensorboard(ctx context.Context, req *aiplatformpb.GetTensorboardRequest, opts ...gax.CallOption) (*aiplatformpb.Tensorboard, error) {
   304  	return c.internalClient.GetTensorboard(ctx, req, opts...)
   305  }
   306  
   307  // UpdateTensorboard updates a Tensorboard.
   308  func (c *TensorboardClient) UpdateTensorboard(ctx context.Context, req *aiplatformpb.UpdateTensorboardRequest, opts ...gax.CallOption) (*UpdateTensorboardOperation, error) {
   309  	return c.internalClient.UpdateTensorboard(ctx, req, opts...)
   310  }
   311  
   312  // UpdateTensorboardOperation returns a new UpdateTensorboardOperation from a given name.
   313  // The name must be that of a previously created UpdateTensorboardOperation, possibly from a different process.
   314  func (c *TensorboardClient) UpdateTensorboardOperation(name string) *UpdateTensorboardOperation {
   315  	return c.internalClient.UpdateTensorboardOperation(name)
   316  }
   317  
   318  // ListTensorboards lists Tensorboards in a Location.
   319  func (c *TensorboardClient) ListTensorboards(ctx context.Context, req *aiplatformpb.ListTensorboardsRequest, opts ...gax.CallOption) *TensorboardIterator {
   320  	return c.internalClient.ListTensorboards(ctx, req, opts...)
   321  }
   322  
   323  // DeleteTensorboard deletes a Tensorboard.
   324  func (c *TensorboardClient) DeleteTensorboard(ctx context.Context, req *aiplatformpb.DeleteTensorboardRequest, opts ...gax.CallOption) (*DeleteTensorboardOperation, error) {
   325  	return c.internalClient.DeleteTensorboard(ctx, req, opts...)
   326  }
   327  
   328  // DeleteTensorboardOperation returns a new DeleteTensorboardOperation from a given name.
   329  // The name must be that of a previously created DeleteTensorboardOperation, possibly from a different process.
   330  func (c *TensorboardClient) DeleteTensorboardOperation(name string) *DeleteTensorboardOperation {
   331  	return c.internalClient.DeleteTensorboardOperation(name)
   332  }
   333  
   334  // ReadTensorboardUsage returns a list of monthly active users for a given TensorBoard instance.
   335  func (c *TensorboardClient) ReadTensorboardUsage(ctx context.Context, req *aiplatformpb.ReadTensorboardUsageRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardUsageResponse, error) {
   336  	return c.internalClient.ReadTensorboardUsage(ctx, req, opts...)
   337  }
   338  
   339  // ReadTensorboardSize returns the storage size for a given TensorBoard instance.
   340  func (c *TensorboardClient) ReadTensorboardSize(ctx context.Context, req *aiplatformpb.ReadTensorboardSizeRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardSizeResponse, error) {
   341  	return c.internalClient.ReadTensorboardSize(ctx, req, opts...)
   342  }
   343  
   344  // CreateTensorboardExperiment creates a TensorboardExperiment.
   345  func (c *TensorboardClient) CreateTensorboardExperiment(ctx context.Context, req *aiplatformpb.CreateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   346  	return c.internalClient.CreateTensorboardExperiment(ctx, req, opts...)
   347  }
   348  
   349  // GetTensorboardExperiment gets a TensorboardExperiment.
   350  func (c *TensorboardClient) GetTensorboardExperiment(ctx context.Context, req *aiplatformpb.GetTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   351  	return c.internalClient.GetTensorboardExperiment(ctx, req, opts...)
   352  }
   353  
   354  // UpdateTensorboardExperiment updates a TensorboardExperiment.
   355  func (c *TensorboardClient) UpdateTensorboardExperiment(ctx context.Context, req *aiplatformpb.UpdateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   356  	return c.internalClient.UpdateTensorboardExperiment(ctx, req, opts...)
   357  }
   358  
   359  // ListTensorboardExperiments lists TensorboardExperiments in a Location.
   360  func (c *TensorboardClient) ListTensorboardExperiments(ctx context.Context, req *aiplatformpb.ListTensorboardExperimentsRequest, opts ...gax.CallOption) *TensorboardExperimentIterator {
   361  	return c.internalClient.ListTensorboardExperiments(ctx, req, opts...)
   362  }
   363  
   364  // DeleteTensorboardExperiment deletes a TensorboardExperiment.
   365  func (c *TensorboardClient) DeleteTensorboardExperiment(ctx context.Context, req *aiplatformpb.DeleteTensorboardExperimentRequest, opts ...gax.CallOption) (*DeleteTensorboardExperimentOperation, error) {
   366  	return c.internalClient.DeleteTensorboardExperiment(ctx, req, opts...)
   367  }
   368  
   369  // DeleteTensorboardExperimentOperation returns a new DeleteTensorboardExperimentOperation from a given name.
   370  // The name must be that of a previously created DeleteTensorboardExperimentOperation, possibly from a different process.
   371  func (c *TensorboardClient) DeleteTensorboardExperimentOperation(name string) *DeleteTensorboardExperimentOperation {
   372  	return c.internalClient.DeleteTensorboardExperimentOperation(name)
   373  }
   374  
   375  // CreateTensorboardRun creates a TensorboardRun.
   376  func (c *TensorboardClient) CreateTensorboardRun(ctx context.Context, req *aiplatformpb.CreateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
   377  	return c.internalClient.CreateTensorboardRun(ctx, req, opts...)
   378  }
   379  
   380  // BatchCreateTensorboardRuns batch create TensorboardRuns.
   381  func (c *TensorboardClient) BatchCreateTensorboardRuns(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardRunsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardRunsResponse, error) {
   382  	return c.internalClient.BatchCreateTensorboardRuns(ctx, req, opts...)
   383  }
   384  
   385  // GetTensorboardRun gets a TensorboardRun.
   386  func (c *TensorboardClient) GetTensorboardRun(ctx context.Context, req *aiplatformpb.GetTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
   387  	return c.internalClient.GetTensorboardRun(ctx, req, opts...)
   388  }
   389  
   390  // UpdateTensorboardRun updates a TensorboardRun.
   391  func (c *TensorboardClient) UpdateTensorboardRun(ctx context.Context, req *aiplatformpb.UpdateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
   392  	return c.internalClient.UpdateTensorboardRun(ctx, req, opts...)
   393  }
   394  
   395  // ListTensorboardRuns lists TensorboardRuns in a Location.
   396  func (c *TensorboardClient) ListTensorboardRuns(ctx context.Context, req *aiplatformpb.ListTensorboardRunsRequest, opts ...gax.CallOption) *TensorboardRunIterator {
   397  	return c.internalClient.ListTensorboardRuns(ctx, req, opts...)
   398  }
   399  
   400  // DeleteTensorboardRun deletes a TensorboardRun.
   401  func (c *TensorboardClient) DeleteTensorboardRun(ctx context.Context, req *aiplatformpb.DeleteTensorboardRunRequest, opts ...gax.CallOption) (*DeleteTensorboardRunOperation, error) {
   402  	return c.internalClient.DeleteTensorboardRun(ctx, req, opts...)
   403  }
   404  
   405  // DeleteTensorboardRunOperation returns a new DeleteTensorboardRunOperation from a given name.
   406  // The name must be that of a previously created DeleteTensorboardRunOperation, possibly from a different process.
   407  func (c *TensorboardClient) DeleteTensorboardRunOperation(name string) *DeleteTensorboardRunOperation {
   408  	return c.internalClient.DeleteTensorboardRunOperation(name)
   409  }
   410  
   411  // BatchCreateTensorboardTimeSeries batch create TensorboardTimeSeries that belong to a TensorboardExperiment.
   412  func (c *TensorboardClient) BatchCreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardTimeSeriesResponse, error) {
   413  	return c.internalClient.BatchCreateTensorboardTimeSeries(ctx, req, opts...)
   414  }
   415  
   416  // CreateTensorboardTimeSeries creates a TensorboardTimeSeries.
   417  func (c *TensorboardClient) CreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.CreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
   418  	return c.internalClient.CreateTensorboardTimeSeries(ctx, req, opts...)
   419  }
   420  
   421  // GetTensorboardTimeSeries gets a TensorboardTimeSeries.
   422  func (c *TensorboardClient) GetTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.GetTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
   423  	return c.internalClient.GetTensorboardTimeSeries(ctx, req, opts...)
   424  }
   425  
   426  // UpdateTensorboardTimeSeries updates a TensorboardTimeSeries.
   427  func (c *TensorboardClient) UpdateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.UpdateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
   428  	return c.internalClient.UpdateTensorboardTimeSeries(ctx, req, opts...)
   429  }
   430  
   431  // ListTensorboardTimeSeries lists TensorboardTimeSeries in a Location.
   432  func (c *TensorboardClient) ListTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.ListTensorboardTimeSeriesRequest, opts ...gax.CallOption) *TensorboardTimeSeriesIterator {
   433  	return c.internalClient.ListTensorboardTimeSeries(ctx, req, opts...)
   434  }
   435  
   436  // DeleteTensorboardTimeSeries deletes a TensorboardTimeSeries.
   437  func (c *TensorboardClient) DeleteTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.DeleteTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*DeleteTensorboardTimeSeriesOperation, error) {
   438  	return c.internalClient.DeleteTensorboardTimeSeries(ctx, req, opts...)
   439  }
   440  
   441  // DeleteTensorboardTimeSeriesOperation returns a new DeleteTensorboardTimeSeriesOperation from a given name.
   442  // The name must be that of a previously created DeleteTensorboardTimeSeriesOperation, possibly from a different process.
   443  func (c *TensorboardClient) DeleteTensorboardTimeSeriesOperation(name string) *DeleteTensorboardTimeSeriesOperation {
   444  	return c.internalClient.DeleteTensorboardTimeSeriesOperation(name)
   445  }
   446  
   447  // BatchReadTensorboardTimeSeriesData reads multiple TensorboardTimeSeries’ data. The data point number limit is
   448  // 1000 for scalars, 100 for tensors and blob references. If the number of
   449  // data points stored is less than the limit, all data is returned.
   450  // Otherwise, the number limit of data points is randomly selected from
   451  // this time series and returned.
   452  func (c *TensorboardClient) BatchReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.BatchReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse, error) {
   453  	return c.internalClient.BatchReadTensorboardTimeSeriesData(ctx, req, opts...)
   454  }
   455  
   456  // ReadTensorboardTimeSeriesData reads a TensorboardTimeSeries’ data. By default, if the number of data
   457  // points stored is less than 1000, all data is returned. Otherwise, 1000
   458  // data points is randomly selected from this time series and returned.
   459  // This value can be changed by changing max_data_points, which can’t be
   460  // greater than 10k.
   461  func (c *TensorboardClient) ReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardTimeSeriesDataResponse, error) {
   462  	return c.internalClient.ReadTensorboardTimeSeriesData(ctx, req, opts...)
   463  }
   464  
   465  // ReadTensorboardBlobData gets bytes of TensorboardBlobs.
   466  // This is to allow reading blob data stored in consumer project’s Cloud
   467  // Storage bucket without users having to obtain Cloud Storage access
   468  // permission.
   469  func (c *TensorboardClient) ReadTensorboardBlobData(ctx context.Context, req *aiplatformpb.ReadTensorboardBlobDataRequest, opts ...gax.CallOption) (aiplatformpb.TensorboardService_ReadTensorboardBlobDataClient, error) {
   470  	return c.internalClient.ReadTensorboardBlobData(ctx, req, opts...)
   471  }
   472  
   473  // WriteTensorboardExperimentData write time series data points of multiple TensorboardTimeSeries in multiple
   474  // TensorboardRun’s. If any data fail to be ingested, an error is returned.
   475  func (c *TensorboardClient) WriteTensorboardExperimentData(ctx context.Context, req *aiplatformpb.WriteTensorboardExperimentDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardExperimentDataResponse, error) {
   476  	return c.internalClient.WriteTensorboardExperimentData(ctx, req, opts...)
   477  }
   478  
   479  // WriteTensorboardRunData write time series data points into multiple TensorboardTimeSeries under
   480  // a TensorboardRun. If any data fail to be ingested, an error is returned.
   481  func (c *TensorboardClient) WriteTensorboardRunData(ctx context.Context, req *aiplatformpb.WriteTensorboardRunDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardRunDataResponse, error) {
   482  	return c.internalClient.WriteTensorboardRunData(ctx, req, opts...)
   483  }
   484  
   485  // ExportTensorboardTimeSeriesData exports a TensorboardTimeSeries’ data. Data is returned in paginated
   486  // responses.
   487  func (c *TensorboardClient) ExportTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ExportTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) *TimeSeriesDataPointIterator {
   488  	return c.internalClient.ExportTensorboardTimeSeriesData(ctx, req, opts...)
   489  }
   490  
   491  // GetLocation gets information about a location.
   492  func (c *TensorboardClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   493  	return c.internalClient.GetLocation(ctx, req, opts...)
   494  }
   495  
   496  // ListLocations lists information about the supported locations for this service.
   497  func (c *TensorboardClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   498  	return c.internalClient.ListLocations(ctx, req, opts...)
   499  }
   500  
   501  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   502  // if the resource exists and does not have a policy set.
   503  func (c *TensorboardClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   504  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   505  }
   506  
   507  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   508  // any existing policy.
   509  //
   510  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   511  // errors.
   512  func (c *TensorboardClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   513  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   514  }
   515  
   516  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   517  // resource does not exist, this will return an empty set of
   518  // permissions, not a NOT_FOUND error.
   519  //
   520  // Note: This operation is designed to be used for building
   521  // permission-aware UIs and command-line tools, not for authorization
   522  // checking. This operation may “fail open” without warning.
   523  func (c *TensorboardClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   524  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   525  }
   526  
   527  // CancelOperation is a utility method from google.longrunning.Operations.
   528  func (c *TensorboardClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   529  	return c.internalClient.CancelOperation(ctx, req, opts...)
   530  }
   531  
   532  // DeleteOperation is a utility method from google.longrunning.Operations.
   533  func (c *TensorboardClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   534  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   535  }
   536  
   537  // GetOperation is a utility method from google.longrunning.Operations.
   538  func (c *TensorboardClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   539  	return c.internalClient.GetOperation(ctx, req, opts...)
   540  }
   541  
   542  // ListOperations is a utility method from google.longrunning.Operations.
   543  func (c *TensorboardClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   544  	return c.internalClient.ListOperations(ctx, req, opts...)
   545  }
   546  
   547  // WaitOperation is a utility method from google.longrunning.Operations.
   548  func (c *TensorboardClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   549  	return c.internalClient.WaitOperation(ctx, req, opts...)
   550  }
   551  
   552  // tensorboardGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   553  //
   554  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   555  type tensorboardGRPCClient struct {
   556  	// Connection pool of gRPC connections to the service.
   557  	connPool gtransport.ConnPool
   558  
   559  	// Points back to the CallOptions field of the containing TensorboardClient
   560  	CallOptions **TensorboardCallOptions
   561  
   562  	// The gRPC API client.
   563  	tensorboardClient aiplatformpb.TensorboardServiceClient
   564  
   565  	// LROClient is used internally to handle long-running operations.
   566  	// It is exposed so that its CallOptions can be modified if required.
   567  	// Users should not Close this client.
   568  	LROClient **lroauto.OperationsClient
   569  
   570  	operationsClient longrunningpb.OperationsClient
   571  
   572  	iamPolicyClient iampb.IAMPolicyClient
   573  
   574  	locationsClient locationpb.LocationsClient
   575  
   576  	// The x-goog-* metadata to be sent with each request.
   577  	xGoogHeaders []string
   578  
   579  	logger *slog.Logger
   580  }
   581  
   582  // NewTensorboardClient creates a new tensorboard service client based on gRPC.
   583  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   584  //
   585  // TensorboardService
   586  func NewTensorboardClient(ctx context.Context, opts ...option.ClientOption) (*TensorboardClient, error) {
   587  	clientOpts := defaultTensorboardGRPCClientOptions()
   588  	if newTensorboardClientHook != nil {
   589  		hookOpts, err := newTensorboardClientHook(ctx, clientHookParams{})
   590  		if err != nil {
   591  			return nil, err
   592  		}
   593  		clientOpts = append(clientOpts, hookOpts...)
   594  	}
   595  
   596  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   597  	if err != nil {
   598  		return nil, err
   599  	}
   600  	client := TensorboardClient{CallOptions: defaultTensorboardCallOptions()}
   601  
   602  	c := &tensorboardGRPCClient{
   603  		connPool:          connPool,
   604  		tensorboardClient: aiplatformpb.NewTensorboardServiceClient(connPool),
   605  		CallOptions:       &client.CallOptions,
   606  		logger:            internaloption.GetLogger(opts),
   607  		operationsClient:  longrunningpb.NewOperationsClient(connPool),
   608  		iamPolicyClient:   iampb.NewIAMPolicyClient(connPool),
   609  		locationsClient:   locationpb.NewLocationsClient(connPool),
   610  	}
   611  	c.setGoogleClientInfo()
   612  
   613  	client.internalClient = c
   614  
   615  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   616  	if err != nil {
   617  		// This error "should not happen", since we are just reusing old connection pool
   618  		// and never actually need to dial.
   619  		// If this does happen, we could leak connp. However, we cannot close conn:
   620  		// If the user invoked the constructor with option.WithGRPCConn,
   621  		// we would close a connection that's still in use.
   622  		// TODO: investigate error conditions.
   623  		return nil, err
   624  	}
   625  	c.LROClient = &client.LROClient
   626  	return &client, nil
   627  }
   628  
   629  // Connection returns a connection to the API service.
   630  //
   631  // Deprecated: Connections are now pooled so this method does not always
   632  // return the same resource.
   633  func (c *tensorboardGRPCClient) Connection() *grpc.ClientConn {
   634  	return c.connPool.Conn()
   635  }
   636  
   637  // setGoogleClientInfo sets the name and version of the application in
   638  // the `x-goog-api-client` header passed on each request. Intended for
   639  // use by Google-written clients.
   640  func (c *tensorboardGRPCClient) setGoogleClientInfo(keyval ...string) {
   641  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   642  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   643  	c.xGoogHeaders = []string{
   644  		"x-goog-api-client", gax.XGoogHeader(kv...),
   645  	}
   646  }
   647  
   648  // Close closes the connection to the API service. The user should invoke this when
   649  // the client is no longer required.
   650  func (c *tensorboardGRPCClient) Close() error {
   651  	return c.connPool.Close()
   652  }
   653  
   654  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   655  type tensorboardRESTClient struct {
   656  	// The http endpoint to connect to.
   657  	endpoint string
   658  
   659  	// The http client.
   660  	httpClient *http.Client
   661  
   662  	// LROClient is used internally to handle long-running operations.
   663  	// It is exposed so that its CallOptions can be modified if required.
   664  	// Users should not Close this client.
   665  	LROClient **lroauto.OperationsClient
   666  
   667  	// The x-goog-* headers to be sent with each request.
   668  	xGoogHeaders []string
   669  
   670  	// Points back to the CallOptions field of the containing TensorboardClient
   671  	CallOptions **TensorboardCallOptions
   672  
   673  	logger *slog.Logger
   674  }
   675  
   676  // NewTensorboardRESTClient creates a new tensorboard service rest client.
   677  //
   678  // TensorboardService
   679  func NewTensorboardRESTClient(ctx context.Context, opts ...option.ClientOption) (*TensorboardClient, error) {
   680  	clientOpts := append(defaultTensorboardRESTClientOptions(), opts...)
   681  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   682  	if err != nil {
   683  		return nil, err
   684  	}
   685  
   686  	callOpts := defaultTensorboardRESTCallOptions()
   687  	c := &tensorboardRESTClient{
   688  		endpoint:    endpoint,
   689  		httpClient:  httpClient,
   690  		CallOptions: &callOpts,
   691  		logger:      internaloption.GetLogger(opts),
   692  	}
   693  	c.setGoogleClientInfo()
   694  
   695  	lroOpts := []option.ClientOption{
   696  		option.WithHTTPClient(httpClient),
   697  		option.WithEndpoint(endpoint),
   698  	}
   699  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   700  	if err != nil {
   701  		return nil, err
   702  	}
   703  	c.LROClient = &opClient
   704  
   705  	return &TensorboardClient{internalClient: c, CallOptions: callOpts}, nil
   706  }
   707  
   708  func defaultTensorboardRESTClientOptions() []option.ClientOption {
   709  	return []option.ClientOption{
   710  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   711  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   712  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   713  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   714  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   715  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   716  		internaloption.EnableNewAuthLibrary(),
   717  	}
   718  }
   719  
   720  // setGoogleClientInfo sets the name and version of the application in
   721  // the `x-goog-api-client` header passed on each request. Intended for
   722  // use by Google-written clients.
   723  func (c *tensorboardRESTClient) setGoogleClientInfo(keyval ...string) {
   724  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   725  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   726  	c.xGoogHeaders = []string{
   727  		"x-goog-api-client", gax.XGoogHeader(kv...),
   728  	}
   729  }
   730  
   731  // Close closes the connection to the API service. The user should invoke this when
   732  // the client is no longer required.
   733  func (c *tensorboardRESTClient) Close() error {
   734  	// Replace httpClient with nil to force cleanup.
   735  	c.httpClient = nil
   736  	return nil
   737  }
   738  
   739  // Connection returns a connection to the API service.
   740  //
   741  // Deprecated: This method always returns nil.
   742  func (c *tensorboardRESTClient) Connection() *grpc.ClientConn {
   743  	return nil
   744  }
   745  func (c *tensorboardGRPCClient) CreateTensorboard(ctx context.Context, req *aiplatformpb.CreateTensorboardRequest, opts ...gax.CallOption) (*CreateTensorboardOperation, error) {
   746  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   747  
   748  	hds = append(c.xGoogHeaders, hds...)
   749  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   750  	opts = append((*c.CallOptions).CreateTensorboard[0:len((*c.CallOptions).CreateTensorboard):len((*c.CallOptions).CreateTensorboard)], opts...)
   751  	var resp *longrunningpb.Operation
   752  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   753  		var err error
   754  		resp, err = executeRPC(ctx, c.tensorboardClient.CreateTensorboard, req, settings.GRPC, c.logger, "CreateTensorboard")
   755  		return err
   756  	}, opts...)
   757  	if err != nil {
   758  		return nil, err
   759  	}
   760  	return &CreateTensorboardOperation{
   761  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   762  	}, nil
   763  }
   764  
   765  func (c *tensorboardGRPCClient) GetTensorboard(ctx context.Context, req *aiplatformpb.GetTensorboardRequest, opts ...gax.CallOption) (*aiplatformpb.Tensorboard, error) {
   766  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   767  
   768  	hds = append(c.xGoogHeaders, hds...)
   769  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   770  	opts = append((*c.CallOptions).GetTensorboard[0:len((*c.CallOptions).GetTensorboard):len((*c.CallOptions).GetTensorboard)], opts...)
   771  	var resp *aiplatformpb.Tensorboard
   772  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   773  		var err error
   774  		resp, err = executeRPC(ctx, c.tensorboardClient.GetTensorboard, req, settings.GRPC, c.logger, "GetTensorboard")
   775  		return err
   776  	}, opts...)
   777  	if err != nil {
   778  		return nil, err
   779  	}
   780  	return resp, nil
   781  }
   782  
   783  func (c *tensorboardGRPCClient) UpdateTensorboard(ctx context.Context, req *aiplatformpb.UpdateTensorboardRequest, opts ...gax.CallOption) (*UpdateTensorboardOperation, error) {
   784  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard.name", url.QueryEscape(req.GetTensorboard().GetName()))}
   785  
   786  	hds = append(c.xGoogHeaders, hds...)
   787  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   788  	opts = append((*c.CallOptions).UpdateTensorboard[0:len((*c.CallOptions).UpdateTensorboard):len((*c.CallOptions).UpdateTensorboard)], opts...)
   789  	var resp *longrunningpb.Operation
   790  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   791  		var err error
   792  		resp, err = executeRPC(ctx, c.tensorboardClient.UpdateTensorboard, req, settings.GRPC, c.logger, "UpdateTensorboard")
   793  		return err
   794  	}, opts...)
   795  	if err != nil {
   796  		return nil, err
   797  	}
   798  	return &UpdateTensorboardOperation{
   799  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   800  	}, nil
   801  }
   802  
   803  func (c *tensorboardGRPCClient) ListTensorboards(ctx context.Context, req *aiplatformpb.ListTensorboardsRequest, opts ...gax.CallOption) *TensorboardIterator {
   804  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   805  
   806  	hds = append(c.xGoogHeaders, hds...)
   807  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   808  	opts = append((*c.CallOptions).ListTensorboards[0:len((*c.CallOptions).ListTensorboards):len((*c.CallOptions).ListTensorboards)], opts...)
   809  	it := &TensorboardIterator{}
   810  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardsRequest)
   811  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Tensorboard, string, error) {
   812  		resp := &aiplatformpb.ListTensorboardsResponse{}
   813  		if pageToken != "" {
   814  			req.PageToken = pageToken
   815  		}
   816  		if pageSize > math.MaxInt32 {
   817  			req.PageSize = math.MaxInt32
   818  		} else if pageSize != 0 {
   819  			req.PageSize = int32(pageSize)
   820  		}
   821  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   822  			var err error
   823  			resp, err = executeRPC(ctx, c.tensorboardClient.ListTensorboards, req, settings.GRPC, c.logger, "ListTensorboards")
   824  			return err
   825  		}, opts...)
   826  		if err != nil {
   827  			return nil, "", err
   828  		}
   829  
   830  		it.Response = resp
   831  		return resp.GetTensorboards(), resp.GetNextPageToken(), nil
   832  	}
   833  	fetch := func(pageSize int, pageToken string) (string, error) {
   834  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   835  		if err != nil {
   836  			return "", err
   837  		}
   838  		it.items = append(it.items, items...)
   839  		return nextPageToken, nil
   840  	}
   841  
   842  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   843  	it.pageInfo.MaxSize = int(req.GetPageSize())
   844  	it.pageInfo.Token = req.GetPageToken()
   845  
   846  	return it
   847  }
   848  
   849  func (c *tensorboardGRPCClient) DeleteTensorboard(ctx context.Context, req *aiplatformpb.DeleteTensorboardRequest, opts ...gax.CallOption) (*DeleteTensorboardOperation, error) {
   850  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   851  
   852  	hds = append(c.xGoogHeaders, hds...)
   853  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   854  	opts = append((*c.CallOptions).DeleteTensorboard[0:len((*c.CallOptions).DeleteTensorboard):len((*c.CallOptions).DeleteTensorboard)], opts...)
   855  	var resp *longrunningpb.Operation
   856  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   857  		var err error
   858  		resp, err = executeRPC(ctx, c.tensorboardClient.DeleteTensorboard, req, settings.GRPC, c.logger, "DeleteTensorboard")
   859  		return err
   860  	}, opts...)
   861  	if err != nil {
   862  		return nil, err
   863  	}
   864  	return &DeleteTensorboardOperation{
   865  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   866  	}, nil
   867  }
   868  
   869  func (c *tensorboardGRPCClient) ReadTensorboardUsage(ctx context.Context, req *aiplatformpb.ReadTensorboardUsageRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardUsageResponse, error) {
   870  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
   871  
   872  	hds = append(c.xGoogHeaders, hds...)
   873  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   874  	opts = append((*c.CallOptions).ReadTensorboardUsage[0:len((*c.CallOptions).ReadTensorboardUsage):len((*c.CallOptions).ReadTensorboardUsage)], opts...)
   875  	var resp *aiplatformpb.ReadTensorboardUsageResponse
   876  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   877  		var err error
   878  		resp, err = executeRPC(ctx, c.tensorboardClient.ReadTensorboardUsage, req, settings.GRPC, c.logger, "ReadTensorboardUsage")
   879  		return err
   880  	}, opts...)
   881  	if err != nil {
   882  		return nil, err
   883  	}
   884  	return resp, nil
   885  }
   886  
   887  func (c *tensorboardGRPCClient) ReadTensorboardSize(ctx context.Context, req *aiplatformpb.ReadTensorboardSizeRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardSizeResponse, error) {
   888  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
   889  
   890  	hds = append(c.xGoogHeaders, hds...)
   891  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   892  	opts = append((*c.CallOptions).ReadTensorboardSize[0:len((*c.CallOptions).ReadTensorboardSize):len((*c.CallOptions).ReadTensorboardSize)], opts...)
   893  	var resp *aiplatformpb.ReadTensorboardSizeResponse
   894  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   895  		var err error
   896  		resp, err = executeRPC(ctx, c.tensorboardClient.ReadTensorboardSize, req, settings.GRPC, c.logger, "ReadTensorboardSize")
   897  		return err
   898  	}, opts...)
   899  	if err != nil {
   900  		return nil, err
   901  	}
   902  	return resp, nil
   903  }
   904  
   905  func (c *tensorboardGRPCClient) CreateTensorboardExperiment(ctx context.Context, req *aiplatformpb.CreateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   906  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   907  
   908  	hds = append(c.xGoogHeaders, hds...)
   909  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   910  	opts = append((*c.CallOptions).CreateTensorboardExperiment[0:len((*c.CallOptions).CreateTensorboardExperiment):len((*c.CallOptions).CreateTensorboardExperiment)], opts...)
   911  	var resp *aiplatformpb.TensorboardExperiment
   912  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   913  		var err error
   914  		resp, err = executeRPC(ctx, c.tensorboardClient.CreateTensorboardExperiment, req, settings.GRPC, c.logger, "CreateTensorboardExperiment")
   915  		return err
   916  	}, opts...)
   917  	if err != nil {
   918  		return nil, err
   919  	}
   920  	return resp, nil
   921  }
   922  
   923  func (c *tensorboardGRPCClient) GetTensorboardExperiment(ctx context.Context, req *aiplatformpb.GetTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   924  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   925  
   926  	hds = append(c.xGoogHeaders, hds...)
   927  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   928  	opts = append((*c.CallOptions).GetTensorboardExperiment[0:len((*c.CallOptions).GetTensorboardExperiment):len((*c.CallOptions).GetTensorboardExperiment)], opts...)
   929  	var resp *aiplatformpb.TensorboardExperiment
   930  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   931  		var err error
   932  		resp, err = executeRPC(ctx, c.tensorboardClient.GetTensorboardExperiment, req, settings.GRPC, c.logger, "GetTensorboardExperiment")
   933  		return err
   934  	}, opts...)
   935  	if err != nil {
   936  		return nil, err
   937  	}
   938  	return resp, nil
   939  }
   940  
   941  func (c *tensorboardGRPCClient) UpdateTensorboardExperiment(ctx context.Context, req *aiplatformpb.UpdateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
   942  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_experiment.name", url.QueryEscape(req.GetTensorboardExperiment().GetName()))}
   943  
   944  	hds = append(c.xGoogHeaders, hds...)
   945  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   946  	opts = append((*c.CallOptions).UpdateTensorboardExperiment[0:len((*c.CallOptions).UpdateTensorboardExperiment):len((*c.CallOptions).UpdateTensorboardExperiment)], opts...)
   947  	var resp *aiplatformpb.TensorboardExperiment
   948  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   949  		var err error
   950  		resp, err = executeRPC(ctx, c.tensorboardClient.UpdateTensorboardExperiment, req, settings.GRPC, c.logger, "UpdateTensorboardExperiment")
   951  		return err
   952  	}, opts...)
   953  	if err != nil {
   954  		return nil, err
   955  	}
   956  	return resp, nil
   957  }
   958  
   959  func (c *tensorboardGRPCClient) ListTensorboardExperiments(ctx context.Context, req *aiplatformpb.ListTensorboardExperimentsRequest, opts ...gax.CallOption) *TensorboardExperimentIterator {
   960  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   961  
   962  	hds = append(c.xGoogHeaders, hds...)
   963  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   964  	opts = append((*c.CallOptions).ListTensorboardExperiments[0:len((*c.CallOptions).ListTensorboardExperiments):len((*c.CallOptions).ListTensorboardExperiments)], opts...)
   965  	it := &TensorboardExperimentIterator{}
   966  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardExperimentsRequest)
   967  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardExperiment, string, error) {
   968  		resp := &aiplatformpb.ListTensorboardExperimentsResponse{}
   969  		if pageToken != "" {
   970  			req.PageToken = pageToken
   971  		}
   972  		if pageSize > math.MaxInt32 {
   973  			req.PageSize = math.MaxInt32
   974  		} else if pageSize != 0 {
   975  			req.PageSize = int32(pageSize)
   976  		}
   977  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   978  			var err error
   979  			resp, err = executeRPC(ctx, c.tensorboardClient.ListTensorboardExperiments, req, settings.GRPC, c.logger, "ListTensorboardExperiments")
   980  			return err
   981  		}, opts...)
   982  		if err != nil {
   983  			return nil, "", err
   984  		}
   985  
   986  		it.Response = resp
   987  		return resp.GetTensorboardExperiments(), resp.GetNextPageToken(), nil
   988  	}
   989  	fetch := func(pageSize int, pageToken string) (string, error) {
   990  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   991  		if err != nil {
   992  			return "", err
   993  		}
   994  		it.items = append(it.items, items...)
   995  		return nextPageToken, nil
   996  	}
   997  
   998  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   999  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1000  	it.pageInfo.Token = req.GetPageToken()
  1001  
  1002  	return it
  1003  }
  1004  
  1005  func (c *tensorboardGRPCClient) DeleteTensorboardExperiment(ctx context.Context, req *aiplatformpb.DeleteTensorboardExperimentRequest, opts ...gax.CallOption) (*DeleteTensorboardExperimentOperation, error) {
  1006  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1007  
  1008  	hds = append(c.xGoogHeaders, hds...)
  1009  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1010  	opts = append((*c.CallOptions).DeleteTensorboardExperiment[0:len((*c.CallOptions).DeleteTensorboardExperiment):len((*c.CallOptions).DeleteTensorboardExperiment)], opts...)
  1011  	var resp *longrunningpb.Operation
  1012  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1013  		var err error
  1014  		resp, err = executeRPC(ctx, c.tensorboardClient.DeleteTensorboardExperiment, req, settings.GRPC, c.logger, "DeleteTensorboardExperiment")
  1015  		return err
  1016  	}, opts...)
  1017  	if err != nil {
  1018  		return nil, err
  1019  	}
  1020  	return &DeleteTensorboardExperimentOperation{
  1021  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1022  	}, nil
  1023  }
  1024  
  1025  func (c *tensorboardGRPCClient) CreateTensorboardRun(ctx context.Context, req *aiplatformpb.CreateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  1026  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1027  
  1028  	hds = append(c.xGoogHeaders, hds...)
  1029  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1030  	opts = append((*c.CallOptions).CreateTensorboardRun[0:len((*c.CallOptions).CreateTensorboardRun):len((*c.CallOptions).CreateTensorboardRun)], opts...)
  1031  	var resp *aiplatformpb.TensorboardRun
  1032  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1033  		var err error
  1034  		resp, err = executeRPC(ctx, c.tensorboardClient.CreateTensorboardRun, req, settings.GRPC, c.logger, "CreateTensorboardRun")
  1035  		return err
  1036  	}, opts...)
  1037  	if err != nil {
  1038  		return nil, err
  1039  	}
  1040  	return resp, nil
  1041  }
  1042  
  1043  func (c *tensorboardGRPCClient) BatchCreateTensorboardRuns(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardRunsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardRunsResponse, error) {
  1044  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1045  
  1046  	hds = append(c.xGoogHeaders, hds...)
  1047  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1048  	opts = append((*c.CallOptions).BatchCreateTensorboardRuns[0:len((*c.CallOptions).BatchCreateTensorboardRuns):len((*c.CallOptions).BatchCreateTensorboardRuns)], opts...)
  1049  	var resp *aiplatformpb.BatchCreateTensorboardRunsResponse
  1050  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1051  		var err error
  1052  		resp, err = executeRPC(ctx, c.tensorboardClient.BatchCreateTensorboardRuns, req, settings.GRPC, c.logger, "BatchCreateTensorboardRuns")
  1053  		return err
  1054  	}, opts...)
  1055  	if err != nil {
  1056  		return nil, err
  1057  	}
  1058  	return resp, nil
  1059  }
  1060  
  1061  func (c *tensorboardGRPCClient) GetTensorboardRun(ctx context.Context, req *aiplatformpb.GetTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  1062  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1063  
  1064  	hds = append(c.xGoogHeaders, hds...)
  1065  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1066  	opts = append((*c.CallOptions).GetTensorboardRun[0:len((*c.CallOptions).GetTensorboardRun):len((*c.CallOptions).GetTensorboardRun)], opts...)
  1067  	var resp *aiplatformpb.TensorboardRun
  1068  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1069  		var err error
  1070  		resp, err = executeRPC(ctx, c.tensorboardClient.GetTensorboardRun, req, settings.GRPC, c.logger, "GetTensorboardRun")
  1071  		return err
  1072  	}, opts...)
  1073  	if err != nil {
  1074  		return nil, err
  1075  	}
  1076  	return resp, nil
  1077  }
  1078  
  1079  func (c *tensorboardGRPCClient) UpdateTensorboardRun(ctx context.Context, req *aiplatformpb.UpdateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  1080  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_run.name", url.QueryEscape(req.GetTensorboardRun().GetName()))}
  1081  
  1082  	hds = append(c.xGoogHeaders, hds...)
  1083  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1084  	opts = append((*c.CallOptions).UpdateTensorboardRun[0:len((*c.CallOptions).UpdateTensorboardRun):len((*c.CallOptions).UpdateTensorboardRun)], opts...)
  1085  	var resp *aiplatformpb.TensorboardRun
  1086  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1087  		var err error
  1088  		resp, err = executeRPC(ctx, c.tensorboardClient.UpdateTensorboardRun, req, settings.GRPC, c.logger, "UpdateTensorboardRun")
  1089  		return err
  1090  	}, opts...)
  1091  	if err != nil {
  1092  		return nil, err
  1093  	}
  1094  	return resp, nil
  1095  }
  1096  
  1097  func (c *tensorboardGRPCClient) ListTensorboardRuns(ctx context.Context, req *aiplatformpb.ListTensorboardRunsRequest, opts ...gax.CallOption) *TensorboardRunIterator {
  1098  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1099  
  1100  	hds = append(c.xGoogHeaders, hds...)
  1101  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1102  	opts = append((*c.CallOptions).ListTensorboardRuns[0:len((*c.CallOptions).ListTensorboardRuns):len((*c.CallOptions).ListTensorboardRuns)], opts...)
  1103  	it := &TensorboardRunIterator{}
  1104  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardRunsRequest)
  1105  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardRun, string, error) {
  1106  		resp := &aiplatformpb.ListTensorboardRunsResponse{}
  1107  		if pageToken != "" {
  1108  			req.PageToken = pageToken
  1109  		}
  1110  		if pageSize > math.MaxInt32 {
  1111  			req.PageSize = math.MaxInt32
  1112  		} else if pageSize != 0 {
  1113  			req.PageSize = int32(pageSize)
  1114  		}
  1115  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1116  			var err error
  1117  			resp, err = executeRPC(ctx, c.tensorboardClient.ListTensorboardRuns, req, settings.GRPC, c.logger, "ListTensorboardRuns")
  1118  			return err
  1119  		}, opts...)
  1120  		if err != nil {
  1121  			return nil, "", err
  1122  		}
  1123  
  1124  		it.Response = resp
  1125  		return resp.GetTensorboardRuns(), resp.GetNextPageToken(), nil
  1126  	}
  1127  	fetch := func(pageSize int, pageToken string) (string, error) {
  1128  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1129  		if err != nil {
  1130  			return "", err
  1131  		}
  1132  		it.items = append(it.items, items...)
  1133  		return nextPageToken, nil
  1134  	}
  1135  
  1136  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1137  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1138  	it.pageInfo.Token = req.GetPageToken()
  1139  
  1140  	return it
  1141  }
  1142  
  1143  func (c *tensorboardGRPCClient) DeleteTensorboardRun(ctx context.Context, req *aiplatformpb.DeleteTensorboardRunRequest, opts ...gax.CallOption) (*DeleteTensorboardRunOperation, error) {
  1144  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1145  
  1146  	hds = append(c.xGoogHeaders, hds...)
  1147  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1148  	opts = append((*c.CallOptions).DeleteTensorboardRun[0:len((*c.CallOptions).DeleteTensorboardRun):len((*c.CallOptions).DeleteTensorboardRun)], opts...)
  1149  	var resp *longrunningpb.Operation
  1150  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1151  		var err error
  1152  		resp, err = executeRPC(ctx, c.tensorboardClient.DeleteTensorboardRun, req, settings.GRPC, c.logger, "DeleteTensorboardRun")
  1153  		return err
  1154  	}, opts...)
  1155  	if err != nil {
  1156  		return nil, err
  1157  	}
  1158  	return &DeleteTensorboardRunOperation{
  1159  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1160  	}, nil
  1161  }
  1162  
  1163  func (c *tensorboardGRPCClient) BatchCreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardTimeSeriesResponse, error) {
  1164  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1165  
  1166  	hds = append(c.xGoogHeaders, hds...)
  1167  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1168  	opts = append((*c.CallOptions).BatchCreateTensorboardTimeSeries[0:len((*c.CallOptions).BatchCreateTensorboardTimeSeries):len((*c.CallOptions).BatchCreateTensorboardTimeSeries)], opts...)
  1169  	var resp *aiplatformpb.BatchCreateTensorboardTimeSeriesResponse
  1170  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1171  		var err error
  1172  		resp, err = executeRPC(ctx, c.tensorboardClient.BatchCreateTensorboardTimeSeries, req, settings.GRPC, c.logger, "BatchCreateTensorboardTimeSeries")
  1173  		return err
  1174  	}, opts...)
  1175  	if err != nil {
  1176  		return nil, err
  1177  	}
  1178  	return resp, nil
  1179  }
  1180  
  1181  func (c *tensorboardGRPCClient) CreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.CreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  1182  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1183  
  1184  	hds = append(c.xGoogHeaders, hds...)
  1185  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1186  	opts = append((*c.CallOptions).CreateTensorboardTimeSeries[0:len((*c.CallOptions).CreateTensorboardTimeSeries):len((*c.CallOptions).CreateTensorboardTimeSeries)], opts...)
  1187  	var resp *aiplatformpb.TensorboardTimeSeries
  1188  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1189  		var err error
  1190  		resp, err = executeRPC(ctx, c.tensorboardClient.CreateTensorboardTimeSeries, req, settings.GRPC, c.logger, "CreateTensorboardTimeSeries")
  1191  		return err
  1192  	}, opts...)
  1193  	if err != nil {
  1194  		return nil, err
  1195  	}
  1196  	return resp, nil
  1197  }
  1198  
  1199  func (c *tensorboardGRPCClient) GetTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.GetTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  1200  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1201  
  1202  	hds = append(c.xGoogHeaders, hds...)
  1203  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1204  	opts = append((*c.CallOptions).GetTensorboardTimeSeries[0:len((*c.CallOptions).GetTensorboardTimeSeries):len((*c.CallOptions).GetTensorboardTimeSeries)], opts...)
  1205  	var resp *aiplatformpb.TensorboardTimeSeries
  1206  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1207  		var err error
  1208  		resp, err = executeRPC(ctx, c.tensorboardClient.GetTensorboardTimeSeries, req, settings.GRPC, c.logger, "GetTensorboardTimeSeries")
  1209  		return err
  1210  	}, opts...)
  1211  	if err != nil {
  1212  		return nil, err
  1213  	}
  1214  	return resp, nil
  1215  }
  1216  
  1217  func (c *tensorboardGRPCClient) UpdateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.UpdateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  1218  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_time_series.name", url.QueryEscape(req.GetTensorboardTimeSeries().GetName()))}
  1219  
  1220  	hds = append(c.xGoogHeaders, hds...)
  1221  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1222  	opts = append((*c.CallOptions).UpdateTensorboardTimeSeries[0:len((*c.CallOptions).UpdateTensorboardTimeSeries):len((*c.CallOptions).UpdateTensorboardTimeSeries)], opts...)
  1223  	var resp *aiplatformpb.TensorboardTimeSeries
  1224  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1225  		var err error
  1226  		resp, err = executeRPC(ctx, c.tensorboardClient.UpdateTensorboardTimeSeries, req, settings.GRPC, c.logger, "UpdateTensorboardTimeSeries")
  1227  		return err
  1228  	}, opts...)
  1229  	if err != nil {
  1230  		return nil, err
  1231  	}
  1232  	return resp, nil
  1233  }
  1234  
  1235  func (c *tensorboardGRPCClient) ListTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.ListTensorboardTimeSeriesRequest, opts ...gax.CallOption) *TensorboardTimeSeriesIterator {
  1236  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1237  
  1238  	hds = append(c.xGoogHeaders, hds...)
  1239  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1240  	opts = append((*c.CallOptions).ListTensorboardTimeSeries[0:len((*c.CallOptions).ListTensorboardTimeSeries):len((*c.CallOptions).ListTensorboardTimeSeries)], opts...)
  1241  	it := &TensorboardTimeSeriesIterator{}
  1242  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardTimeSeriesRequest)
  1243  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardTimeSeries, string, error) {
  1244  		resp := &aiplatformpb.ListTensorboardTimeSeriesResponse{}
  1245  		if pageToken != "" {
  1246  			req.PageToken = pageToken
  1247  		}
  1248  		if pageSize > math.MaxInt32 {
  1249  			req.PageSize = math.MaxInt32
  1250  		} else if pageSize != 0 {
  1251  			req.PageSize = int32(pageSize)
  1252  		}
  1253  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1254  			var err error
  1255  			resp, err = executeRPC(ctx, c.tensorboardClient.ListTensorboardTimeSeries, req, settings.GRPC, c.logger, "ListTensorboardTimeSeries")
  1256  			return err
  1257  		}, opts...)
  1258  		if err != nil {
  1259  			return nil, "", err
  1260  		}
  1261  
  1262  		it.Response = resp
  1263  		return resp.GetTensorboardTimeSeries(), resp.GetNextPageToken(), nil
  1264  	}
  1265  	fetch := func(pageSize int, pageToken string) (string, error) {
  1266  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1267  		if err != nil {
  1268  			return "", err
  1269  		}
  1270  		it.items = append(it.items, items...)
  1271  		return nextPageToken, nil
  1272  	}
  1273  
  1274  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1275  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1276  	it.pageInfo.Token = req.GetPageToken()
  1277  
  1278  	return it
  1279  }
  1280  
  1281  func (c *tensorboardGRPCClient) DeleteTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.DeleteTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*DeleteTensorboardTimeSeriesOperation, error) {
  1282  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1283  
  1284  	hds = append(c.xGoogHeaders, hds...)
  1285  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1286  	opts = append((*c.CallOptions).DeleteTensorboardTimeSeries[0:len((*c.CallOptions).DeleteTensorboardTimeSeries):len((*c.CallOptions).DeleteTensorboardTimeSeries)], opts...)
  1287  	var resp *longrunningpb.Operation
  1288  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1289  		var err error
  1290  		resp, err = executeRPC(ctx, c.tensorboardClient.DeleteTensorboardTimeSeries, req, settings.GRPC, c.logger, "DeleteTensorboardTimeSeries")
  1291  		return err
  1292  	}, opts...)
  1293  	if err != nil {
  1294  		return nil, err
  1295  	}
  1296  	return &DeleteTensorboardTimeSeriesOperation{
  1297  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1298  	}, nil
  1299  }
  1300  
  1301  func (c *tensorboardGRPCClient) BatchReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.BatchReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse, error) {
  1302  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
  1303  
  1304  	hds = append(c.xGoogHeaders, hds...)
  1305  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1306  	opts = append((*c.CallOptions).BatchReadTensorboardTimeSeriesData[0:len((*c.CallOptions).BatchReadTensorboardTimeSeriesData):len((*c.CallOptions).BatchReadTensorboardTimeSeriesData)], opts...)
  1307  	var resp *aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse
  1308  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1309  		var err error
  1310  		resp, err = executeRPC(ctx, c.tensorboardClient.BatchReadTensorboardTimeSeriesData, req, settings.GRPC, c.logger, "BatchReadTensorboardTimeSeriesData")
  1311  		return err
  1312  	}, opts...)
  1313  	if err != nil {
  1314  		return nil, err
  1315  	}
  1316  	return resp, nil
  1317  }
  1318  
  1319  func (c *tensorboardGRPCClient) ReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardTimeSeriesDataResponse, error) {
  1320  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_time_series", url.QueryEscape(req.GetTensorboardTimeSeries()))}
  1321  
  1322  	hds = append(c.xGoogHeaders, hds...)
  1323  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1324  	opts = append((*c.CallOptions).ReadTensorboardTimeSeriesData[0:len((*c.CallOptions).ReadTensorboardTimeSeriesData):len((*c.CallOptions).ReadTensorboardTimeSeriesData)], opts...)
  1325  	var resp *aiplatformpb.ReadTensorboardTimeSeriesDataResponse
  1326  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1327  		var err error
  1328  		resp, err = executeRPC(ctx, c.tensorboardClient.ReadTensorboardTimeSeriesData, req, settings.GRPC, c.logger, "ReadTensorboardTimeSeriesData")
  1329  		return err
  1330  	}, opts...)
  1331  	if err != nil {
  1332  		return nil, err
  1333  	}
  1334  	return resp, nil
  1335  }
  1336  
  1337  func (c *tensorboardGRPCClient) ReadTensorboardBlobData(ctx context.Context, req *aiplatformpb.ReadTensorboardBlobDataRequest, opts ...gax.CallOption) (aiplatformpb.TensorboardService_ReadTensorboardBlobDataClient, error) {
  1338  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "time_series", url.QueryEscape(req.GetTimeSeries()))}
  1339  
  1340  	hds = append(c.xGoogHeaders, hds...)
  1341  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1342  	opts = append((*c.CallOptions).ReadTensorboardBlobData[0:len((*c.CallOptions).ReadTensorboardBlobData):len((*c.CallOptions).ReadTensorboardBlobData)], opts...)
  1343  	var resp aiplatformpb.TensorboardService_ReadTensorboardBlobDataClient
  1344  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1345  		var err error
  1346  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "ReadTensorboardBlobData")
  1347  		resp, err = c.tensorboardClient.ReadTensorboardBlobData(ctx, req, settings.GRPC...)
  1348  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "ReadTensorboardBlobData")
  1349  		return err
  1350  	}, opts...)
  1351  	if err != nil {
  1352  		return nil, err
  1353  	}
  1354  	return resp, nil
  1355  }
  1356  
  1357  func (c *tensorboardGRPCClient) WriteTensorboardExperimentData(ctx context.Context, req *aiplatformpb.WriteTensorboardExperimentDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardExperimentDataResponse, error) {
  1358  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_experiment", url.QueryEscape(req.GetTensorboardExperiment()))}
  1359  
  1360  	hds = append(c.xGoogHeaders, hds...)
  1361  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1362  	opts = append((*c.CallOptions).WriteTensorboardExperimentData[0:len((*c.CallOptions).WriteTensorboardExperimentData):len((*c.CallOptions).WriteTensorboardExperimentData)], opts...)
  1363  	var resp *aiplatformpb.WriteTensorboardExperimentDataResponse
  1364  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1365  		var err error
  1366  		resp, err = executeRPC(ctx, c.tensorboardClient.WriteTensorboardExperimentData, req, settings.GRPC, c.logger, "WriteTensorboardExperimentData")
  1367  		return err
  1368  	}, opts...)
  1369  	if err != nil {
  1370  		return nil, err
  1371  	}
  1372  	return resp, nil
  1373  }
  1374  
  1375  func (c *tensorboardGRPCClient) WriteTensorboardRunData(ctx context.Context, req *aiplatformpb.WriteTensorboardRunDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardRunDataResponse, error) {
  1376  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_run", url.QueryEscape(req.GetTensorboardRun()))}
  1377  
  1378  	hds = append(c.xGoogHeaders, hds...)
  1379  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1380  	opts = append((*c.CallOptions).WriteTensorboardRunData[0:len((*c.CallOptions).WriteTensorboardRunData):len((*c.CallOptions).WriteTensorboardRunData)], opts...)
  1381  	var resp *aiplatformpb.WriteTensorboardRunDataResponse
  1382  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1383  		var err error
  1384  		resp, err = executeRPC(ctx, c.tensorboardClient.WriteTensorboardRunData, req, settings.GRPC, c.logger, "WriteTensorboardRunData")
  1385  		return err
  1386  	}, opts...)
  1387  	if err != nil {
  1388  		return nil, err
  1389  	}
  1390  	return resp, nil
  1391  }
  1392  
  1393  func (c *tensorboardGRPCClient) ExportTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ExportTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) *TimeSeriesDataPointIterator {
  1394  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_time_series", url.QueryEscape(req.GetTensorboardTimeSeries()))}
  1395  
  1396  	hds = append(c.xGoogHeaders, hds...)
  1397  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1398  	opts = append((*c.CallOptions).ExportTensorboardTimeSeriesData[0:len((*c.CallOptions).ExportTensorboardTimeSeriesData):len((*c.CallOptions).ExportTensorboardTimeSeriesData)], opts...)
  1399  	it := &TimeSeriesDataPointIterator{}
  1400  	req = proto.Clone(req).(*aiplatformpb.ExportTensorboardTimeSeriesDataRequest)
  1401  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TimeSeriesDataPoint, string, error) {
  1402  		resp := &aiplatformpb.ExportTensorboardTimeSeriesDataResponse{}
  1403  		if pageToken != "" {
  1404  			req.PageToken = pageToken
  1405  		}
  1406  		if pageSize > math.MaxInt32 {
  1407  			req.PageSize = math.MaxInt32
  1408  		} else if pageSize != 0 {
  1409  			req.PageSize = int32(pageSize)
  1410  		}
  1411  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1412  			var err error
  1413  			resp, err = executeRPC(ctx, c.tensorboardClient.ExportTensorboardTimeSeriesData, req, settings.GRPC, c.logger, "ExportTensorboardTimeSeriesData")
  1414  			return err
  1415  		}, opts...)
  1416  		if err != nil {
  1417  			return nil, "", err
  1418  		}
  1419  
  1420  		it.Response = resp
  1421  		return resp.GetTimeSeriesDataPoints(), resp.GetNextPageToken(), nil
  1422  	}
  1423  	fetch := func(pageSize int, pageToken string) (string, error) {
  1424  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1425  		if err != nil {
  1426  			return "", err
  1427  		}
  1428  		it.items = append(it.items, items...)
  1429  		return nextPageToken, nil
  1430  	}
  1431  
  1432  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1433  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1434  	it.pageInfo.Token = req.GetPageToken()
  1435  
  1436  	return it
  1437  }
  1438  
  1439  func (c *tensorboardGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1440  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1441  
  1442  	hds = append(c.xGoogHeaders, hds...)
  1443  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1444  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1445  	var resp *locationpb.Location
  1446  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1447  		var err error
  1448  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1449  		return err
  1450  	}, opts...)
  1451  	if err != nil {
  1452  		return nil, err
  1453  	}
  1454  	return resp, nil
  1455  }
  1456  
  1457  func (c *tensorboardGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1458  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1459  
  1460  	hds = append(c.xGoogHeaders, hds...)
  1461  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1462  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1463  	it := &LocationIterator{}
  1464  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1465  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1466  		resp := &locationpb.ListLocationsResponse{}
  1467  		if pageToken != "" {
  1468  			req.PageToken = pageToken
  1469  		}
  1470  		if pageSize > math.MaxInt32 {
  1471  			req.PageSize = math.MaxInt32
  1472  		} else if pageSize != 0 {
  1473  			req.PageSize = int32(pageSize)
  1474  		}
  1475  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1476  			var err error
  1477  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1478  			return err
  1479  		}, opts...)
  1480  		if err != nil {
  1481  			return nil, "", err
  1482  		}
  1483  
  1484  		it.Response = resp
  1485  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1486  	}
  1487  	fetch := func(pageSize int, pageToken string) (string, error) {
  1488  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1489  		if err != nil {
  1490  			return "", err
  1491  		}
  1492  		it.items = append(it.items, items...)
  1493  		return nextPageToken, nil
  1494  	}
  1495  
  1496  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1497  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1498  	it.pageInfo.Token = req.GetPageToken()
  1499  
  1500  	return it
  1501  }
  1502  
  1503  func (c *tensorboardGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1504  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1505  
  1506  	hds = append(c.xGoogHeaders, hds...)
  1507  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1508  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1509  	var resp *iampb.Policy
  1510  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1511  		var err error
  1512  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1513  		return err
  1514  	}, opts...)
  1515  	if err != nil {
  1516  		return nil, err
  1517  	}
  1518  	return resp, nil
  1519  }
  1520  
  1521  func (c *tensorboardGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1522  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1523  
  1524  	hds = append(c.xGoogHeaders, hds...)
  1525  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1526  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1527  	var resp *iampb.Policy
  1528  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1529  		var err error
  1530  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1531  		return err
  1532  	}, opts...)
  1533  	if err != nil {
  1534  		return nil, err
  1535  	}
  1536  	return resp, nil
  1537  }
  1538  
  1539  func (c *tensorboardGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1540  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1541  
  1542  	hds = append(c.xGoogHeaders, hds...)
  1543  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1544  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1545  	var resp *iampb.TestIamPermissionsResponse
  1546  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1547  		var err error
  1548  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1549  		return err
  1550  	}, opts...)
  1551  	if err != nil {
  1552  		return nil, err
  1553  	}
  1554  	return resp, nil
  1555  }
  1556  
  1557  func (c *tensorboardGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1558  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1559  
  1560  	hds = append(c.xGoogHeaders, hds...)
  1561  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1562  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1563  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1564  		var err error
  1565  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1566  		return err
  1567  	}, opts...)
  1568  	return err
  1569  }
  1570  
  1571  func (c *tensorboardGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1572  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1573  
  1574  	hds = append(c.xGoogHeaders, hds...)
  1575  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1576  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1577  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1578  		var err error
  1579  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1580  		return err
  1581  	}, opts...)
  1582  	return err
  1583  }
  1584  
  1585  func (c *tensorboardGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1586  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1587  
  1588  	hds = append(c.xGoogHeaders, hds...)
  1589  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1590  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1591  	var resp *longrunningpb.Operation
  1592  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1593  		var err error
  1594  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1595  		return err
  1596  	}, opts...)
  1597  	if err != nil {
  1598  		return nil, err
  1599  	}
  1600  	return resp, nil
  1601  }
  1602  
  1603  func (c *tensorboardGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1604  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1605  
  1606  	hds = append(c.xGoogHeaders, hds...)
  1607  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1608  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1609  	it := &OperationIterator{}
  1610  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1611  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1612  		resp := &longrunningpb.ListOperationsResponse{}
  1613  		if pageToken != "" {
  1614  			req.PageToken = pageToken
  1615  		}
  1616  		if pageSize > math.MaxInt32 {
  1617  			req.PageSize = math.MaxInt32
  1618  		} else if pageSize != 0 {
  1619  			req.PageSize = int32(pageSize)
  1620  		}
  1621  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1622  			var err error
  1623  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1624  			return err
  1625  		}, opts...)
  1626  		if err != nil {
  1627  			return nil, "", err
  1628  		}
  1629  
  1630  		it.Response = resp
  1631  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1632  	}
  1633  	fetch := func(pageSize int, pageToken string) (string, error) {
  1634  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1635  		if err != nil {
  1636  			return "", err
  1637  		}
  1638  		it.items = append(it.items, items...)
  1639  		return nextPageToken, nil
  1640  	}
  1641  
  1642  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1643  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1644  	it.pageInfo.Token = req.GetPageToken()
  1645  
  1646  	return it
  1647  }
  1648  
  1649  func (c *tensorboardGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1650  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1651  
  1652  	hds = append(c.xGoogHeaders, hds...)
  1653  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1654  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1655  	var resp *longrunningpb.Operation
  1656  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1657  		var err error
  1658  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  1659  		return err
  1660  	}, opts...)
  1661  	if err != nil {
  1662  		return nil, err
  1663  	}
  1664  	return resp, nil
  1665  }
  1666  
  1667  // CreateTensorboard creates a Tensorboard.
  1668  func (c *tensorboardRESTClient) CreateTensorboard(ctx context.Context, req *aiplatformpb.CreateTensorboardRequest, opts ...gax.CallOption) (*CreateTensorboardOperation, error) {
  1669  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1670  	body := req.GetTensorboard()
  1671  	jsonReq, err := m.Marshal(body)
  1672  	if err != nil {
  1673  		return nil, err
  1674  	}
  1675  
  1676  	baseUrl, err := url.Parse(c.endpoint)
  1677  	if err != nil {
  1678  		return nil, err
  1679  	}
  1680  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/tensorboards", req.GetParent())
  1681  
  1682  	params := url.Values{}
  1683  	params.Add("$alt", "json;enum-encoding=int")
  1684  
  1685  	baseUrl.RawQuery = params.Encode()
  1686  
  1687  	// Build HTTP headers from client and context metadata.
  1688  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1689  
  1690  	hds = append(c.xGoogHeaders, hds...)
  1691  	hds = append(hds, "Content-Type", "application/json")
  1692  	headers := gax.BuildHeaders(ctx, hds...)
  1693  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1694  	resp := &longrunningpb.Operation{}
  1695  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1696  		if settings.Path != "" {
  1697  			baseUrl.Path = settings.Path
  1698  		}
  1699  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1700  		if err != nil {
  1701  			return err
  1702  		}
  1703  		httpReq = httpReq.WithContext(ctx)
  1704  		httpReq.Header = headers
  1705  
  1706  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTensorboard")
  1707  		if err != nil {
  1708  			return err
  1709  		}
  1710  		if err := unm.Unmarshal(buf, resp); err != nil {
  1711  			return err
  1712  		}
  1713  
  1714  		return nil
  1715  	}, opts...)
  1716  	if e != nil {
  1717  		return nil, e
  1718  	}
  1719  
  1720  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1721  	return &CreateTensorboardOperation{
  1722  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1723  		pollPath: override,
  1724  	}, nil
  1725  }
  1726  
  1727  // GetTensorboard gets a Tensorboard.
  1728  func (c *tensorboardRESTClient) GetTensorboard(ctx context.Context, req *aiplatformpb.GetTensorboardRequest, opts ...gax.CallOption) (*aiplatformpb.Tensorboard, error) {
  1729  	baseUrl, err := url.Parse(c.endpoint)
  1730  	if err != nil {
  1731  		return nil, err
  1732  	}
  1733  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1734  
  1735  	params := url.Values{}
  1736  	params.Add("$alt", "json;enum-encoding=int")
  1737  
  1738  	baseUrl.RawQuery = params.Encode()
  1739  
  1740  	// Build HTTP headers from client and context metadata.
  1741  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1742  
  1743  	hds = append(c.xGoogHeaders, hds...)
  1744  	hds = append(hds, "Content-Type", "application/json")
  1745  	headers := gax.BuildHeaders(ctx, hds...)
  1746  	opts = append((*c.CallOptions).GetTensorboard[0:len((*c.CallOptions).GetTensorboard):len((*c.CallOptions).GetTensorboard)], opts...)
  1747  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1748  	resp := &aiplatformpb.Tensorboard{}
  1749  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1750  		if settings.Path != "" {
  1751  			baseUrl.Path = settings.Path
  1752  		}
  1753  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1754  		if err != nil {
  1755  			return err
  1756  		}
  1757  		httpReq = httpReq.WithContext(ctx)
  1758  		httpReq.Header = headers
  1759  
  1760  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTensorboard")
  1761  		if err != nil {
  1762  			return err
  1763  		}
  1764  
  1765  		if err := unm.Unmarshal(buf, resp); err != nil {
  1766  			return err
  1767  		}
  1768  
  1769  		return nil
  1770  	}, opts...)
  1771  	if e != nil {
  1772  		return nil, e
  1773  	}
  1774  	return resp, nil
  1775  }
  1776  
  1777  // UpdateTensorboard updates a Tensorboard.
  1778  func (c *tensorboardRESTClient) UpdateTensorboard(ctx context.Context, req *aiplatformpb.UpdateTensorboardRequest, opts ...gax.CallOption) (*UpdateTensorboardOperation, error) {
  1779  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1780  	body := req.GetTensorboard()
  1781  	jsonReq, err := m.Marshal(body)
  1782  	if err != nil {
  1783  		return nil, err
  1784  	}
  1785  
  1786  	baseUrl, err := url.Parse(c.endpoint)
  1787  	if err != nil {
  1788  		return nil, err
  1789  	}
  1790  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTensorboard().GetName())
  1791  
  1792  	params := url.Values{}
  1793  	params.Add("$alt", "json;enum-encoding=int")
  1794  	if req.GetUpdateMask() != nil {
  1795  		field, err := protojson.Marshal(req.GetUpdateMask())
  1796  		if err != nil {
  1797  			return nil, err
  1798  		}
  1799  		params.Add("updateMask", string(field[1:len(field)-1]))
  1800  	}
  1801  
  1802  	baseUrl.RawQuery = params.Encode()
  1803  
  1804  	// Build HTTP headers from client and context metadata.
  1805  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard.name", url.QueryEscape(req.GetTensorboard().GetName()))}
  1806  
  1807  	hds = append(c.xGoogHeaders, hds...)
  1808  	hds = append(hds, "Content-Type", "application/json")
  1809  	headers := gax.BuildHeaders(ctx, hds...)
  1810  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1811  	resp := &longrunningpb.Operation{}
  1812  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1813  		if settings.Path != "" {
  1814  			baseUrl.Path = settings.Path
  1815  		}
  1816  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  1817  		if err != nil {
  1818  			return err
  1819  		}
  1820  		httpReq = httpReq.WithContext(ctx)
  1821  		httpReq.Header = headers
  1822  
  1823  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTensorboard")
  1824  		if err != nil {
  1825  			return err
  1826  		}
  1827  		if err := unm.Unmarshal(buf, resp); err != nil {
  1828  			return err
  1829  		}
  1830  
  1831  		return nil
  1832  	}, opts...)
  1833  	if e != nil {
  1834  		return nil, e
  1835  	}
  1836  
  1837  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1838  	return &UpdateTensorboardOperation{
  1839  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1840  		pollPath: override,
  1841  	}, nil
  1842  }
  1843  
  1844  // ListTensorboards lists Tensorboards in a Location.
  1845  func (c *tensorboardRESTClient) ListTensorboards(ctx context.Context, req *aiplatformpb.ListTensorboardsRequest, opts ...gax.CallOption) *TensorboardIterator {
  1846  	it := &TensorboardIterator{}
  1847  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardsRequest)
  1848  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1849  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Tensorboard, string, error) {
  1850  		resp := &aiplatformpb.ListTensorboardsResponse{}
  1851  		if pageToken != "" {
  1852  			req.PageToken = pageToken
  1853  		}
  1854  		if pageSize > math.MaxInt32 {
  1855  			req.PageSize = math.MaxInt32
  1856  		} else if pageSize != 0 {
  1857  			req.PageSize = int32(pageSize)
  1858  		}
  1859  		baseUrl, err := url.Parse(c.endpoint)
  1860  		if err != nil {
  1861  			return nil, "", err
  1862  		}
  1863  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/tensorboards", req.GetParent())
  1864  
  1865  		params := url.Values{}
  1866  		params.Add("$alt", "json;enum-encoding=int")
  1867  		if req.GetFilter() != "" {
  1868  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1869  		}
  1870  		if req.GetOrderBy() != "" {
  1871  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  1872  		}
  1873  		if req.GetPageSize() != 0 {
  1874  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1875  		}
  1876  		if req.GetPageToken() != "" {
  1877  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1878  		}
  1879  		if req.GetReadMask() != nil {
  1880  			field, err := protojson.Marshal(req.GetReadMask())
  1881  			if err != nil {
  1882  				return nil, "", err
  1883  			}
  1884  			params.Add("readMask", string(field[1:len(field)-1]))
  1885  		}
  1886  
  1887  		baseUrl.RawQuery = params.Encode()
  1888  
  1889  		// Build HTTP headers from client and context metadata.
  1890  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1891  		headers := gax.BuildHeaders(ctx, hds...)
  1892  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1893  			if settings.Path != "" {
  1894  				baseUrl.Path = settings.Path
  1895  			}
  1896  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1897  			if err != nil {
  1898  				return err
  1899  			}
  1900  			httpReq.Header = headers
  1901  
  1902  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTensorboards")
  1903  			if err != nil {
  1904  				return err
  1905  			}
  1906  			if err := unm.Unmarshal(buf, resp); err != nil {
  1907  				return err
  1908  			}
  1909  
  1910  			return nil
  1911  		}, opts...)
  1912  		if e != nil {
  1913  			return nil, "", e
  1914  		}
  1915  		it.Response = resp
  1916  		return resp.GetTensorboards(), resp.GetNextPageToken(), nil
  1917  	}
  1918  
  1919  	fetch := func(pageSize int, pageToken string) (string, error) {
  1920  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1921  		if err != nil {
  1922  			return "", err
  1923  		}
  1924  		it.items = append(it.items, items...)
  1925  		return nextPageToken, nil
  1926  	}
  1927  
  1928  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1929  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1930  	it.pageInfo.Token = req.GetPageToken()
  1931  
  1932  	return it
  1933  }
  1934  
  1935  // DeleteTensorboard deletes a Tensorboard.
  1936  func (c *tensorboardRESTClient) DeleteTensorboard(ctx context.Context, req *aiplatformpb.DeleteTensorboardRequest, opts ...gax.CallOption) (*DeleteTensorboardOperation, error) {
  1937  	baseUrl, err := url.Parse(c.endpoint)
  1938  	if err != nil {
  1939  		return nil, err
  1940  	}
  1941  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1942  
  1943  	params := url.Values{}
  1944  	params.Add("$alt", "json;enum-encoding=int")
  1945  
  1946  	baseUrl.RawQuery = params.Encode()
  1947  
  1948  	// Build HTTP headers from client and context metadata.
  1949  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1950  
  1951  	hds = append(c.xGoogHeaders, hds...)
  1952  	hds = append(hds, "Content-Type", "application/json")
  1953  	headers := gax.BuildHeaders(ctx, hds...)
  1954  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1955  	resp := &longrunningpb.Operation{}
  1956  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1957  		if settings.Path != "" {
  1958  			baseUrl.Path = settings.Path
  1959  		}
  1960  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1961  		if err != nil {
  1962  			return err
  1963  		}
  1964  		httpReq = httpReq.WithContext(ctx)
  1965  		httpReq.Header = headers
  1966  
  1967  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTensorboard")
  1968  		if err != nil {
  1969  			return err
  1970  		}
  1971  		if err := unm.Unmarshal(buf, resp); err != nil {
  1972  			return err
  1973  		}
  1974  
  1975  		return nil
  1976  	}, opts...)
  1977  	if e != nil {
  1978  		return nil, e
  1979  	}
  1980  
  1981  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1982  	return &DeleteTensorboardOperation{
  1983  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1984  		pollPath: override,
  1985  	}, nil
  1986  }
  1987  
  1988  // ReadTensorboardUsage returns a list of monthly active users for a given TensorBoard instance.
  1989  func (c *tensorboardRESTClient) ReadTensorboardUsage(ctx context.Context, req *aiplatformpb.ReadTensorboardUsageRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardUsageResponse, error) {
  1990  	baseUrl, err := url.Parse(c.endpoint)
  1991  	if err != nil {
  1992  		return nil, err
  1993  	}
  1994  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:readUsage", req.GetTensorboard())
  1995  
  1996  	params := url.Values{}
  1997  	params.Add("$alt", "json;enum-encoding=int")
  1998  
  1999  	baseUrl.RawQuery = params.Encode()
  2000  
  2001  	// Build HTTP headers from client and context metadata.
  2002  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
  2003  
  2004  	hds = append(c.xGoogHeaders, hds...)
  2005  	hds = append(hds, "Content-Type", "application/json")
  2006  	headers := gax.BuildHeaders(ctx, hds...)
  2007  	opts = append((*c.CallOptions).ReadTensorboardUsage[0:len((*c.CallOptions).ReadTensorboardUsage):len((*c.CallOptions).ReadTensorboardUsage)], opts...)
  2008  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2009  	resp := &aiplatformpb.ReadTensorboardUsageResponse{}
  2010  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2011  		if settings.Path != "" {
  2012  			baseUrl.Path = settings.Path
  2013  		}
  2014  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2015  		if err != nil {
  2016  			return err
  2017  		}
  2018  		httpReq = httpReq.WithContext(ctx)
  2019  		httpReq.Header = headers
  2020  
  2021  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ReadTensorboardUsage")
  2022  		if err != nil {
  2023  			return err
  2024  		}
  2025  
  2026  		if err := unm.Unmarshal(buf, resp); err != nil {
  2027  			return err
  2028  		}
  2029  
  2030  		return nil
  2031  	}, opts...)
  2032  	if e != nil {
  2033  		return nil, e
  2034  	}
  2035  	return resp, nil
  2036  }
  2037  
  2038  // ReadTensorboardSize returns the storage size for a given TensorBoard instance.
  2039  func (c *tensorboardRESTClient) ReadTensorboardSize(ctx context.Context, req *aiplatformpb.ReadTensorboardSizeRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardSizeResponse, error) {
  2040  	baseUrl, err := url.Parse(c.endpoint)
  2041  	if err != nil {
  2042  		return nil, err
  2043  	}
  2044  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:readSize", req.GetTensorboard())
  2045  
  2046  	params := url.Values{}
  2047  	params.Add("$alt", "json;enum-encoding=int")
  2048  
  2049  	baseUrl.RawQuery = params.Encode()
  2050  
  2051  	// Build HTTP headers from client and context metadata.
  2052  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
  2053  
  2054  	hds = append(c.xGoogHeaders, hds...)
  2055  	hds = append(hds, "Content-Type", "application/json")
  2056  	headers := gax.BuildHeaders(ctx, hds...)
  2057  	opts = append((*c.CallOptions).ReadTensorboardSize[0:len((*c.CallOptions).ReadTensorboardSize):len((*c.CallOptions).ReadTensorboardSize)], opts...)
  2058  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2059  	resp := &aiplatformpb.ReadTensorboardSizeResponse{}
  2060  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2061  		if settings.Path != "" {
  2062  			baseUrl.Path = settings.Path
  2063  		}
  2064  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2065  		if err != nil {
  2066  			return err
  2067  		}
  2068  		httpReq = httpReq.WithContext(ctx)
  2069  		httpReq.Header = headers
  2070  
  2071  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ReadTensorboardSize")
  2072  		if err != nil {
  2073  			return err
  2074  		}
  2075  
  2076  		if err := unm.Unmarshal(buf, resp); err != nil {
  2077  			return err
  2078  		}
  2079  
  2080  		return nil
  2081  	}, opts...)
  2082  	if e != nil {
  2083  		return nil, e
  2084  	}
  2085  	return resp, nil
  2086  }
  2087  
  2088  // CreateTensorboardExperiment creates a TensorboardExperiment.
  2089  func (c *tensorboardRESTClient) CreateTensorboardExperiment(ctx context.Context, req *aiplatformpb.CreateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
  2090  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2091  	body := req.GetTensorboardExperiment()
  2092  	jsonReq, err := m.Marshal(body)
  2093  	if err != nil {
  2094  		return nil, err
  2095  	}
  2096  
  2097  	baseUrl, err := url.Parse(c.endpoint)
  2098  	if err != nil {
  2099  		return nil, err
  2100  	}
  2101  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/experiments", req.GetParent())
  2102  
  2103  	params := url.Values{}
  2104  	params.Add("$alt", "json;enum-encoding=int")
  2105  	params.Add("tensorboardExperimentId", fmt.Sprintf("%v", req.GetTensorboardExperimentId()))
  2106  
  2107  	baseUrl.RawQuery = params.Encode()
  2108  
  2109  	// Build HTTP headers from client and context metadata.
  2110  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2111  
  2112  	hds = append(c.xGoogHeaders, hds...)
  2113  	hds = append(hds, "Content-Type", "application/json")
  2114  	headers := gax.BuildHeaders(ctx, hds...)
  2115  	opts = append((*c.CallOptions).CreateTensorboardExperiment[0:len((*c.CallOptions).CreateTensorboardExperiment):len((*c.CallOptions).CreateTensorboardExperiment)], opts...)
  2116  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2117  	resp := &aiplatformpb.TensorboardExperiment{}
  2118  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2119  		if settings.Path != "" {
  2120  			baseUrl.Path = settings.Path
  2121  		}
  2122  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2123  		if err != nil {
  2124  			return err
  2125  		}
  2126  		httpReq = httpReq.WithContext(ctx)
  2127  		httpReq.Header = headers
  2128  
  2129  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTensorboardExperiment")
  2130  		if err != nil {
  2131  			return err
  2132  		}
  2133  
  2134  		if err := unm.Unmarshal(buf, resp); err != nil {
  2135  			return err
  2136  		}
  2137  
  2138  		return nil
  2139  	}, opts...)
  2140  	if e != nil {
  2141  		return nil, e
  2142  	}
  2143  	return resp, nil
  2144  }
  2145  
  2146  // GetTensorboardExperiment gets a TensorboardExperiment.
  2147  func (c *tensorboardRESTClient) GetTensorboardExperiment(ctx context.Context, req *aiplatformpb.GetTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
  2148  	baseUrl, err := url.Parse(c.endpoint)
  2149  	if err != nil {
  2150  		return nil, err
  2151  	}
  2152  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2153  
  2154  	params := url.Values{}
  2155  	params.Add("$alt", "json;enum-encoding=int")
  2156  
  2157  	baseUrl.RawQuery = params.Encode()
  2158  
  2159  	// Build HTTP headers from client and context metadata.
  2160  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2161  
  2162  	hds = append(c.xGoogHeaders, hds...)
  2163  	hds = append(hds, "Content-Type", "application/json")
  2164  	headers := gax.BuildHeaders(ctx, hds...)
  2165  	opts = append((*c.CallOptions).GetTensorboardExperiment[0:len((*c.CallOptions).GetTensorboardExperiment):len((*c.CallOptions).GetTensorboardExperiment)], opts...)
  2166  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2167  	resp := &aiplatformpb.TensorboardExperiment{}
  2168  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2169  		if settings.Path != "" {
  2170  			baseUrl.Path = settings.Path
  2171  		}
  2172  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2173  		if err != nil {
  2174  			return err
  2175  		}
  2176  		httpReq = httpReq.WithContext(ctx)
  2177  		httpReq.Header = headers
  2178  
  2179  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTensorboardExperiment")
  2180  		if err != nil {
  2181  			return err
  2182  		}
  2183  
  2184  		if err := unm.Unmarshal(buf, resp); err != nil {
  2185  			return err
  2186  		}
  2187  
  2188  		return nil
  2189  	}, opts...)
  2190  	if e != nil {
  2191  		return nil, e
  2192  	}
  2193  	return resp, nil
  2194  }
  2195  
  2196  // UpdateTensorboardExperiment updates a TensorboardExperiment.
  2197  func (c *tensorboardRESTClient) UpdateTensorboardExperiment(ctx context.Context, req *aiplatformpb.UpdateTensorboardExperimentRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardExperiment, error) {
  2198  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2199  	body := req.GetTensorboardExperiment()
  2200  	jsonReq, err := m.Marshal(body)
  2201  	if err != nil {
  2202  		return nil, err
  2203  	}
  2204  
  2205  	baseUrl, err := url.Parse(c.endpoint)
  2206  	if err != nil {
  2207  		return nil, err
  2208  	}
  2209  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTensorboardExperiment().GetName())
  2210  
  2211  	params := url.Values{}
  2212  	params.Add("$alt", "json;enum-encoding=int")
  2213  	if req.GetUpdateMask() != nil {
  2214  		field, err := protojson.Marshal(req.GetUpdateMask())
  2215  		if err != nil {
  2216  			return nil, err
  2217  		}
  2218  		params.Add("updateMask", string(field[1:len(field)-1]))
  2219  	}
  2220  
  2221  	baseUrl.RawQuery = params.Encode()
  2222  
  2223  	// Build HTTP headers from client and context metadata.
  2224  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_experiment.name", url.QueryEscape(req.GetTensorboardExperiment().GetName()))}
  2225  
  2226  	hds = append(c.xGoogHeaders, hds...)
  2227  	hds = append(hds, "Content-Type", "application/json")
  2228  	headers := gax.BuildHeaders(ctx, hds...)
  2229  	opts = append((*c.CallOptions).UpdateTensorboardExperiment[0:len((*c.CallOptions).UpdateTensorboardExperiment):len((*c.CallOptions).UpdateTensorboardExperiment)], opts...)
  2230  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2231  	resp := &aiplatformpb.TensorboardExperiment{}
  2232  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2233  		if settings.Path != "" {
  2234  			baseUrl.Path = settings.Path
  2235  		}
  2236  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  2237  		if err != nil {
  2238  			return err
  2239  		}
  2240  		httpReq = httpReq.WithContext(ctx)
  2241  		httpReq.Header = headers
  2242  
  2243  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTensorboardExperiment")
  2244  		if err != nil {
  2245  			return err
  2246  		}
  2247  
  2248  		if err := unm.Unmarshal(buf, resp); err != nil {
  2249  			return err
  2250  		}
  2251  
  2252  		return nil
  2253  	}, opts...)
  2254  	if e != nil {
  2255  		return nil, e
  2256  	}
  2257  	return resp, nil
  2258  }
  2259  
  2260  // ListTensorboardExperiments lists TensorboardExperiments in a Location.
  2261  func (c *tensorboardRESTClient) ListTensorboardExperiments(ctx context.Context, req *aiplatformpb.ListTensorboardExperimentsRequest, opts ...gax.CallOption) *TensorboardExperimentIterator {
  2262  	it := &TensorboardExperimentIterator{}
  2263  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardExperimentsRequest)
  2264  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2265  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardExperiment, string, error) {
  2266  		resp := &aiplatformpb.ListTensorboardExperimentsResponse{}
  2267  		if pageToken != "" {
  2268  			req.PageToken = pageToken
  2269  		}
  2270  		if pageSize > math.MaxInt32 {
  2271  			req.PageSize = math.MaxInt32
  2272  		} else if pageSize != 0 {
  2273  			req.PageSize = int32(pageSize)
  2274  		}
  2275  		baseUrl, err := url.Parse(c.endpoint)
  2276  		if err != nil {
  2277  			return nil, "", err
  2278  		}
  2279  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/experiments", req.GetParent())
  2280  
  2281  		params := url.Values{}
  2282  		params.Add("$alt", "json;enum-encoding=int")
  2283  		if req.GetFilter() != "" {
  2284  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2285  		}
  2286  		if req.GetOrderBy() != "" {
  2287  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2288  		}
  2289  		if req.GetPageSize() != 0 {
  2290  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2291  		}
  2292  		if req.GetPageToken() != "" {
  2293  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2294  		}
  2295  		if req.GetReadMask() != nil {
  2296  			field, err := protojson.Marshal(req.GetReadMask())
  2297  			if err != nil {
  2298  				return nil, "", err
  2299  			}
  2300  			params.Add("readMask", string(field[1:len(field)-1]))
  2301  		}
  2302  
  2303  		baseUrl.RawQuery = params.Encode()
  2304  
  2305  		// Build HTTP headers from client and context metadata.
  2306  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2307  		headers := gax.BuildHeaders(ctx, hds...)
  2308  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2309  			if settings.Path != "" {
  2310  				baseUrl.Path = settings.Path
  2311  			}
  2312  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2313  			if err != nil {
  2314  				return err
  2315  			}
  2316  			httpReq.Header = headers
  2317  
  2318  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTensorboardExperiments")
  2319  			if err != nil {
  2320  				return err
  2321  			}
  2322  			if err := unm.Unmarshal(buf, resp); err != nil {
  2323  				return err
  2324  			}
  2325  
  2326  			return nil
  2327  		}, opts...)
  2328  		if e != nil {
  2329  			return nil, "", e
  2330  		}
  2331  		it.Response = resp
  2332  		return resp.GetTensorboardExperiments(), resp.GetNextPageToken(), nil
  2333  	}
  2334  
  2335  	fetch := func(pageSize int, pageToken string) (string, error) {
  2336  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2337  		if err != nil {
  2338  			return "", err
  2339  		}
  2340  		it.items = append(it.items, items...)
  2341  		return nextPageToken, nil
  2342  	}
  2343  
  2344  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2345  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2346  	it.pageInfo.Token = req.GetPageToken()
  2347  
  2348  	return it
  2349  }
  2350  
  2351  // DeleteTensorboardExperiment deletes a TensorboardExperiment.
  2352  func (c *tensorboardRESTClient) DeleteTensorboardExperiment(ctx context.Context, req *aiplatformpb.DeleteTensorboardExperimentRequest, opts ...gax.CallOption) (*DeleteTensorboardExperimentOperation, error) {
  2353  	baseUrl, err := url.Parse(c.endpoint)
  2354  	if err != nil {
  2355  		return nil, err
  2356  	}
  2357  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2358  
  2359  	params := url.Values{}
  2360  	params.Add("$alt", "json;enum-encoding=int")
  2361  
  2362  	baseUrl.RawQuery = params.Encode()
  2363  
  2364  	// Build HTTP headers from client and context metadata.
  2365  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2366  
  2367  	hds = append(c.xGoogHeaders, hds...)
  2368  	hds = append(hds, "Content-Type", "application/json")
  2369  	headers := gax.BuildHeaders(ctx, hds...)
  2370  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2371  	resp := &longrunningpb.Operation{}
  2372  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2373  		if settings.Path != "" {
  2374  			baseUrl.Path = settings.Path
  2375  		}
  2376  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2377  		if err != nil {
  2378  			return err
  2379  		}
  2380  		httpReq = httpReq.WithContext(ctx)
  2381  		httpReq.Header = headers
  2382  
  2383  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTensorboardExperiment")
  2384  		if err != nil {
  2385  			return err
  2386  		}
  2387  		if err := unm.Unmarshal(buf, resp); err != nil {
  2388  			return err
  2389  		}
  2390  
  2391  		return nil
  2392  	}, opts...)
  2393  	if e != nil {
  2394  		return nil, e
  2395  	}
  2396  
  2397  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2398  	return &DeleteTensorboardExperimentOperation{
  2399  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2400  		pollPath: override,
  2401  	}, nil
  2402  }
  2403  
  2404  // CreateTensorboardRun creates a TensorboardRun.
  2405  func (c *tensorboardRESTClient) CreateTensorboardRun(ctx context.Context, req *aiplatformpb.CreateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  2406  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2407  	body := req.GetTensorboardRun()
  2408  	jsonReq, err := m.Marshal(body)
  2409  	if err != nil {
  2410  		return nil, err
  2411  	}
  2412  
  2413  	baseUrl, err := url.Parse(c.endpoint)
  2414  	if err != nil {
  2415  		return nil, err
  2416  	}
  2417  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/runs", req.GetParent())
  2418  
  2419  	params := url.Values{}
  2420  	params.Add("$alt", "json;enum-encoding=int")
  2421  	params.Add("tensorboardRunId", fmt.Sprintf("%v", req.GetTensorboardRunId()))
  2422  
  2423  	baseUrl.RawQuery = params.Encode()
  2424  
  2425  	// Build HTTP headers from client and context metadata.
  2426  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2427  
  2428  	hds = append(c.xGoogHeaders, hds...)
  2429  	hds = append(hds, "Content-Type", "application/json")
  2430  	headers := gax.BuildHeaders(ctx, hds...)
  2431  	opts = append((*c.CallOptions).CreateTensorboardRun[0:len((*c.CallOptions).CreateTensorboardRun):len((*c.CallOptions).CreateTensorboardRun)], opts...)
  2432  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2433  	resp := &aiplatformpb.TensorboardRun{}
  2434  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2435  		if settings.Path != "" {
  2436  			baseUrl.Path = settings.Path
  2437  		}
  2438  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2439  		if err != nil {
  2440  			return err
  2441  		}
  2442  		httpReq = httpReq.WithContext(ctx)
  2443  		httpReq.Header = headers
  2444  
  2445  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTensorboardRun")
  2446  		if err != nil {
  2447  			return err
  2448  		}
  2449  
  2450  		if err := unm.Unmarshal(buf, resp); err != nil {
  2451  			return err
  2452  		}
  2453  
  2454  		return nil
  2455  	}, opts...)
  2456  	if e != nil {
  2457  		return nil, e
  2458  	}
  2459  	return resp, nil
  2460  }
  2461  
  2462  // BatchCreateTensorboardRuns batch create TensorboardRuns.
  2463  func (c *tensorboardRESTClient) BatchCreateTensorboardRuns(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardRunsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardRunsResponse, error) {
  2464  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2465  	jsonReq, err := m.Marshal(req)
  2466  	if err != nil {
  2467  		return nil, err
  2468  	}
  2469  
  2470  	baseUrl, err := url.Parse(c.endpoint)
  2471  	if err != nil {
  2472  		return nil, err
  2473  	}
  2474  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/runs:batchCreate", req.GetParent())
  2475  
  2476  	params := url.Values{}
  2477  	params.Add("$alt", "json;enum-encoding=int")
  2478  
  2479  	baseUrl.RawQuery = params.Encode()
  2480  
  2481  	// Build HTTP headers from client and context metadata.
  2482  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2483  
  2484  	hds = append(c.xGoogHeaders, hds...)
  2485  	hds = append(hds, "Content-Type", "application/json")
  2486  	headers := gax.BuildHeaders(ctx, hds...)
  2487  	opts = append((*c.CallOptions).BatchCreateTensorboardRuns[0:len((*c.CallOptions).BatchCreateTensorboardRuns):len((*c.CallOptions).BatchCreateTensorboardRuns)], opts...)
  2488  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2489  	resp := &aiplatformpb.BatchCreateTensorboardRunsResponse{}
  2490  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2491  		if settings.Path != "" {
  2492  			baseUrl.Path = settings.Path
  2493  		}
  2494  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2495  		if err != nil {
  2496  			return err
  2497  		}
  2498  		httpReq = httpReq.WithContext(ctx)
  2499  		httpReq.Header = headers
  2500  
  2501  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchCreateTensorboardRuns")
  2502  		if err != nil {
  2503  			return err
  2504  		}
  2505  
  2506  		if err := unm.Unmarshal(buf, resp); err != nil {
  2507  			return err
  2508  		}
  2509  
  2510  		return nil
  2511  	}, opts...)
  2512  	if e != nil {
  2513  		return nil, e
  2514  	}
  2515  	return resp, nil
  2516  }
  2517  
  2518  // GetTensorboardRun gets a TensorboardRun.
  2519  func (c *tensorboardRESTClient) GetTensorboardRun(ctx context.Context, req *aiplatformpb.GetTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  2520  	baseUrl, err := url.Parse(c.endpoint)
  2521  	if err != nil {
  2522  		return nil, err
  2523  	}
  2524  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2525  
  2526  	params := url.Values{}
  2527  	params.Add("$alt", "json;enum-encoding=int")
  2528  
  2529  	baseUrl.RawQuery = params.Encode()
  2530  
  2531  	// Build HTTP headers from client and context metadata.
  2532  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2533  
  2534  	hds = append(c.xGoogHeaders, hds...)
  2535  	hds = append(hds, "Content-Type", "application/json")
  2536  	headers := gax.BuildHeaders(ctx, hds...)
  2537  	opts = append((*c.CallOptions).GetTensorboardRun[0:len((*c.CallOptions).GetTensorboardRun):len((*c.CallOptions).GetTensorboardRun)], opts...)
  2538  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2539  	resp := &aiplatformpb.TensorboardRun{}
  2540  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2541  		if settings.Path != "" {
  2542  			baseUrl.Path = settings.Path
  2543  		}
  2544  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2545  		if err != nil {
  2546  			return err
  2547  		}
  2548  		httpReq = httpReq.WithContext(ctx)
  2549  		httpReq.Header = headers
  2550  
  2551  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTensorboardRun")
  2552  		if err != nil {
  2553  			return err
  2554  		}
  2555  
  2556  		if err := unm.Unmarshal(buf, resp); err != nil {
  2557  			return err
  2558  		}
  2559  
  2560  		return nil
  2561  	}, opts...)
  2562  	if e != nil {
  2563  		return nil, e
  2564  	}
  2565  	return resp, nil
  2566  }
  2567  
  2568  // UpdateTensorboardRun updates a TensorboardRun.
  2569  func (c *tensorboardRESTClient) UpdateTensorboardRun(ctx context.Context, req *aiplatformpb.UpdateTensorboardRunRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardRun, error) {
  2570  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2571  	body := req.GetTensorboardRun()
  2572  	jsonReq, err := m.Marshal(body)
  2573  	if err != nil {
  2574  		return nil, err
  2575  	}
  2576  
  2577  	baseUrl, err := url.Parse(c.endpoint)
  2578  	if err != nil {
  2579  		return nil, err
  2580  	}
  2581  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTensorboardRun().GetName())
  2582  
  2583  	params := url.Values{}
  2584  	params.Add("$alt", "json;enum-encoding=int")
  2585  	if req.GetUpdateMask() != nil {
  2586  		field, err := protojson.Marshal(req.GetUpdateMask())
  2587  		if err != nil {
  2588  			return nil, err
  2589  		}
  2590  		params.Add("updateMask", string(field[1:len(field)-1]))
  2591  	}
  2592  
  2593  	baseUrl.RawQuery = params.Encode()
  2594  
  2595  	// Build HTTP headers from client and context metadata.
  2596  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_run.name", url.QueryEscape(req.GetTensorboardRun().GetName()))}
  2597  
  2598  	hds = append(c.xGoogHeaders, hds...)
  2599  	hds = append(hds, "Content-Type", "application/json")
  2600  	headers := gax.BuildHeaders(ctx, hds...)
  2601  	opts = append((*c.CallOptions).UpdateTensorboardRun[0:len((*c.CallOptions).UpdateTensorboardRun):len((*c.CallOptions).UpdateTensorboardRun)], opts...)
  2602  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2603  	resp := &aiplatformpb.TensorboardRun{}
  2604  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2605  		if settings.Path != "" {
  2606  			baseUrl.Path = settings.Path
  2607  		}
  2608  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  2609  		if err != nil {
  2610  			return err
  2611  		}
  2612  		httpReq = httpReq.WithContext(ctx)
  2613  		httpReq.Header = headers
  2614  
  2615  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTensorboardRun")
  2616  		if err != nil {
  2617  			return err
  2618  		}
  2619  
  2620  		if err := unm.Unmarshal(buf, resp); err != nil {
  2621  			return err
  2622  		}
  2623  
  2624  		return nil
  2625  	}, opts...)
  2626  	if e != nil {
  2627  		return nil, e
  2628  	}
  2629  	return resp, nil
  2630  }
  2631  
  2632  // ListTensorboardRuns lists TensorboardRuns in a Location.
  2633  func (c *tensorboardRESTClient) ListTensorboardRuns(ctx context.Context, req *aiplatformpb.ListTensorboardRunsRequest, opts ...gax.CallOption) *TensorboardRunIterator {
  2634  	it := &TensorboardRunIterator{}
  2635  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardRunsRequest)
  2636  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2637  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardRun, string, error) {
  2638  		resp := &aiplatformpb.ListTensorboardRunsResponse{}
  2639  		if pageToken != "" {
  2640  			req.PageToken = pageToken
  2641  		}
  2642  		if pageSize > math.MaxInt32 {
  2643  			req.PageSize = math.MaxInt32
  2644  		} else if pageSize != 0 {
  2645  			req.PageSize = int32(pageSize)
  2646  		}
  2647  		baseUrl, err := url.Parse(c.endpoint)
  2648  		if err != nil {
  2649  			return nil, "", err
  2650  		}
  2651  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/runs", req.GetParent())
  2652  
  2653  		params := url.Values{}
  2654  		params.Add("$alt", "json;enum-encoding=int")
  2655  		if req.GetFilter() != "" {
  2656  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2657  		}
  2658  		if req.GetOrderBy() != "" {
  2659  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2660  		}
  2661  		if req.GetPageSize() != 0 {
  2662  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2663  		}
  2664  		if req.GetPageToken() != "" {
  2665  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2666  		}
  2667  		if req.GetReadMask() != nil {
  2668  			field, err := protojson.Marshal(req.GetReadMask())
  2669  			if err != nil {
  2670  				return nil, "", err
  2671  			}
  2672  			params.Add("readMask", string(field[1:len(field)-1]))
  2673  		}
  2674  
  2675  		baseUrl.RawQuery = params.Encode()
  2676  
  2677  		// Build HTTP headers from client and context metadata.
  2678  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2679  		headers := gax.BuildHeaders(ctx, hds...)
  2680  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2681  			if settings.Path != "" {
  2682  				baseUrl.Path = settings.Path
  2683  			}
  2684  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2685  			if err != nil {
  2686  				return err
  2687  			}
  2688  			httpReq.Header = headers
  2689  
  2690  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTensorboardRuns")
  2691  			if err != nil {
  2692  				return err
  2693  			}
  2694  			if err := unm.Unmarshal(buf, resp); err != nil {
  2695  				return err
  2696  			}
  2697  
  2698  			return nil
  2699  		}, opts...)
  2700  		if e != nil {
  2701  			return nil, "", e
  2702  		}
  2703  		it.Response = resp
  2704  		return resp.GetTensorboardRuns(), resp.GetNextPageToken(), nil
  2705  	}
  2706  
  2707  	fetch := func(pageSize int, pageToken string) (string, error) {
  2708  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2709  		if err != nil {
  2710  			return "", err
  2711  		}
  2712  		it.items = append(it.items, items...)
  2713  		return nextPageToken, nil
  2714  	}
  2715  
  2716  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2717  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2718  	it.pageInfo.Token = req.GetPageToken()
  2719  
  2720  	return it
  2721  }
  2722  
  2723  // DeleteTensorboardRun deletes a TensorboardRun.
  2724  func (c *tensorboardRESTClient) DeleteTensorboardRun(ctx context.Context, req *aiplatformpb.DeleteTensorboardRunRequest, opts ...gax.CallOption) (*DeleteTensorboardRunOperation, error) {
  2725  	baseUrl, err := url.Parse(c.endpoint)
  2726  	if err != nil {
  2727  		return nil, err
  2728  	}
  2729  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2730  
  2731  	params := url.Values{}
  2732  	params.Add("$alt", "json;enum-encoding=int")
  2733  
  2734  	baseUrl.RawQuery = params.Encode()
  2735  
  2736  	// Build HTTP headers from client and context metadata.
  2737  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2738  
  2739  	hds = append(c.xGoogHeaders, hds...)
  2740  	hds = append(hds, "Content-Type", "application/json")
  2741  	headers := gax.BuildHeaders(ctx, hds...)
  2742  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2743  	resp := &longrunningpb.Operation{}
  2744  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2745  		if settings.Path != "" {
  2746  			baseUrl.Path = settings.Path
  2747  		}
  2748  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2749  		if err != nil {
  2750  			return err
  2751  		}
  2752  		httpReq = httpReq.WithContext(ctx)
  2753  		httpReq.Header = headers
  2754  
  2755  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTensorboardRun")
  2756  		if err != nil {
  2757  			return err
  2758  		}
  2759  		if err := unm.Unmarshal(buf, resp); err != nil {
  2760  			return err
  2761  		}
  2762  
  2763  		return nil
  2764  	}, opts...)
  2765  	if e != nil {
  2766  		return nil, e
  2767  	}
  2768  
  2769  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2770  	return &DeleteTensorboardRunOperation{
  2771  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2772  		pollPath: override,
  2773  	}, nil
  2774  }
  2775  
  2776  // BatchCreateTensorboardTimeSeries batch create TensorboardTimeSeries that belong to a TensorboardExperiment.
  2777  func (c *tensorboardRESTClient) BatchCreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.BatchCreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchCreateTensorboardTimeSeriesResponse, error) {
  2778  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2779  	jsonReq, err := m.Marshal(req)
  2780  	if err != nil {
  2781  		return nil, err
  2782  	}
  2783  
  2784  	baseUrl, err := url.Parse(c.endpoint)
  2785  	if err != nil {
  2786  		return nil, err
  2787  	}
  2788  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:batchCreate", req.GetParent())
  2789  
  2790  	params := url.Values{}
  2791  	params.Add("$alt", "json;enum-encoding=int")
  2792  
  2793  	baseUrl.RawQuery = params.Encode()
  2794  
  2795  	// Build HTTP headers from client and context metadata.
  2796  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2797  
  2798  	hds = append(c.xGoogHeaders, hds...)
  2799  	hds = append(hds, "Content-Type", "application/json")
  2800  	headers := gax.BuildHeaders(ctx, hds...)
  2801  	opts = append((*c.CallOptions).BatchCreateTensorboardTimeSeries[0:len((*c.CallOptions).BatchCreateTensorboardTimeSeries):len((*c.CallOptions).BatchCreateTensorboardTimeSeries)], opts...)
  2802  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2803  	resp := &aiplatformpb.BatchCreateTensorboardTimeSeriesResponse{}
  2804  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2805  		if settings.Path != "" {
  2806  			baseUrl.Path = settings.Path
  2807  		}
  2808  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2809  		if err != nil {
  2810  			return err
  2811  		}
  2812  		httpReq = httpReq.WithContext(ctx)
  2813  		httpReq.Header = headers
  2814  
  2815  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchCreateTensorboardTimeSeries")
  2816  		if err != nil {
  2817  			return err
  2818  		}
  2819  
  2820  		if err := unm.Unmarshal(buf, resp); err != nil {
  2821  			return err
  2822  		}
  2823  
  2824  		return nil
  2825  	}, opts...)
  2826  	if e != nil {
  2827  		return nil, e
  2828  	}
  2829  	return resp, nil
  2830  }
  2831  
  2832  // CreateTensorboardTimeSeries creates a TensorboardTimeSeries.
  2833  func (c *tensorboardRESTClient) CreateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.CreateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  2834  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2835  	body := req.GetTensorboardTimeSeries()
  2836  	jsonReq, err := m.Marshal(body)
  2837  	if err != nil {
  2838  		return nil, err
  2839  	}
  2840  
  2841  	baseUrl, err := url.Parse(c.endpoint)
  2842  	if err != nil {
  2843  		return nil, err
  2844  	}
  2845  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/timeSeries", req.GetParent())
  2846  
  2847  	params := url.Values{}
  2848  	params.Add("$alt", "json;enum-encoding=int")
  2849  	if req.GetTensorboardTimeSeriesId() != "" {
  2850  		params.Add("tensorboardTimeSeriesId", fmt.Sprintf("%v", req.GetTensorboardTimeSeriesId()))
  2851  	}
  2852  
  2853  	baseUrl.RawQuery = params.Encode()
  2854  
  2855  	// Build HTTP headers from client and context metadata.
  2856  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2857  
  2858  	hds = append(c.xGoogHeaders, hds...)
  2859  	hds = append(hds, "Content-Type", "application/json")
  2860  	headers := gax.BuildHeaders(ctx, hds...)
  2861  	opts = append((*c.CallOptions).CreateTensorboardTimeSeries[0:len((*c.CallOptions).CreateTensorboardTimeSeries):len((*c.CallOptions).CreateTensorboardTimeSeries)], opts...)
  2862  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2863  	resp := &aiplatformpb.TensorboardTimeSeries{}
  2864  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2865  		if settings.Path != "" {
  2866  			baseUrl.Path = settings.Path
  2867  		}
  2868  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2869  		if err != nil {
  2870  			return err
  2871  		}
  2872  		httpReq = httpReq.WithContext(ctx)
  2873  		httpReq.Header = headers
  2874  
  2875  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTensorboardTimeSeries")
  2876  		if err != nil {
  2877  			return err
  2878  		}
  2879  
  2880  		if err := unm.Unmarshal(buf, resp); err != nil {
  2881  			return err
  2882  		}
  2883  
  2884  		return nil
  2885  	}, opts...)
  2886  	if e != nil {
  2887  		return nil, e
  2888  	}
  2889  	return resp, nil
  2890  }
  2891  
  2892  // GetTensorboardTimeSeries gets a TensorboardTimeSeries.
  2893  func (c *tensorboardRESTClient) GetTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.GetTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  2894  	baseUrl, err := url.Parse(c.endpoint)
  2895  	if err != nil {
  2896  		return nil, err
  2897  	}
  2898  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2899  
  2900  	params := url.Values{}
  2901  	params.Add("$alt", "json;enum-encoding=int")
  2902  
  2903  	baseUrl.RawQuery = params.Encode()
  2904  
  2905  	// Build HTTP headers from client and context metadata.
  2906  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2907  
  2908  	hds = append(c.xGoogHeaders, hds...)
  2909  	hds = append(hds, "Content-Type", "application/json")
  2910  	headers := gax.BuildHeaders(ctx, hds...)
  2911  	opts = append((*c.CallOptions).GetTensorboardTimeSeries[0:len((*c.CallOptions).GetTensorboardTimeSeries):len((*c.CallOptions).GetTensorboardTimeSeries)], opts...)
  2912  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2913  	resp := &aiplatformpb.TensorboardTimeSeries{}
  2914  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2915  		if settings.Path != "" {
  2916  			baseUrl.Path = settings.Path
  2917  		}
  2918  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2919  		if err != nil {
  2920  			return err
  2921  		}
  2922  		httpReq = httpReq.WithContext(ctx)
  2923  		httpReq.Header = headers
  2924  
  2925  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTensorboardTimeSeries")
  2926  		if err != nil {
  2927  			return err
  2928  		}
  2929  
  2930  		if err := unm.Unmarshal(buf, resp); err != nil {
  2931  			return err
  2932  		}
  2933  
  2934  		return nil
  2935  	}, opts...)
  2936  	if e != nil {
  2937  		return nil, e
  2938  	}
  2939  	return resp, nil
  2940  }
  2941  
  2942  // UpdateTensorboardTimeSeries updates a TensorboardTimeSeries.
  2943  func (c *tensorboardRESTClient) UpdateTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.UpdateTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*aiplatformpb.TensorboardTimeSeries, error) {
  2944  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2945  	body := req.GetTensorboardTimeSeries()
  2946  	jsonReq, err := m.Marshal(body)
  2947  	if err != nil {
  2948  		return nil, err
  2949  	}
  2950  
  2951  	baseUrl, err := url.Parse(c.endpoint)
  2952  	if err != nil {
  2953  		return nil, err
  2954  	}
  2955  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetTensorboardTimeSeries().GetName())
  2956  
  2957  	params := url.Values{}
  2958  	params.Add("$alt", "json;enum-encoding=int")
  2959  	if req.GetUpdateMask() != nil {
  2960  		field, err := protojson.Marshal(req.GetUpdateMask())
  2961  		if err != nil {
  2962  			return nil, err
  2963  		}
  2964  		params.Add("updateMask", string(field[1:len(field)-1]))
  2965  	}
  2966  
  2967  	baseUrl.RawQuery = params.Encode()
  2968  
  2969  	// Build HTTP headers from client and context metadata.
  2970  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_time_series.name", url.QueryEscape(req.GetTensorboardTimeSeries().GetName()))}
  2971  
  2972  	hds = append(c.xGoogHeaders, hds...)
  2973  	hds = append(hds, "Content-Type", "application/json")
  2974  	headers := gax.BuildHeaders(ctx, hds...)
  2975  	opts = append((*c.CallOptions).UpdateTensorboardTimeSeries[0:len((*c.CallOptions).UpdateTensorboardTimeSeries):len((*c.CallOptions).UpdateTensorboardTimeSeries)], opts...)
  2976  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2977  	resp := &aiplatformpb.TensorboardTimeSeries{}
  2978  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2979  		if settings.Path != "" {
  2980  			baseUrl.Path = settings.Path
  2981  		}
  2982  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  2983  		if err != nil {
  2984  			return err
  2985  		}
  2986  		httpReq = httpReq.WithContext(ctx)
  2987  		httpReq.Header = headers
  2988  
  2989  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTensorboardTimeSeries")
  2990  		if err != nil {
  2991  			return err
  2992  		}
  2993  
  2994  		if err := unm.Unmarshal(buf, resp); err != nil {
  2995  			return err
  2996  		}
  2997  
  2998  		return nil
  2999  	}, opts...)
  3000  	if e != nil {
  3001  		return nil, e
  3002  	}
  3003  	return resp, nil
  3004  }
  3005  
  3006  // ListTensorboardTimeSeries lists TensorboardTimeSeries in a Location.
  3007  func (c *tensorboardRESTClient) ListTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.ListTensorboardTimeSeriesRequest, opts ...gax.CallOption) *TensorboardTimeSeriesIterator {
  3008  	it := &TensorboardTimeSeriesIterator{}
  3009  	req = proto.Clone(req).(*aiplatformpb.ListTensorboardTimeSeriesRequest)
  3010  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3011  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TensorboardTimeSeries, string, error) {
  3012  		resp := &aiplatformpb.ListTensorboardTimeSeriesResponse{}
  3013  		if pageToken != "" {
  3014  			req.PageToken = pageToken
  3015  		}
  3016  		if pageSize > math.MaxInt32 {
  3017  			req.PageSize = math.MaxInt32
  3018  		} else if pageSize != 0 {
  3019  			req.PageSize = int32(pageSize)
  3020  		}
  3021  		baseUrl, err := url.Parse(c.endpoint)
  3022  		if err != nil {
  3023  			return nil, "", err
  3024  		}
  3025  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/timeSeries", req.GetParent())
  3026  
  3027  		params := url.Values{}
  3028  		params.Add("$alt", "json;enum-encoding=int")
  3029  		if req.GetFilter() != "" {
  3030  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3031  		}
  3032  		if req.GetOrderBy() != "" {
  3033  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  3034  		}
  3035  		if req.GetPageSize() != 0 {
  3036  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3037  		}
  3038  		if req.GetPageToken() != "" {
  3039  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3040  		}
  3041  		if req.GetReadMask() != nil {
  3042  			field, err := protojson.Marshal(req.GetReadMask())
  3043  			if err != nil {
  3044  				return nil, "", err
  3045  			}
  3046  			params.Add("readMask", string(field[1:len(field)-1]))
  3047  		}
  3048  
  3049  		baseUrl.RawQuery = params.Encode()
  3050  
  3051  		// Build HTTP headers from client and context metadata.
  3052  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3053  		headers := gax.BuildHeaders(ctx, hds...)
  3054  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3055  			if settings.Path != "" {
  3056  				baseUrl.Path = settings.Path
  3057  			}
  3058  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3059  			if err != nil {
  3060  				return err
  3061  			}
  3062  			httpReq.Header = headers
  3063  
  3064  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTensorboardTimeSeries")
  3065  			if err != nil {
  3066  				return err
  3067  			}
  3068  			if err := unm.Unmarshal(buf, resp); err != nil {
  3069  				return err
  3070  			}
  3071  
  3072  			return nil
  3073  		}, opts...)
  3074  		if e != nil {
  3075  			return nil, "", e
  3076  		}
  3077  		it.Response = resp
  3078  		return resp.GetTensorboardTimeSeries(), resp.GetNextPageToken(), nil
  3079  	}
  3080  
  3081  	fetch := func(pageSize int, pageToken string) (string, error) {
  3082  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3083  		if err != nil {
  3084  			return "", err
  3085  		}
  3086  		it.items = append(it.items, items...)
  3087  		return nextPageToken, nil
  3088  	}
  3089  
  3090  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3091  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3092  	it.pageInfo.Token = req.GetPageToken()
  3093  
  3094  	return it
  3095  }
  3096  
  3097  // DeleteTensorboardTimeSeries deletes a TensorboardTimeSeries.
  3098  func (c *tensorboardRESTClient) DeleteTensorboardTimeSeries(ctx context.Context, req *aiplatformpb.DeleteTensorboardTimeSeriesRequest, opts ...gax.CallOption) (*DeleteTensorboardTimeSeriesOperation, error) {
  3099  	baseUrl, err := url.Parse(c.endpoint)
  3100  	if err != nil {
  3101  		return nil, err
  3102  	}
  3103  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3104  
  3105  	params := url.Values{}
  3106  	params.Add("$alt", "json;enum-encoding=int")
  3107  
  3108  	baseUrl.RawQuery = params.Encode()
  3109  
  3110  	// Build HTTP headers from client and context metadata.
  3111  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3112  
  3113  	hds = append(c.xGoogHeaders, hds...)
  3114  	hds = append(hds, "Content-Type", "application/json")
  3115  	headers := gax.BuildHeaders(ctx, hds...)
  3116  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3117  	resp := &longrunningpb.Operation{}
  3118  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3119  		if settings.Path != "" {
  3120  			baseUrl.Path = settings.Path
  3121  		}
  3122  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3123  		if err != nil {
  3124  			return err
  3125  		}
  3126  		httpReq = httpReq.WithContext(ctx)
  3127  		httpReq.Header = headers
  3128  
  3129  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTensorboardTimeSeries")
  3130  		if err != nil {
  3131  			return err
  3132  		}
  3133  		if err := unm.Unmarshal(buf, resp); err != nil {
  3134  			return err
  3135  		}
  3136  
  3137  		return nil
  3138  	}, opts...)
  3139  	if e != nil {
  3140  		return nil, e
  3141  	}
  3142  
  3143  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3144  	return &DeleteTensorboardTimeSeriesOperation{
  3145  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3146  		pollPath: override,
  3147  	}, nil
  3148  }
  3149  
  3150  // BatchReadTensorboardTimeSeriesData reads multiple TensorboardTimeSeries’ data. The data point number limit is
  3151  // 1000 for scalars, 100 for tensors and blob references. If the number of
  3152  // data points stored is less than the limit, all data is returned.
  3153  // Otherwise, the number limit of data points is randomly selected from
  3154  // this time series and returned.
  3155  func (c *tensorboardRESTClient) BatchReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.BatchReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse, error) {
  3156  	baseUrl, err := url.Parse(c.endpoint)
  3157  	if err != nil {
  3158  		return nil, err
  3159  	}
  3160  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:batchRead", req.GetTensorboard())
  3161  
  3162  	params := url.Values{}
  3163  	params.Add("$alt", "json;enum-encoding=int")
  3164  	if items := req.GetTimeSeries(); len(items) > 0 {
  3165  		for _, item := range items {
  3166  			params.Add("timeSeries", fmt.Sprintf("%v", item))
  3167  		}
  3168  	}
  3169  
  3170  	baseUrl.RawQuery = params.Encode()
  3171  
  3172  	// Build HTTP headers from client and context metadata.
  3173  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard", url.QueryEscape(req.GetTensorboard()))}
  3174  
  3175  	hds = append(c.xGoogHeaders, hds...)
  3176  	hds = append(hds, "Content-Type", "application/json")
  3177  	headers := gax.BuildHeaders(ctx, hds...)
  3178  	opts = append((*c.CallOptions).BatchReadTensorboardTimeSeriesData[0:len((*c.CallOptions).BatchReadTensorboardTimeSeriesData):len((*c.CallOptions).BatchReadTensorboardTimeSeriesData)], opts...)
  3179  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3180  	resp := &aiplatformpb.BatchReadTensorboardTimeSeriesDataResponse{}
  3181  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3182  		if settings.Path != "" {
  3183  			baseUrl.Path = settings.Path
  3184  		}
  3185  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3186  		if err != nil {
  3187  			return err
  3188  		}
  3189  		httpReq = httpReq.WithContext(ctx)
  3190  		httpReq.Header = headers
  3191  
  3192  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "BatchReadTensorboardTimeSeriesData")
  3193  		if err != nil {
  3194  			return err
  3195  		}
  3196  
  3197  		if err := unm.Unmarshal(buf, resp); err != nil {
  3198  			return err
  3199  		}
  3200  
  3201  		return nil
  3202  	}, opts...)
  3203  	if e != nil {
  3204  		return nil, e
  3205  	}
  3206  	return resp, nil
  3207  }
  3208  
  3209  // ReadTensorboardTimeSeriesData reads a TensorboardTimeSeries’ data. By default, if the number of data
  3210  // points stored is less than 1000, all data is returned. Otherwise, 1000
  3211  // data points is randomly selected from this time series and returned.
  3212  // This value can be changed by changing max_data_points, which can’t be
  3213  // greater than 10k.
  3214  func (c *tensorboardRESTClient) ReadTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ReadTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) (*aiplatformpb.ReadTensorboardTimeSeriesDataResponse, error) {
  3215  	baseUrl, err := url.Parse(c.endpoint)
  3216  	if err != nil {
  3217  		return nil, err
  3218  	}
  3219  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:read", req.GetTensorboardTimeSeries())
  3220  
  3221  	params := url.Values{}
  3222  	params.Add("$alt", "json;enum-encoding=int")
  3223  	if req.GetFilter() != "" {
  3224  		params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3225  	}
  3226  	if req.GetMaxDataPoints() != 0 {
  3227  		params.Add("maxDataPoints", fmt.Sprintf("%v", req.GetMaxDataPoints()))
  3228  	}
  3229  
  3230  	baseUrl.RawQuery = params.Encode()
  3231  
  3232  	// Build HTTP headers from client and context metadata.
  3233  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_time_series", url.QueryEscape(req.GetTensorboardTimeSeries()))}
  3234  
  3235  	hds = append(c.xGoogHeaders, hds...)
  3236  	hds = append(hds, "Content-Type", "application/json")
  3237  	headers := gax.BuildHeaders(ctx, hds...)
  3238  	opts = append((*c.CallOptions).ReadTensorboardTimeSeriesData[0:len((*c.CallOptions).ReadTensorboardTimeSeriesData):len((*c.CallOptions).ReadTensorboardTimeSeriesData)], opts...)
  3239  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3240  	resp := &aiplatformpb.ReadTensorboardTimeSeriesDataResponse{}
  3241  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3242  		if settings.Path != "" {
  3243  			baseUrl.Path = settings.Path
  3244  		}
  3245  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3246  		if err != nil {
  3247  			return err
  3248  		}
  3249  		httpReq = httpReq.WithContext(ctx)
  3250  		httpReq.Header = headers
  3251  
  3252  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ReadTensorboardTimeSeriesData")
  3253  		if err != nil {
  3254  			return err
  3255  		}
  3256  
  3257  		if err := unm.Unmarshal(buf, resp); err != nil {
  3258  			return err
  3259  		}
  3260  
  3261  		return nil
  3262  	}, opts...)
  3263  	if e != nil {
  3264  		return nil, e
  3265  	}
  3266  	return resp, nil
  3267  }
  3268  
  3269  // ReadTensorboardBlobData gets bytes of TensorboardBlobs.
  3270  // This is to allow reading blob data stored in consumer project’s Cloud
  3271  // Storage bucket without users having to obtain Cloud Storage access
  3272  // permission.
  3273  func (c *tensorboardRESTClient) ReadTensorboardBlobData(ctx context.Context, req *aiplatformpb.ReadTensorboardBlobDataRequest, opts ...gax.CallOption) (aiplatformpb.TensorboardService_ReadTensorboardBlobDataClient, error) {
  3274  	baseUrl, err := url.Parse(c.endpoint)
  3275  	if err != nil {
  3276  		return nil, err
  3277  	}
  3278  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:readBlobData", req.GetTimeSeries())
  3279  
  3280  	params := url.Values{}
  3281  	params.Add("$alt", "json;enum-encoding=int")
  3282  	if items := req.GetBlobIds(); len(items) > 0 {
  3283  		for _, item := range items {
  3284  			params.Add("blobIds", fmt.Sprintf("%v", item))
  3285  		}
  3286  	}
  3287  
  3288  	baseUrl.RawQuery = params.Encode()
  3289  
  3290  	// Build HTTP headers from client and context metadata.
  3291  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "time_series", url.QueryEscape(req.GetTimeSeries()))}
  3292  
  3293  	hds = append(c.xGoogHeaders, hds...)
  3294  	hds = append(hds, "Content-Type", "application/json")
  3295  	headers := gax.BuildHeaders(ctx, hds...)
  3296  	var streamClient *readTensorboardBlobDataRESTStreamClient
  3297  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3298  		if settings.Path != "" {
  3299  			baseUrl.Path = settings.Path
  3300  		}
  3301  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3302  		if err != nil {
  3303  			return err
  3304  		}
  3305  		httpReq = httpReq.WithContext(ctx)
  3306  		httpReq.Header = headers
  3307  
  3308  		httpRsp, err := executeStreamingHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ReadTensorboardBlobData")
  3309  		if err != nil {
  3310  			return err
  3311  		}
  3312  
  3313  		streamClient = &readTensorboardBlobDataRESTStreamClient{
  3314  			ctx:    ctx,
  3315  			md:     metadata.MD(httpRsp.Header),
  3316  			stream: gax.NewProtoJSONStreamReader(httpRsp.Body, (&aiplatformpb.ReadTensorboardBlobDataResponse{}).ProtoReflect().Type()),
  3317  		}
  3318  		return nil
  3319  	}, opts...)
  3320  
  3321  	return streamClient, e
  3322  }
  3323  
  3324  // readTensorboardBlobDataRESTStreamClient is the stream client used to consume the server stream created by
  3325  // the REST implementation of ReadTensorboardBlobData.
  3326  type readTensorboardBlobDataRESTStreamClient struct {
  3327  	ctx    context.Context
  3328  	md     metadata.MD
  3329  	stream *gax.ProtoJSONStream
  3330  }
  3331  
  3332  func (c *readTensorboardBlobDataRESTStreamClient) Recv() (*aiplatformpb.ReadTensorboardBlobDataResponse, error) {
  3333  	if err := c.ctx.Err(); err != nil {
  3334  		defer c.stream.Close()
  3335  		return nil, err
  3336  	}
  3337  	msg, err := c.stream.Recv()
  3338  	if err != nil {
  3339  		defer c.stream.Close()
  3340  		return nil, err
  3341  	}
  3342  	res := msg.(*aiplatformpb.ReadTensorboardBlobDataResponse)
  3343  	return res, nil
  3344  }
  3345  
  3346  func (c *readTensorboardBlobDataRESTStreamClient) Header() (metadata.MD, error) {
  3347  	return c.md, nil
  3348  }
  3349  
  3350  func (c *readTensorboardBlobDataRESTStreamClient) Trailer() metadata.MD {
  3351  	return c.md
  3352  }
  3353  
  3354  func (c *readTensorboardBlobDataRESTStreamClient) CloseSend() error {
  3355  	// This is a no-op to fulfill the interface.
  3356  	return errors.New("this method is not implemented for a server-stream")
  3357  }
  3358  
  3359  func (c *readTensorboardBlobDataRESTStreamClient) Context() context.Context {
  3360  	return c.ctx
  3361  }
  3362  
  3363  func (c *readTensorboardBlobDataRESTStreamClient) SendMsg(m interface{}) error {
  3364  	// This is a no-op to fulfill the interface.
  3365  	return errors.New("this method is not implemented for a server-stream")
  3366  }
  3367  
  3368  func (c *readTensorboardBlobDataRESTStreamClient) RecvMsg(m interface{}) error {
  3369  	// This is a no-op to fulfill the interface.
  3370  	return errors.New("this method is not implemented, use Recv")
  3371  }
  3372  
  3373  // WriteTensorboardExperimentData write time series data points of multiple TensorboardTimeSeries in multiple
  3374  // TensorboardRun’s. If any data fail to be ingested, an error is returned.
  3375  func (c *tensorboardRESTClient) WriteTensorboardExperimentData(ctx context.Context, req *aiplatformpb.WriteTensorboardExperimentDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardExperimentDataResponse, error) {
  3376  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3377  	jsonReq, err := m.Marshal(req)
  3378  	if err != nil {
  3379  		return nil, err
  3380  	}
  3381  
  3382  	baseUrl, err := url.Parse(c.endpoint)
  3383  	if err != nil {
  3384  		return nil, err
  3385  	}
  3386  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:write", req.GetTensorboardExperiment())
  3387  
  3388  	params := url.Values{}
  3389  	params.Add("$alt", "json;enum-encoding=int")
  3390  
  3391  	baseUrl.RawQuery = params.Encode()
  3392  
  3393  	// Build HTTP headers from client and context metadata.
  3394  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_experiment", url.QueryEscape(req.GetTensorboardExperiment()))}
  3395  
  3396  	hds = append(c.xGoogHeaders, hds...)
  3397  	hds = append(hds, "Content-Type", "application/json")
  3398  	headers := gax.BuildHeaders(ctx, hds...)
  3399  	opts = append((*c.CallOptions).WriteTensorboardExperimentData[0:len((*c.CallOptions).WriteTensorboardExperimentData):len((*c.CallOptions).WriteTensorboardExperimentData)], opts...)
  3400  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3401  	resp := &aiplatformpb.WriteTensorboardExperimentDataResponse{}
  3402  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3403  		if settings.Path != "" {
  3404  			baseUrl.Path = settings.Path
  3405  		}
  3406  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3407  		if err != nil {
  3408  			return err
  3409  		}
  3410  		httpReq = httpReq.WithContext(ctx)
  3411  		httpReq.Header = headers
  3412  
  3413  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "WriteTensorboardExperimentData")
  3414  		if err != nil {
  3415  			return err
  3416  		}
  3417  
  3418  		if err := unm.Unmarshal(buf, resp); err != nil {
  3419  			return err
  3420  		}
  3421  
  3422  		return nil
  3423  	}, opts...)
  3424  	if e != nil {
  3425  		return nil, e
  3426  	}
  3427  	return resp, nil
  3428  }
  3429  
  3430  // WriteTensorboardRunData write time series data points into multiple TensorboardTimeSeries under
  3431  // a TensorboardRun. If any data fail to be ingested, an error is returned.
  3432  func (c *tensorboardRESTClient) WriteTensorboardRunData(ctx context.Context, req *aiplatformpb.WriteTensorboardRunDataRequest, opts ...gax.CallOption) (*aiplatformpb.WriteTensorboardRunDataResponse, error) {
  3433  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3434  	jsonReq, err := m.Marshal(req)
  3435  	if err != nil {
  3436  		return nil, err
  3437  	}
  3438  
  3439  	baseUrl, err := url.Parse(c.endpoint)
  3440  	if err != nil {
  3441  		return nil, err
  3442  	}
  3443  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:write", req.GetTensorboardRun())
  3444  
  3445  	params := url.Values{}
  3446  	params.Add("$alt", "json;enum-encoding=int")
  3447  
  3448  	baseUrl.RawQuery = params.Encode()
  3449  
  3450  	// Build HTTP headers from client and context metadata.
  3451  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tensorboard_run", url.QueryEscape(req.GetTensorboardRun()))}
  3452  
  3453  	hds = append(c.xGoogHeaders, hds...)
  3454  	hds = append(hds, "Content-Type", "application/json")
  3455  	headers := gax.BuildHeaders(ctx, hds...)
  3456  	opts = append((*c.CallOptions).WriteTensorboardRunData[0:len((*c.CallOptions).WriteTensorboardRunData):len((*c.CallOptions).WriteTensorboardRunData)], opts...)
  3457  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3458  	resp := &aiplatformpb.WriteTensorboardRunDataResponse{}
  3459  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3460  		if settings.Path != "" {
  3461  			baseUrl.Path = settings.Path
  3462  		}
  3463  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3464  		if err != nil {
  3465  			return err
  3466  		}
  3467  		httpReq = httpReq.WithContext(ctx)
  3468  		httpReq.Header = headers
  3469  
  3470  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "WriteTensorboardRunData")
  3471  		if err != nil {
  3472  			return err
  3473  		}
  3474  
  3475  		if err := unm.Unmarshal(buf, resp); err != nil {
  3476  			return err
  3477  		}
  3478  
  3479  		return nil
  3480  	}, opts...)
  3481  	if e != nil {
  3482  		return nil, e
  3483  	}
  3484  	return resp, nil
  3485  }
  3486  
  3487  // ExportTensorboardTimeSeriesData exports a TensorboardTimeSeries’ data. Data is returned in paginated
  3488  // responses.
  3489  func (c *tensorboardRESTClient) ExportTensorboardTimeSeriesData(ctx context.Context, req *aiplatformpb.ExportTensorboardTimeSeriesDataRequest, opts ...gax.CallOption) *TimeSeriesDataPointIterator {
  3490  	it := &TimeSeriesDataPointIterator{}
  3491  	req = proto.Clone(req).(*aiplatformpb.ExportTensorboardTimeSeriesDataRequest)
  3492  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3493  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3494  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.TimeSeriesDataPoint, string, error) {
  3495  		resp := &aiplatformpb.ExportTensorboardTimeSeriesDataResponse{}
  3496  		if pageToken != "" {
  3497  			req.PageToken = pageToken
  3498  		}
  3499  		if pageSize > math.MaxInt32 {
  3500  			req.PageSize = math.MaxInt32
  3501  		} else if pageSize != 0 {
  3502  			req.PageSize = int32(pageSize)
  3503  		}
  3504  		jsonReq, err := m.Marshal(req)
  3505  		if err != nil {
  3506  			return nil, "", err
  3507  		}
  3508  
  3509  		baseUrl, err := url.Parse(c.endpoint)
  3510  		if err != nil {
  3511  			return nil, "", err
  3512  		}
  3513  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v:exportTensorboardTimeSeries", req.GetTensorboardTimeSeries())
  3514  
  3515  		params := url.Values{}
  3516  		params.Add("$alt", "json;enum-encoding=int")
  3517  
  3518  		baseUrl.RawQuery = params.Encode()
  3519  
  3520  		// Build HTTP headers from client and context metadata.
  3521  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3522  		headers := gax.BuildHeaders(ctx, hds...)
  3523  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3524  			if settings.Path != "" {
  3525  				baseUrl.Path = settings.Path
  3526  			}
  3527  			httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3528  			if err != nil {
  3529  				return err
  3530  			}
  3531  			httpReq.Header = headers
  3532  
  3533  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportTensorboardTimeSeriesData")
  3534  			if err != nil {
  3535  				return err
  3536  			}
  3537  			if err := unm.Unmarshal(buf, resp); err != nil {
  3538  				return err
  3539  			}
  3540  
  3541  			return nil
  3542  		}, opts...)
  3543  		if e != nil {
  3544  			return nil, "", e
  3545  		}
  3546  		it.Response = resp
  3547  		return resp.GetTimeSeriesDataPoints(), resp.GetNextPageToken(), nil
  3548  	}
  3549  
  3550  	fetch := func(pageSize int, pageToken string) (string, error) {
  3551  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3552  		if err != nil {
  3553  			return "", err
  3554  		}
  3555  		it.items = append(it.items, items...)
  3556  		return nextPageToken, nil
  3557  	}
  3558  
  3559  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3560  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3561  	it.pageInfo.Token = req.GetPageToken()
  3562  
  3563  	return it
  3564  }
  3565  
  3566  // GetLocation gets information about a location.
  3567  func (c *tensorboardRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  3568  	baseUrl, err := url.Parse(c.endpoint)
  3569  	if err != nil {
  3570  		return nil, err
  3571  	}
  3572  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3573  
  3574  	params := url.Values{}
  3575  	params.Add("$alt", "json;enum-encoding=int")
  3576  
  3577  	baseUrl.RawQuery = params.Encode()
  3578  
  3579  	// Build HTTP headers from client and context metadata.
  3580  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3581  
  3582  	hds = append(c.xGoogHeaders, hds...)
  3583  	hds = append(hds, "Content-Type", "application/json")
  3584  	headers := gax.BuildHeaders(ctx, hds...)
  3585  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  3586  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3587  	resp := &locationpb.Location{}
  3588  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3589  		if settings.Path != "" {
  3590  			baseUrl.Path = settings.Path
  3591  		}
  3592  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3593  		if err != nil {
  3594  			return err
  3595  		}
  3596  		httpReq = httpReq.WithContext(ctx)
  3597  		httpReq.Header = headers
  3598  
  3599  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  3600  		if err != nil {
  3601  			return err
  3602  		}
  3603  
  3604  		if err := unm.Unmarshal(buf, resp); err != nil {
  3605  			return err
  3606  		}
  3607  
  3608  		return nil
  3609  	}, opts...)
  3610  	if e != nil {
  3611  		return nil, e
  3612  	}
  3613  	return resp, nil
  3614  }
  3615  
  3616  // ListLocations lists information about the supported locations for this service.
  3617  func (c *tensorboardRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  3618  	it := &LocationIterator{}
  3619  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  3620  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3621  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  3622  		resp := &locationpb.ListLocationsResponse{}
  3623  		if pageToken != "" {
  3624  			req.PageToken = pageToken
  3625  		}
  3626  		if pageSize > math.MaxInt32 {
  3627  			req.PageSize = math.MaxInt32
  3628  		} else if pageSize != 0 {
  3629  			req.PageSize = int32(pageSize)
  3630  		}
  3631  		baseUrl, err := url.Parse(c.endpoint)
  3632  		if err != nil {
  3633  			return nil, "", err
  3634  		}
  3635  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  3636  
  3637  		params := url.Values{}
  3638  		params.Add("$alt", "json;enum-encoding=int")
  3639  		if req.GetFilter() != "" {
  3640  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3641  		}
  3642  		if req.GetPageSize() != 0 {
  3643  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3644  		}
  3645  		if req.GetPageToken() != "" {
  3646  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3647  		}
  3648  
  3649  		baseUrl.RawQuery = params.Encode()
  3650  
  3651  		// Build HTTP headers from client and context metadata.
  3652  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3653  		headers := gax.BuildHeaders(ctx, hds...)
  3654  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3655  			if settings.Path != "" {
  3656  				baseUrl.Path = settings.Path
  3657  			}
  3658  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3659  			if err != nil {
  3660  				return err
  3661  			}
  3662  			httpReq.Header = headers
  3663  
  3664  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  3665  			if err != nil {
  3666  				return err
  3667  			}
  3668  			if err := unm.Unmarshal(buf, resp); err != nil {
  3669  				return err
  3670  			}
  3671  
  3672  			return nil
  3673  		}, opts...)
  3674  		if e != nil {
  3675  			return nil, "", e
  3676  		}
  3677  		it.Response = resp
  3678  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  3679  	}
  3680  
  3681  	fetch := func(pageSize int, pageToken string) (string, error) {
  3682  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3683  		if err != nil {
  3684  			return "", err
  3685  		}
  3686  		it.items = append(it.items, items...)
  3687  		return nextPageToken, nil
  3688  	}
  3689  
  3690  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3691  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3692  	it.pageInfo.Token = req.GetPageToken()
  3693  
  3694  	return it
  3695  }
  3696  
  3697  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  3698  // if the resource exists and does not have a policy set.
  3699  func (c *tensorboardRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  3700  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3701  	jsonReq, err := m.Marshal(req)
  3702  	if err != nil {
  3703  		return nil, err
  3704  	}
  3705  
  3706  	baseUrl, err := url.Parse(c.endpoint)
  3707  	if err != nil {
  3708  		return nil, err
  3709  	}
  3710  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  3711  
  3712  	params := url.Values{}
  3713  	params.Add("$alt", "json;enum-encoding=int")
  3714  
  3715  	baseUrl.RawQuery = params.Encode()
  3716  
  3717  	// Build HTTP headers from client and context metadata.
  3718  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  3719  
  3720  	hds = append(c.xGoogHeaders, hds...)
  3721  	hds = append(hds, "Content-Type", "application/json")
  3722  	headers := gax.BuildHeaders(ctx, hds...)
  3723  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  3724  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3725  	resp := &iampb.Policy{}
  3726  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3727  		if settings.Path != "" {
  3728  			baseUrl.Path = settings.Path
  3729  		}
  3730  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3731  		if err != nil {
  3732  			return err
  3733  		}
  3734  		httpReq = httpReq.WithContext(ctx)
  3735  		httpReq.Header = headers
  3736  
  3737  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  3738  		if err != nil {
  3739  			return err
  3740  		}
  3741  
  3742  		if err := unm.Unmarshal(buf, resp); err != nil {
  3743  			return err
  3744  		}
  3745  
  3746  		return nil
  3747  	}, opts...)
  3748  	if e != nil {
  3749  		return nil, e
  3750  	}
  3751  	return resp, nil
  3752  }
  3753  
  3754  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  3755  // any existing policy.
  3756  //
  3757  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  3758  // errors.
  3759  func (c *tensorboardRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  3760  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3761  	jsonReq, err := m.Marshal(req)
  3762  	if err != nil {
  3763  		return nil, err
  3764  	}
  3765  
  3766  	baseUrl, err := url.Parse(c.endpoint)
  3767  	if err != nil {
  3768  		return nil, err
  3769  	}
  3770  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  3771  
  3772  	params := url.Values{}
  3773  	params.Add("$alt", "json;enum-encoding=int")
  3774  
  3775  	baseUrl.RawQuery = params.Encode()
  3776  
  3777  	// Build HTTP headers from client and context metadata.
  3778  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  3779  
  3780  	hds = append(c.xGoogHeaders, hds...)
  3781  	hds = append(hds, "Content-Type", "application/json")
  3782  	headers := gax.BuildHeaders(ctx, hds...)
  3783  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  3784  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3785  	resp := &iampb.Policy{}
  3786  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3787  		if settings.Path != "" {
  3788  			baseUrl.Path = settings.Path
  3789  		}
  3790  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3791  		if err != nil {
  3792  			return err
  3793  		}
  3794  		httpReq = httpReq.WithContext(ctx)
  3795  		httpReq.Header = headers
  3796  
  3797  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  3798  		if err != nil {
  3799  			return err
  3800  		}
  3801  
  3802  		if err := unm.Unmarshal(buf, resp); err != nil {
  3803  			return err
  3804  		}
  3805  
  3806  		return nil
  3807  	}, opts...)
  3808  	if e != nil {
  3809  		return nil, e
  3810  	}
  3811  	return resp, nil
  3812  }
  3813  
  3814  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  3815  // resource does not exist, this will return an empty set of
  3816  // permissions, not a NOT_FOUND error.
  3817  //
  3818  // Note: This operation is designed to be used for building
  3819  // permission-aware UIs and command-line tools, not for authorization
  3820  // checking. This operation may “fail open” without warning.
  3821  func (c *tensorboardRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  3822  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3823  	jsonReq, err := m.Marshal(req)
  3824  	if err != nil {
  3825  		return nil, err
  3826  	}
  3827  
  3828  	baseUrl, err := url.Parse(c.endpoint)
  3829  	if err != nil {
  3830  		return nil, err
  3831  	}
  3832  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  3833  
  3834  	params := url.Values{}
  3835  	params.Add("$alt", "json;enum-encoding=int")
  3836  
  3837  	baseUrl.RawQuery = params.Encode()
  3838  
  3839  	// Build HTTP headers from client and context metadata.
  3840  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  3841  
  3842  	hds = append(c.xGoogHeaders, hds...)
  3843  	hds = append(hds, "Content-Type", "application/json")
  3844  	headers := gax.BuildHeaders(ctx, hds...)
  3845  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  3846  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3847  	resp := &iampb.TestIamPermissionsResponse{}
  3848  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3849  		if settings.Path != "" {
  3850  			baseUrl.Path = settings.Path
  3851  		}
  3852  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3853  		if err != nil {
  3854  			return err
  3855  		}
  3856  		httpReq = httpReq.WithContext(ctx)
  3857  		httpReq.Header = headers
  3858  
  3859  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  3860  		if err != nil {
  3861  			return err
  3862  		}
  3863  
  3864  		if err := unm.Unmarshal(buf, resp); err != nil {
  3865  			return err
  3866  		}
  3867  
  3868  		return nil
  3869  	}, opts...)
  3870  	if e != nil {
  3871  		return nil, e
  3872  	}
  3873  	return resp, nil
  3874  }
  3875  
  3876  // CancelOperation is a utility method from google.longrunning.Operations.
  3877  func (c *tensorboardRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  3878  	baseUrl, err := url.Parse(c.endpoint)
  3879  	if err != nil {
  3880  		return err
  3881  	}
  3882  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  3883  
  3884  	params := url.Values{}
  3885  	params.Add("$alt", "json;enum-encoding=int")
  3886  
  3887  	baseUrl.RawQuery = params.Encode()
  3888  
  3889  	// Build HTTP headers from client and context metadata.
  3890  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3891  
  3892  	hds = append(c.xGoogHeaders, hds...)
  3893  	hds = append(hds, "Content-Type", "application/json")
  3894  	headers := gax.BuildHeaders(ctx, hds...)
  3895  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3896  		if settings.Path != "" {
  3897  			baseUrl.Path = settings.Path
  3898  		}
  3899  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  3900  		if err != nil {
  3901  			return err
  3902  		}
  3903  		httpReq = httpReq.WithContext(ctx)
  3904  		httpReq.Header = headers
  3905  
  3906  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  3907  		return err
  3908  	}, opts...)
  3909  }
  3910  
  3911  // DeleteOperation is a utility method from google.longrunning.Operations.
  3912  func (c *tensorboardRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  3913  	baseUrl, err := url.Parse(c.endpoint)
  3914  	if err != nil {
  3915  		return err
  3916  	}
  3917  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3918  
  3919  	params := url.Values{}
  3920  	params.Add("$alt", "json;enum-encoding=int")
  3921  
  3922  	baseUrl.RawQuery = params.Encode()
  3923  
  3924  	// Build HTTP headers from client and context metadata.
  3925  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3926  
  3927  	hds = append(c.xGoogHeaders, hds...)
  3928  	hds = append(hds, "Content-Type", "application/json")
  3929  	headers := gax.BuildHeaders(ctx, hds...)
  3930  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3931  		if settings.Path != "" {
  3932  			baseUrl.Path = settings.Path
  3933  		}
  3934  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3935  		if err != nil {
  3936  			return err
  3937  		}
  3938  		httpReq = httpReq.WithContext(ctx)
  3939  		httpReq.Header = headers
  3940  
  3941  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  3942  		return err
  3943  	}, opts...)
  3944  }
  3945  
  3946  // GetOperation is a utility method from google.longrunning.Operations.
  3947  func (c *tensorboardRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  3948  	baseUrl, err := url.Parse(c.endpoint)
  3949  	if err != nil {
  3950  		return nil, err
  3951  	}
  3952  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3953  
  3954  	params := url.Values{}
  3955  	params.Add("$alt", "json;enum-encoding=int")
  3956  
  3957  	baseUrl.RawQuery = params.Encode()
  3958  
  3959  	// Build HTTP headers from client and context metadata.
  3960  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3961  
  3962  	hds = append(c.xGoogHeaders, hds...)
  3963  	hds = append(hds, "Content-Type", "application/json")
  3964  	headers := gax.BuildHeaders(ctx, hds...)
  3965  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  3966  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3967  	resp := &longrunningpb.Operation{}
  3968  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3969  		if settings.Path != "" {
  3970  			baseUrl.Path = settings.Path
  3971  		}
  3972  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3973  		if err != nil {
  3974  			return err
  3975  		}
  3976  		httpReq = httpReq.WithContext(ctx)
  3977  		httpReq.Header = headers
  3978  
  3979  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  3980  		if err != nil {
  3981  			return err
  3982  		}
  3983  
  3984  		if err := unm.Unmarshal(buf, resp); err != nil {
  3985  			return err
  3986  		}
  3987  
  3988  		return nil
  3989  	}, opts...)
  3990  	if e != nil {
  3991  		return nil, e
  3992  	}
  3993  	return resp, nil
  3994  }
  3995  
  3996  // ListOperations is a utility method from google.longrunning.Operations.
  3997  func (c *tensorboardRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  3998  	it := &OperationIterator{}
  3999  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  4000  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4001  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  4002  		resp := &longrunningpb.ListOperationsResponse{}
  4003  		if pageToken != "" {
  4004  			req.PageToken = pageToken
  4005  		}
  4006  		if pageSize > math.MaxInt32 {
  4007  			req.PageSize = math.MaxInt32
  4008  		} else if pageSize != 0 {
  4009  			req.PageSize = int32(pageSize)
  4010  		}
  4011  		baseUrl, err := url.Parse(c.endpoint)
  4012  		if err != nil {
  4013  			return nil, "", err
  4014  		}
  4015  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  4016  
  4017  		params := url.Values{}
  4018  		params.Add("$alt", "json;enum-encoding=int")
  4019  		if req.GetFilter() != "" {
  4020  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  4021  		}
  4022  		if req.GetPageSize() != 0 {
  4023  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  4024  		}
  4025  		if req.GetPageToken() != "" {
  4026  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  4027  		}
  4028  
  4029  		baseUrl.RawQuery = params.Encode()
  4030  
  4031  		// Build HTTP headers from client and context metadata.
  4032  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  4033  		headers := gax.BuildHeaders(ctx, hds...)
  4034  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4035  			if settings.Path != "" {
  4036  				baseUrl.Path = settings.Path
  4037  			}
  4038  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4039  			if err != nil {
  4040  				return err
  4041  			}
  4042  			httpReq.Header = headers
  4043  
  4044  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  4045  			if err != nil {
  4046  				return err
  4047  			}
  4048  			if err := unm.Unmarshal(buf, resp); err != nil {
  4049  				return err
  4050  			}
  4051  
  4052  			return nil
  4053  		}, opts...)
  4054  		if e != nil {
  4055  			return nil, "", e
  4056  		}
  4057  		it.Response = resp
  4058  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  4059  	}
  4060  
  4061  	fetch := func(pageSize int, pageToken string) (string, error) {
  4062  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  4063  		if err != nil {
  4064  			return "", err
  4065  		}
  4066  		it.items = append(it.items, items...)
  4067  		return nextPageToken, nil
  4068  	}
  4069  
  4070  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  4071  	it.pageInfo.MaxSize = int(req.GetPageSize())
  4072  	it.pageInfo.Token = req.GetPageToken()
  4073  
  4074  	return it
  4075  }
  4076  
  4077  // WaitOperation is a utility method from google.longrunning.Operations.
  4078  func (c *tensorboardRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  4079  	baseUrl, err := url.Parse(c.endpoint)
  4080  	if err != nil {
  4081  		return nil, err
  4082  	}
  4083  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  4084  
  4085  	params := url.Values{}
  4086  	params.Add("$alt", "json;enum-encoding=int")
  4087  	if req.GetTimeout() != nil {
  4088  		field, err := protojson.Marshal(req.GetTimeout())
  4089  		if err != nil {
  4090  			return nil, err
  4091  		}
  4092  		params.Add("timeout", string(field[1:len(field)-1]))
  4093  	}
  4094  
  4095  	baseUrl.RawQuery = params.Encode()
  4096  
  4097  	// Build HTTP headers from client and context metadata.
  4098  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4099  
  4100  	hds = append(c.xGoogHeaders, hds...)
  4101  	hds = append(hds, "Content-Type", "application/json")
  4102  	headers := gax.BuildHeaders(ctx, hds...)
  4103  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  4104  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4105  	resp := &longrunningpb.Operation{}
  4106  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4107  		if settings.Path != "" {
  4108  			baseUrl.Path = settings.Path
  4109  		}
  4110  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  4111  		if err != nil {
  4112  			return err
  4113  		}
  4114  		httpReq = httpReq.WithContext(ctx)
  4115  		httpReq.Header = headers
  4116  
  4117  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  4118  		if err != nil {
  4119  			return err
  4120  		}
  4121  
  4122  		if err := unm.Unmarshal(buf, resp); err != nil {
  4123  			return err
  4124  		}
  4125  
  4126  		return nil
  4127  	}, opts...)
  4128  	if e != nil {
  4129  		return nil, e
  4130  	}
  4131  	return resp, nil
  4132  }
  4133  
  4134  // CreateTensorboardOperation returns a new CreateTensorboardOperation from a given name.
  4135  // The name must be that of a previously created CreateTensorboardOperation, possibly from a different process.
  4136  func (c *tensorboardGRPCClient) CreateTensorboardOperation(name string) *CreateTensorboardOperation {
  4137  	return &CreateTensorboardOperation{
  4138  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4139  	}
  4140  }
  4141  
  4142  // CreateTensorboardOperation returns a new CreateTensorboardOperation from a given name.
  4143  // The name must be that of a previously created CreateTensorboardOperation, possibly from a different process.
  4144  func (c *tensorboardRESTClient) CreateTensorboardOperation(name string) *CreateTensorboardOperation {
  4145  	override := fmt.Sprintf("/ui/%s", name)
  4146  	return &CreateTensorboardOperation{
  4147  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4148  		pollPath: override,
  4149  	}
  4150  }
  4151  
  4152  // DeleteTensorboardOperation returns a new DeleteTensorboardOperation from a given name.
  4153  // The name must be that of a previously created DeleteTensorboardOperation, possibly from a different process.
  4154  func (c *tensorboardGRPCClient) DeleteTensorboardOperation(name string) *DeleteTensorboardOperation {
  4155  	return &DeleteTensorboardOperation{
  4156  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4157  	}
  4158  }
  4159  
  4160  // DeleteTensorboardOperation returns a new DeleteTensorboardOperation from a given name.
  4161  // The name must be that of a previously created DeleteTensorboardOperation, possibly from a different process.
  4162  func (c *tensorboardRESTClient) DeleteTensorboardOperation(name string) *DeleteTensorboardOperation {
  4163  	override := fmt.Sprintf("/ui/%s", name)
  4164  	return &DeleteTensorboardOperation{
  4165  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4166  		pollPath: override,
  4167  	}
  4168  }
  4169  
  4170  // DeleteTensorboardExperimentOperation returns a new DeleteTensorboardExperimentOperation from a given name.
  4171  // The name must be that of a previously created DeleteTensorboardExperimentOperation, possibly from a different process.
  4172  func (c *tensorboardGRPCClient) DeleteTensorboardExperimentOperation(name string) *DeleteTensorboardExperimentOperation {
  4173  	return &DeleteTensorboardExperimentOperation{
  4174  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4175  	}
  4176  }
  4177  
  4178  // DeleteTensorboardExperimentOperation returns a new DeleteTensorboardExperimentOperation from a given name.
  4179  // The name must be that of a previously created DeleteTensorboardExperimentOperation, possibly from a different process.
  4180  func (c *tensorboardRESTClient) DeleteTensorboardExperimentOperation(name string) *DeleteTensorboardExperimentOperation {
  4181  	override := fmt.Sprintf("/ui/%s", name)
  4182  	return &DeleteTensorboardExperimentOperation{
  4183  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4184  		pollPath: override,
  4185  	}
  4186  }
  4187  
  4188  // DeleteTensorboardRunOperation returns a new DeleteTensorboardRunOperation from a given name.
  4189  // The name must be that of a previously created DeleteTensorboardRunOperation, possibly from a different process.
  4190  func (c *tensorboardGRPCClient) DeleteTensorboardRunOperation(name string) *DeleteTensorboardRunOperation {
  4191  	return &DeleteTensorboardRunOperation{
  4192  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4193  	}
  4194  }
  4195  
  4196  // DeleteTensorboardRunOperation returns a new DeleteTensorboardRunOperation from a given name.
  4197  // The name must be that of a previously created DeleteTensorboardRunOperation, possibly from a different process.
  4198  func (c *tensorboardRESTClient) DeleteTensorboardRunOperation(name string) *DeleteTensorboardRunOperation {
  4199  	override := fmt.Sprintf("/ui/%s", name)
  4200  	return &DeleteTensorboardRunOperation{
  4201  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4202  		pollPath: override,
  4203  	}
  4204  }
  4205  
  4206  // DeleteTensorboardTimeSeriesOperation returns a new DeleteTensorboardTimeSeriesOperation from a given name.
  4207  // The name must be that of a previously created DeleteTensorboardTimeSeriesOperation, possibly from a different process.
  4208  func (c *tensorboardGRPCClient) DeleteTensorboardTimeSeriesOperation(name string) *DeleteTensorboardTimeSeriesOperation {
  4209  	return &DeleteTensorboardTimeSeriesOperation{
  4210  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4211  	}
  4212  }
  4213  
  4214  // DeleteTensorboardTimeSeriesOperation returns a new DeleteTensorboardTimeSeriesOperation from a given name.
  4215  // The name must be that of a previously created DeleteTensorboardTimeSeriesOperation, possibly from a different process.
  4216  func (c *tensorboardRESTClient) DeleteTensorboardTimeSeriesOperation(name string) *DeleteTensorboardTimeSeriesOperation {
  4217  	override := fmt.Sprintf("/ui/%s", name)
  4218  	return &DeleteTensorboardTimeSeriesOperation{
  4219  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4220  		pollPath: override,
  4221  	}
  4222  }
  4223  
  4224  // UpdateTensorboardOperation returns a new UpdateTensorboardOperation from a given name.
  4225  // The name must be that of a previously created UpdateTensorboardOperation, possibly from a different process.
  4226  func (c *tensorboardGRPCClient) UpdateTensorboardOperation(name string) *UpdateTensorboardOperation {
  4227  	return &UpdateTensorboardOperation{
  4228  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4229  	}
  4230  }
  4231  
  4232  // UpdateTensorboardOperation returns a new UpdateTensorboardOperation from a given name.
  4233  // The name must be that of a previously created UpdateTensorboardOperation, possibly from a different process.
  4234  func (c *tensorboardRESTClient) UpdateTensorboardOperation(name string) *UpdateTensorboardOperation {
  4235  	override := fmt.Sprintf("/ui/%s", name)
  4236  	return &UpdateTensorboardOperation{
  4237  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4238  		pollPath: override,
  4239  	}
  4240  }