cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/feature_registry_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 newFeatureRegistryClientHook clientHook 46 47 // FeatureRegistryCallOptions contains the retry settings for each method of FeatureRegistryClient. 48 type FeatureRegistryCallOptions struct { 49 CreateFeatureGroup []gax.CallOption 50 GetFeatureGroup []gax.CallOption 51 ListFeatureGroups []gax.CallOption 52 UpdateFeatureGroup []gax.CallOption 53 DeleteFeatureGroup []gax.CallOption 54 CreateFeature []gax.CallOption 55 BatchCreateFeatures []gax.CallOption 56 GetFeature []gax.CallOption 57 ListFeatures []gax.CallOption 58 UpdateFeature []gax.CallOption 59 DeleteFeature []gax.CallOption 60 CreateFeatureMonitor []gax.CallOption 61 GetFeatureMonitor []gax.CallOption 62 ListFeatureMonitors []gax.CallOption 63 UpdateFeatureMonitor []gax.CallOption 64 DeleteFeatureMonitor []gax.CallOption 65 CreateFeatureMonitorJob []gax.CallOption 66 GetFeatureMonitorJob []gax.CallOption 67 ListFeatureMonitorJobs []gax.CallOption 68 GetLocation []gax.CallOption 69 ListLocations []gax.CallOption 70 GetIamPolicy []gax.CallOption 71 SetIamPolicy []gax.CallOption 72 TestIamPermissions []gax.CallOption 73 CancelOperation []gax.CallOption 74 DeleteOperation []gax.CallOption 75 GetOperation []gax.CallOption 76 ListOperations []gax.CallOption 77 WaitOperation []gax.CallOption 78 } 79 80 func defaultFeatureRegistryGRPCClientOptions() []option.ClientOption { 81 return []option.ClientOption{ 82 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 83 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 84 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 85 internaloption.WithDefaultUniverseDomain("googleapis.com"), 86 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 87 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 88 internaloption.EnableJwtWithScope(), 89 internaloption.EnableNewAuthLibrary(), 90 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 91 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 92 } 93 } 94 95 func defaultFeatureRegistryCallOptions() *FeatureRegistryCallOptions { 96 return &FeatureRegistryCallOptions{ 97 CreateFeatureGroup: []gax.CallOption{}, 98 GetFeatureGroup: []gax.CallOption{}, 99 ListFeatureGroups: []gax.CallOption{}, 100 UpdateFeatureGroup: []gax.CallOption{}, 101 DeleteFeatureGroup: []gax.CallOption{}, 102 CreateFeature: []gax.CallOption{}, 103 BatchCreateFeatures: []gax.CallOption{}, 104 GetFeature: []gax.CallOption{}, 105 ListFeatures: []gax.CallOption{}, 106 UpdateFeature: []gax.CallOption{}, 107 DeleteFeature: []gax.CallOption{}, 108 CreateFeatureMonitor: []gax.CallOption{}, 109 GetFeatureMonitor: []gax.CallOption{}, 110 ListFeatureMonitors: []gax.CallOption{}, 111 UpdateFeatureMonitor: []gax.CallOption{}, 112 DeleteFeatureMonitor: []gax.CallOption{}, 113 CreateFeatureMonitorJob: []gax.CallOption{}, 114 GetFeatureMonitorJob: []gax.CallOption{}, 115 ListFeatureMonitorJobs: []gax.CallOption{}, 116 GetLocation: []gax.CallOption{}, 117 ListLocations: []gax.CallOption{}, 118 GetIamPolicy: []gax.CallOption{}, 119 SetIamPolicy: []gax.CallOption{}, 120 TestIamPermissions: []gax.CallOption{}, 121 CancelOperation: []gax.CallOption{}, 122 DeleteOperation: []gax.CallOption{}, 123 GetOperation: []gax.CallOption{}, 124 ListOperations: []gax.CallOption{}, 125 WaitOperation: []gax.CallOption{}, 126 } 127 } 128 129 func defaultFeatureRegistryRESTCallOptions() *FeatureRegistryCallOptions { 130 return &FeatureRegistryCallOptions{ 131 CreateFeatureGroup: []gax.CallOption{}, 132 GetFeatureGroup: []gax.CallOption{}, 133 ListFeatureGroups: []gax.CallOption{}, 134 UpdateFeatureGroup: []gax.CallOption{}, 135 DeleteFeatureGroup: []gax.CallOption{}, 136 CreateFeature: []gax.CallOption{}, 137 BatchCreateFeatures: []gax.CallOption{}, 138 GetFeature: []gax.CallOption{}, 139 ListFeatures: []gax.CallOption{}, 140 UpdateFeature: []gax.CallOption{}, 141 DeleteFeature: []gax.CallOption{}, 142 CreateFeatureMonitor: []gax.CallOption{}, 143 GetFeatureMonitor: []gax.CallOption{}, 144 ListFeatureMonitors: []gax.CallOption{}, 145 UpdateFeatureMonitor: []gax.CallOption{}, 146 DeleteFeatureMonitor: []gax.CallOption{}, 147 CreateFeatureMonitorJob: []gax.CallOption{}, 148 GetFeatureMonitorJob: []gax.CallOption{}, 149 ListFeatureMonitorJobs: []gax.CallOption{}, 150 GetLocation: []gax.CallOption{}, 151 ListLocations: []gax.CallOption{}, 152 GetIamPolicy: []gax.CallOption{}, 153 SetIamPolicy: []gax.CallOption{}, 154 TestIamPermissions: []gax.CallOption{}, 155 CancelOperation: []gax.CallOption{}, 156 DeleteOperation: []gax.CallOption{}, 157 GetOperation: []gax.CallOption{}, 158 ListOperations: []gax.CallOption{}, 159 WaitOperation: []gax.CallOption{}, 160 } 161 } 162 163 // internalFeatureRegistryClient is an interface that defines the methods available from Vertex AI API. 164 type internalFeatureRegistryClient interface { 165 Close() error 166 setGoogleClientInfo(...string) 167 Connection() *grpc.ClientConn 168 CreateFeatureGroup(context.Context, *aiplatformpb.CreateFeatureGroupRequest, ...gax.CallOption) (*CreateFeatureGroupOperation, error) 169 CreateFeatureGroupOperation(name string) *CreateFeatureGroupOperation 170 GetFeatureGroup(context.Context, *aiplatformpb.GetFeatureGroupRequest, ...gax.CallOption) (*aiplatformpb.FeatureGroup, error) 171 ListFeatureGroups(context.Context, *aiplatformpb.ListFeatureGroupsRequest, ...gax.CallOption) *FeatureGroupIterator 172 UpdateFeatureGroup(context.Context, *aiplatformpb.UpdateFeatureGroupRequest, ...gax.CallOption) (*UpdateFeatureGroupOperation, error) 173 UpdateFeatureGroupOperation(name string) *UpdateFeatureGroupOperation 174 DeleteFeatureGroup(context.Context, *aiplatformpb.DeleteFeatureGroupRequest, ...gax.CallOption) (*DeleteFeatureGroupOperation, error) 175 DeleteFeatureGroupOperation(name string) *DeleteFeatureGroupOperation 176 CreateFeature(context.Context, *aiplatformpb.CreateFeatureRequest, ...gax.CallOption) (*CreateFeatureOperation, error) 177 CreateFeatureOperation(name string) *CreateFeatureOperation 178 BatchCreateFeatures(context.Context, *aiplatformpb.BatchCreateFeaturesRequest, ...gax.CallOption) (*BatchCreateFeaturesOperation, error) 179 BatchCreateFeaturesOperation(name string) *BatchCreateFeaturesOperation 180 GetFeature(context.Context, *aiplatformpb.GetFeatureRequest, ...gax.CallOption) (*aiplatformpb.Feature, error) 181 ListFeatures(context.Context, *aiplatformpb.ListFeaturesRequest, ...gax.CallOption) *FeatureIterator 182 UpdateFeature(context.Context, *aiplatformpb.UpdateFeatureRequest, ...gax.CallOption) (*UpdateFeatureOperation, error) 183 UpdateFeatureOperation(name string) *UpdateFeatureOperation 184 DeleteFeature(context.Context, *aiplatformpb.DeleteFeatureRequest, ...gax.CallOption) (*DeleteFeatureOperation, error) 185 DeleteFeatureOperation(name string) *DeleteFeatureOperation 186 CreateFeatureMonitor(context.Context, *aiplatformpb.CreateFeatureMonitorRequest, ...gax.CallOption) (*CreateFeatureMonitorOperation, error) 187 CreateFeatureMonitorOperation(name string) *CreateFeatureMonitorOperation 188 GetFeatureMonitor(context.Context, *aiplatformpb.GetFeatureMonitorRequest, ...gax.CallOption) (*aiplatformpb.FeatureMonitor, error) 189 ListFeatureMonitors(context.Context, *aiplatformpb.ListFeatureMonitorsRequest, ...gax.CallOption) *FeatureMonitorIterator 190 UpdateFeatureMonitor(context.Context, *aiplatformpb.UpdateFeatureMonitorRequest, ...gax.CallOption) (*UpdateFeatureMonitorOperation, error) 191 UpdateFeatureMonitorOperation(name string) *UpdateFeatureMonitorOperation 192 DeleteFeatureMonitor(context.Context, *aiplatformpb.DeleteFeatureMonitorRequest, ...gax.CallOption) (*DeleteFeatureMonitorOperation, error) 193 DeleteFeatureMonitorOperation(name string) *DeleteFeatureMonitorOperation 194 CreateFeatureMonitorJob(context.Context, *aiplatformpb.CreateFeatureMonitorJobRequest, ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) 195 GetFeatureMonitorJob(context.Context, *aiplatformpb.GetFeatureMonitorJobRequest, ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) 196 ListFeatureMonitorJobs(context.Context, *aiplatformpb.ListFeatureMonitorJobsRequest, ...gax.CallOption) *FeatureMonitorJobIterator 197 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 198 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 199 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 200 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 201 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 202 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 203 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 204 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 205 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 206 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 207 } 208 209 // FeatureRegistryClient is a client for interacting with Vertex AI API. 210 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 211 // 212 // The service that handles CRUD and List for resources for 213 // FeatureRegistry. 214 type FeatureRegistryClient struct { 215 // The internal transport-dependent client. 216 internalClient internalFeatureRegistryClient 217 218 // The call options for this service. 219 CallOptions *FeatureRegistryCallOptions 220 221 // LROClient is used internally to handle long-running operations. 222 // It is exposed so that its CallOptions can be modified if required. 223 // Users should not Close this client. 224 LROClient *lroauto.OperationsClient 225 } 226 227 // Wrapper methods routed to the internal client. 228 229 // Close closes the connection to the API service. The user should invoke this when 230 // the client is no longer required. 231 func (c *FeatureRegistryClient) Close() error { 232 return c.internalClient.Close() 233 } 234 235 // setGoogleClientInfo sets the name and version of the application in 236 // the `x-goog-api-client` header passed on each request. Intended for 237 // use by Google-written clients. 238 func (c *FeatureRegistryClient) setGoogleClientInfo(keyval ...string) { 239 c.internalClient.setGoogleClientInfo(keyval...) 240 } 241 242 // Connection returns a connection to the API service. 243 // 244 // Deprecated: Connections are now pooled so this method does not always 245 // return the same resource. 246 func (c *FeatureRegistryClient) Connection() *grpc.ClientConn { 247 return c.internalClient.Connection() 248 } 249 250 // CreateFeatureGroup creates a new FeatureGroup in a given project and location. 251 func (c *FeatureRegistryClient) CreateFeatureGroup(ctx context.Context, req *aiplatformpb.CreateFeatureGroupRequest, opts ...gax.CallOption) (*CreateFeatureGroupOperation, error) { 252 return c.internalClient.CreateFeatureGroup(ctx, req, opts...) 253 } 254 255 // CreateFeatureGroupOperation returns a new CreateFeatureGroupOperation from a given name. 256 // The name must be that of a previously created CreateFeatureGroupOperation, possibly from a different process. 257 func (c *FeatureRegistryClient) CreateFeatureGroupOperation(name string) *CreateFeatureGroupOperation { 258 return c.internalClient.CreateFeatureGroupOperation(name) 259 } 260 261 // GetFeatureGroup gets details of a single FeatureGroup. 262 func (c *FeatureRegistryClient) GetFeatureGroup(ctx context.Context, req *aiplatformpb.GetFeatureGroupRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureGroup, error) { 263 return c.internalClient.GetFeatureGroup(ctx, req, opts...) 264 } 265 266 // ListFeatureGroups lists FeatureGroups in a given project and location. 267 func (c *FeatureRegistryClient) ListFeatureGroups(ctx context.Context, req *aiplatformpb.ListFeatureGroupsRequest, opts ...gax.CallOption) *FeatureGroupIterator { 268 return c.internalClient.ListFeatureGroups(ctx, req, opts...) 269 } 270 271 // UpdateFeatureGroup updates the parameters of a single FeatureGroup. 272 func (c *FeatureRegistryClient) UpdateFeatureGroup(ctx context.Context, req *aiplatformpb.UpdateFeatureGroupRequest, opts ...gax.CallOption) (*UpdateFeatureGroupOperation, error) { 273 return c.internalClient.UpdateFeatureGroup(ctx, req, opts...) 274 } 275 276 // UpdateFeatureGroupOperation returns a new UpdateFeatureGroupOperation from a given name. 277 // The name must be that of a previously created UpdateFeatureGroupOperation, possibly from a different process. 278 func (c *FeatureRegistryClient) UpdateFeatureGroupOperation(name string) *UpdateFeatureGroupOperation { 279 return c.internalClient.UpdateFeatureGroupOperation(name) 280 } 281 282 // DeleteFeatureGroup deletes a single FeatureGroup. 283 func (c *FeatureRegistryClient) DeleteFeatureGroup(ctx context.Context, req *aiplatformpb.DeleteFeatureGroupRequest, opts ...gax.CallOption) (*DeleteFeatureGroupOperation, error) { 284 return c.internalClient.DeleteFeatureGroup(ctx, req, opts...) 285 } 286 287 // DeleteFeatureGroupOperation returns a new DeleteFeatureGroupOperation from a given name. 288 // The name must be that of a previously created DeleteFeatureGroupOperation, possibly from a different process. 289 func (c *FeatureRegistryClient) DeleteFeatureGroupOperation(name string) *DeleteFeatureGroupOperation { 290 return c.internalClient.DeleteFeatureGroupOperation(name) 291 } 292 293 // CreateFeature creates a new Feature in a given FeatureGroup. 294 func (c *FeatureRegistryClient) CreateFeature(ctx context.Context, req *aiplatformpb.CreateFeatureRequest, opts ...gax.CallOption) (*CreateFeatureOperation, error) { 295 return c.internalClient.CreateFeature(ctx, req, opts...) 296 } 297 298 // CreateFeatureOperation returns a new CreateFeatureOperation from a given name. 299 // The name must be that of a previously created CreateFeatureOperation, possibly from a different process. 300 func (c *FeatureRegistryClient) CreateFeatureOperation(name string) *CreateFeatureOperation { 301 return c.internalClient.CreateFeatureOperation(name) 302 } 303 304 // BatchCreateFeatures creates a batch of Features in a given FeatureGroup. 305 func (c *FeatureRegistryClient) BatchCreateFeatures(ctx context.Context, req *aiplatformpb.BatchCreateFeaturesRequest, opts ...gax.CallOption) (*BatchCreateFeaturesOperation, error) { 306 return c.internalClient.BatchCreateFeatures(ctx, req, opts...) 307 } 308 309 // BatchCreateFeaturesOperation returns a new BatchCreateFeaturesOperation from a given name. 310 // The name must be that of a previously created BatchCreateFeaturesOperation, possibly from a different process. 311 func (c *FeatureRegistryClient) BatchCreateFeaturesOperation(name string) *BatchCreateFeaturesOperation { 312 return c.internalClient.BatchCreateFeaturesOperation(name) 313 } 314 315 // GetFeature gets details of a single Feature. 316 func (c *FeatureRegistryClient) GetFeature(ctx context.Context, req *aiplatformpb.GetFeatureRequest, opts ...gax.CallOption) (*aiplatformpb.Feature, error) { 317 return c.internalClient.GetFeature(ctx, req, opts...) 318 } 319 320 // ListFeatures lists Features in a given FeatureGroup. 321 func (c *FeatureRegistryClient) ListFeatures(ctx context.Context, req *aiplatformpb.ListFeaturesRequest, opts ...gax.CallOption) *FeatureIterator { 322 return c.internalClient.ListFeatures(ctx, req, opts...) 323 } 324 325 // UpdateFeature updates the parameters of a single Feature. 326 func (c *FeatureRegistryClient) UpdateFeature(ctx context.Context, req *aiplatformpb.UpdateFeatureRequest, opts ...gax.CallOption) (*UpdateFeatureOperation, error) { 327 return c.internalClient.UpdateFeature(ctx, req, opts...) 328 } 329 330 // UpdateFeatureOperation returns a new UpdateFeatureOperation from a given name. 331 // The name must be that of a previously created UpdateFeatureOperation, possibly from a different process. 332 func (c *FeatureRegistryClient) UpdateFeatureOperation(name string) *UpdateFeatureOperation { 333 return c.internalClient.UpdateFeatureOperation(name) 334 } 335 336 // DeleteFeature deletes a single Feature. 337 func (c *FeatureRegistryClient) DeleteFeature(ctx context.Context, req *aiplatformpb.DeleteFeatureRequest, opts ...gax.CallOption) (*DeleteFeatureOperation, error) { 338 return c.internalClient.DeleteFeature(ctx, req, opts...) 339 } 340 341 // DeleteFeatureOperation returns a new DeleteFeatureOperation from a given name. 342 // The name must be that of a previously created DeleteFeatureOperation, possibly from a different process. 343 func (c *FeatureRegistryClient) DeleteFeatureOperation(name string) *DeleteFeatureOperation { 344 return c.internalClient.DeleteFeatureOperation(name) 345 } 346 347 // CreateFeatureMonitor creates a new FeatureMonitor in a given project, location and FeatureGroup. 348 func (c *FeatureRegistryClient) CreateFeatureMonitor(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorRequest, opts ...gax.CallOption) (*CreateFeatureMonitorOperation, error) { 349 return c.internalClient.CreateFeatureMonitor(ctx, req, opts...) 350 } 351 352 // CreateFeatureMonitorOperation returns a new CreateFeatureMonitorOperation from a given name. 353 // The name must be that of a previously created CreateFeatureMonitorOperation, possibly from a different process. 354 func (c *FeatureRegistryClient) CreateFeatureMonitorOperation(name string) *CreateFeatureMonitorOperation { 355 return c.internalClient.CreateFeatureMonitorOperation(name) 356 } 357 358 // GetFeatureMonitor gets details of a single FeatureMonitor. 359 func (c *FeatureRegistryClient) GetFeatureMonitor(ctx context.Context, req *aiplatformpb.GetFeatureMonitorRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitor, error) { 360 return c.internalClient.GetFeatureMonitor(ctx, req, opts...) 361 } 362 363 // ListFeatureMonitors lists FeatureGroups in a given project and location. 364 func (c *FeatureRegistryClient) ListFeatureMonitors(ctx context.Context, req *aiplatformpb.ListFeatureMonitorsRequest, opts ...gax.CallOption) *FeatureMonitorIterator { 365 return c.internalClient.ListFeatureMonitors(ctx, req, opts...) 366 } 367 368 // UpdateFeatureMonitor updates the parameters of a single FeatureMonitor. 369 func (c *FeatureRegistryClient) UpdateFeatureMonitor(ctx context.Context, req *aiplatformpb.UpdateFeatureMonitorRequest, opts ...gax.CallOption) (*UpdateFeatureMonitorOperation, error) { 370 return c.internalClient.UpdateFeatureMonitor(ctx, req, opts...) 371 } 372 373 // UpdateFeatureMonitorOperation returns a new UpdateFeatureMonitorOperation from a given name. 374 // The name must be that of a previously created UpdateFeatureMonitorOperation, possibly from a different process. 375 func (c *FeatureRegistryClient) UpdateFeatureMonitorOperation(name string) *UpdateFeatureMonitorOperation { 376 return c.internalClient.UpdateFeatureMonitorOperation(name) 377 } 378 379 // DeleteFeatureMonitor deletes a single FeatureMonitor. 380 func (c *FeatureRegistryClient) DeleteFeatureMonitor(ctx context.Context, req *aiplatformpb.DeleteFeatureMonitorRequest, opts ...gax.CallOption) (*DeleteFeatureMonitorOperation, error) { 381 return c.internalClient.DeleteFeatureMonitor(ctx, req, opts...) 382 } 383 384 // DeleteFeatureMonitorOperation returns a new DeleteFeatureMonitorOperation from a given name. 385 // The name must be that of a previously created DeleteFeatureMonitorOperation, possibly from a different process. 386 func (c *FeatureRegistryClient) DeleteFeatureMonitorOperation(name string) *DeleteFeatureMonitorOperation { 387 return c.internalClient.DeleteFeatureMonitorOperation(name) 388 } 389 390 // CreateFeatureMonitorJob creates a new feature monitor job. 391 func (c *FeatureRegistryClient) CreateFeatureMonitorJob(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 392 return c.internalClient.CreateFeatureMonitorJob(ctx, req, opts...) 393 } 394 395 // GetFeatureMonitorJob get a feature monitor job. 396 func (c *FeatureRegistryClient) GetFeatureMonitorJob(ctx context.Context, req *aiplatformpb.GetFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 397 return c.internalClient.GetFeatureMonitorJob(ctx, req, opts...) 398 } 399 400 // ListFeatureMonitorJobs list feature monitor jobs. 401 func (c *FeatureRegistryClient) ListFeatureMonitorJobs(ctx context.Context, req *aiplatformpb.ListFeatureMonitorJobsRequest, opts ...gax.CallOption) *FeatureMonitorJobIterator { 402 return c.internalClient.ListFeatureMonitorJobs(ctx, req, opts...) 403 } 404 405 // GetLocation gets information about a location. 406 func (c *FeatureRegistryClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 407 return c.internalClient.GetLocation(ctx, req, opts...) 408 } 409 410 // ListLocations lists information about the supported locations for this service. 411 func (c *FeatureRegistryClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 412 return c.internalClient.ListLocations(ctx, req, opts...) 413 } 414 415 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 416 // if the resource exists and does not have a policy set. 417 func (c *FeatureRegistryClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 418 return c.internalClient.GetIamPolicy(ctx, req, opts...) 419 } 420 421 // SetIamPolicy sets the access control policy on the specified resource. Replaces 422 // any existing policy. 423 // 424 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 425 // errors. 426 func (c *FeatureRegistryClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 427 return c.internalClient.SetIamPolicy(ctx, req, opts...) 428 } 429 430 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 431 // resource does not exist, this will return an empty set of 432 // permissions, not a NOT_FOUND error. 433 // 434 // Note: This operation is designed to be used for building 435 // permission-aware UIs and command-line tools, not for authorization 436 // checking. This operation may “fail open” without warning. 437 func (c *FeatureRegistryClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 438 return c.internalClient.TestIamPermissions(ctx, req, opts...) 439 } 440 441 // CancelOperation is a utility method from google.longrunning.Operations. 442 func (c *FeatureRegistryClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 443 return c.internalClient.CancelOperation(ctx, req, opts...) 444 } 445 446 // DeleteOperation is a utility method from google.longrunning.Operations. 447 func (c *FeatureRegistryClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 448 return c.internalClient.DeleteOperation(ctx, req, opts...) 449 } 450 451 // GetOperation is a utility method from google.longrunning.Operations. 452 func (c *FeatureRegistryClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 453 return c.internalClient.GetOperation(ctx, req, opts...) 454 } 455 456 // ListOperations is a utility method from google.longrunning.Operations. 457 func (c *FeatureRegistryClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 458 return c.internalClient.ListOperations(ctx, req, opts...) 459 } 460 461 // WaitOperation is a utility method from google.longrunning.Operations. 462 func (c *FeatureRegistryClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 463 return c.internalClient.WaitOperation(ctx, req, opts...) 464 } 465 466 // featureRegistryGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 467 // 468 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 469 type featureRegistryGRPCClient struct { 470 // Connection pool of gRPC connections to the service. 471 connPool gtransport.ConnPool 472 473 // Points back to the CallOptions field of the containing FeatureRegistryClient 474 CallOptions **FeatureRegistryCallOptions 475 476 // The gRPC API client. 477 featureRegistryClient aiplatformpb.FeatureRegistryServiceClient 478 479 // LROClient is used internally to handle long-running operations. 480 // It is exposed so that its CallOptions can be modified if required. 481 // Users should not Close this client. 482 LROClient **lroauto.OperationsClient 483 484 operationsClient longrunningpb.OperationsClient 485 486 iamPolicyClient iampb.IAMPolicyClient 487 488 locationsClient locationpb.LocationsClient 489 490 // The x-goog-* metadata to be sent with each request. 491 xGoogHeaders []string 492 493 logger *slog.Logger 494 } 495 496 // NewFeatureRegistryClient creates a new feature registry service client based on gRPC. 497 // The returned client must be Closed when it is done being used to clean up its underlying connections. 498 // 499 // The service that handles CRUD and List for resources for 500 // FeatureRegistry. 501 func NewFeatureRegistryClient(ctx context.Context, opts ...option.ClientOption) (*FeatureRegistryClient, error) { 502 clientOpts := defaultFeatureRegistryGRPCClientOptions() 503 if newFeatureRegistryClientHook != nil { 504 hookOpts, err := newFeatureRegistryClientHook(ctx, clientHookParams{}) 505 if err != nil { 506 return nil, err 507 } 508 clientOpts = append(clientOpts, hookOpts...) 509 } 510 511 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 512 if err != nil { 513 return nil, err 514 } 515 client := FeatureRegistryClient{CallOptions: defaultFeatureRegistryCallOptions()} 516 517 c := &featureRegistryGRPCClient{ 518 connPool: connPool, 519 featureRegistryClient: aiplatformpb.NewFeatureRegistryServiceClient(connPool), 520 CallOptions: &client.CallOptions, 521 logger: internaloption.GetLogger(opts), 522 operationsClient: longrunningpb.NewOperationsClient(connPool), 523 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 524 locationsClient: locationpb.NewLocationsClient(connPool), 525 } 526 c.setGoogleClientInfo() 527 528 client.internalClient = c 529 530 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 531 if err != nil { 532 // This error "should not happen", since we are just reusing old connection pool 533 // and never actually need to dial. 534 // If this does happen, we could leak connp. However, we cannot close conn: 535 // If the user invoked the constructor with option.WithGRPCConn, 536 // we would close a connection that's still in use. 537 // TODO: investigate error conditions. 538 return nil, err 539 } 540 c.LROClient = &client.LROClient 541 return &client, nil 542 } 543 544 // Connection returns a connection to the API service. 545 // 546 // Deprecated: Connections are now pooled so this method does not always 547 // return the same resource. 548 func (c *featureRegistryGRPCClient) Connection() *grpc.ClientConn { 549 return c.connPool.Conn() 550 } 551 552 // setGoogleClientInfo sets the name and version of the application in 553 // the `x-goog-api-client` header passed on each request. Intended for 554 // use by Google-written clients. 555 func (c *featureRegistryGRPCClient) setGoogleClientInfo(keyval ...string) { 556 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 557 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 558 c.xGoogHeaders = []string{ 559 "x-goog-api-client", gax.XGoogHeader(kv...), 560 } 561 } 562 563 // Close closes the connection to the API service. The user should invoke this when 564 // the client is no longer required. 565 func (c *featureRegistryGRPCClient) Close() error { 566 return c.connPool.Close() 567 } 568 569 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 570 type featureRegistryRESTClient struct { 571 // The http endpoint to connect to. 572 endpoint string 573 574 // The http client. 575 httpClient *http.Client 576 577 // LROClient is used internally to handle long-running operations. 578 // It is exposed so that its CallOptions can be modified if required. 579 // Users should not Close this client. 580 LROClient **lroauto.OperationsClient 581 582 // The x-goog-* headers to be sent with each request. 583 xGoogHeaders []string 584 585 // Points back to the CallOptions field of the containing FeatureRegistryClient 586 CallOptions **FeatureRegistryCallOptions 587 588 logger *slog.Logger 589 } 590 591 // NewFeatureRegistryRESTClient creates a new feature registry service rest client. 592 // 593 // The service that handles CRUD and List for resources for 594 // FeatureRegistry. 595 func NewFeatureRegistryRESTClient(ctx context.Context, opts ...option.ClientOption) (*FeatureRegistryClient, error) { 596 clientOpts := append(defaultFeatureRegistryRESTClientOptions(), opts...) 597 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...) 598 if err != nil { 599 return nil, err 600 } 601 602 callOpts := defaultFeatureRegistryRESTCallOptions() 603 c := &featureRegistryRESTClient{ 604 endpoint: endpoint, 605 httpClient: httpClient, 606 CallOptions: &callOpts, 607 logger: internaloption.GetLogger(opts), 608 } 609 c.setGoogleClientInfo() 610 611 lroOpts := []option.ClientOption{ 612 option.WithHTTPClient(httpClient), 613 option.WithEndpoint(endpoint), 614 } 615 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...) 616 if err != nil { 617 return nil, err 618 } 619 c.LROClient = &opClient 620 621 return &FeatureRegistryClient{internalClient: c, CallOptions: callOpts}, nil 622 } 623 624 func defaultFeatureRegistryRESTClientOptions() []option.ClientOption { 625 return []option.ClientOption{ 626 internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"), 627 internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"), 628 internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"), 629 internaloption.WithDefaultUniverseDomain("googleapis.com"), 630 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 631 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 632 internaloption.EnableNewAuthLibrary(), 633 } 634 } 635 636 // setGoogleClientInfo sets the name and version of the application in 637 // the `x-goog-api-client` header passed on each request. Intended for 638 // use by Google-written clients. 639 func (c *featureRegistryRESTClient) setGoogleClientInfo(keyval ...string) { 640 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 641 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion) 642 c.xGoogHeaders = []string{ 643 "x-goog-api-client", gax.XGoogHeader(kv...), 644 } 645 } 646 647 // Close closes the connection to the API service. The user should invoke this when 648 // the client is no longer required. 649 func (c *featureRegistryRESTClient) Close() error { 650 // Replace httpClient with nil to force cleanup. 651 c.httpClient = nil 652 return nil 653 } 654 655 // Connection returns a connection to the API service. 656 // 657 // Deprecated: This method always returns nil. 658 func (c *featureRegistryRESTClient) Connection() *grpc.ClientConn { 659 return nil 660 } 661 func (c *featureRegistryGRPCClient) CreateFeatureGroup(ctx context.Context, req *aiplatformpb.CreateFeatureGroupRequest, opts ...gax.CallOption) (*CreateFeatureGroupOperation, error) { 662 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 663 664 hds = append(c.xGoogHeaders, hds...) 665 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 666 opts = append((*c.CallOptions).CreateFeatureGroup[0:len((*c.CallOptions).CreateFeatureGroup):len((*c.CallOptions).CreateFeatureGroup)], opts...) 667 var resp *longrunningpb.Operation 668 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 669 var err error 670 resp, err = executeRPC(ctx, c.featureRegistryClient.CreateFeatureGroup, req, settings.GRPC, c.logger, "CreateFeatureGroup") 671 return err 672 }, opts...) 673 if err != nil { 674 return nil, err 675 } 676 return &CreateFeatureGroupOperation{ 677 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 678 }, nil 679 } 680 681 func (c *featureRegistryGRPCClient) GetFeatureGroup(ctx context.Context, req *aiplatformpb.GetFeatureGroupRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureGroup, error) { 682 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 683 684 hds = append(c.xGoogHeaders, hds...) 685 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 686 opts = append((*c.CallOptions).GetFeatureGroup[0:len((*c.CallOptions).GetFeatureGroup):len((*c.CallOptions).GetFeatureGroup)], opts...) 687 var resp *aiplatformpb.FeatureGroup 688 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 689 var err error 690 resp, err = executeRPC(ctx, c.featureRegistryClient.GetFeatureGroup, req, settings.GRPC, c.logger, "GetFeatureGroup") 691 return err 692 }, opts...) 693 if err != nil { 694 return nil, err 695 } 696 return resp, nil 697 } 698 699 func (c *featureRegistryGRPCClient) ListFeatureGroups(ctx context.Context, req *aiplatformpb.ListFeatureGroupsRequest, opts ...gax.CallOption) *FeatureGroupIterator { 700 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 701 702 hds = append(c.xGoogHeaders, hds...) 703 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 704 opts = append((*c.CallOptions).ListFeatureGroups[0:len((*c.CallOptions).ListFeatureGroups):len((*c.CallOptions).ListFeatureGroups)], opts...) 705 it := &FeatureGroupIterator{} 706 req = proto.Clone(req).(*aiplatformpb.ListFeatureGroupsRequest) 707 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureGroup, string, error) { 708 resp := &aiplatformpb.ListFeatureGroupsResponse{} 709 if pageToken != "" { 710 req.PageToken = pageToken 711 } 712 if pageSize > math.MaxInt32 { 713 req.PageSize = math.MaxInt32 714 } else if pageSize != 0 { 715 req.PageSize = int32(pageSize) 716 } 717 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 718 var err error 719 resp, err = executeRPC(ctx, c.featureRegistryClient.ListFeatureGroups, req, settings.GRPC, c.logger, "ListFeatureGroups") 720 return err 721 }, opts...) 722 if err != nil { 723 return nil, "", err 724 } 725 726 it.Response = resp 727 return resp.GetFeatureGroups(), resp.GetNextPageToken(), nil 728 } 729 fetch := func(pageSize int, pageToken string) (string, error) { 730 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 731 if err != nil { 732 return "", err 733 } 734 it.items = append(it.items, items...) 735 return nextPageToken, nil 736 } 737 738 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 739 it.pageInfo.MaxSize = int(req.GetPageSize()) 740 it.pageInfo.Token = req.GetPageToken() 741 742 return it 743 } 744 745 func (c *featureRegistryGRPCClient) UpdateFeatureGroup(ctx context.Context, req *aiplatformpb.UpdateFeatureGroupRequest, opts ...gax.CallOption) (*UpdateFeatureGroupOperation, error) { 746 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_group.name", url.QueryEscape(req.GetFeatureGroup().GetName()))} 747 748 hds = append(c.xGoogHeaders, hds...) 749 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 750 opts = append((*c.CallOptions).UpdateFeatureGroup[0:len((*c.CallOptions).UpdateFeatureGroup):len((*c.CallOptions).UpdateFeatureGroup)], opts...) 751 var resp *longrunningpb.Operation 752 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 753 var err error 754 resp, err = executeRPC(ctx, c.featureRegistryClient.UpdateFeatureGroup, req, settings.GRPC, c.logger, "UpdateFeatureGroup") 755 return err 756 }, opts...) 757 if err != nil { 758 return nil, err 759 } 760 return &UpdateFeatureGroupOperation{ 761 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 762 }, nil 763 } 764 765 func (c *featureRegistryGRPCClient) DeleteFeatureGroup(ctx context.Context, req *aiplatformpb.DeleteFeatureGroupRequest, opts ...gax.CallOption) (*DeleteFeatureGroupOperation, error) { 766 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 767 768 hds = append(c.xGoogHeaders, hds...) 769 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 770 opts = append((*c.CallOptions).DeleteFeatureGroup[0:len((*c.CallOptions).DeleteFeatureGroup):len((*c.CallOptions).DeleteFeatureGroup)], opts...) 771 var resp *longrunningpb.Operation 772 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 773 var err error 774 resp, err = executeRPC(ctx, c.featureRegistryClient.DeleteFeatureGroup, req, settings.GRPC, c.logger, "DeleteFeatureGroup") 775 return err 776 }, opts...) 777 if err != nil { 778 return nil, err 779 } 780 return &DeleteFeatureGroupOperation{ 781 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 782 }, nil 783 } 784 785 func (c *featureRegistryGRPCClient) CreateFeature(ctx context.Context, req *aiplatformpb.CreateFeatureRequest, opts ...gax.CallOption) (*CreateFeatureOperation, error) { 786 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 787 788 hds = append(c.xGoogHeaders, hds...) 789 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 790 opts = append((*c.CallOptions).CreateFeature[0:len((*c.CallOptions).CreateFeature):len((*c.CallOptions).CreateFeature)], opts...) 791 var resp *longrunningpb.Operation 792 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 793 var err error 794 resp, err = executeRPC(ctx, c.featureRegistryClient.CreateFeature, req, settings.GRPC, c.logger, "CreateFeature") 795 return err 796 }, opts...) 797 if err != nil { 798 return nil, err 799 } 800 return &CreateFeatureOperation{ 801 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 802 }, nil 803 } 804 805 func (c *featureRegistryGRPCClient) BatchCreateFeatures(ctx context.Context, req *aiplatformpb.BatchCreateFeaturesRequest, opts ...gax.CallOption) (*BatchCreateFeaturesOperation, error) { 806 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 807 808 hds = append(c.xGoogHeaders, hds...) 809 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 810 opts = append((*c.CallOptions).BatchCreateFeatures[0:len((*c.CallOptions).BatchCreateFeatures):len((*c.CallOptions).BatchCreateFeatures)], opts...) 811 var resp *longrunningpb.Operation 812 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 813 var err error 814 resp, err = executeRPC(ctx, c.featureRegistryClient.BatchCreateFeatures, req, settings.GRPC, c.logger, "BatchCreateFeatures") 815 return err 816 }, opts...) 817 if err != nil { 818 return nil, err 819 } 820 return &BatchCreateFeaturesOperation{ 821 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 822 }, nil 823 } 824 825 func (c *featureRegistryGRPCClient) GetFeature(ctx context.Context, req *aiplatformpb.GetFeatureRequest, opts ...gax.CallOption) (*aiplatformpb.Feature, error) { 826 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 827 828 hds = append(c.xGoogHeaders, hds...) 829 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 830 opts = append((*c.CallOptions).GetFeature[0:len((*c.CallOptions).GetFeature):len((*c.CallOptions).GetFeature)], opts...) 831 var resp *aiplatformpb.Feature 832 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 833 var err error 834 resp, err = executeRPC(ctx, c.featureRegistryClient.GetFeature, req, settings.GRPC, c.logger, "GetFeature") 835 return err 836 }, opts...) 837 if err != nil { 838 return nil, err 839 } 840 return resp, nil 841 } 842 843 func (c *featureRegistryGRPCClient) ListFeatures(ctx context.Context, req *aiplatformpb.ListFeaturesRequest, opts ...gax.CallOption) *FeatureIterator { 844 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 845 846 hds = append(c.xGoogHeaders, hds...) 847 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 848 opts = append((*c.CallOptions).ListFeatures[0:len((*c.CallOptions).ListFeatures):len((*c.CallOptions).ListFeatures)], opts...) 849 it := &FeatureIterator{} 850 req = proto.Clone(req).(*aiplatformpb.ListFeaturesRequest) 851 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Feature, string, error) { 852 resp := &aiplatformpb.ListFeaturesResponse{} 853 if pageToken != "" { 854 req.PageToken = pageToken 855 } 856 if pageSize > math.MaxInt32 { 857 req.PageSize = math.MaxInt32 858 } else if pageSize != 0 { 859 req.PageSize = int32(pageSize) 860 } 861 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 862 var err error 863 resp, err = executeRPC(ctx, c.featureRegistryClient.ListFeatures, req, settings.GRPC, c.logger, "ListFeatures") 864 return err 865 }, opts...) 866 if err != nil { 867 return nil, "", err 868 } 869 870 it.Response = resp 871 return resp.GetFeatures(), resp.GetNextPageToken(), nil 872 } 873 fetch := func(pageSize int, pageToken string) (string, error) { 874 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 875 if err != nil { 876 return "", err 877 } 878 it.items = append(it.items, items...) 879 return nextPageToken, nil 880 } 881 882 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 883 it.pageInfo.MaxSize = int(req.GetPageSize()) 884 it.pageInfo.Token = req.GetPageToken() 885 886 return it 887 } 888 889 func (c *featureRegistryGRPCClient) UpdateFeature(ctx context.Context, req *aiplatformpb.UpdateFeatureRequest, opts ...gax.CallOption) (*UpdateFeatureOperation, error) { 890 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature.name", url.QueryEscape(req.GetFeature().GetName()))} 891 892 hds = append(c.xGoogHeaders, hds...) 893 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 894 opts = append((*c.CallOptions).UpdateFeature[0:len((*c.CallOptions).UpdateFeature):len((*c.CallOptions).UpdateFeature)], 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.featureRegistryClient.UpdateFeature, req, settings.GRPC, c.logger, "UpdateFeature") 899 return err 900 }, opts...) 901 if err != nil { 902 return nil, err 903 } 904 return &UpdateFeatureOperation{ 905 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 906 }, nil 907 } 908 909 func (c *featureRegistryGRPCClient) DeleteFeature(ctx context.Context, req *aiplatformpb.DeleteFeatureRequest, opts ...gax.CallOption) (*DeleteFeatureOperation, error) { 910 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 911 912 hds = append(c.xGoogHeaders, hds...) 913 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 914 opts = append((*c.CallOptions).DeleteFeature[0:len((*c.CallOptions).DeleteFeature):len((*c.CallOptions).DeleteFeature)], opts...) 915 var resp *longrunningpb.Operation 916 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 917 var err error 918 resp, err = executeRPC(ctx, c.featureRegistryClient.DeleteFeature, req, settings.GRPC, c.logger, "DeleteFeature") 919 return err 920 }, opts...) 921 if err != nil { 922 return nil, err 923 } 924 return &DeleteFeatureOperation{ 925 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 926 }, nil 927 } 928 929 func (c *featureRegistryGRPCClient) CreateFeatureMonitor(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorRequest, opts ...gax.CallOption) (*CreateFeatureMonitorOperation, error) { 930 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 931 932 hds = append(c.xGoogHeaders, hds...) 933 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 934 opts = append((*c.CallOptions).CreateFeatureMonitor[0:len((*c.CallOptions).CreateFeatureMonitor):len((*c.CallOptions).CreateFeatureMonitor)], opts...) 935 var resp *longrunningpb.Operation 936 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 937 var err error 938 resp, err = executeRPC(ctx, c.featureRegistryClient.CreateFeatureMonitor, req, settings.GRPC, c.logger, "CreateFeatureMonitor") 939 return err 940 }, opts...) 941 if err != nil { 942 return nil, err 943 } 944 return &CreateFeatureMonitorOperation{ 945 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 946 }, nil 947 } 948 949 func (c *featureRegistryGRPCClient) GetFeatureMonitor(ctx context.Context, req *aiplatformpb.GetFeatureMonitorRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitor, error) { 950 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 951 952 hds = append(c.xGoogHeaders, hds...) 953 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 954 opts = append((*c.CallOptions).GetFeatureMonitor[0:len((*c.CallOptions).GetFeatureMonitor):len((*c.CallOptions).GetFeatureMonitor)], opts...) 955 var resp *aiplatformpb.FeatureMonitor 956 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 957 var err error 958 resp, err = executeRPC(ctx, c.featureRegistryClient.GetFeatureMonitor, req, settings.GRPC, c.logger, "GetFeatureMonitor") 959 return err 960 }, opts...) 961 if err != nil { 962 return nil, err 963 } 964 return resp, nil 965 } 966 967 func (c *featureRegistryGRPCClient) ListFeatureMonitors(ctx context.Context, req *aiplatformpb.ListFeatureMonitorsRequest, opts ...gax.CallOption) *FeatureMonitorIterator { 968 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 969 970 hds = append(c.xGoogHeaders, hds...) 971 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 972 opts = append((*c.CallOptions).ListFeatureMonitors[0:len((*c.CallOptions).ListFeatureMonitors):len((*c.CallOptions).ListFeatureMonitors)], opts...) 973 it := &FeatureMonitorIterator{} 974 req = proto.Clone(req).(*aiplatformpb.ListFeatureMonitorsRequest) 975 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureMonitor, string, error) { 976 resp := &aiplatformpb.ListFeatureMonitorsResponse{} 977 if pageToken != "" { 978 req.PageToken = pageToken 979 } 980 if pageSize > math.MaxInt32 { 981 req.PageSize = math.MaxInt32 982 } else if pageSize != 0 { 983 req.PageSize = int32(pageSize) 984 } 985 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 986 var err error 987 resp, err = executeRPC(ctx, c.featureRegistryClient.ListFeatureMonitors, req, settings.GRPC, c.logger, "ListFeatureMonitors") 988 return err 989 }, opts...) 990 if err != nil { 991 return nil, "", err 992 } 993 994 it.Response = resp 995 return resp.GetFeatureMonitors(), resp.GetNextPageToken(), nil 996 } 997 fetch := func(pageSize int, pageToken string) (string, error) { 998 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 999 if err != nil { 1000 return "", err 1001 } 1002 it.items = append(it.items, items...) 1003 return nextPageToken, nil 1004 } 1005 1006 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1007 it.pageInfo.MaxSize = int(req.GetPageSize()) 1008 it.pageInfo.Token = req.GetPageToken() 1009 1010 return it 1011 } 1012 1013 func (c *featureRegistryGRPCClient) UpdateFeatureMonitor(ctx context.Context, req *aiplatformpb.UpdateFeatureMonitorRequest, opts ...gax.CallOption) (*UpdateFeatureMonitorOperation, error) { 1014 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_monitor.name", url.QueryEscape(req.GetFeatureMonitor().GetName()))} 1015 1016 hds = append(c.xGoogHeaders, hds...) 1017 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1018 opts = append((*c.CallOptions).UpdateFeatureMonitor[0:len((*c.CallOptions).UpdateFeatureMonitor):len((*c.CallOptions).UpdateFeatureMonitor)], opts...) 1019 var resp *longrunningpb.Operation 1020 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1021 var err error 1022 resp, err = executeRPC(ctx, c.featureRegistryClient.UpdateFeatureMonitor, req, settings.GRPC, c.logger, "UpdateFeatureMonitor") 1023 return err 1024 }, opts...) 1025 if err != nil { 1026 return nil, err 1027 } 1028 return &UpdateFeatureMonitorOperation{ 1029 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1030 }, nil 1031 } 1032 1033 func (c *featureRegistryGRPCClient) DeleteFeatureMonitor(ctx context.Context, req *aiplatformpb.DeleteFeatureMonitorRequest, opts ...gax.CallOption) (*DeleteFeatureMonitorOperation, error) { 1034 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1035 1036 hds = append(c.xGoogHeaders, hds...) 1037 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1038 opts = append((*c.CallOptions).DeleteFeatureMonitor[0:len((*c.CallOptions).DeleteFeatureMonitor):len((*c.CallOptions).DeleteFeatureMonitor)], opts...) 1039 var resp *longrunningpb.Operation 1040 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1041 var err error 1042 resp, err = executeRPC(ctx, c.featureRegistryClient.DeleteFeatureMonitor, req, settings.GRPC, c.logger, "DeleteFeatureMonitor") 1043 return err 1044 }, opts...) 1045 if err != nil { 1046 return nil, err 1047 } 1048 return &DeleteFeatureMonitorOperation{ 1049 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1050 }, nil 1051 } 1052 1053 func (c *featureRegistryGRPCClient) CreateFeatureMonitorJob(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 1054 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1055 1056 hds = append(c.xGoogHeaders, hds...) 1057 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1058 opts = append((*c.CallOptions).CreateFeatureMonitorJob[0:len((*c.CallOptions).CreateFeatureMonitorJob):len((*c.CallOptions).CreateFeatureMonitorJob)], opts...) 1059 var resp *aiplatformpb.FeatureMonitorJob 1060 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1061 var err error 1062 resp, err = executeRPC(ctx, c.featureRegistryClient.CreateFeatureMonitorJob, req, settings.GRPC, c.logger, "CreateFeatureMonitorJob") 1063 return err 1064 }, opts...) 1065 if err != nil { 1066 return nil, err 1067 } 1068 return resp, nil 1069 } 1070 1071 func (c *featureRegistryGRPCClient) GetFeatureMonitorJob(ctx context.Context, req *aiplatformpb.GetFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 1072 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1073 1074 hds = append(c.xGoogHeaders, hds...) 1075 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1076 opts = append((*c.CallOptions).GetFeatureMonitorJob[0:len((*c.CallOptions).GetFeatureMonitorJob):len((*c.CallOptions).GetFeatureMonitorJob)], opts...) 1077 var resp *aiplatformpb.FeatureMonitorJob 1078 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1079 var err error 1080 resp, err = executeRPC(ctx, c.featureRegistryClient.GetFeatureMonitorJob, req, settings.GRPC, c.logger, "GetFeatureMonitorJob") 1081 return err 1082 }, opts...) 1083 if err != nil { 1084 return nil, err 1085 } 1086 return resp, nil 1087 } 1088 1089 func (c *featureRegistryGRPCClient) ListFeatureMonitorJobs(ctx context.Context, req *aiplatformpb.ListFeatureMonitorJobsRequest, opts ...gax.CallOption) *FeatureMonitorJobIterator { 1090 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1091 1092 hds = append(c.xGoogHeaders, hds...) 1093 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1094 opts = append((*c.CallOptions).ListFeatureMonitorJobs[0:len((*c.CallOptions).ListFeatureMonitorJobs):len((*c.CallOptions).ListFeatureMonitorJobs)], opts...) 1095 it := &FeatureMonitorJobIterator{} 1096 req = proto.Clone(req).(*aiplatformpb.ListFeatureMonitorJobsRequest) 1097 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureMonitorJob, string, error) { 1098 resp := &aiplatformpb.ListFeatureMonitorJobsResponse{} 1099 if pageToken != "" { 1100 req.PageToken = pageToken 1101 } 1102 if pageSize > math.MaxInt32 { 1103 req.PageSize = math.MaxInt32 1104 } else if pageSize != 0 { 1105 req.PageSize = int32(pageSize) 1106 } 1107 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1108 var err error 1109 resp, err = executeRPC(ctx, c.featureRegistryClient.ListFeatureMonitorJobs, req, settings.GRPC, c.logger, "ListFeatureMonitorJobs") 1110 return err 1111 }, opts...) 1112 if err != nil { 1113 return nil, "", err 1114 } 1115 1116 it.Response = resp 1117 return resp.GetFeatureMonitorJobs(), resp.GetNextPageToken(), nil 1118 } 1119 fetch := func(pageSize int, pageToken string) (string, error) { 1120 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1121 if err != nil { 1122 return "", err 1123 } 1124 it.items = append(it.items, items...) 1125 return nextPageToken, nil 1126 } 1127 1128 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1129 it.pageInfo.MaxSize = int(req.GetPageSize()) 1130 it.pageInfo.Token = req.GetPageToken() 1131 1132 return it 1133 } 1134 1135 func (c *featureRegistryGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 1136 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1137 1138 hds = append(c.xGoogHeaders, hds...) 1139 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1140 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 1141 var resp *locationpb.Location 1142 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1143 var err error 1144 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 1145 return err 1146 }, opts...) 1147 if err != nil { 1148 return nil, err 1149 } 1150 return resp, nil 1151 } 1152 1153 func (c *featureRegistryGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 1154 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1155 1156 hds = append(c.xGoogHeaders, hds...) 1157 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1158 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 1159 it := &LocationIterator{} 1160 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 1161 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 1162 resp := &locationpb.ListLocationsResponse{} 1163 if pageToken != "" { 1164 req.PageToken = pageToken 1165 } 1166 if pageSize > math.MaxInt32 { 1167 req.PageSize = math.MaxInt32 1168 } else if pageSize != 0 { 1169 req.PageSize = int32(pageSize) 1170 } 1171 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1172 var err error 1173 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 1174 return err 1175 }, opts...) 1176 if err != nil { 1177 return nil, "", err 1178 } 1179 1180 it.Response = resp 1181 return resp.GetLocations(), resp.GetNextPageToken(), nil 1182 } 1183 fetch := func(pageSize int, pageToken string) (string, error) { 1184 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1185 if err != nil { 1186 return "", err 1187 } 1188 it.items = append(it.items, items...) 1189 return nextPageToken, nil 1190 } 1191 1192 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1193 it.pageInfo.MaxSize = int(req.GetPageSize()) 1194 it.pageInfo.Token = req.GetPageToken() 1195 1196 return it 1197 } 1198 1199 func (c *featureRegistryGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1200 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1201 1202 hds = append(c.xGoogHeaders, hds...) 1203 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1204 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 1205 var resp *iampb.Policy 1206 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1207 var err error 1208 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 1209 return err 1210 }, opts...) 1211 if err != nil { 1212 return nil, err 1213 } 1214 return resp, nil 1215 } 1216 1217 func (c *featureRegistryGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 1218 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1219 1220 hds = append(c.xGoogHeaders, hds...) 1221 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1222 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 1223 var resp *iampb.Policy 1224 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1225 var err error 1226 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 1227 return err 1228 }, opts...) 1229 if err != nil { 1230 return nil, err 1231 } 1232 return resp, nil 1233 } 1234 1235 func (c *featureRegistryGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 1236 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 1237 1238 hds = append(c.xGoogHeaders, hds...) 1239 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1240 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 1241 var resp *iampb.TestIamPermissionsResponse 1242 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1243 var err error 1244 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 1245 return err 1246 }, opts...) 1247 if err != nil { 1248 return nil, err 1249 } 1250 return resp, nil 1251 } 1252 1253 func (c *featureRegistryGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 1254 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1255 1256 hds = append(c.xGoogHeaders, hds...) 1257 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1258 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 1259 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1260 var err error 1261 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 1262 return err 1263 }, opts...) 1264 return err 1265 } 1266 1267 func (c *featureRegistryGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 1268 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1269 1270 hds = append(c.xGoogHeaders, hds...) 1271 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1272 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 1273 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1274 var err error 1275 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 1276 return err 1277 }, opts...) 1278 return err 1279 } 1280 1281 func (c *featureRegistryGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1282 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1283 1284 hds = append(c.xGoogHeaders, hds...) 1285 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1286 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 1287 var resp *longrunningpb.Operation 1288 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1289 var err error 1290 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 1291 return err 1292 }, opts...) 1293 if err != nil { 1294 return nil, err 1295 } 1296 return resp, nil 1297 } 1298 1299 func (c *featureRegistryGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 1300 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1301 1302 hds = append(c.xGoogHeaders, hds...) 1303 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1304 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 1305 it := &OperationIterator{} 1306 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 1307 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 1308 resp := &longrunningpb.ListOperationsResponse{} 1309 if pageToken != "" { 1310 req.PageToken = pageToken 1311 } 1312 if pageSize > math.MaxInt32 { 1313 req.PageSize = math.MaxInt32 1314 } else if pageSize != 0 { 1315 req.PageSize = int32(pageSize) 1316 } 1317 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1318 var err error 1319 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 1320 return err 1321 }, opts...) 1322 if err != nil { 1323 return nil, "", err 1324 } 1325 1326 it.Response = resp 1327 return resp.GetOperations(), resp.GetNextPageToken(), nil 1328 } 1329 fetch := func(pageSize int, pageToken string) (string, error) { 1330 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1331 if err != nil { 1332 return "", err 1333 } 1334 it.items = append(it.items, items...) 1335 return nextPageToken, nil 1336 } 1337 1338 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1339 it.pageInfo.MaxSize = int(req.GetPageSize()) 1340 it.pageInfo.Token = req.GetPageToken() 1341 1342 return it 1343 } 1344 1345 func (c *featureRegistryGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1346 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1347 1348 hds = append(c.xGoogHeaders, hds...) 1349 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1350 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 1351 var resp *longrunningpb.Operation 1352 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1353 var err error 1354 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 1355 return err 1356 }, opts...) 1357 if err != nil { 1358 return nil, err 1359 } 1360 return resp, nil 1361 } 1362 1363 // CreateFeatureGroup creates a new FeatureGroup in a given project and location. 1364 func (c *featureRegistryRESTClient) CreateFeatureGroup(ctx context.Context, req *aiplatformpb.CreateFeatureGroupRequest, opts ...gax.CallOption) (*CreateFeatureGroupOperation, error) { 1365 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1366 body := req.GetFeatureGroup() 1367 jsonReq, err := m.Marshal(body) 1368 if err != nil { 1369 return nil, err 1370 } 1371 1372 baseUrl, err := url.Parse(c.endpoint) 1373 if err != nil { 1374 return nil, err 1375 } 1376 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureGroups", req.GetParent()) 1377 1378 params := url.Values{} 1379 params.Add("$alt", "json;enum-encoding=int") 1380 params.Add("featureGroupId", fmt.Sprintf("%v", req.GetFeatureGroupId())) 1381 1382 baseUrl.RawQuery = params.Encode() 1383 1384 // Build HTTP headers from client and context metadata. 1385 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1386 1387 hds = append(c.xGoogHeaders, hds...) 1388 hds = append(hds, "Content-Type", "application/json") 1389 headers := gax.BuildHeaders(ctx, hds...) 1390 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1391 resp := &longrunningpb.Operation{} 1392 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1393 if settings.Path != "" { 1394 baseUrl.Path = settings.Path 1395 } 1396 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1397 if err != nil { 1398 return err 1399 } 1400 httpReq = httpReq.WithContext(ctx) 1401 httpReq.Header = headers 1402 1403 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFeatureGroup") 1404 if err != nil { 1405 return err 1406 } 1407 if err := unm.Unmarshal(buf, resp); err != nil { 1408 return err 1409 } 1410 1411 return nil 1412 }, opts...) 1413 if e != nil { 1414 return nil, e 1415 } 1416 1417 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1418 return &CreateFeatureGroupOperation{ 1419 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1420 pollPath: override, 1421 }, nil 1422 } 1423 1424 // GetFeatureGroup gets details of a single FeatureGroup. 1425 func (c *featureRegistryRESTClient) GetFeatureGroup(ctx context.Context, req *aiplatformpb.GetFeatureGroupRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureGroup, error) { 1426 baseUrl, err := url.Parse(c.endpoint) 1427 if err != nil { 1428 return nil, err 1429 } 1430 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1431 1432 params := url.Values{} 1433 params.Add("$alt", "json;enum-encoding=int") 1434 1435 baseUrl.RawQuery = params.Encode() 1436 1437 // Build HTTP headers from client and context metadata. 1438 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1439 1440 hds = append(c.xGoogHeaders, hds...) 1441 hds = append(hds, "Content-Type", "application/json") 1442 headers := gax.BuildHeaders(ctx, hds...) 1443 opts = append((*c.CallOptions).GetFeatureGroup[0:len((*c.CallOptions).GetFeatureGroup):len((*c.CallOptions).GetFeatureGroup)], opts...) 1444 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1445 resp := &aiplatformpb.FeatureGroup{} 1446 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1447 if settings.Path != "" { 1448 baseUrl.Path = settings.Path 1449 } 1450 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1451 if err != nil { 1452 return err 1453 } 1454 httpReq = httpReq.WithContext(ctx) 1455 httpReq.Header = headers 1456 1457 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFeatureGroup") 1458 if err != nil { 1459 return err 1460 } 1461 1462 if err := unm.Unmarshal(buf, resp); err != nil { 1463 return err 1464 } 1465 1466 return nil 1467 }, opts...) 1468 if e != nil { 1469 return nil, e 1470 } 1471 return resp, nil 1472 } 1473 1474 // ListFeatureGroups lists FeatureGroups in a given project and location. 1475 func (c *featureRegistryRESTClient) ListFeatureGroups(ctx context.Context, req *aiplatformpb.ListFeatureGroupsRequest, opts ...gax.CallOption) *FeatureGroupIterator { 1476 it := &FeatureGroupIterator{} 1477 req = proto.Clone(req).(*aiplatformpb.ListFeatureGroupsRequest) 1478 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1479 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureGroup, string, error) { 1480 resp := &aiplatformpb.ListFeatureGroupsResponse{} 1481 if pageToken != "" { 1482 req.PageToken = pageToken 1483 } 1484 if pageSize > math.MaxInt32 { 1485 req.PageSize = math.MaxInt32 1486 } else if pageSize != 0 { 1487 req.PageSize = int32(pageSize) 1488 } 1489 baseUrl, err := url.Parse(c.endpoint) 1490 if err != nil { 1491 return nil, "", err 1492 } 1493 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureGroups", req.GetParent()) 1494 1495 params := url.Values{} 1496 params.Add("$alt", "json;enum-encoding=int") 1497 if req.GetFilter() != "" { 1498 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1499 } 1500 if req.GetOrderBy() != "" { 1501 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 1502 } 1503 if req.GetPageSize() != 0 { 1504 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1505 } 1506 if req.GetPageToken() != "" { 1507 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1508 } 1509 1510 baseUrl.RawQuery = params.Encode() 1511 1512 // Build HTTP headers from client and context metadata. 1513 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1514 headers := gax.BuildHeaders(ctx, hds...) 1515 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1516 if settings.Path != "" { 1517 baseUrl.Path = settings.Path 1518 } 1519 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1520 if err != nil { 1521 return err 1522 } 1523 httpReq.Header = headers 1524 1525 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFeatureGroups") 1526 if err != nil { 1527 return err 1528 } 1529 if err := unm.Unmarshal(buf, resp); err != nil { 1530 return err 1531 } 1532 1533 return nil 1534 }, opts...) 1535 if e != nil { 1536 return nil, "", e 1537 } 1538 it.Response = resp 1539 return resp.GetFeatureGroups(), resp.GetNextPageToken(), nil 1540 } 1541 1542 fetch := func(pageSize int, pageToken string) (string, error) { 1543 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1544 if err != nil { 1545 return "", err 1546 } 1547 it.items = append(it.items, items...) 1548 return nextPageToken, nil 1549 } 1550 1551 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1552 it.pageInfo.MaxSize = int(req.GetPageSize()) 1553 it.pageInfo.Token = req.GetPageToken() 1554 1555 return it 1556 } 1557 1558 // UpdateFeatureGroup updates the parameters of a single FeatureGroup. 1559 func (c *featureRegistryRESTClient) UpdateFeatureGroup(ctx context.Context, req *aiplatformpb.UpdateFeatureGroupRequest, opts ...gax.CallOption) (*UpdateFeatureGroupOperation, error) { 1560 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1561 body := req.GetFeatureGroup() 1562 jsonReq, err := m.Marshal(body) 1563 if err != nil { 1564 return nil, err 1565 } 1566 1567 baseUrl, err := url.Parse(c.endpoint) 1568 if err != nil { 1569 return nil, err 1570 } 1571 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetFeatureGroup().GetName()) 1572 1573 params := url.Values{} 1574 params.Add("$alt", "json;enum-encoding=int") 1575 if req.GetUpdateMask() != nil { 1576 field, err := protojson.Marshal(req.GetUpdateMask()) 1577 if err != nil { 1578 return nil, err 1579 } 1580 params.Add("updateMask", string(field[1:len(field)-1])) 1581 } 1582 1583 baseUrl.RawQuery = params.Encode() 1584 1585 // Build HTTP headers from client and context metadata. 1586 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_group.name", url.QueryEscape(req.GetFeatureGroup().GetName()))} 1587 1588 hds = append(c.xGoogHeaders, hds...) 1589 hds = append(hds, "Content-Type", "application/json") 1590 headers := gax.BuildHeaders(ctx, hds...) 1591 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1592 resp := &longrunningpb.Operation{} 1593 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1594 if settings.Path != "" { 1595 baseUrl.Path = settings.Path 1596 } 1597 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 1598 if err != nil { 1599 return err 1600 } 1601 httpReq = httpReq.WithContext(ctx) 1602 httpReq.Header = headers 1603 1604 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFeatureGroup") 1605 if err != nil { 1606 return err 1607 } 1608 if err := unm.Unmarshal(buf, resp); err != nil { 1609 return err 1610 } 1611 1612 return nil 1613 }, opts...) 1614 if e != nil { 1615 return nil, e 1616 } 1617 1618 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1619 return &UpdateFeatureGroupOperation{ 1620 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1621 pollPath: override, 1622 }, nil 1623 } 1624 1625 // DeleteFeatureGroup deletes a single FeatureGroup. 1626 func (c *featureRegistryRESTClient) DeleteFeatureGroup(ctx context.Context, req *aiplatformpb.DeleteFeatureGroupRequest, opts ...gax.CallOption) (*DeleteFeatureGroupOperation, error) { 1627 baseUrl, err := url.Parse(c.endpoint) 1628 if err != nil { 1629 return nil, err 1630 } 1631 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1632 1633 params := url.Values{} 1634 params.Add("$alt", "json;enum-encoding=int") 1635 if req.GetForce() { 1636 params.Add("force", fmt.Sprintf("%v", req.GetForce())) 1637 } 1638 1639 baseUrl.RawQuery = params.Encode() 1640 1641 // Build HTTP headers from client and context metadata. 1642 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1643 1644 hds = append(c.xGoogHeaders, hds...) 1645 hds = append(hds, "Content-Type", "application/json") 1646 headers := gax.BuildHeaders(ctx, hds...) 1647 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1648 resp := &longrunningpb.Operation{} 1649 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1650 if settings.Path != "" { 1651 baseUrl.Path = settings.Path 1652 } 1653 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 1654 if err != nil { 1655 return err 1656 } 1657 httpReq = httpReq.WithContext(ctx) 1658 httpReq.Header = headers 1659 1660 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFeatureGroup") 1661 if err != nil { 1662 return err 1663 } 1664 if err := unm.Unmarshal(buf, resp); err != nil { 1665 return err 1666 } 1667 1668 return nil 1669 }, opts...) 1670 if e != nil { 1671 return nil, e 1672 } 1673 1674 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1675 return &DeleteFeatureGroupOperation{ 1676 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1677 pollPath: override, 1678 }, nil 1679 } 1680 1681 // CreateFeature creates a new Feature in a given FeatureGroup. 1682 func (c *featureRegistryRESTClient) CreateFeature(ctx context.Context, req *aiplatformpb.CreateFeatureRequest, opts ...gax.CallOption) (*CreateFeatureOperation, error) { 1683 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1684 body := req.GetFeature() 1685 jsonReq, err := m.Marshal(body) 1686 if err != nil { 1687 return nil, err 1688 } 1689 1690 baseUrl, err := url.Parse(c.endpoint) 1691 if err != nil { 1692 return nil, err 1693 } 1694 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/features", req.GetParent()) 1695 1696 params := url.Values{} 1697 params.Add("$alt", "json;enum-encoding=int") 1698 params.Add("featureId", fmt.Sprintf("%v", req.GetFeatureId())) 1699 1700 baseUrl.RawQuery = params.Encode() 1701 1702 // Build HTTP headers from client and context metadata. 1703 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1704 1705 hds = append(c.xGoogHeaders, hds...) 1706 hds = append(hds, "Content-Type", "application/json") 1707 headers := gax.BuildHeaders(ctx, hds...) 1708 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1709 resp := &longrunningpb.Operation{} 1710 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1711 if settings.Path != "" { 1712 baseUrl.Path = settings.Path 1713 } 1714 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1715 if err != nil { 1716 return err 1717 } 1718 httpReq = httpReq.WithContext(ctx) 1719 httpReq.Header = headers 1720 1721 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFeature") 1722 if err != nil { 1723 return err 1724 } 1725 if err := unm.Unmarshal(buf, resp); err != nil { 1726 return err 1727 } 1728 1729 return nil 1730 }, opts...) 1731 if e != nil { 1732 return nil, e 1733 } 1734 1735 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1736 return &CreateFeatureOperation{ 1737 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1738 pollPath: override, 1739 }, nil 1740 } 1741 1742 // BatchCreateFeatures creates a batch of Features in a given FeatureGroup. 1743 func (c *featureRegistryRESTClient) BatchCreateFeatures(ctx context.Context, req *aiplatformpb.BatchCreateFeaturesRequest, opts ...gax.CallOption) (*BatchCreateFeaturesOperation, error) { 1744 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1745 jsonReq, err := m.Marshal(req) 1746 if err != nil { 1747 return nil, err 1748 } 1749 1750 baseUrl, err := url.Parse(c.endpoint) 1751 if err != nil { 1752 return nil, err 1753 } 1754 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/features:batchCreate", req.GetParent()) 1755 1756 params := url.Values{} 1757 params.Add("$alt", "json;enum-encoding=int") 1758 1759 baseUrl.RawQuery = params.Encode() 1760 1761 // Build HTTP headers from client and context metadata. 1762 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 1763 1764 hds = append(c.xGoogHeaders, hds...) 1765 hds = append(hds, "Content-Type", "application/json") 1766 headers := gax.BuildHeaders(ctx, hds...) 1767 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1768 resp := &longrunningpb.Operation{} 1769 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1770 if settings.Path != "" { 1771 baseUrl.Path = settings.Path 1772 } 1773 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 1774 if err != nil { 1775 return err 1776 } 1777 httpReq = httpReq.WithContext(ctx) 1778 httpReq.Header = headers 1779 1780 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchCreateFeatures") 1781 if err != nil { 1782 return err 1783 } 1784 if err := unm.Unmarshal(buf, resp); err != nil { 1785 return err 1786 } 1787 1788 return nil 1789 }, opts...) 1790 if e != nil { 1791 return nil, e 1792 } 1793 1794 override := fmt.Sprintf("/ui/%s", resp.GetName()) 1795 return &BatchCreateFeaturesOperation{ 1796 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 1797 pollPath: override, 1798 }, nil 1799 } 1800 1801 // GetFeature gets details of a single Feature. 1802 func (c *featureRegistryRESTClient) GetFeature(ctx context.Context, req *aiplatformpb.GetFeatureRequest, opts ...gax.CallOption) (*aiplatformpb.Feature, error) { 1803 baseUrl, err := url.Parse(c.endpoint) 1804 if err != nil { 1805 return nil, err 1806 } 1807 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 1808 1809 params := url.Values{} 1810 params.Add("$alt", "json;enum-encoding=int") 1811 if req.GetFeatureStatsAndAnomalySpec() != nil && req.GetFeatureStatsAndAnomalySpec().LatestStatsCount != nil { 1812 params.Add("featureStatsAndAnomalySpec.latestStatsCount", fmt.Sprintf("%v", req.GetFeatureStatsAndAnomalySpec().GetLatestStatsCount())) 1813 } 1814 if req.GetFeatureStatsAndAnomalySpec().GetStatsTimeRange().GetEndTime() != nil { 1815 field, err := protojson.Marshal(req.GetFeatureStatsAndAnomalySpec().GetStatsTimeRange().GetEndTime()) 1816 if err != nil { 1817 return nil, err 1818 } 1819 params.Add("featureStatsAndAnomalySpec.statsTimeRange.endTime", string(field[1:len(field)-1])) 1820 } 1821 if req.GetFeatureStatsAndAnomalySpec().GetStatsTimeRange().GetStartTime() != nil { 1822 field, err := protojson.Marshal(req.GetFeatureStatsAndAnomalySpec().GetStatsTimeRange().GetStartTime()) 1823 if err != nil { 1824 return nil, err 1825 } 1826 params.Add("featureStatsAndAnomalySpec.statsTimeRange.startTime", string(field[1:len(field)-1])) 1827 } 1828 1829 baseUrl.RawQuery = params.Encode() 1830 1831 // Build HTTP headers from client and context metadata. 1832 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1833 1834 hds = append(c.xGoogHeaders, hds...) 1835 hds = append(hds, "Content-Type", "application/json") 1836 headers := gax.BuildHeaders(ctx, hds...) 1837 opts = append((*c.CallOptions).GetFeature[0:len((*c.CallOptions).GetFeature):len((*c.CallOptions).GetFeature)], opts...) 1838 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1839 resp := &aiplatformpb.Feature{} 1840 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1841 if settings.Path != "" { 1842 baseUrl.Path = settings.Path 1843 } 1844 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1845 if err != nil { 1846 return err 1847 } 1848 httpReq = httpReq.WithContext(ctx) 1849 httpReq.Header = headers 1850 1851 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFeature") 1852 if err != nil { 1853 return err 1854 } 1855 1856 if err := unm.Unmarshal(buf, resp); err != nil { 1857 return err 1858 } 1859 1860 return nil 1861 }, opts...) 1862 if e != nil { 1863 return nil, e 1864 } 1865 return resp, nil 1866 } 1867 1868 // ListFeatures lists Features in a given FeatureGroup. 1869 func (c *featureRegistryRESTClient) ListFeatures(ctx context.Context, req *aiplatformpb.ListFeaturesRequest, opts ...gax.CallOption) *FeatureIterator { 1870 it := &FeatureIterator{} 1871 req = proto.Clone(req).(*aiplatformpb.ListFeaturesRequest) 1872 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1873 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Feature, string, error) { 1874 resp := &aiplatformpb.ListFeaturesResponse{} 1875 if pageToken != "" { 1876 req.PageToken = pageToken 1877 } 1878 if pageSize > math.MaxInt32 { 1879 req.PageSize = math.MaxInt32 1880 } else if pageSize != 0 { 1881 req.PageSize = int32(pageSize) 1882 } 1883 baseUrl, err := url.Parse(c.endpoint) 1884 if err != nil { 1885 return nil, "", err 1886 } 1887 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/features", req.GetParent()) 1888 1889 params := url.Values{} 1890 params.Add("$alt", "json;enum-encoding=int") 1891 if req.GetFilter() != "" { 1892 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 1893 } 1894 if req.GetLatestStatsCount() != 0 { 1895 params.Add("latestStatsCount", fmt.Sprintf("%v", req.GetLatestStatsCount())) 1896 } 1897 if req.GetOrderBy() != "" { 1898 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 1899 } 1900 if req.GetPageSize() != 0 { 1901 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 1902 } 1903 if req.GetPageToken() != "" { 1904 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 1905 } 1906 if req.GetReadMask() != nil { 1907 field, err := protojson.Marshal(req.GetReadMask()) 1908 if err != nil { 1909 return nil, "", err 1910 } 1911 params.Add("readMask", string(field[1:len(field)-1])) 1912 } 1913 1914 baseUrl.RawQuery = params.Encode() 1915 1916 // Build HTTP headers from client and context metadata. 1917 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 1918 headers := gax.BuildHeaders(ctx, hds...) 1919 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1920 if settings.Path != "" { 1921 baseUrl.Path = settings.Path 1922 } 1923 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 1924 if err != nil { 1925 return err 1926 } 1927 httpReq.Header = headers 1928 1929 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFeatures") 1930 if err != nil { 1931 return err 1932 } 1933 if err := unm.Unmarshal(buf, resp); err != nil { 1934 return err 1935 } 1936 1937 return nil 1938 }, opts...) 1939 if e != nil { 1940 return nil, "", e 1941 } 1942 it.Response = resp 1943 return resp.GetFeatures(), resp.GetNextPageToken(), nil 1944 } 1945 1946 fetch := func(pageSize int, pageToken string) (string, error) { 1947 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1948 if err != nil { 1949 return "", err 1950 } 1951 it.items = append(it.items, items...) 1952 return nextPageToken, nil 1953 } 1954 1955 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1956 it.pageInfo.MaxSize = int(req.GetPageSize()) 1957 it.pageInfo.Token = req.GetPageToken() 1958 1959 return it 1960 } 1961 1962 // UpdateFeature updates the parameters of a single Feature. 1963 func (c *featureRegistryRESTClient) UpdateFeature(ctx context.Context, req *aiplatformpb.UpdateFeatureRequest, opts ...gax.CallOption) (*UpdateFeatureOperation, error) { 1964 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 1965 body := req.GetFeature() 1966 jsonReq, err := m.Marshal(body) 1967 if err != nil { 1968 return nil, err 1969 } 1970 1971 baseUrl, err := url.Parse(c.endpoint) 1972 if err != nil { 1973 return nil, err 1974 } 1975 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetFeature().GetName()) 1976 1977 params := url.Values{} 1978 params.Add("$alt", "json;enum-encoding=int") 1979 if req.GetUpdateMask() != nil { 1980 field, err := protojson.Marshal(req.GetUpdateMask()) 1981 if err != nil { 1982 return nil, err 1983 } 1984 params.Add("updateMask", string(field[1:len(field)-1])) 1985 } 1986 1987 baseUrl.RawQuery = params.Encode() 1988 1989 // Build HTTP headers from client and context metadata. 1990 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature.name", url.QueryEscape(req.GetFeature().GetName()))} 1991 1992 hds = append(c.xGoogHeaders, hds...) 1993 hds = append(hds, "Content-Type", "application/json") 1994 headers := gax.BuildHeaders(ctx, hds...) 1995 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 1996 resp := &longrunningpb.Operation{} 1997 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1998 if settings.Path != "" { 1999 baseUrl.Path = settings.Path 2000 } 2001 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 2002 if err != nil { 2003 return err 2004 } 2005 httpReq = httpReq.WithContext(ctx) 2006 httpReq.Header = headers 2007 2008 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFeature") 2009 if err != nil { 2010 return err 2011 } 2012 if err := unm.Unmarshal(buf, resp); err != nil { 2013 return err 2014 } 2015 2016 return nil 2017 }, opts...) 2018 if e != nil { 2019 return nil, e 2020 } 2021 2022 override := fmt.Sprintf("/ui/%s", resp.GetName()) 2023 return &UpdateFeatureOperation{ 2024 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 2025 pollPath: override, 2026 }, nil 2027 } 2028 2029 // DeleteFeature deletes a single Feature. 2030 func (c *featureRegistryRESTClient) DeleteFeature(ctx context.Context, req *aiplatformpb.DeleteFeatureRequest, opts ...gax.CallOption) (*DeleteFeatureOperation, error) { 2031 baseUrl, err := url.Parse(c.endpoint) 2032 if err != nil { 2033 return nil, err 2034 } 2035 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 2036 2037 params := url.Values{} 2038 params.Add("$alt", "json;enum-encoding=int") 2039 2040 baseUrl.RawQuery = params.Encode() 2041 2042 // Build HTTP headers from client and context metadata. 2043 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2044 2045 hds = append(c.xGoogHeaders, hds...) 2046 hds = append(hds, "Content-Type", "application/json") 2047 headers := gax.BuildHeaders(ctx, hds...) 2048 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2049 resp := &longrunningpb.Operation{} 2050 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2051 if settings.Path != "" { 2052 baseUrl.Path = settings.Path 2053 } 2054 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 2055 if err != nil { 2056 return err 2057 } 2058 httpReq = httpReq.WithContext(ctx) 2059 httpReq.Header = headers 2060 2061 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFeature") 2062 if err != nil { 2063 return err 2064 } 2065 if err := unm.Unmarshal(buf, resp); err != nil { 2066 return err 2067 } 2068 2069 return nil 2070 }, opts...) 2071 if e != nil { 2072 return nil, e 2073 } 2074 2075 override := fmt.Sprintf("/ui/%s", resp.GetName()) 2076 return &DeleteFeatureOperation{ 2077 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 2078 pollPath: override, 2079 }, nil 2080 } 2081 2082 // CreateFeatureMonitor creates a new FeatureMonitor in a given project, location and FeatureGroup. 2083 func (c *featureRegistryRESTClient) CreateFeatureMonitor(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorRequest, opts ...gax.CallOption) (*CreateFeatureMonitorOperation, error) { 2084 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2085 body := req.GetFeatureMonitor() 2086 jsonReq, err := m.Marshal(body) 2087 if err != nil { 2088 return nil, err 2089 } 2090 2091 baseUrl, err := url.Parse(c.endpoint) 2092 if err != nil { 2093 return nil, err 2094 } 2095 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureMonitors", req.GetParent()) 2096 2097 params := url.Values{} 2098 params.Add("$alt", "json;enum-encoding=int") 2099 params.Add("featureMonitorId", fmt.Sprintf("%v", req.GetFeatureMonitorId())) 2100 2101 baseUrl.RawQuery = params.Encode() 2102 2103 // Build HTTP headers from client and context metadata. 2104 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 2105 2106 hds = append(c.xGoogHeaders, hds...) 2107 hds = append(hds, "Content-Type", "application/json") 2108 headers := gax.BuildHeaders(ctx, hds...) 2109 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2110 resp := &longrunningpb.Operation{} 2111 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2112 if settings.Path != "" { 2113 baseUrl.Path = settings.Path 2114 } 2115 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 2116 if err != nil { 2117 return err 2118 } 2119 httpReq = httpReq.WithContext(ctx) 2120 httpReq.Header = headers 2121 2122 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFeatureMonitor") 2123 if err != nil { 2124 return err 2125 } 2126 if err := unm.Unmarshal(buf, resp); err != nil { 2127 return err 2128 } 2129 2130 return nil 2131 }, opts...) 2132 if e != nil { 2133 return nil, e 2134 } 2135 2136 override := fmt.Sprintf("/ui/%s", resp.GetName()) 2137 return &CreateFeatureMonitorOperation{ 2138 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 2139 pollPath: override, 2140 }, nil 2141 } 2142 2143 // GetFeatureMonitor gets details of a single FeatureMonitor. 2144 func (c *featureRegistryRESTClient) GetFeatureMonitor(ctx context.Context, req *aiplatformpb.GetFeatureMonitorRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitor, error) { 2145 baseUrl, err := url.Parse(c.endpoint) 2146 if err != nil { 2147 return nil, err 2148 } 2149 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 2150 2151 params := url.Values{} 2152 params.Add("$alt", "json;enum-encoding=int") 2153 2154 baseUrl.RawQuery = params.Encode() 2155 2156 // Build HTTP headers from client and context metadata. 2157 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2158 2159 hds = append(c.xGoogHeaders, hds...) 2160 hds = append(hds, "Content-Type", "application/json") 2161 headers := gax.BuildHeaders(ctx, hds...) 2162 opts = append((*c.CallOptions).GetFeatureMonitor[0:len((*c.CallOptions).GetFeatureMonitor):len((*c.CallOptions).GetFeatureMonitor)], opts...) 2163 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2164 resp := &aiplatformpb.FeatureMonitor{} 2165 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2166 if settings.Path != "" { 2167 baseUrl.Path = settings.Path 2168 } 2169 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2170 if err != nil { 2171 return err 2172 } 2173 httpReq = httpReq.WithContext(ctx) 2174 httpReq.Header = headers 2175 2176 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFeatureMonitor") 2177 if err != nil { 2178 return err 2179 } 2180 2181 if err := unm.Unmarshal(buf, resp); err != nil { 2182 return err 2183 } 2184 2185 return nil 2186 }, opts...) 2187 if e != nil { 2188 return nil, e 2189 } 2190 return resp, nil 2191 } 2192 2193 // ListFeatureMonitors lists FeatureGroups in a given project and location. 2194 func (c *featureRegistryRESTClient) ListFeatureMonitors(ctx context.Context, req *aiplatformpb.ListFeatureMonitorsRequest, opts ...gax.CallOption) *FeatureMonitorIterator { 2195 it := &FeatureMonitorIterator{} 2196 req = proto.Clone(req).(*aiplatformpb.ListFeatureMonitorsRequest) 2197 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2198 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureMonitor, string, error) { 2199 resp := &aiplatformpb.ListFeatureMonitorsResponse{} 2200 if pageToken != "" { 2201 req.PageToken = pageToken 2202 } 2203 if pageSize > math.MaxInt32 { 2204 req.PageSize = math.MaxInt32 2205 } else if pageSize != 0 { 2206 req.PageSize = int32(pageSize) 2207 } 2208 baseUrl, err := url.Parse(c.endpoint) 2209 if err != nil { 2210 return nil, "", err 2211 } 2212 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureMonitors", req.GetParent()) 2213 2214 params := url.Values{} 2215 params.Add("$alt", "json;enum-encoding=int") 2216 if req.GetFilter() != "" { 2217 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 2218 } 2219 if req.GetOrderBy() != "" { 2220 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 2221 } 2222 if req.GetPageSize() != 0 { 2223 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 2224 } 2225 if req.GetPageToken() != "" { 2226 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 2227 } 2228 2229 baseUrl.RawQuery = params.Encode() 2230 2231 // Build HTTP headers from client and context metadata. 2232 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 2233 headers := gax.BuildHeaders(ctx, hds...) 2234 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2235 if settings.Path != "" { 2236 baseUrl.Path = settings.Path 2237 } 2238 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2239 if err != nil { 2240 return err 2241 } 2242 httpReq.Header = headers 2243 2244 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFeatureMonitors") 2245 if err != nil { 2246 return err 2247 } 2248 if err := unm.Unmarshal(buf, resp); err != nil { 2249 return err 2250 } 2251 2252 return nil 2253 }, opts...) 2254 if e != nil { 2255 return nil, "", e 2256 } 2257 it.Response = resp 2258 return resp.GetFeatureMonitors(), resp.GetNextPageToken(), nil 2259 } 2260 2261 fetch := func(pageSize int, pageToken string) (string, error) { 2262 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 2263 if err != nil { 2264 return "", err 2265 } 2266 it.items = append(it.items, items...) 2267 return nextPageToken, nil 2268 } 2269 2270 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 2271 it.pageInfo.MaxSize = int(req.GetPageSize()) 2272 it.pageInfo.Token = req.GetPageToken() 2273 2274 return it 2275 } 2276 2277 // UpdateFeatureMonitor updates the parameters of a single FeatureMonitor. 2278 func (c *featureRegistryRESTClient) UpdateFeatureMonitor(ctx context.Context, req *aiplatformpb.UpdateFeatureMonitorRequest, opts ...gax.CallOption) (*UpdateFeatureMonitorOperation, error) { 2279 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2280 body := req.GetFeatureMonitor() 2281 jsonReq, err := m.Marshal(body) 2282 if err != nil { 2283 return nil, err 2284 } 2285 2286 baseUrl, err := url.Parse(c.endpoint) 2287 if err != nil { 2288 return nil, err 2289 } 2290 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetFeatureMonitor().GetName()) 2291 2292 params := url.Values{} 2293 params.Add("$alt", "json;enum-encoding=int") 2294 if req.GetUpdateMask() != nil { 2295 field, err := protojson.Marshal(req.GetUpdateMask()) 2296 if err != nil { 2297 return nil, err 2298 } 2299 params.Add("updateMask", string(field[1:len(field)-1])) 2300 } 2301 2302 baseUrl.RawQuery = params.Encode() 2303 2304 // Build HTTP headers from client and context metadata. 2305 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_monitor.name", url.QueryEscape(req.GetFeatureMonitor().GetName()))} 2306 2307 hds = append(c.xGoogHeaders, hds...) 2308 hds = append(hds, "Content-Type", "application/json") 2309 headers := gax.BuildHeaders(ctx, hds...) 2310 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2311 resp := &longrunningpb.Operation{} 2312 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2313 if settings.Path != "" { 2314 baseUrl.Path = settings.Path 2315 } 2316 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq)) 2317 if err != nil { 2318 return err 2319 } 2320 httpReq = httpReq.WithContext(ctx) 2321 httpReq.Header = headers 2322 2323 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFeatureMonitor") 2324 if err != nil { 2325 return err 2326 } 2327 if err := unm.Unmarshal(buf, resp); err != nil { 2328 return err 2329 } 2330 2331 return nil 2332 }, opts...) 2333 if e != nil { 2334 return nil, e 2335 } 2336 2337 override := fmt.Sprintf("/ui/%s", resp.GetName()) 2338 return &UpdateFeatureMonitorOperation{ 2339 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 2340 pollPath: override, 2341 }, nil 2342 } 2343 2344 // DeleteFeatureMonitor deletes a single FeatureMonitor. 2345 func (c *featureRegistryRESTClient) DeleteFeatureMonitor(ctx context.Context, req *aiplatformpb.DeleteFeatureMonitorRequest, opts ...gax.CallOption) (*DeleteFeatureMonitorOperation, error) { 2346 baseUrl, err := url.Parse(c.endpoint) 2347 if err != nil { 2348 return nil, err 2349 } 2350 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 2351 2352 params := url.Values{} 2353 params.Add("$alt", "json;enum-encoding=int") 2354 2355 baseUrl.RawQuery = params.Encode() 2356 2357 // Build HTTP headers from client and context metadata. 2358 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2359 2360 hds = append(c.xGoogHeaders, hds...) 2361 hds = append(hds, "Content-Type", "application/json") 2362 headers := gax.BuildHeaders(ctx, hds...) 2363 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2364 resp := &longrunningpb.Operation{} 2365 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2366 if settings.Path != "" { 2367 baseUrl.Path = settings.Path 2368 } 2369 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 2370 if err != nil { 2371 return err 2372 } 2373 httpReq = httpReq.WithContext(ctx) 2374 httpReq.Header = headers 2375 2376 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFeatureMonitor") 2377 if err != nil { 2378 return err 2379 } 2380 if err := unm.Unmarshal(buf, resp); err != nil { 2381 return err 2382 } 2383 2384 return nil 2385 }, opts...) 2386 if e != nil { 2387 return nil, e 2388 } 2389 2390 override := fmt.Sprintf("/ui/%s", resp.GetName()) 2391 return &DeleteFeatureMonitorOperation{ 2392 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 2393 pollPath: override, 2394 }, nil 2395 } 2396 2397 // CreateFeatureMonitorJob creates a new feature monitor job. 2398 func (c *featureRegistryRESTClient) CreateFeatureMonitorJob(ctx context.Context, req *aiplatformpb.CreateFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 2399 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2400 body := req.GetFeatureMonitorJob() 2401 jsonReq, err := m.Marshal(body) 2402 if err != nil { 2403 return nil, err 2404 } 2405 2406 baseUrl, err := url.Parse(c.endpoint) 2407 if err != nil { 2408 return nil, err 2409 } 2410 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureMonitorJobs", req.GetParent()) 2411 2412 params := url.Values{} 2413 params.Add("$alt", "json;enum-encoding=int") 2414 if req.GetFeatureMonitorJobId() != 0 { 2415 params.Add("featureMonitorJobId", fmt.Sprintf("%v", req.GetFeatureMonitorJobId())) 2416 } 2417 2418 baseUrl.RawQuery = params.Encode() 2419 2420 // Build HTTP headers from client and context metadata. 2421 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 2422 2423 hds = append(c.xGoogHeaders, hds...) 2424 hds = append(hds, "Content-Type", "application/json") 2425 headers := gax.BuildHeaders(ctx, hds...) 2426 opts = append((*c.CallOptions).CreateFeatureMonitorJob[0:len((*c.CallOptions).CreateFeatureMonitorJob):len((*c.CallOptions).CreateFeatureMonitorJob)], opts...) 2427 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2428 resp := &aiplatformpb.FeatureMonitorJob{} 2429 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2430 if settings.Path != "" { 2431 baseUrl.Path = settings.Path 2432 } 2433 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 2434 if err != nil { 2435 return err 2436 } 2437 httpReq = httpReq.WithContext(ctx) 2438 httpReq.Header = headers 2439 2440 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateFeatureMonitorJob") 2441 if err != nil { 2442 return err 2443 } 2444 2445 if err := unm.Unmarshal(buf, resp); err != nil { 2446 return err 2447 } 2448 2449 return nil 2450 }, opts...) 2451 if e != nil { 2452 return nil, e 2453 } 2454 return resp, nil 2455 } 2456 2457 // GetFeatureMonitorJob get a feature monitor job. 2458 func (c *featureRegistryRESTClient) GetFeatureMonitorJob(ctx context.Context, req *aiplatformpb.GetFeatureMonitorJobRequest, opts ...gax.CallOption) (*aiplatformpb.FeatureMonitorJob, error) { 2459 baseUrl, err := url.Parse(c.endpoint) 2460 if err != nil { 2461 return nil, err 2462 } 2463 baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName()) 2464 2465 params := url.Values{} 2466 params.Add("$alt", "json;enum-encoding=int") 2467 2468 baseUrl.RawQuery = params.Encode() 2469 2470 // Build HTTP headers from client and context metadata. 2471 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2472 2473 hds = append(c.xGoogHeaders, hds...) 2474 hds = append(hds, "Content-Type", "application/json") 2475 headers := gax.BuildHeaders(ctx, hds...) 2476 opts = append((*c.CallOptions).GetFeatureMonitorJob[0:len((*c.CallOptions).GetFeatureMonitorJob):len((*c.CallOptions).GetFeatureMonitorJob)], opts...) 2477 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2478 resp := &aiplatformpb.FeatureMonitorJob{} 2479 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2480 if settings.Path != "" { 2481 baseUrl.Path = settings.Path 2482 } 2483 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2484 if err != nil { 2485 return err 2486 } 2487 httpReq = httpReq.WithContext(ctx) 2488 httpReq.Header = headers 2489 2490 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFeatureMonitorJob") 2491 if err != nil { 2492 return err 2493 } 2494 2495 if err := unm.Unmarshal(buf, resp); err != nil { 2496 return err 2497 } 2498 2499 return nil 2500 }, opts...) 2501 if e != nil { 2502 return nil, e 2503 } 2504 return resp, nil 2505 } 2506 2507 // ListFeatureMonitorJobs list feature monitor jobs. 2508 func (c *featureRegistryRESTClient) ListFeatureMonitorJobs(ctx context.Context, req *aiplatformpb.ListFeatureMonitorJobsRequest, opts ...gax.CallOption) *FeatureMonitorJobIterator { 2509 it := &FeatureMonitorJobIterator{} 2510 req = proto.Clone(req).(*aiplatformpb.ListFeatureMonitorJobsRequest) 2511 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2512 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.FeatureMonitorJob, string, error) { 2513 resp := &aiplatformpb.ListFeatureMonitorJobsResponse{} 2514 if pageToken != "" { 2515 req.PageToken = pageToken 2516 } 2517 if pageSize > math.MaxInt32 { 2518 req.PageSize = math.MaxInt32 2519 } else if pageSize != 0 { 2520 req.PageSize = int32(pageSize) 2521 } 2522 baseUrl, err := url.Parse(c.endpoint) 2523 if err != nil { 2524 return nil, "", err 2525 } 2526 baseUrl.Path += fmt.Sprintf("/v1beta1/%v/featureMonitorJobs", req.GetParent()) 2527 2528 params := url.Values{} 2529 params.Add("$alt", "json;enum-encoding=int") 2530 if req.GetFilter() != "" { 2531 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 2532 } 2533 if req.GetOrderBy() != "" { 2534 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy())) 2535 } 2536 if req.GetPageSize() != 0 { 2537 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 2538 } 2539 if req.GetPageToken() != "" { 2540 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 2541 } 2542 2543 baseUrl.RawQuery = params.Encode() 2544 2545 // Build HTTP headers from client and context metadata. 2546 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 2547 headers := gax.BuildHeaders(ctx, hds...) 2548 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2549 if settings.Path != "" { 2550 baseUrl.Path = settings.Path 2551 } 2552 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2553 if err != nil { 2554 return err 2555 } 2556 httpReq.Header = headers 2557 2558 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFeatureMonitorJobs") 2559 if err != nil { 2560 return err 2561 } 2562 if err := unm.Unmarshal(buf, resp); err != nil { 2563 return err 2564 } 2565 2566 return nil 2567 }, opts...) 2568 if e != nil { 2569 return nil, "", e 2570 } 2571 it.Response = resp 2572 return resp.GetFeatureMonitorJobs(), resp.GetNextPageToken(), nil 2573 } 2574 2575 fetch := func(pageSize int, pageToken string) (string, error) { 2576 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 2577 if err != nil { 2578 return "", err 2579 } 2580 it.items = append(it.items, items...) 2581 return nextPageToken, nil 2582 } 2583 2584 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 2585 it.pageInfo.MaxSize = int(req.GetPageSize()) 2586 it.pageInfo.Token = req.GetPageToken() 2587 2588 return it 2589 } 2590 2591 // GetLocation gets information about a location. 2592 func (c *featureRegistryRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 2593 baseUrl, err := url.Parse(c.endpoint) 2594 if err != nil { 2595 return nil, err 2596 } 2597 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 2598 2599 params := url.Values{} 2600 params.Add("$alt", "json;enum-encoding=int") 2601 2602 baseUrl.RawQuery = params.Encode() 2603 2604 // Build HTTP headers from client and context metadata. 2605 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2606 2607 hds = append(c.xGoogHeaders, hds...) 2608 hds = append(hds, "Content-Type", "application/json") 2609 headers := gax.BuildHeaders(ctx, hds...) 2610 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 2611 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2612 resp := &locationpb.Location{} 2613 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2614 if settings.Path != "" { 2615 baseUrl.Path = settings.Path 2616 } 2617 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2618 if err != nil { 2619 return err 2620 } 2621 httpReq = httpReq.WithContext(ctx) 2622 httpReq.Header = headers 2623 2624 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation") 2625 if err != nil { 2626 return err 2627 } 2628 2629 if err := unm.Unmarshal(buf, resp); err != nil { 2630 return err 2631 } 2632 2633 return nil 2634 }, opts...) 2635 if e != nil { 2636 return nil, e 2637 } 2638 return resp, nil 2639 } 2640 2641 // ListLocations lists information about the supported locations for this service. 2642 func (c *featureRegistryRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 2643 it := &LocationIterator{} 2644 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 2645 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2646 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 2647 resp := &locationpb.ListLocationsResponse{} 2648 if pageToken != "" { 2649 req.PageToken = pageToken 2650 } 2651 if pageSize > math.MaxInt32 { 2652 req.PageSize = math.MaxInt32 2653 } else if pageSize != 0 { 2654 req.PageSize = int32(pageSize) 2655 } 2656 baseUrl, err := url.Parse(c.endpoint) 2657 if err != nil { 2658 return nil, "", err 2659 } 2660 baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName()) 2661 2662 params := url.Values{} 2663 params.Add("$alt", "json;enum-encoding=int") 2664 if req.GetFilter() != "" { 2665 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 2666 } 2667 if req.GetPageSize() != 0 { 2668 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 2669 } 2670 if req.GetPageToken() != "" { 2671 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 2672 } 2673 2674 baseUrl.RawQuery = params.Encode() 2675 2676 // Build HTTP headers from client and context metadata. 2677 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 2678 headers := gax.BuildHeaders(ctx, hds...) 2679 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2680 if settings.Path != "" { 2681 baseUrl.Path = settings.Path 2682 } 2683 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2684 if err != nil { 2685 return err 2686 } 2687 httpReq.Header = headers 2688 2689 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations") 2690 if err != nil { 2691 return err 2692 } 2693 if err := unm.Unmarshal(buf, resp); err != nil { 2694 return err 2695 } 2696 2697 return nil 2698 }, opts...) 2699 if e != nil { 2700 return nil, "", e 2701 } 2702 it.Response = resp 2703 return resp.GetLocations(), resp.GetNextPageToken(), nil 2704 } 2705 2706 fetch := func(pageSize int, pageToken string) (string, error) { 2707 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 2708 if err != nil { 2709 return "", err 2710 } 2711 it.items = append(it.items, items...) 2712 return nextPageToken, nil 2713 } 2714 2715 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 2716 it.pageInfo.MaxSize = int(req.GetPageSize()) 2717 it.pageInfo.Token = req.GetPageToken() 2718 2719 return it 2720 } 2721 2722 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 2723 // if the resource exists and does not have a policy set. 2724 func (c *featureRegistryRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 2725 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2726 jsonReq, err := m.Marshal(req) 2727 if err != nil { 2728 return nil, err 2729 } 2730 2731 baseUrl, err := url.Parse(c.endpoint) 2732 if err != nil { 2733 return nil, err 2734 } 2735 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource()) 2736 2737 params := url.Values{} 2738 params.Add("$alt", "json;enum-encoding=int") 2739 2740 baseUrl.RawQuery = params.Encode() 2741 2742 // Build HTTP headers from client and context metadata. 2743 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 2744 2745 hds = append(c.xGoogHeaders, hds...) 2746 hds = append(hds, "Content-Type", "application/json") 2747 headers := gax.BuildHeaders(ctx, hds...) 2748 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 2749 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2750 resp := &iampb.Policy{} 2751 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2752 if settings.Path != "" { 2753 baseUrl.Path = settings.Path 2754 } 2755 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 2756 if err != nil { 2757 return err 2758 } 2759 httpReq = httpReq.WithContext(ctx) 2760 httpReq.Header = headers 2761 2762 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy") 2763 if err != nil { 2764 return err 2765 } 2766 2767 if err := unm.Unmarshal(buf, resp); err != nil { 2768 return err 2769 } 2770 2771 return nil 2772 }, opts...) 2773 if e != nil { 2774 return nil, e 2775 } 2776 return resp, nil 2777 } 2778 2779 // SetIamPolicy sets the access control policy on the specified resource. Replaces 2780 // any existing policy. 2781 // 2782 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 2783 // errors. 2784 func (c *featureRegistryRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 2785 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2786 jsonReq, err := m.Marshal(req) 2787 if err != nil { 2788 return nil, err 2789 } 2790 2791 baseUrl, err := url.Parse(c.endpoint) 2792 if err != nil { 2793 return nil, err 2794 } 2795 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource()) 2796 2797 params := url.Values{} 2798 params.Add("$alt", "json;enum-encoding=int") 2799 2800 baseUrl.RawQuery = params.Encode() 2801 2802 // Build HTTP headers from client and context metadata. 2803 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 2804 2805 hds = append(c.xGoogHeaders, hds...) 2806 hds = append(hds, "Content-Type", "application/json") 2807 headers := gax.BuildHeaders(ctx, hds...) 2808 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 2809 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2810 resp := &iampb.Policy{} 2811 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2812 if settings.Path != "" { 2813 baseUrl.Path = settings.Path 2814 } 2815 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 2816 if err != nil { 2817 return err 2818 } 2819 httpReq = httpReq.WithContext(ctx) 2820 httpReq.Header = headers 2821 2822 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy") 2823 if err != nil { 2824 return err 2825 } 2826 2827 if err := unm.Unmarshal(buf, resp); err != nil { 2828 return err 2829 } 2830 2831 return nil 2832 }, opts...) 2833 if e != nil { 2834 return nil, e 2835 } 2836 return resp, nil 2837 } 2838 2839 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 2840 // resource does not exist, this will return an empty set of 2841 // permissions, not a NOT_FOUND error. 2842 // 2843 // Note: This operation is designed to be used for building 2844 // permission-aware UIs and command-line tools, not for authorization 2845 // checking. This operation may “fail open” without warning. 2846 func (c *featureRegistryRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 2847 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true} 2848 jsonReq, err := m.Marshal(req) 2849 if err != nil { 2850 return nil, err 2851 } 2852 2853 baseUrl, err := url.Parse(c.endpoint) 2854 if err != nil { 2855 return nil, err 2856 } 2857 baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource()) 2858 2859 params := url.Values{} 2860 params.Add("$alt", "json;enum-encoding=int") 2861 2862 baseUrl.RawQuery = params.Encode() 2863 2864 // Build HTTP headers from client and context metadata. 2865 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 2866 2867 hds = append(c.xGoogHeaders, hds...) 2868 hds = append(hds, "Content-Type", "application/json") 2869 headers := gax.BuildHeaders(ctx, hds...) 2870 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 2871 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2872 resp := &iampb.TestIamPermissionsResponse{} 2873 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2874 if settings.Path != "" { 2875 baseUrl.Path = settings.Path 2876 } 2877 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq)) 2878 if err != nil { 2879 return err 2880 } 2881 httpReq = httpReq.WithContext(ctx) 2882 httpReq.Header = headers 2883 2884 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions") 2885 if err != nil { 2886 return err 2887 } 2888 2889 if err := unm.Unmarshal(buf, resp); err != nil { 2890 return err 2891 } 2892 2893 return nil 2894 }, opts...) 2895 if e != nil { 2896 return nil, e 2897 } 2898 return resp, nil 2899 } 2900 2901 // CancelOperation is a utility method from google.longrunning.Operations. 2902 func (c *featureRegistryRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 2903 baseUrl, err := url.Parse(c.endpoint) 2904 if err != nil { 2905 return err 2906 } 2907 baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName()) 2908 2909 params := url.Values{} 2910 params.Add("$alt", "json;enum-encoding=int") 2911 2912 baseUrl.RawQuery = params.Encode() 2913 2914 // Build HTTP headers from client and context metadata. 2915 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2916 2917 hds = append(c.xGoogHeaders, hds...) 2918 hds = append(hds, "Content-Type", "application/json") 2919 headers := gax.BuildHeaders(ctx, hds...) 2920 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2921 if settings.Path != "" { 2922 baseUrl.Path = settings.Path 2923 } 2924 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 2925 if err != nil { 2926 return err 2927 } 2928 httpReq = httpReq.WithContext(ctx) 2929 httpReq.Header = headers 2930 2931 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation") 2932 return err 2933 }, opts...) 2934 } 2935 2936 // DeleteOperation is a utility method from google.longrunning.Operations. 2937 func (c *featureRegistryRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 2938 baseUrl, err := url.Parse(c.endpoint) 2939 if err != nil { 2940 return err 2941 } 2942 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 2943 2944 params := url.Values{} 2945 params.Add("$alt", "json;enum-encoding=int") 2946 2947 baseUrl.RawQuery = params.Encode() 2948 2949 // Build HTTP headers from client and context metadata. 2950 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2951 2952 hds = append(c.xGoogHeaders, hds...) 2953 hds = append(hds, "Content-Type", "application/json") 2954 headers := gax.BuildHeaders(ctx, hds...) 2955 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2956 if settings.Path != "" { 2957 baseUrl.Path = settings.Path 2958 } 2959 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil) 2960 if err != nil { 2961 return err 2962 } 2963 httpReq = httpReq.WithContext(ctx) 2964 httpReq.Header = headers 2965 2966 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation") 2967 return err 2968 }, opts...) 2969 } 2970 2971 // GetOperation is a utility method from google.longrunning.Operations. 2972 func (c *featureRegistryRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 2973 baseUrl, err := url.Parse(c.endpoint) 2974 if err != nil { 2975 return nil, err 2976 } 2977 baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName()) 2978 2979 params := url.Values{} 2980 params.Add("$alt", "json;enum-encoding=int") 2981 2982 baseUrl.RawQuery = params.Encode() 2983 2984 // Build HTTP headers from client and context metadata. 2985 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 2986 2987 hds = append(c.xGoogHeaders, hds...) 2988 hds = append(hds, "Content-Type", "application/json") 2989 headers := gax.BuildHeaders(ctx, hds...) 2990 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 2991 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 2992 resp := &longrunningpb.Operation{} 2993 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 2994 if settings.Path != "" { 2995 baseUrl.Path = settings.Path 2996 } 2997 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 2998 if err != nil { 2999 return err 3000 } 3001 httpReq = httpReq.WithContext(ctx) 3002 httpReq.Header = headers 3003 3004 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation") 3005 if err != nil { 3006 return err 3007 } 3008 3009 if err := unm.Unmarshal(buf, resp); err != nil { 3010 return err 3011 } 3012 3013 return nil 3014 }, opts...) 3015 if e != nil { 3016 return nil, e 3017 } 3018 return resp, nil 3019 } 3020 3021 // ListOperations is a utility method from google.longrunning.Operations. 3022 func (c *featureRegistryRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 3023 it := &OperationIterator{} 3024 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 3025 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 3026 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 3027 resp := &longrunningpb.ListOperationsResponse{} 3028 if pageToken != "" { 3029 req.PageToken = pageToken 3030 } 3031 if pageSize > math.MaxInt32 { 3032 req.PageSize = math.MaxInt32 3033 } else if pageSize != 0 { 3034 req.PageSize = int32(pageSize) 3035 } 3036 baseUrl, err := url.Parse(c.endpoint) 3037 if err != nil { 3038 return nil, "", err 3039 } 3040 baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName()) 3041 3042 params := url.Values{} 3043 params.Add("$alt", "json;enum-encoding=int") 3044 if req.GetFilter() != "" { 3045 params.Add("filter", fmt.Sprintf("%v", req.GetFilter())) 3046 } 3047 if req.GetPageSize() != 0 { 3048 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize())) 3049 } 3050 if req.GetPageToken() != "" { 3051 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken())) 3052 } 3053 3054 baseUrl.RawQuery = params.Encode() 3055 3056 // Build HTTP headers from client and context metadata. 3057 hds := append(c.xGoogHeaders, "Content-Type", "application/json") 3058 headers := gax.BuildHeaders(ctx, hds...) 3059 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 3060 if settings.Path != "" { 3061 baseUrl.Path = settings.Path 3062 } 3063 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil) 3064 if err != nil { 3065 return err 3066 } 3067 httpReq.Header = headers 3068 3069 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations") 3070 if err != nil { 3071 return err 3072 } 3073 if err := unm.Unmarshal(buf, resp); err != nil { 3074 return err 3075 } 3076 3077 return nil 3078 }, opts...) 3079 if e != nil { 3080 return nil, "", e 3081 } 3082 it.Response = resp 3083 return resp.GetOperations(), resp.GetNextPageToken(), nil 3084 } 3085 3086 fetch := func(pageSize int, pageToken string) (string, error) { 3087 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 3088 if err != nil { 3089 return "", err 3090 } 3091 it.items = append(it.items, items...) 3092 return nextPageToken, nil 3093 } 3094 3095 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 3096 it.pageInfo.MaxSize = int(req.GetPageSize()) 3097 it.pageInfo.Token = req.GetPageToken() 3098 3099 return it 3100 } 3101 3102 // WaitOperation is a utility method from google.longrunning.Operations. 3103 func (c *featureRegistryRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 3104 baseUrl, err := url.Parse(c.endpoint) 3105 if err != nil { 3106 return nil, err 3107 } 3108 baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName()) 3109 3110 params := url.Values{} 3111 params.Add("$alt", "json;enum-encoding=int") 3112 if req.GetTimeout() != nil { 3113 field, err := protojson.Marshal(req.GetTimeout()) 3114 if err != nil { 3115 return nil, err 3116 } 3117 params.Add("timeout", string(field[1:len(field)-1])) 3118 } 3119 3120 baseUrl.RawQuery = params.Encode() 3121 3122 // Build HTTP headers from client and context metadata. 3123 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 3124 3125 hds = append(c.xGoogHeaders, hds...) 3126 hds = append(hds, "Content-Type", "application/json") 3127 headers := gax.BuildHeaders(ctx, hds...) 3128 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 3129 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true} 3130 resp := &longrunningpb.Operation{} 3131 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 3132 if settings.Path != "" { 3133 baseUrl.Path = settings.Path 3134 } 3135 httpReq, err := http.NewRequest("POST", baseUrl.String(), nil) 3136 if err != nil { 3137 return err 3138 } 3139 httpReq = httpReq.WithContext(ctx) 3140 httpReq.Header = headers 3141 3142 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation") 3143 if err != nil { 3144 return err 3145 } 3146 3147 if err := unm.Unmarshal(buf, resp); err != nil { 3148 return err 3149 } 3150 3151 return nil 3152 }, opts...) 3153 if e != nil { 3154 return nil, e 3155 } 3156 return resp, nil 3157 } 3158 3159 // BatchCreateFeaturesOperation returns a new BatchCreateFeaturesOperation from a given name. 3160 // The name must be that of a previously created BatchCreateFeaturesOperation, possibly from a different process. 3161 func (c *featureRegistryGRPCClient) BatchCreateFeaturesOperation(name string) *BatchCreateFeaturesOperation { 3162 return &BatchCreateFeaturesOperation{ 3163 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3164 } 3165 } 3166 3167 // BatchCreateFeaturesOperation returns a new BatchCreateFeaturesOperation from a given name. 3168 // The name must be that of a previously created BatchCreateFeaturesOperation, possibly from a different process. 3169 func (c *featureRegistryRESTClient) BatchCreateFeaturesOperation(name string) *BatchCreateFeaturesOperation { 3170 override := fmt.Sprintf("/ui/%s", name) 3171 return &BatchCreateFeaturesOperation{ 3172 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3173 pollPath: override, 3174 } 3175 } 3176 3177 // CreateFeatureOperation returns a new CreateFeatureOperation from a given name. 3178 // The name must be that of a previously created CreateFeatureOperation, possibly from a different process. 3179 func (c *featureRegistryGRPCClient) CreateFeatureOperation(name string) *CreateFeatureOperation { 3180 return &CreateFeatureOperation{ 3181 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3182 } 3183 } 3184 3185 // CreateFeatureOperation returns a new CreateFeatureOperation from a given name. 3186 // The name must be that of a previously created CreateFeatureOperation, possibly from a different process. 3187 func (c *featureRegistryRESTClient) CreateFeatureOperation(name string) *CreateFeatureOperation { 3188 override := fmt.Sprintf("/ui/%s", name) 3189 return &CreateFeatureOperation{ 3190 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3191 pollPath: override, 3192 } 3193 } 3194 3195 // CreateFeatureGroupOperation returns a new CreateFeatureGroupOperation from a given name. 3196 // The name must be that of a previously created CreateFeatureGroupOperation, possibly from a different process. 3197 func (c *featureRegistryGRPCClient) CreateFeatureGroupOperation(name string) *CreateFeatureGroupOperation { 3198 return &CreateFeatureGroupOperation{ 3199 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3200 } 3201 } 3202 3203 // CreateFeatureGroupOperation returns a new CreateFeatureGroupOperation from a given name. 3204 // The name must be that of a previously created CreateFeatureGroupOperation, possibly from a different process. 3205 func (c *featureRegistryRESTClient) CreateFeatureGroupOperation(name string) *CreateFeatureGroupOperation { 3206 override := fmt.Sprintf("/ui/%s", name) 3207 return &CreateFeatureGroupOperation{ 3208 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3209 pollPath: override, 3210 } 3211 } 3212 3213 // CreateFeatureMonitorOperation returns a new CreateFeatureMonitorOperation from a given name. 3214 // The name must be that of a previously created CreateFeatureMonitorOperation, possibly from a different process. 3215 func (c *featureRegistryGRPCClient) CreateFeatureMonitorOperation(name string) *CreateFeatureMonitorOperation { 3216 return &CreateFeatureMonitorOperation{ 3217 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3218 } 3219 } 3220 3221 // CreateFeatureMonitorOperation returns a new CreateFeatureMonitorOperation from a given name. 3222 // The name must be that of a previously created CreateFeatureMonitorOperation, possibly from a different process. 3223 func (c *featureRegistryRESTClient) CreateFeatureMonitorOperation(name string) *CreateFeatureMonitorOperation { 3224 override := fmt.Sprintf("/ui/%s", name) 3225 return &CreateFeatureMonitorOperation{ 3226 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3227 pollPath: override, 3228 } 3229 } 3230 3231 // DeleteFeatureOperation returns a new DeleteFeatureOperation from a given name. 3232 // The name must be that of a previously created DeleteFeatureOperation, possibly from a different process. 3233 func (c *featureRegistryGRPCClient) DeleteFeatureOperation(name string) *DeleteFeatureOperation { 3234 return &DeleteFeatureOperation{ 3235 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3236 } 3237 } 3238 3239 // DeleteFeatureOperation returns a new DeleteFeatureOperation from a given name. 3240 // The name must be that of a previously created DeleteFeatureOperation, possibly from a different process. 3241 func (c *featureRegistryRESTClient) DeleteFeatureOperation(name string) *DeleteFeatureOperation { 3242 override := fmt.Sprintf("/ui/%s", name) 3243 return &DeleteFeatureOperation{ 3244 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3245 pollPath: override, 3246 } 3247 } 3248 3249 // DeleteFeatureGroupOperation returns a new DeleteFeatureGroupOperation from a given name. 3250 // The name must be that of a previously created DeleteFeatureGroupOperation, possibly from a different process. 3251 func (c *featureRegistryGRPCClient) DeleteFeatureGroupOperation(name string) *DeleteFeatureGroupOperation { 3252 return &DeleteFeatureGroupOperation{ 3253 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3254 } 3255 } 3256 3257 // DeleteFeatureGroupOperation returns a new DeleteFeatureGroupOperation from a given name. 3258 // The name must be that of a previously created DeleteFeatureGroupOperation, possibly from a different process. 3259 func (c *featureRegistryRESTClient) DeleteFeatureGroupOperation(name string) *DeleteFeatureGroupOperation { 3260 override := fmt.Sprintf("/ui/%s", name) 3261 return &DeleteFeatureGroupOperation{ 3262 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3263 pollPath: override, 3264 } 3265 } 3266 3267 // DeleteFeatureMonitorOperation returns a new DeleteFeatureMonitorOperation from a given name. 3268 // The name must be that of a previously created DeleteFeatureMonitorOperation, possibly from a different process. 3269 func (c *featureRegistryGRPCClient) DeleteFeatureMonitorOperation(name string) *DeleteFeatureMonitorOperation { 3270 return &DeleteFeatureMonitorOperation{ 3271 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3272 } 3273 } 3274 3275 // DeleteFeatureMonitorOperation returns a new DeleteFeatureMonitorOperation from a given name. 3276 // The name must be that of a previously created DeleteFeatureMonitorOperation, possibly from a different process. 3277 func (c *featureRegistryRESTClient) DeleteFeatureMonitorOperation(name string) *DeleteFeatureMonitorOperation { 3278 override := fmt.Sprintf("/ui/%s", name) 3279 return &DeleteFeatureMonitorOperation{ 3280 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3281 pollPath: override, 3282 } 3283 } 3284 3285 // UpdateFeatureOperation returns a new UpdateFeatureOperation from a given name. 3286 // The name must be that of a previously created UpdateFeatureOperation, possibly from a different process. 3287 func (c *featureRegistryGRPCClient) UpdateFeatureOperation(name string) *UpdateFeatureOperation { 3288 return &UpdateFeatureOperation{ 3289 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3290 } 3291 } 3292 3293 // UpdateFeatureOperation returns a new UpdateFeatureOperation from a given name. 3294 // The name must be that of a previously created UpdateFeatureOperation, possibly from a different process. 3295 func (c *featureRegistryRESTClient) UpdateFeatureOperation(name string) *UpdateFeatureOperation { 3296 override := fmt.Sprintf("/ui/%s", name) 3297 return &UpdateFeatureOperation{ 3298 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3299 pollPath: override, 3300 } 3301 } 3302 3303 // UpdateFeatureGroupOperation returns a new UpdateFeatureGroupOperation from a given name. 3304 // The name must be that of a previously created UpdateFeatureGroupOperation, possibly from a different process. 3305 func (c *featureRegistryGRPCClient) UpdateFeatureGroupOperation(name string) *UpdateFeatureGroupOperation { 3306 return &UpdateFeatureGroupOperation{ 3307 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3308 } 3309 } 3310 3311 // UpdateFeatureGroupOperation returns a new UpdateFeatureGroupOperation from a given name. 3312 // The name must be that of a previously created UpdateFeatureGroupOperation, possibly from a different process. 3313 func (c *featureRegistryRESTClient) UpdateFeatureGroupOperation(name string) *UpdateFeatureGroupOperation { 3314 override := fmt.Sprintf("/ui/%s", name) 3315 return &UpdateFeatureGroupOperation{ 3316 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3317 pollPath: override, 3318 } 3319 } 3320 3321 // UpdateFeatureMonitorOperation returns a new UpdateFeatureMonitorOperation from a given name. 3322 // The name must be that of a previously created UpdateFeatureMonitorOperation, possibly from a different process. 3323 func (c *featureRegistryGRPCClient) UpdateFeatureMonitorOperation(name string) *UpdateFeatureMonitorOperation { 3324 return &UpdateFeatureMonitorOperation{ 3325 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3326 } 3327 } 3328 3329 // UpdateFeatureMonitorOperation returns a new UpdateFeatureMonitorOperation from a given name. 3330 // The name must be that of a previously created UpdateFeatureMonitorOperation, possibly from a different process. 3331 func (c *featureRegistryRESTClient) UpdateFeatureMonitorOperation(name string) *UpdateFeatureMonitorOperation { 3332 override := fmt.Sprintf("/ui/%s", name) 3333 return &UpdateFeatureMonitorOperation{ 3334 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 3335 pollPath: override, 3336 } 3337 }