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