cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/example_store_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 "fmt" 23 "log/slog" 24 "math" 25 "net/http" 26 "net/url" 27 28 aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb" 29 iampb "cloud.google.com/go/iam/apiv1/iampb" 30 "cloud.google.com/go/longrunning" 31 lroauto "cloud.google.com/go/longrunning/autogen" 32 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 33 gax "github.com/googleapis/gax-go/v2" 34 "google.golang.org/api/iterator" 35 "google.golang.org/api/option" 36 "google.golang.org/api/option/internaloption" 37 gtransport "google.golang.org/api/transport/grpc" 38 httptransport "google.golang.org/api/transport/http" 39 locationpb "google.golang.org/genproto/googleapis/cloud/location" 40 "google.golang.org/grpc" 41 "google.golang.org/protobuf/encoding/protojson" 42 "google.golang.org/protobuf/proto" 43 ) 44 45 var newExampleStoreClientHook clientHook 46 47 // ExampleStoreCallOptions contains the retry settings for each method of ExampleStoreClient. 48 type ExampleStoreCallOptions struct { 49 CreateExampleStore []gax.CallOption 50 GetExampleStore []gax.CallOption 51 UpdateExampleStore []gax.CallOption 52 DeleteExampleStore []gax.CallOption 53 ListExampleStores []gax.CallOption 54 UpsertExamples []gax.CallOption 55 RemoveExamples []gax.CallOption 56 SearchExamples []gax.CallOption 57 FetchExamples []gax.CallOption 58 GetLocation []gax.CallOption 59 ListLocations []gax.CallOption 60 GetIamPolicy []gax.CallOption 61 SetIamPolicy []gax.CallOption 62 TestIamPermissions []gax.CallOption 63 CancelOperation []gax.CallOption 64 DeleteOperation []gax.CallOption 65 GetOperation []gax.CallOption 66 ListOperations []gax.CallOption 67 WaitOperation []gax.CallOption 68 } 69 70 func defaultExampleStoreGRPCClientOptions() []option.ClientOption { 71 return []option.ClientOption{ 72 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 73 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 74 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 75 internaloption.WithDefaultUniverseDomain("googleapis.com"), 76 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 77 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 78 internaloption.EnableJwtWithScope(), 79 internaloption.EnableNewAuthLibrary(), 80 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 81 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 82 } 83 } 84 85 func defaultExampleStoreCallOptions() *ExampleStoreCallOptions { 86 return &ExampleStoreCallOptions{ 87 CreateExampleStore: []gax.CallOption{}, 88 GetExampleStore: []gax.CallOption{}, 89 UpdateExampleStore: []gax.CallOption{}, 90 DeleteExampleStore: []gax.CallOption{}, 91 ListExampleStores: []gax.CallOption{}, 92 UpsertExamples: []gax.CallOption{}, 93 RemoveExamples: []gax.CallOption{}, 94 SearchExamples: []gax.CallOption{}, 95 FetchExamples: []gax.CallOption{}, 96 GetLocation: []gax.CallOption{}, 97 ListLocations: []gax.CallOption{}, 98 GetIamPolicy: []gax.CallOption{}, 99 SetIamPolicy: []gax.CallOption{}, 100 TestIamPermissions: []gax.CallOption{}, 101 CancelOperation: []gax.CallOption{}, 102 DeleteOperation: []gax.CallOption{}, 103 GetOperation: []gax.CallOption{}, 104 ListOperations: []gax.CallOption{}, 105 WaitOperation: []gax.CallOption{}, 106 } 107 } 108 109 func defaultExampleStoreRESTCallOptions() *ExampleStoreCallOptions { 110 return &ExampleStoreCallOptions{ 111 CreateExampleStore: []gax.CallOption{}, 112 GetExampleStore: []gax.CallOption{}, 113 UpdateExampleStore: []gax.CallOption{}, 114 DeleteExampleStore: []gax.CallOption{}, 115 ListExampleStores: []gax.CallOption{}, 116 UpsertExamples: []gax.CallOption{}, 117 RemoveExamples: []gax.CallOption{}, 118 SearchExamples: []gax.CallOption{}, 119 FetchExamples: []gax.CallOption{}, 120 GetLocation: []gax.CallOption{}, 121 ListLocations: []gax.CallOption{}, 122 GetIamPolicy: []gax.CallOption{}, 123 SetIamPolicy: []gax.CallOption{}, 124 TestIamPermissions: []gax.CallOption{}, 125 CancelOperation: []gax.CallOption{}, 126 DeleteOperation: []gax.CallOption{}, 127 GetOperation: []gax.CallOption{}, 128 ListOperations: []gax.CallOption{}, 129 WaitOperation: []gax.CallOption{}, 130 } 131 } 132 133 // internalExampleStoreClient is an interface that defines the methods available from Vertex AI API. 134 type internalExampleStoreClient interface { 135 Close() error 136 setGoogleClientInfo(...string) 137 Connection() *grpc.ClientConn 138 CreateExampleStore(context.Context, *aiplatformpb.CreateExampleStoreRequest, ...gax.CallOption) (*CreateExampleStoreOperation, error) 139 CreateExampleStoreOperation(name string) *CreateExampleStoreOperation 140 GetExampleStore(context.Context, *aiplatformpb.GetExampleStoreRequest, ...gax.CallOption) (*aiplatformpb.ExampleStore, error) 141 UpdateExampleStore(context.Context, *aiplatformpb.UpdateExampleStoreRequest, ...gax.CallOption) (*UpdateExampleStoreOperation, error) 142 UpdateExampleStoreOperation(name string) *UpdateExampleStoreOperation 143 DeleteExampleStore(context.Context, *aiplatformpb.DeleteExampleStoreRequest, ...gax.CallOption) (*DeleteExampleStoreOperation, error) 144 DeleteExampleStoreOperation(name string) *DeleteExampleStoreOperation 145 ListExampleStores(context.Context, *aiplatformpb.ListExampleStoresRequest, ...gax.CallOption) *ExampleStoreIterator 146 UpsertExamples(context.Context, *aiplatformpb.UpsertExamplesRequest, ...gax.CallOption) (*aiplatformpb.UpsertExamplesResponse, error) 147 RemoveExamples(context.Context, *aiplatformpb.RemoveExamplesRequest, ...gax.CallOption) (*aiplatformpb.RemoveExamplesResponse, error) 148 SearchExamples(context.Context, *aiplatformpb.SearchExamplesRequest, ...gax.CallOption) (*aiplatformpb.SearchExamplesResponse, error) 149 FetchExamples(context.Context, *aiplatformpb.FetchExamplesRequest, ...gax.CallOption) *ExampleIterator 150 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 151 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 152 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 153 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 154 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 155 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 156 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 157 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 158 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 159 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 160 } 161 162 // ExampleStoreClient is a client for interacting with Vertex AI API. 163 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 164 // 165 // A service for managing and retrieving few-shot examples. 166 type ExampleStoreClient struct { 167 // The internal transport-dependent client. 168 internalClient internalExampleStoreClient 169 170 // The call options for this service. 171 CallOptions *ExampleStoreCallOptions 172 173 // LROClient is used internally to handle long-running operations. 174 // It is exposed so that its CallOptions can be modified if required. 175 // Users should not Close this client. 176 LROClient *lroauto.OperationsClient 177 } 178 179 // Wrapper methods routed to the internal client. 180 181 // Close closes the connection to the API service. The user should invoke this when 182 // the client is no longer required. 183 func (c *ExampleStoreClient) Close() error { 184 return c.internalClient.Close() 185 } 186 187 // setGoogleClientInfo sets the name and version of the application in 188 // the `x-goog-api-client` header passed on each request. Intended for 189 // use by Google-written clients. 190 func (c *ExampleStoreClient) setGoogleClientInfo(keyval ...string) { 191 c.internalClient.setGoogleClientInfo(keyval...) 192 } 193 194 // Connection returns a connection to the API service. 195 // 196 // Deprecated: Connections are now pooled so this method does not always 197 // return the same resource. 198 func (c *ExampleStoreClient) Connection() *grpc.ClientConn { 199 return c.internalClient.Connection() 200 } 201 202 // CreateExampleStore create an ExampleStore. 203 func (c *ExampleStoreClient) CreateExampleStore(ctx context.Context, req *aiplatformpb.CreateExampleStoreRequest, opts ...gax.CallOption) (*CreateExampleStoreOperation, error) { 204 return c.internalClient.CreateExampleStore(ctx, req, opts...) 205 } 206 207 // CreateExampleStoreOperation returns a new CreateExampleStoreOperation from a given name. 208 // The name must be that of a previously created CreateExampleStoreOperation, possibly from a different process. 209 func (c *ExampleStoreClient) CreateExampleStoreOperation(name string) *CreateExampleStoreOperation { 210 return c.internalClient.CreateExampleStoreOperation(name) 211 } 212 213 // GetExampleStore get an ExampleStore. 214 func (c *ExampleStoreClient) GetExampleStore(ctx context.Context, req *aiplatformpb.GetExampleStoreRequest, opts ...gax.CallOption) (*aiplatformpb.ExampleStore, error) { 215 return c.internalClient.GetExampleStore(ctx, req, opts...) 216 } 217 218 // UpdateExampleStore update an ExampleStore. 219 func (c *ExampleStoreClient) UpdateExampleStore(ctx context.Context, req *aiplatformpb.UpdateExampleStoreRequest, opts ...gax.CallOption) (*UpdateExampleStoreOperation, error) { 220 return c.internalClient.UpdateExampleStore(ctx, req, opts...) 221 } 222 223 // UpdateExampleStoreOperation returns a new UpdateExampleStoreOperation from a given name. 224 // The name must be that of a previously created UpdateExampleStoreOperation, possibly from a different process. 225 func (c *ExampleStoreClient) UpdateExampleStoreOperation(name string) *UpdateExampleStoreOperation { 226 return c.internalClient.UpdateExampleStoreOperation(name) 227 } 228 229 // DeleteExampleStore delete an ExampleStore. 230 func (c *ExampleStoreClient) DeleteExampleStore(ctx context.Context, req *aiplatformpb.DeleteExampleStoreRequest, opts ...gax.CallOption) (*DeleteExampleStoreOperation, error) { 231 return c.internalClient.DeleteExampleStore(ctx, req, opts...) 232 } 233 234 // DeleteExampleStoreOperation returns a new DeleteExampleStoreOperation from a given name. 235 // The name must be that of a previously created DeleteExampleStoreOperation, possibly from a different process. 236 func (c *ExampleStoreClient) DeleteExampleStoreOperation(name string) *DeleteExampleStoreOperation { 237 return c.internalClient.DeleteExampleStoreOperation(name) 238 } 239 240 // ListExampleStores list ExampleStores in a Location. 241 func (c *ExampleStoreClient) ListExampleStores(ctx context.Context, req *aiplatformpb.ListExampleStoresRequest, opts ...gax.CallOption) *ExampleStoreIterator { 242 return c.internalClient.ListExampleStores(ctx, req, opts...) 243 } 244 245 // UpsertExamples create or update Examples in the Example Store. 246 func (c *ExampleStoreClient) UpsertExamples(ctx context.Context, req *aiplatformpb.UpsertExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.UpsertExamplesResponse, error) { 247 return c.internalClient.UpsertExamples(ctx, req, opts...) 248 } 249 250 // RemoveExamples remove Examples from the Example Store. 251 func (c *ExampleStoreClient) RemoveExamples(ctx context.Context, req *aiplatformpb.RemoveExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveExamplesResponse, error) { 252 return c.internalClient.RemoveExamples(ctx, req, opts...) 253 } 254 255 // SearchExamples search for similar Examples for given selection criteria. 256 func (c *ExampleStoreClient) SearchExamples(ctx context.Context, req *aiplatformpb.SearchExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchExamplesResponse, error) { 257 return c.internalClient.SearchExamples(ctx, req, opts...) 258 } 259 260 // FetchExamples get Examples from the Example Store. 261 func (c *ExampleStoreClient) FetchExamples(ctx context.Context, req *aiplatformpb.FetchExamplesRequest, opts ...gax.CallOption) *ExampleIterator { 262 return c.internalClient.FetchExamples(ctx, req, opts...) 263 } 264 265 // GetLocation gets information about a location. 266 func (c *ExampleStoreClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 267 return c.internalClient.GetLocation(ctx, req, opts...) 268 } 269 270 // ListLocations lists information about the supported locations for this service. 271 func (c *ExampleStoreClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 272 return c.internalClient.ListLocations(ctx, req, opts...) 273 } 274 275 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 276 // if the resource exists and does not have a policy set. 277 func (c *ExampleStoreClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 278 return c.internalClient.GetIamPolicy(ctx, req, opts...) 279 } 280 281 // SetIamPolicy sets the access control policy on the specified resource. Replaces 282 // any existing policy. 283 // 284 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 285 // errors. 286 func (c *ExampleStoreClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 287 return c.internalClient.SetIamPolicy(ctx, req, opts...) 288 } 289 290 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 291 // resource does not exist, this will return an empty set of 292 // permissions, not a NOT_FOUND error. 293 // 294 // Note: This operation is designed to be used for building 295 // permission-aware UIs and command-line tools, not for authorization 296 // checking. This operation may “fail open” without warning. 297 func (c *ExampleStoreClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 298 return c.internalClient.TestIamPermissions(ctx, req, opts...) 299 } 300 301 // CancelOperation is a utility method from google.longrunning.Operations. 302 func (c *ExampleStoreClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 303 return c.internalClient.CancelOperation(ctx, req, opts...) 304 } 305 306 // DeleteOperation is a utility method from google.longrunning.Operations. 307 func (c *ExampleStoreClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 308 return c.internalClient.DeleteOperation(ctx, req, opts...) 309 } 310 311 // GetOperation is a utility method from google.longrunning.Operations. 312 func (c *ExampleStoreClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 313 return c.internalClient.GetOperation(ctx, req, opts...) 314 } 315 316 // ListOperations is a utility method from google.longrunning.Operations. 317 func (c *ExampleStoreClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 318 return c.internalClient.ListOperations(ctx, req, opts...) 319 } 320 321 // WaitOperation is a utility method from google.longrunning.Operations. 322 func (c *ExampleStoreClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 323 return c.internalClient.WaitOperation(ctx, req, opts...) 324 } 325 326 // exampleStoreGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 327 // 328 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 329 type exampleStoreGRPCClient struct { 330 // Connection pool of gRPC connections to the service. 331 connPool gtransport.ConnPool 332 333 // Points back to the CallOptions field of the containing ExampleStoreClient 334 CallOptions **ExampleStoreCallOptions 335 336 // The gRPC API client. 337 exampleStoreClient aiplatformpb.ExampleStoreServiceClient 338 339 // LROClient is used internally to handle long-running operations. 340 // It is exposed so that its CallOptions can be modified if required. 341 // Users should not Close this client. 342 LROClient **lroauto.OperationsClient 343 344 operationsClient longrunningpb.OperationsClient 345 346 iamPolicyClient iampb.IAMPolicyClient 347 348 locationsClient locationpb.LocationsClient 349 350 // The x-goog-* metadata to be sent with each request. 351 xGoogHeaders []string 352 353 logger *slog.Logger 354 } 355 356 // NewExampleStoreClient creates a new example store service client based on gRPC. 357 // The returned client must be Closed when it is done being used to clean up its underlying connections. 358 // 359 // A service for managing and retrieving few-shot examples. 360 func NewExampleStoreClient(ctx context.Context, opts ...option.ClientOption) (*ExampleStoreClient, error) { 361 clientOpts := defaultExampleStoreGRPCClientOptions() 362 if newExampleStoreClientHook != nil { 363 hookOpts, err := newExampleStoreClientHook(ctx, clientHookParams{}) 364 if err != nil { 365 return nil, err 366 } 367 clientOpts = append(clientOpts, hookOpts...) 368 } 369 370 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 371 if err != nil { 372 return nil, err 373 } 374 client := ExampleStoreClient{CallOptions: defaultExampleStoreCallOptions()} 375 376 c := &exampleStoreGRPCClient{ 377 connPool: connPool, 378 exampleStoreClient: aiplatformpb.NewExampleStoreServiceClient(connPool), 379 CallOptions: &client.CallOptions, 380 logger: internaloption.GetLogger(opts), 381 operationsClient: longrunningpb.NewOperationsClient(connPool), 382 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 383 locationsClient: locationpb.NewLocationsClient(connPool), 384 } 385 c.setGoogleClientInfo() 386 387 client.internalClient = c 388 389 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 390 if err != nil { 391 // This error "should not happen", since we are just reusing old connection pool 392 // and never actually need to dial. 393 // If this does happen, we could leak connp. However, we cannot close conn: 394 // If the user invoked the constructor with option.WithGRPCConn, 395 // we would close a connection that's still in use. 396 // TODO: investigate error conditions. 397 return nil, err 398 } 399 c.LROClient = &client.LROClient 400 return &client, nil 401 } 402 403 // Connection returns a connection to the API service. 404 // 405 // Deprecated: Connections are now pooled so this method does not always 406 // return the same resource. 407 func (c *exampleStoreGRPCClient) Connection() *grpc.ClientConn { 408 return c.connPool.Conn() 409 } 410 411 // setGoogleClientInfo sets the name and version of the application in 412 // the `x-goog-api-client` header passed on each request. Intended for 413 // use by Google-written clients. 414 func (c *exampleStoreGRPCClient) setGoogleClientInfo(keyval ...string) { 415 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 416 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 417 c.xGoogHeaders = []string{ 418 "x-goog-api-client", gax.XGoogHeader(kv...), 419 } 420 } 421 422 // Close closes the connection to the API service. The user should invoke this when 423 // the client is no longer required. 424 func (c *exampleStoreGRPCClient) Close() error { 425 return c.connPool.Close() 426 } 427 428 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 429 type exampleStoreRESTClient struct { 430 // The http endpoint to connect to. 431 endpoint string 432 433 // The http client. 434 httpClient *http.Client 435 436 // LROClient is used internally to handle long-running operations. 437 // It is exposed so that its CallOptions can be modified if required. 438 // Users should not Close this client. 439 LROClient **lroauto.OperationsClient 440 441 // The x-goog-* headers to be sent with each request. 442 xGoogHeaders []string 443 444 // Points back to the CallOptions field of the containing ExampleStoreClient 445 CallOptions **ExampleStoreCallOptions 446 447 logger *slog.Logger 448 } 449 450 // NewExampleStoreRESTClient creates a new example store service rest client. 451 // 452 // A service for managing and retrieving few-shot examples. 453 func NewExampleStoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*ExampleStoreClient, error) { 454 clientOpts := append(defaultExampleStoreRESTClientOptions(), opts...) 455 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) 456 if err != nil { 457 return nil, err 458 } 459 460 callOpts := defaultExampleStoreRESTCallOptions() 461 c := &exampleStoreRESTClient{ 462 endpoint: endpoint, 463 httpClient: httpClient, 464 CallOptions: &callOpts, 465 logger: internaloption.GetLogger(opts), 466 } 467 c.setGoogleClientInfo() 468 469 lroOpts := []option.ClientOption{ 470 option.WithHTTPClient(httpClient), 471 option.WithEndpoint(endpoint), 472 } 473 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...) 474 if err != nil { 475 return nil, err 476 } 477 c.LROClient = &opClient 478 479 return &ExampleStoreClient{internalClient: c, CallOptions: callOpts}, nil 480 } 481 482 func defaultExampleStoreRESTClientOptions() []option.ClientOption { 483 return []option.ClientOption{ 484 internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"), 485 internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"), 486 internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"), 487 internaloption.WithDefaultUniverseDomain("googleapis.com"), 488 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 489 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 490 internaloption.EnableNewAuthLibrary(), 491 } 492 } 493 494 // setGoogleClientInfo sets the name and version of the application in 495 // the `x-goog-api-client` header passed on each request. Intended for 496 // use by Google-written clients. 497 func (c *exampleStoreRESTClient) setGoogleClientInfo(keyval ...string) { 498 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 499 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) 500 c.xGoogHeaders = []string{ 501 "x-goog-api-client", gax.XGoogHeader(kv...), 502 } 503 } 504 505 // Close closes the connection to the API service. The user should invoke this when 506 // the client is no longer required. 507 func (c *exampleStoreRESTClient) Close() error { 508 // Replace httpClient with nil to force cleanup. 509 c.httpClient = nil 510 return nil 511 } 512 513 // Connection returns a connection to the API service. 514 // 515 // Deprecated: This method always returns nil. 516 func (c *exampleStoreRESTClient) Connection() *grpc.ClientConn { 517 return nil 518 } 519 func (c *exampleStoreGRPCClient) CreateExampleStore(ctx context.Context, req *aiplatformpb.CreateExampleStoreRequest, opts ...gax.CallOption) (*CreateExampleStoreOperation, error) { 520 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 521 522 hds = append(c.xGoogHeaders, hds...) 523 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 524 opts = append((*c.CallOptions).CreateExampleStore[0:len((*c.CallOptions).CreateExampleStore):len((*c.CallOptions).CreateExampleStore)], opts...) 525 var resp *longrunningpb.Operation 526 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 527 var err error 528 resp, err = executeRPC(ctx, c.exampleStoreClient.CreateExampleStore, req, settings.GRPC, c.logger, "CreateExampleStore") 529 return err 530 }, opts...) 531 if err != nil { 532 return nil, err 533 } 534 return &CreateExampleStoreOperation{ 535 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 536 }, nil 537 } 538 539 func (c *exampleStoreGRPCClient) GetExampleStore(ctx context.Context, req *aiplatformpb.GetExampleStoreRequest, opts ...gax.CallOption) (*aiplatformpb.ExampleStore, error) { 540 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 541 542 hds = append(c.xGoogHeaders, hds...) 543 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 544 opts = append((*c.CallOptions).GetExampleStore[0:len((*c.CallOptions).GetExampleStore):len((*c.CallOptions).GetExampleStore)], opts...) 545 var resp *aiplatformpb.ExampleStore 546 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 547 var err error 548 resp, err = executeRPC(ctx, c.exampleStoreClient.GetExampleStore, req, settings.GRPC, c.logger, "GetExampleStore") 549 return err 550 }, opts...) 551 if err != nil { 552 return nil, err 553 } 554 return resp, nil 555 } 556 557 func (c *exampleStoreGRPCClient) UpdateExampleStore(ctx context.Context, req *aiplatformpb.UpdateExampleStoreRequest, opts ...gax.CallOption) (*UpdateExampleStoreOperation, error) { 558 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store.name", url.QueryEscape(req.GetExampleStore().GetName()))} 559 560 hds = append(c.xGoogHeaders, hds...) 561 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 562 opts = append((*c.CallOptions).UpdateExampleStore[0:len((*c.CallOptions).UpdateExampleStore):len((*c.CallOptions).UpdateExampleStore)], opts...) 563 var resp *longrunningpb.Operation 564 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 565 var err error 566 resp, err = executeRPC(ctx, c.exampleStoreClient.UpdateExampleStore, req, settings.GRPC, c.logger, "UpdateExampleStore") 567 return err 568 }, opts...) 569 if err != nil { 570 return nil, err 571 } 572 return &UpdateExampleStoreOperation{ 573 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 574 }, nil 575 } 576 577 func (c *exampleStoreGRPCClient) DeleteExampleStore(ctx context.Context, req *aiplatformpb.DeleteExampleStoreRequest, opts ...gax.CallOption) (*DeleteExampleStoreOperation, error) { 578 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 579 580 hds = append(c.xGoogHeaders, hds...) 581 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 582 opts = append((*c.CallOptions).DeleteExampleStore[0:len((*c.CallOptions).DeleteExampleStore):len((*c.CallOptions).DeleteExampleStore)], opts...) 583 var resp *longrunningpb.Operation 584 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 585 var err error 586 resp, err = executeRPC(ctx, c.exampleStoreClient.DeleteExampleStore, req, settings.GRPC, c.logger, "DeleteExampleStore") 587 return err 588 }, opts...) 589 if err != nil { 590 return nil, err 591 } 592 return &DeleteExampleStoreOperation{ 593 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 594 }, nil 595 } 596 597 func (c *exampleStoreGRPCClient) ListExampleStores(ctx context.Context, req *aiplatformpb.ListExampleStoresRequest, opts ...gax.CallOption) *ExampleStoreIterator { 598 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 599 600 hds = append(c.xGoogHeaders, hds...) 601 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 602 opts = append((*c.CallOptions).ListExampleStores[0:len((*c.CallOptions).ListExampleStores):len((*c.CallOptions).ListExampleStores)], opts...) 603 it := &ExampleStoreIterator{} 604 req = proto.Clone(req).(*aiplatformpb.ListExampleStoresRequest) 605 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ExampleStore, string, error) { 606 resp := &aiplatformpb.ListExampleStoresResponse{} 607 if pageToken != "" { 608 req.PageToken = pageToken 609 } 610 if pageSize > math.MaxInt32 { 611 req.PageSize = math.MaxInt32 612 } else if pageSize != 0 { 613 req.PageSize = int32(pageSize) 614 } 615 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 616 var err error 617 resp, err = executeRPC(ctx, c.exampleStoreClient.ListExampleStores, req, settings.GRPC, c.logger, "ListExampleStores") 618 return err 619 }, opts...) 620 if err != nil { 621 return nil, "", err 622 } 623 624 it.Response = resp 625 return resp.GetExampleStores(), resp.GetNextPageToken(), nil 626 } 627 fetch := func(pageSize int, pageToken string) (string, error) { 628 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 629 if err != nil { 630 return "", err 631 } 632 it.items = append(it.items, items...) 633 return nextPageToken, nil 634 } 635 636 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 637 it.pageInfo.MaxSize = int(req.GetPageSize()) 638 it.pageInfo.Token = req.GetPageToken() 639 640 return it 641 } 642 643 func (c *exampleStoreGRPCClient) UpsertExamples(ctx context.Context, req *aiplatformpb.UpsertExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.UpsertExamplesResponse, error) { 644 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 645 646 hds = append(c.xGoogHeaders, hds...) 647 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 648 opts = append((*c.CallOptions).UpsertExamples[0:len((*c.CallOptions).UpsertExamples):len((*c.CallOptions).UpsertExamples)], opts...) 649 var resp *aiplatformpb.UpsertExamplesResponse 650 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 651 var err error 652 resp, err = executeRPC(ctx, c.exampleStoreClient.UpsertExamples, req, settings.GRPC, c.logger, "UpsertExamples") 653 return err 654 }, opts...) 655 if err != nil { 656 return nil, err 657 } 658 return resp, nil 659 } 660 661 func (c *exampleStoreGRPCClient) RemoveExamples(ctx context.Context, req *aiplatformpb.RemoveExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveExamplesResponse, error) { 662 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 663 664 hds = append(c.xGoogHeaders, hds...) 665 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 666 opts = append((*c.CallOptions).RemoveExamples[0:len((*c.CallOptions).RemoveExamples):len((*c.CallOptions).RemoveExamples)], opts...) 667 var resp *aiplatformpb.RemoveExamplesResponse 668 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 669 var err error 670 resp, err = executeRPC(ctx, c.exampleStoreClient.RemoveExamples, req, settings.GRPC, c.logger, "RemoveExamples") 671 return err 672 }, opts...) 673 if err != nil { 674 return nil, err 675 } 676 return resp, nil 677 } 678 679 func (c *exampleStoreGRPCClient) SearchExamples(ctx context.Context, req *aiplatformpb.SearchExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchExamplesResponse, error) { 680 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 681 682 hds = append(c.xGoogHeaders, hds...) 683 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 684 opts = append((*c.CallOptions).SearchExamples[0:len((*c.CallOptions).SearchExamples):len((*c.CallOptions).SearchExamples)], opts...) 685 var resp *aiplatformpb.SearchExamplesResponse 686 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 687 var err error 688 resp, err = executeRPC(ctx, c.exampleStoreClient.SearchExamples, req, settings.GRPC, c.logger, "SearchExamples") 689 return err 690 }, opts...) 691 if err != nil { 692 return nil, err 693 } 694 return resp, nil 695 } 696 697 func (c *exampleStoreGRPCClient) FetchExamples(ctx context.Context, req *aiplatformpb.FetchExamplesRequest, opts ...gax.CallOption) *ExampleIterator { 698 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 699 700 hds = append(c.xGoogHeaders, hds...) 701 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 702 opts = append((*c.CallOptions).FetchExamples[0:len((*c.CallOptions).FetchExamples):len((*c.CallOptions).FetchExamples)], opts...) 703 it := &ExampleIterator{} 704 req = proto.Clone(req).(*aiplatformpb.FetchExamplesRequest) 705 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Example, string, error) { 706 resp := &aiplatformpb.FetchExamplesResponse{} 707 if pageToken != "" { 708 req.PageToken = pageToken 709 } 710 if pageSize > math.MaxInt32 { 711 req.PageSize = math.MaxInt32 712 } else if pageSize != 0 { 713 req.PageSize = int32(pageSize) 714 } 715 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 716 var err error 717 resp, err = executeRPC(ctx, c.exampleStoreClient.FetchExamples, req, settings.GRPC, c.logger, "FetchExamples") 718 return err 719 }, opts...) 720 if err != nil { 721 return nil, "", err 722 } 723 724 it.Response = resp 725 return resp.GetExamples(), resp.GetNextPageToken(), nil 726 } 727 fetch := func(pageSize int, pageToken string) (string, error) { 728 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 729 if err != nil { 730 return "", err 731 } 732 it.items = append(it.items, items...) 733 return nextPageToken, nil 734 } 735 736 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 737 it.pageInfo.MaxSize = int(req.GetPageSize()) 738 it.pageInfo.Token = req.GetPageToken() 739 740 return it 741 } 742 743 func (c *exampleStoreGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 744 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 745 746 hds = append(c.xGoogHeaders, hds...) 747 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 748 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 749 var resp *locationpb.Location 750 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 751 var err error 752 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 753 return err 754 }, opts...) 755 if err != nil { 756 return nil, err 757 } 758 return resp, nil 759 } 760 761 func (c *exampleStoreGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 762 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 763 764 hds = append(c.xGoogHeaders, hds...) 765 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 766 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 767 it := &LocationIterator{} 768 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 769 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 770 resp := &locationpb.ListLocationsResponse{} 771 if pageToken != "" { 772 req.PageToken = pageToken 773 } 774 if pageSize > math.MaxInt32 { 775 req.PageSize = math.MaxInt32 776 } else if pageSize != 0 { 777 req.PageSize = int32(pageSize) 778 } 779 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 780 var err error 781 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 782 return err 783 }, opts...) 784 if err != nil { 785 return nil, "", err 786 } 787 788 it.Response = resp 789 return resp.GetLocations(), resp.GetNextPageToken(), nil 790 } 791 fetch := func(pageSize int, pageToken string) (string, error) { 792 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 793 if err != nil { 794 return "", err 795 } 796 it.items = append(it.items, items...) 797 return nextPageToken, nil 798 } 799 800 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 801 it.pageInfo.MaxSize = int(req.GetPageSize()) 802 it.pageInfo.Token = req.GetPageToken() 803 804 return it 805 } 806 807 func (c *exampleStoreGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 808 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 809 810 hds = append(c.xGoogHeaders, hds...) 811 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 812 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 813 var resp *iampb.Policy 814 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 815 var err error 816 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 817 return err 818 }, opts...) 819 if err != nil { 820 return nil, err 821 } 822 return resp, nil 823 } 824 825 func (c *exampleStoreGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 826 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 827 828 hds = append(c.xGoogHeaders, hds...) 829 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 830 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 831 var resp *iampb.Policy 832 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 833 var err error 834 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 835 return err 836 }, opts...) 837 if err != nil { 838 return nil, err 839 } 840 return resp, nil 841 } 842 843 func (c *exampleStoreGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 844 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 845 846 hds = append(c.xGoogHeaders, hds...) 847 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 848 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 849 var resp *iampb.TestIamPermissionsResponse 850 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 851 var err error 852 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 853 return err 854 }, opts...) 855 if err != nil { 856 return nil, err 857 } 858 return resp, nil 859 } 860 861 func (c *exampleStoreGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 862 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 863 864 hds = append(c.xGoogHeaders, hds...) 865 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 866 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 867 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 868 var err error 869 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 870 return err 871 }, opts...) 872 return err 873 } 874 875 func (c *exampleStoreGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 876 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 877 878 hds = append(c.xGoogHeaders, hds...) 879 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 880 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 881 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 882 var err error 883 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 884 return err 885 }, opts...) 886 return err 887 } 888 889 func (c *exampleStoreGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 890 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 891 892 hds = append(c.xGoogHeaders, hds...) 893 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 894 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 895 var resp *longrunningpb.Operation 896 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 897 var err error 898 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 899 return err 900 }, opts...) 901 if err != nil { 902 return nil, err 903 } 904 return resp, nil 905 } 906 907 func (c *exampleStoreGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 908 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 909 910 hds = append(c.xGoogHeaders, hds...) 911 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 912 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 913 it := &OperationIterator{} 914 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 915 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 916 resp := &longrunningpb.ListOperationsResponse{} 917 if pageToken != "" { 918 req.PageToken = pageToken 919 } 920 if pageSize > math.MaxInt32 { 921 req.PageSize = math.MaxInt32 922 } else if pageSize != 0 { 923 req.PageSize = int32(pageSize) 924 } 925 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 926 var err error 927 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 928 return err 929 }, opts...) 930 if err != nil { 931 return nil, "", err 932 } 933 934 it.Response = resp 935 return resp.GetOperations(), resp.GetNextPageToken(), nil 936 } 937 fetch := func(pageSize int, pageToken string) (string, error) { 938 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 939 if err != nil { 940 return "", err 941 } 942 it.items = append(it.items, items...) 943 return nextPageToken, nil 944 } 945 946 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 947 it.pageInfo.MaxSize = int(req.GetPageSize()) 948 it.pageInfo.Token = req.GetPageToken() 949 950 return it 951 } 952 953 func (c *exampleStoreGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 954 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 955 956 hds = append(c.xGoogHeaders, hds...) 957 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 958 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 959 var resp *longrunningpb.Operation 960 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 961 var err error 962 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 963 return err 964 }, opts...) 965 if err != nil { 966 return nil, err 967 } 968 return resp, nil 969 } 970 971 // CreateExampleStore create an ExampleStore. 972 func (c *exampleStoreRESTClient) CreateExampleStore(ctx context.Context, req *aiplatformpb.CreateExampleStoreRequest, opts ...gax.CallOption) (*CreateExampleStoreOperation, error) { 973 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 974 body := req.GetExampleStore() 975 jsonReq, err := m.Marshal(body) 976 if err != nil { 977 return nil, err 978 } 979 980 baseUrl, err := url.Parse(c.endpoint) 981 if err != nil { 982 return nil, err 983 } 984 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/exampleStores", req.GetParent()) 985 986 params := url.Values{} 987 params.Add("$alt", "json;enum-encoding=int") 988 989 baseUrl.RawQuery = params.Encode() 990 991 // Build HTTP headers from client and context metadata. 992 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 993 994 hds = append(c.xGoogHeaders, hds...) 995 hds = append(hds, "Content-Type", "application/json") 996 headers := gax.BuildHeaders(ctx, hds...) 997 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 998 resp := &longrunningpb.Operation{} 999 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1000 if settings.Path != "" { 1001 baseUrl.Path = settings.Path 1002 } 1003 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1004 if err != nil { 1005 return err 1006 } 1007 httpReq = httpReq.WithContext(ctx) 1008 httpReq.Header = headers 1009 1010 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateExampleStore") 1011 if err != nil { 1012 return err 1013 } 1014 if err := unm.Unmarshal(buf, resp); err != nil { 1015 return err 1016 } 1017 1018 return nil 1019 }, opts...) 1020 if e != nil { 1021 return nil, e 1022 } 1023 1024 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1025 return &CreateExampleStoreOperation{ 1026 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1027 pollPath: override, 1028 }, nil 1029 } 1030 1031 // GetExampleStore get an ExampleStore. 1032 func (c *exampleStoreRESTClient) GetExampleStore(ctx context.Context, req *aiplatformpb.GetExampleStoreRequest, opts ...gax.CallOption) (*aiplatformpb.ExampleStore, error) { 1033 baseUrl, err := url.Parse(c.endpoint) 1034 if err != nil { 1035 return nil, err 1036 } 1037 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1038 1039 params := url.Values{} 1040 params.Add("$alt", "json;enum-encoding=int") 1041 1042 baseUrl.RawQuery = params.Encode() 1043 1044 // Build HTTP headers from client and context metadata. 1045 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1046 1047 hds = append(c.xGoogHeaders, hds...) 1048 hds = append(hds, "Content-Type", "application/json") 1049 headers := gax.BuildHeaders(ctx, hds...) 1050 opts = append((*c.CallOptions).GetExampleStore[0:len((*c.CallOptions).GetExampleStore):len((*c.CallOptions).GetExampleStore)], opts...) 1051 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1052 resp := &aiplatformpb.ExampleStore{} 1053 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1054 if settings.Path != "" { 1055 baseUrl.Path = settings.Path 1056 } 1057 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1058 if err != nil { 1059 return err 1060 } 1061 httpReq = httpReq.WithContext(ctx) 1062 httpReq.Header = headers 1063 1064 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetExampleStore") 1065 if err != nil { 1066 return err 1067 } 1068 1069 if err := unm.Unmarshal(buf, resp); err != nil { 1070 return err 1071 } 1072 1073 return nil 1074 }, opts...) 1075 if e != nil { 1076 return nil, e 1077 } 1078 return resp, nil 1079 } 1080 1081 // UpdateExampleStore update an ExampleStore. 1082 func (c *exampleStoreRESTClient) UpdateExampleStore(ctx context.Context, req *aiplatformpb.UpdateExampleStoreRequest, opts ...gax.CallOption) (*UpdateExampleStoreOperation, error) { 1083 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1084 body := req.GetExampleStore() 1085 jsonReq, err := m.Marshal(body) 1086 if err != nil { 1087 return nil, err 1088 } 1089 1090 baseUrl, err := url.Parse(c.endpoint) 1091 if err != nil { 1092 return nil, err 1093 } 1094 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetExampleStore().GetName()) 1095 1096 params := url.Values{} 1097 params.Add("$alt", "json;enum-encoding=int") 1098 if req.GetUpdateMask() != nil { 1099 field, err := protojson.Marshal(req.GetUpdateMask()) 1100 if err != nil { 1101 return nil, err 1102 } 1103 params.Add("updateMask", string(field[1:len(field)-1])) 1104 } 1105 1106 baseUrl.RawQuery = params.Encode() 1107 1108 // Build HTTP headers from client and context metadata. 1109 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store.name", url.QueryEscape(req.GetExampleStore().GetName()))} 1110 1111 hds = append(c.xGoogHeaders, hds...) 1112 hds = append(hds, "Content-Type", "application/json") 1113 headers := gax.BuildHeaders(ctx, hds...) 1114 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1115 resp := &longrunningpb.Operation{} 1116 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1117 if settings.Path != "" { 1118 baseUrl.Path = settings.Path 1119 } 1120 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 1121 if err != nil { 1122 return err 1123 } 1124 httpReq = httpReq.WithContext(ctx) 1125 httpReq.Header = headers 1126 1127 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateExampleStore") 1128 if err != nil { 1129 return err 1130 } 1131 if err := unm.Unmarshal(buf, resp); err != nil { 1132 return err 1133 } 1134 1135 return nil 1136 }, opts...) 1137 if e != nil { 1138 return nil, e 1139 } 1140 1141 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1142 return &UpdateExampleStoreOperation{ 1143 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1144 pollPath: override, 1145 }, nil 1146 } 1147 1148 // DeleteExampleStore delete an ExampleStore. 1149 func (c *exampleStoreRESTClient) DeleteExampleStore(ctx context.Context, req *aiplatformpb.DeleteExampleStoreRequest, opts ...gax.CallOption) (*DeleteExampleStoreOperation, error) { 1150 baseUrl, err := url.Parse(c.endpoint) 1151 if err != nil { 1152 return nil, err 1153 } 1154 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1155 1156 params := url.Values{} 1157 params.Add("$alt", "json;enum-encoding=int") 1158 1159 baseUrl.RawQuery = params.Encode() 1160 1161 // Build HTTP headers from client and context metadata. 1162 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1163 1164 hds = append(c.xGoogHeaders, hds...) 1165 hds = append(hds, "Content-Type", "application/json") 1166 headers := gax.BuildHeaders(ctx, hds...) 1167 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1168 resp := &longrunningpb.Operation{} 1169 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1170 if settings.Path != "" { 1171 baseUrl.Path = settings.Path 1172 } 1173 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 1174 if err != nil { 1175 return err 1176 } 1177 httpReq = httpReq.WithContext(ctx) 1178 httpReq.Header = headers 1179 1180 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteExampleStore") 1181 if err != nil { 1182 return err 1183 } 1184 if err := unm.Unmarshal(buf, resp); err != nil { 1185 return err 1186 } 1187 1188 return nil 1189 }, opts...) 1190 if e != nil { 1191 return nil, e 1192 } 1193 1194 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1195 return &DeleteExampleStoreOperation{ 1196 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1197 pollPath: override, 1198 }, nil 1199 } 1200 1201 // ListExampleStores list ExampleStores in a Location. 1202 func (c *exampleStoreRESTClient) ListExampleStores(ctx context.Context, req *aiplatformpb.ListExampleStoresRequest, opts ...gax.CallOption) *ExampleStoreIterator { 1203 it := &ExampleStoreIterator{} 1204 req = proto.Clone(req).(*aiplatformpb.ListExampleStoresRequest) 1205 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1206 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ExampleStore, string, error) { 1207 resp := &aiplatformpb.ListExampleStoresResponse{} 1208 if pageToken != "" { 1209 req.PageToken = pageToken 1210 } 1211 if pageSize > math.MaxInt32 { 1212 req.PageSize = math.MaxInt32 1213 } else if pageSize != 0 { 1214 req.PageSize = int32(pageSize) 1215 } 1216 baseUrl, err := url.Parse(c.endpoint) 1217 if err != nil { 1218 return nil, "", err 1219 } 1220 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/exampleStores", req.GetParent()) 1221 1222 params := url.Values{} 1223 params.Add("$alt", "json;enum-encoding=int") 1224 if req.GetFilter() != "" { 1225 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1226 } 1227 if req.GetPageSize() != 0 { 1228 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1229 } 1230 if req.GetPageToken() != "" { 1231 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1232 } 1233 1234 baseUrl.RawQuery = params.Encode() 1235 1236 // Build HTTP headers from client and context metadata. 1237 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1238 headers := gax.BuildHeaders(ctx, hds...) 1239 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1240 if settings.Path != "" { 1241 baseUrl.Path = settings.Path 1242 } 1243 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1244 if err != nil { 1245 return err 1246 } 1247 httpReq.Header = headers 1248 1249 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListExampleStores") 1250 if err != nil { 1251 return err 1252 } 1253 if err := unm.Unmarshal(buf, resp); err != nil { 1254 return err 1255 } 1256 1257 return nil 1258 }, opts...) 1259 if e != nil { 1260 return nil, "", e 1261 } 1262 it.Response = resp 1263 return resp.GetExampleStores(), resp.GetNextPageToken(), nil 1264 } 1265 1266 fetch := func(pageSize int, pageToken string) (string, error) { 1267 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1268 if err != nil { 1269 return "", err 1270 } 1271 it.items = append(it.items, items...) 1272 return nextPageToken, nil 1273 } 1274 1275 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1276 it.pageInfo.MaxSize = int(req.GetPageSize()) 1277 it.pageInfo.Token = req.GetPageToken() 1278 1279 return it 1280 } 1281 1282 // UpsertExamples create or update Examples in the Example Store. 1283 func (c *exampleStoreRESTClient) UpsertExamples(ctx context.Context, req *aiplatformpb.UpsertExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.UpsertExamplesResponse, error) { 1284 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1285 jsonReq, err := m.Marshal(req) 1286 if err != nil { 1287 return nil, err 1288 } 1289 1290 baseUrl, err := url.Parse(c.endpoint) 1291 if err != nil { 1292 return nil, err 1293 } 1294 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:upsertExamples", req.GetExampleStore()) 1295 1296 params := url.Values{} 1297 params.Add("$alt", "json;enum-encoding=int") 1298 1299 baseUrl.RawQuery = params.Encode() 1300 1301 // Build HTTP headers from client and context metadata. 1302 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 1303 1304 hds = append(c.xGoogHeaders, hds...) 1305 hds = append(hds, "Content-Type", "application/json") 1306 headers := gax.BuildHeaders(ctx, hds...) 1307 opts = append((*c.CallOptions).UpsertExamples[0:len((*c.CallOptions).UpsertExamples):len((*c.CallOptions).UpsertExamples)], opts...) 1308 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1309 resp := &aiplatformpb.UpsertExamplesResponse{} 1310 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1311 if settings.Path != "" { 1312 baseUrl.Path = settings.Path 1313 } 1314 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1315 if err != nil { 1316 return err 1317 } 1318 httpReq = httpReq.WithContext(ctx) 1319 httpReq.Header = headers 1320 1321 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpsertExamples") 1322 if err != nil { 1323 return err 1324 } 1325 1326 if err := unm.Unmarshal(buf, resp); err != nil { 1327 return err 1328 } 1329 1330 return nil 1331 }, opts...) 1332 if e != nil { 1333 return nil, e 1334 } 1335 return resp, nil 1336 } 1337 1338 // RemoveExamples remove Examples from the Example Store. 1339 func (c *exampleStoreRESTClient) RemoveExamples(ctx context.Context, req *aiplatformpb.RemoveExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveExamplesResponse, error) { 1340 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1341 jsonReq, err := m.Marshal(req) 1342 if err != nil { 1343 return nil, err 1344 } 1345 1346 baseUrl, err := url.Parse(c.endpoint) 1347 if err != nil { 1348 return nil, err 1349 } 1350 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:removeExamples", req.GetExampleStore()) 1351 1352 params := url.Values{} 1353 params.Add("$alt", "json;enum-encoding=int") 1354 1355 baseUrl.RawQuery = params.Encode() 1356 1357 // Build HTTP headers from client and context metadata. 1358 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 1359 1360 hds = append(c.xGoogHeaders, hds...) 1361 hds = append(hds, "Content-Type", "application/json") 1362 headers := gax.BuildHeaders(ctx, hds...) 1363 opts = append((*c.CallOptions).RemoveExamples[0:len((*c.CallOptions).RemoveExamples):len((*c.CallOptions).RemoveExamples)], opts...) 1364 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1365 resp := &aiplatformpb.RemoveExamplesResponse{} 1366 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1367 if settings.Path != "" { 1368 baseUrl.Path = settings.Path 1369 } 1370 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1371 if err != nil { 1372 return err 1373 } 1374 httpReq = httpReq.WithContext(ctx) 1375 httpReq.Header = headers 1376 1377 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RemoveExamples") 1378 if err != nil { 1379 return err 1380 } 1381 1382 if err := unm.Unmarshal(buf, resp); err != nil { 1383 return err 1384 } 1385 1386 return nil 1387 }, opts...) 1388 if e != nil { 1389 return nil, e 1390 } 1391 return resp, nil 1392 } 1393 1394 // SearchExamples search for similar Examples for given selection criteria. 1395 func (c *exampleStoreRESTClient) SearchExamples(ctx context.Context, req *aiplatformpb.SearchExamplesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchExamplesResponse, error) { 1396 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1397 jsonReq, err := m.Marshal(req) 1398 if err != nil { 1399 return nil, err 1400 } 1401 1402 baseUrl, err := url.Parse(c.endpoint) 1403 if err != nil { 1404 return nil, err 1405 } 1406 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:searchExamples", req.GetExampleStore()) 1407 1408 params := url.Values{} 1409 params.Add("$alt", "json;enum-encoding=int") 1410 1411 baseUrl.RawQuery = params.Encode() 1412 1413 // Build HTTP headers from client and context metadata. 1414 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "example_store", url.QueryEscape(req.GetExampleStore()))} 1415 1416 hds = append(c.xGoogHeaders, hds...) 1417 hds = append(hds, "Content-Type", "application/json") 1418 headers := gax.BuildHeaders(ctx, hds...) 1419 opts = append((*c.CallOptions).SearchExamples[0:len((*c.CallOptions).SearchExamples):len((*c.CallOptions).SearchExamples)], opts...) 1420 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1421 resp := &aiplatformpb.SearchExamplesResponse{} 1422 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1423 if settings.Path != "" { 1424 baseUrl.Path = settings.Path 1425 } 1426 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1427 if err != nil { 1428 return err 1429 } 1430 httpReq = httpReq.WithContext(ctx) 1431 httpReq.Header = headers 1432 1433 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SearchExamples") 1434 if err != nil { 1435 return err 1436 } 1437 1438 if err := unm.Unmarshal(buf, resp); err != nil { 1439 return err 1440 } 1441 1442 return nil 1443 }, opts...) 1444 if e != nil { 1445 return nil, e 1446 } 1447 return resp, nil 1448 } 1449 1450 // FetchExamples get Examples from the Example Store. 1451 func (c *exampleStoreRESTClient) FetchExamples(ctx context.Context, req *aiplatformpb.FetchExamplesRequest, opts ...gax.CallOption) *ExampleIterator { 1452 it := &ExampleIterator{} 1453 req = proto.Clone(req).(*aiplatformpb.FetchExamplesRequest) 1454 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1455 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1456 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Example, string, error) { 1457 resp := &aiplatformpb.FetchExamplesResponse{} 1458 if pageToken != "" { 1459 req.PageToken = pageToken 1460 } 1461 if pageSize > math.MaxInt32 { 1462 req.PageSize = math.MaxInt32 1463 } else if pageSize != 0 { 1464 req.PageSize = int32(pageSize) 1465 } 1466 jsonReq, err := m.Marshal(req) 1467 if err != nil { 1468 return nil, "", err 1469 } 1470 1471 baseUrl, err := url.Parse(c.endpoint) 1472 if err != nil { 1473 return nil, "", err 1474 } 1475 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:fetchExamples", req.GetExampleStore()) 1476 1477 params := url.Values{} 1478 params.Add("$alt", "json;enum-encoding=int") 1479 1480 baseUrl.RawQuery = params.Encode() 1481 1482 // Build HTTP headers from client and context metadata. 1483 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1484 headers := gax.BuildHeaders(ctx, hds...) 1485 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1486 if settings.Path != "" { 1487 baseUrl.Path = settings.Path 1488 } 1489 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1490 if err != nil { 1491 return err 1492 } 1493 httpReq.Header = headers 1494 1495 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "FetchExamples") 1496 if err != nil { 1497 return err 1498 } 1499 if err := unm.Unmarshal(buf, resp); err != nil { 1500 return err 1501 } 1502 1503 return nil 1504 }, opts...) 1505 if e != nil { 1506 return nil, "", e 1507 } 1508 it.Response = resp 1509 return resp.GetExamples(), resp.GetNextPageToken(), nil 1510 } 1511 1512 fetch := func(pageSize int, pageToken string) (string, error) { 1513 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1514 if err != nil { 1515 return "", err 1516 } 1517 it.items = append(it.items, items...) 1518 return nextPageToken, nil 1519 } 1520 1521 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1522 it.pageInfo.MaxSize = int(req.GetPageSize()) 1523 it.pageInfo.Token = req.GetPageToken() 1524 1525 return it 1526 } 1527 1528 // GetLocation gets information about a location. 1529 func (c *exampleStoreRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 1530 baseUrl, err := url.Parse(c.endpoint) 1531 if err != nil { 1532 return nil, err 1533 } 1534 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1535 1536 params := url.Values{} 1537 params.Add("$alt", "json;enum-encoding=int") 1538 1539 baseUrl.RawQuery = params.Encode() 1540 1541 // Build HTTP headers from client and context metadata. 1542 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1543 1544 hds = append(c.xGoogHeaders, hds...) 1545 hds = append(hds, "Content-Type", "application/json") 1546 headers := gax.BuildHeaders(ctx, hds...) 1547 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 1548 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1549 resp := &locationpb.Location{} 1550 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1551 if settings.Path != "" { 1552 baseUrl.Path = settings.Path 1553 } 1554 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1555 if err != nil { 1556 return err 1557 } 1558 httpReq = httpReq.WithContext(ctx) 1559 httpReq.Header = headers 1560 1561 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation") 1562 if err != nil { 1563 return err 1564 } 1565 1566 if err := unm.Unmarshal(buf, resp); err != nil { 1567 return err 1568 } 1569 1570 return nil 1571 }, opts...) 1572 if e != nil { 1573 return nil, e 1574 } 1575 return resp, nil 1576 } 1577 1578 // ListLocations lists information about the supported locations for this service. 1579 func (c *exampleStoreRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 1580 it := &LocationIterator{} 1581 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 1582 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1583 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 1584 resp := &locationpb.ListLocationsResponse{} 1585 if pageToken != "" { 1586 req.PageToken = pageToken 1587 } 1588 if pageSize > math.MaxInt32 { 1589 req.PageSize = math.MaxInt32 1590 } else if pageSize != 0 { 1591 req.PageSize = int32(pageSize) 1592 } 1593 baseUrl, err := url.Parse(c.endpoint) 1594 if err != nil { 1595 return nil, "", err 1596 } 1597 baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName()) 1598 1599 params := url.Values{} 1600 params.Add("$alt", "json;enum-encoding=int") 1601 if req.GetFilter() != "" { 1602 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1603 } 1604 if req.GetPageSize() != 0 { 1605 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1606 } 1607 if req.GetPageToken() != "" { 1608 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1609 } 1610 1611 baseUrl.RawQuery = params.Encode() 1612 1613 // Build HTTP headers from client and context metadata. 1614 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1615 headers := gax.BuildHeaders(ctx, hds...) 1616 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1617 if settings.Path != "" { 1618 baseUrl.Path = settings.Path 1619 } 1620 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1621 if err != nil { 1622 return err 1623 } 1624 httpReq.Header = headers 1625 1626 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations") 1627 if err != nil { 1628 return err 1629 } 1630 if err := unm.Unmarshal(buf, resp); err != nil { 1631 return err 1632 } 1633 1634 return nil 1635 }, opts...) 1636 if e != nil { 1637 return nil, "", e 1638 } 1639 it.Response = resp 1640 return resp.GetLocations(), resp.GetNextPageToken(), nil 1641 } 1642 1643 fetch := func(pageSize int, pageToken string) (string, error) { 1644 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1645 if err != nil { 1646 return "", err 1647 } 1648 it.items = append(it.items, items...) 1649 return nextPageToken, nil 1650 } 1651 1652 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1653 it.pageInfo.MaxSize = int(req.GetPageSize()) 1654 it.pageInfo.Token = req.GetPageToken() 1655 1656 return it 1657 } 1658 1659 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 1660 // if the resource exists and does not have a policy set. 1661 func (c *exampleStoreRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1662 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1663 jsonReq, err := m.Marshal(req) 1664 if err != nil { 1665 return nil, err 1666 } 1667 1668 baseUrl, err := url.Parse(c.endpoint) 1669 if err != nil { 1670 return nil, err 1671 } 1672 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource()) 1673 1674 params := url.Values{} 1675 params.Add("$alt", "json;enum-encoding=int") 1676 1677 baseUrl.RawQuery = params.Encode() 1678 1679 // Build HTTP headers from client and context metadata. 1680 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1681 1682 hds = append(c.xGoogHeaders, hds...) 1683 hds = append(hds, "Content-Type", "application/json") 1684 headers := gax.BuildHeaders(ctx, hds...) 1685 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 1686 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1687 resp := &iampb.Policy{} 1688 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1689 if settings.Path != "" { 1690 baseUrl.Path = settings.Path 1691 } 1692 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1693 if err != nil { 1694 return err 1695 } 1696 httpReq = httpReq.WithContext(ctx) 1697 httpReq.Header = headers 1698 1699 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy") 1700 if err != nil { 1701 return err 1702 } 1703 1704 if err := unm.Unmarshal(buf, resp); err != nil { 1705 return err 1706 } 1707 1708 return nil 1709 }, opts...) 1710 if e != nil { 1711 return nil, e 1712 } 1713 return resp, nil 1714 } 1715 1716 // SetIamPolicy sets the access control policy on the specified resource. Replaces 1717 // any existing policy. 1718 // 1719 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 1720 // errors. 1721 func (c *exampleStoreRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1722 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1723 jsonReq, err := m.Marshal(req) 1724 if err != nil { 1725 return nil, err 1726 } 1727 1728 baseUrl, err := url.Parse(c.endpoint) 1729 if err != nil { 1730 return nil, err 1731 } 1732 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource()) 1733 1734 params := url.Values{} 1735 params.Add("$alt", "json;enum-encoding=int") 1736 1737 baseUrl.RawQuery = params.Encode() 1738 1739 // Build HTTP headers from client and context metadata. 1740 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1741 1742 hds = append(c.xGoogHeaders, hds...) 1743 hds = append(hds, "Content-Type", "application/json") 1744 headers := gax.BuildHeaders(ctx, hds...) 1745 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 1746 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1747 resp := &iampb.Policy{} 1748 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1749 if settings.Path != "" { 1750 baseUrl.Path = settings.Path 1751 } 1752 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1753 if err != nil { 1754 return err 1755 } 1756 httpReq = httpReq.WithContext(ctx) 1757 httpReq.Header = headers 1758 1759 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy") 1760 if err != nil { 1761 return err 1762 } 1763 1764 if err := unm.Unmarshal(buf, resp); err != nil { 1765 return err 1766 } 1767 1768 return nil 1769 }, opts...) 1770 if e != nil { 1771 return nil, e 1772 } 1773 return resp, nil 1774 } 1775 1776 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 1777 // resource does not exist, this will return an empty set of 1778 // permissions, not a NOT_FOUND error. 1779 // 1780 // Note: This operation is designed to be used for building 1781 // permission-aware UIs and command-line tools, not for authorization 1782 // checking. This operation may “fail open” without warning. 1783 func (c *exampleStoreRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 1784 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1785 jsonReq, err := m.Marshal(req) 1786 if err != nil { 1787 return nil, err 1788 } 1789 1790 baseUrl, err := url.Parse(c.endpoint) 1791 if err != nil { 1792 return nil, err 1793 } 1794 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource()) 1795 1796 params := url.Values{} 1797 params.Add("$alt", "json;enum-encoding=int") 1798 1799 baseUrl.RawQuery = params.Encode() 1800 1801 // Build HTTP headers from client and context metadata. 1802 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1803 1804 hds = append(c.xGoogHeaders, hds...) 1805 hds = append(hds, "Content-Type", "application/json") 1806 headers := gax.BuildHeaders(ctx, hds...) 1807 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 1808 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1809 resp := &iampb.TestIamPermissionsResponse{} 1810 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1811 if settings.Path != "" { 1812 baseUrl.Path = settings.Path 1813 } 1814 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1815 if err != nil { 1816 return err 1817 } 1818 httpReq = httpReq.WithContext(ctx) 1819 httpReq.Header = headers 1820 1821 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions") 1822 if err != nil { 1823 return err 1824 } 1825 1826 if err := unm.Unmarshal(buf, resp); err != nil { 1827 return err 1828 } 1829 1830 return nil 1831 }, opts...) 1832 if e != nil { 1833 return nil, e 1834 } 1835 return resp, nil 1836 } 1837 1838 // CancelOperation is a utility method from google.longrunning.Operations. 1839 func (c *exampleStoreRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 1840 baseUrl, err := url.Parse(c.endpoint) 1841 if err != nil { 1842 return err 1843 } 1844 baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName()) 1845 1846 params := url.Values{} 1847 params.Add("$alt", "json;enum-encoding=int") 1848 1849 baseUrl.RawQuery = params.Encode() 1850 1851 // Build HTTP headers from client and context metadata. 1852 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1853 1854 hds = append(c.xGoogHeaders, hds...) 1855 hds = append(hds, "Content-Type", "application/json") 1856 headers := gax.BuildHeaders(ctx, hds...) 1857 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1858 if settings.Path != "" { 1859 baseUrl.Path = settings.Path 1860 } 1861 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 1862 if err != nil { 1863 return err 1864 } 1865 httpReq = httpReq.WithContext(ctx) 1866 httpReq.Header = headers 1867 1868 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation") 1869 return err 1870 }, opts...) 1871 } 1872 1873 // DeleteOperation is a utility method from google.longrunning.Operations. 1874 func (c *exampleStoreRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 1875 baseUrl, err := url.Parse(c.endpoint) 1876 if err != nil { 1877 return err 1878 } 1879 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1880 1881 params := url.Values{} 1882 params.Add("$alt", "json;enum-encoding=int") 1883 1884 baseUrl.RawQuery = params.Encode() 1885 1886 // Build HTTP headers from client and context metadata. 1887 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1888 1889 hds = append(c.xGoogHeaders, hds...) 1890 hds = append(hds, "Content-Type", "application/json") 1891 headers := gax.BuildHeaders(ctx, hds...) 1892 return 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("DELETE", baseUrl.String(), nil) 1897 if err != nil { 1898 return err 1899 } 1900 httpReq = httpReq.WithContext(ctx) 1901 httpReq.Header = headers 1902 1903 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation") 1904 return err 1905 }, opts...) 1906 } 1907 1908 // GetOperation is a utility method from google.longrunning.Operations. 1909 func (c *exampleStoreRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1910 baseUrl, err := url.Parse(c.endpoint) 1911 if err != nil { 1912 return nil, err 1913 } 1914 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 1915 1916 params := url.Values{} 1917 params.Add("$alt", "json;enum-encoding=int") 1918 1919 baseUrl.RawQuery = params.Encode() 1920 1921 // Build HTTP headers from client and context metadata. 1922 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1923 1924 hds = append(c.xGoogHeaders, hds...) 1925 hds = append(hds, "Content-Type", "application/json") 1926 headers := gax.BuildHeaders(ctx, hds...) 1927 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 1928 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1929 resp := &longrunningpb.Operation{} 1930 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1931 if settings.Path != "" { 1932 baseUrl.Path = settings.Path 1933 } 1934 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1935 if err != nil { 1936 return err 1937 } 1938 httpReq = httpReq.WithContext(ctx) 1939 httpReq.Header = headers 1940 1941 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation") 1942 if err != nil { 1943 return err 1944 } 1945 1946 if err := unm.Unmarshal(buf, resp); err != nil { 1947 return err 1948 } 1949 1950 return nil 1951 }, opts...) 1952 if e != nil { 1953 return nil, e 1954 } 1955 return resp, nil 1956 } 1957 1958 // ListOperations is a utility method from google.longrunning.Operations. 1959 func (c *exampleStoreRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 1960 it := &OperationIterator{} 1961 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 1962 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1963 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 1964 resp := &longrunningpb.ListOperationsResponse{} 1965 if pageToken != "" { 1966 req.PageToken = pageToken 1967 } 1968 if pageSize > math.MaxInt32 { 1969 req.PageSize = math.MaxInt32 1970 } else if pageSize != 0 { 1971 req.PageSize = int32(pageSize) 1972 } 1973 baseUrl, err := url.Parse(c.endpoint) 1974 if err != nil { 1975 return nil, "", err 1976 } 1977 baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName()) 1978 1979 params := url.Values{} 1980 params.Add("$alt", "json;enum-encoding=int") 1981 if req.GetFilter() != "" { 1982 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1983 } 1984 if req.GetPageSize() != 0 { 1985 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1986 } 1987 if req.GetPageToken() != "" { 1988 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1989 } 1990 1991 baseUrl.RawQuery = params.Encode() 1992 1993 // Build HTTP headers from client and context metadata. 1994 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1995 headers := gax.BuildHeaders(ctx, hds...) 1996 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1997 if settings.Path != "" { 1998 baseUrl.Path = settings.Path 1999 } 2000 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2001 if err != nil { 2002 return err 2003 } 2004 httpReq.Header = headers 2005 2006 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations") 2007 if err != nil { 2008 return err 2009 } 2010 if err := unm.Unmarshal(buf, resp); err != nil { 2011 return err 2012 } 2013 2014 return nil 2015 }, opts...) 2016 if e != nil { 2017 return nil, "", e 2018 } 2019 it.Response = resp 2020 return resp.GetOperations(), resp.GetNextPageToken(), nil 2021 } 2022 2023 fetch := func(pageSize int, pageToken string) (string, error) { 2024 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 2025 if err != nil { 2026 return "", err 2027 } 2028 it.items = append(it.items, items...) 2029 return nextPageToken, nil 2030 } 2031 2032 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 2033 it.pageInfo.MaxSize = int(req.GetPageSize()) 2034 it.pageInfo.Token = req.GetPageToken() 2035 2036 return it 2037 } 2038 2039 // WaitOperation is a utility method from google.longrunning.Operations. 2040 func (c *exampleStoreRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 2041 baseUrl, err := url.Parse(c.endpoint) 2042 if err != nil { 2043 return nil, err 2044 } 2045 baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName()) 2046 2047 params := url.Values{} 2048 params.Add("$alt", "json;enum-encoding=int") 2049 if req.GetTimeout() != nil { 2050 field, err := protojson.Marshal(req.GetTimeout()) 2051 if err != nil { 2052 return nil, err 2053 } 2054 params.Add("timeout", string(field[1:len(field)-1])) 2055 } 2056 2057 baseUrl.RawQuery = params.Encode() 2058 2059 // Build HTTP headers from client and context metadata. 2060 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2061 2062 hds = append(c.xGoogHeaders, hds...) 2063 hds = append(hds, "Content-Type", "application/json") 2064 headers := gax.BuildHeaders(ctx, hds...) 2065 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 2066 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2067 resp := &longrunningpb.Operation{} 2068 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2069 if settings.Path != "" { 2070 baseUrl.Path = settings.Path 2071 } 2072 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 2073 if err != nil { 2074 return err 2075 } 2076 httpReq = httpReq.WithContext(ctx) 2077 httpReq.Header = headers 2078 2079 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation") 2080 if err != nil { 2081 return err 2082 } 2083 2084 if err := unm.Unmarshal(buf, resp); err != nil { 2085 return err 2086 } 2087 2088 return nil 2089 }, opts...) 2090 if e != nil { 2091 return nil, e 2092 } 2093 return resp, nil 2094 } 2095 2096 // CreateExampleStoreOperation returns a new CreateExampleStoreOperation from a given name. 2097 // The name must be that of a previously created CreateExampleStoreOperation, possibly from a different process. 2098 func (c *exampleStoreGRPCClient) CreateExampleStoreOperation(name string) *CreateExampleStoreOperation { 2099 return &CreateExampleStoreOperation{ 2100 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2101 } 2102 } 2103 2104 // CreateExampleStoreOperation returns a new CreateExampleStoreOperation from a given name. 2105 // The name must be that of a previously created CreateExampleStoreOperation, possibly from a different process. 2106 func (c *exampleStoreRESTClient) CreateExampleStoreOperation(name string) *CreateExampleStoreOperation { 2107 override := fmt.Sprintf("/ui/%s", name) 2108 return &CreateExampleStoreOperation{ 2109 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2110 pollPath: override, 2111 } 2112 } 2113 2114 // DeleteExampleStoreOperation returns a new DeleteExampleStoreOperation from a given name. 2115 // The name must be that of a previously created DeleteExampleStoreOperation, possibly from a different process. 2116 func (c *exampleStoreGRPCClient) DeleteExampleStoreOperation(name string) *DeleteExampleStoreOperation { 2117 return &DeleteExampleStoreOperation{ 2118 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2119 } 2120 } 2121 2122 // DeleteExampleStoreOperation returns a new DeleteExampleStoreOperation from a given name. 2123 // The name must be that of a previously created DeleteExampleStoreOperation, possibly from a different process. 2124 func (c *exampleStoreRESTClient) DeleteExampleStoreOperation(name string) *DeleteExampleStoreOperation { 2125 override := fmt.Sprintf("/ui/%s", name) 2126 return &DeleteExampleStoreOperation{ 2127 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2128 pollPath: override, 2129 } 2130 } 2131 2132 // UpdateExampleStoreOperation returns a new UpdateExampleStoreOperation from a given name. 2133 // The name must be that of a previously created UpdateExampleStoreOperation, possibly from a different process. 2134 func (c *exampleStoreGRPCClient) UpdateExampleStoreOperation(name string) *UpdateExampleStoreOperation { 2135 return &UpdateExampleStoreOperation{ 2136 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2137 } 2138 } 2139 2140 // UpdateExampleStoreOperation returns a new UpdateExampleStoreOperation from a given name. 2141 // The name must be that of a previously created UpdateExampleStoreOperation, possibly from a different process. 2142 func (c *exampleStoreRESTClient) UpdateExampleStoreOperation(name string) *UpdateExampleStoreOperation { 2143 override := fmt.Sprintf("/ui/%s", name) 2144 return &UpdateExampleStoreOperation{ 2145 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 2146 pollPath: override, 2147 } 2148 }