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