Debian Codegraph @

artifactregistry/apiv1/artifact_registry_client.go

raw
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 artifactregistry
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 artifactregistrypb "cloud.google.com/go/artifactregistry/apiv1/artifactregistrypb"
30 iampb "cloud.google.com/go/iam/apiv1/iampb"
31 "cloud.google.com/go/longrunning"
32 lroauto "cloud.google.com/go/longrunning/autogen"
33 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
34 gax "github.com/googleapis/gax-go/v2"
35 "google.golang.org/api/iterator"
36 "google.golang.org/api/option"
37 "google.golang.org/api/option/internaloption"
38 gtransport "google.golang.org/api/transport/grpc"
39 httptransport "google.golang.org/api/transport/http"
40 locationpb "google.golang.org/genproto/googleapis/cloud/location"
41 "google.golang.org/grpc"
42 "google.golang.org/protobuf/encoding/protojson"
43 "google.golang.org/protobuf/proto"
44 )
45
46 var newClientHook clientHook
47
48 // CallOptions contains the retry settings for each method of Client.
49 type CallOptions struct {
50 ListDockerImages []gax.CallOption
51 GetDockerImage []gax.CallOption
52 ListMavenArtifacts []gax.CallOption
53 GetMavenArtifact []gax.CallOption
54 ListNpmPackages []gax.CallOption
55 GetNpmPackage []gax.CallOption
56 ListPythonPackages []gax.CallOption
57 GetPythonPackage []gax.CallOption
58 ImportAptArtifacts []gax.CallOption
59 ImportYumArtifacts []gax.CallOption
60 ListRepositories []gax.CallOption
61 GetRepository []gax.CallOption
62 CreateRepository []gax.CallOption
63 UpdateRepository []gax.CallOption
64 DeleteRepository []gax.CallOption
65 ListPackages []gax.CallOption
66 GetPackage []gax.CallOption
67 DeletePackage []gax.CallOption
68 ListVersions []gax.CallOption
69 GetVersion []gax.CallOption
70 DeleteVersion []gax.CallOption
71 BatchDeleteVersions []gax.CallOption
72 UpdateVersion []gax.CallOption
73 ListFiles []gax.CallOption
74 GetFile []gax.CallOption
75 DeleteFile []gax.CallOption
76 UpdateFile []gax.CallOption
77 ListTags []gax.CallOption
78 GetTag []gax.CallOption
79 CreateTag []gax.CallOption
80 UpdateTag []gax.CallOption
81 DeleteTag []gax.CallOption
82 CreateRule []gax.CallOption
83 ListRules []gax.CallOption
84 GetRule []gax.CallOption
85 UpdateRule []gax.CallOption
86 DeleteRule []gax.CallOption
87 SetIamPolicy []gax.CallOption
88 GetIamPolicy []gax.CallOption
89 TestIamPermissions []gax.CallOption
90 GetProjectSettings []gax.CallOption
91 UpdateProjectSettings []gax.CallOption
92 GetVPCSCConfig []gax.CallOption
93 UpdateVPCSCConfig []gax.CallOption
94 UpdatePackage []gax.CallOption
95 ListAttachments []gax.CallOption
96 GetAttachment []gax.CallOption
97 CreateAttachment []gax.CallOption
98 DeleteAttachment []gax.CallOption
99 GetLocation []gax.CallOption
100 ListLocations []gax.CallOption
101 GetOperation []gax.CallOption
102 }
103
104 func defaultGRPCClientOptions() []option.ClientOption {
105 return []option.ClientOption{
106 internaloption.WithDefaultEndpoint("artifactregistry.googleapis.com:443"),
107 internaloption.WithDefaultEndpointTemplate("artifactregistry.UNIVERSE_DOMAIN:443"),
108 internaloption.WithDefaultMTLSEndpoint("artifactregistry.mtls.googleapis.com:443"),
109 internaloption.WithDefaultUniverseDomain("googleapis.com"),
110 internaloption.WithDefaultAudience("https://artifactregistry.googleapis.com/"),
111 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
112 internaloption.EnableJwtWithScope(),
113 internaloption.EnableNewAuthLibrary(),
114 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
115 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
116 }
117 }
118
119 func defaultCallOptions() *CallOptions {
120 return &CallOptions{
121 ListDockerImages: []gax.CallOption{
122 gax.WithTimeout(60000 * time.Millisecond),
123 },
124 GetDockerImage: []gax.CallOption{
125 gax.WithTimeout(60000 * time.Millisecond),
126 },
127 ListMavenArtifacts: []gax.CallOption{
128 gax.WithTimeout(60000 * time.Millisecond),
129 },
130 GetMavenArtifact: []gax.CallOption{
131 gax.WithTimeout(60000 * time.Millisecond),
132 },
133 ListNpmPackages: []gax.CallOption{
134 gax.WithTimeout(60000 * time.Millisecond),
135 },
136 GetNpmPackage: []gax.CallOption{
137 gax.WithTimeout(60000 * time.Millisecond),
138 },
139 ListPythonPackages: []gax.CallOption{
140 gax.WithTimeout(60000 * time.Millisecond),
141 },
142 GetPythonPackage: []gax.CallOption{
143 gax.WithTimeout(60000 * time.Millisecond),
144 },
145 ImportAptArtifacts: []gax.CallOption{
146 gax.WithTimeout(60000 * time.Millisecond),
147 },
148 ImportYumArtifacts: []gax.CallOption{
149 gax.WithTimeout(60000 * time.Millisecond),
150 },
151 ListRepositories: []gax.CallOption{
152 gax.WithTimeout(60000 * time.Millisecond),
153 },
154 GetRepository: []gax.CallOption{
155 gax.WithTimeout(60000 * time.Millisecond),
156 },
157 CreateRepository: []gax.CallOption{
158 gax.WithTimeout(60000 * time.Millisecond),
159 },
160 UpdateRepository: []gax.CallOption{
161 gax.WithTimeout(60000 * time.Millisecond),
162 },
163 DeleteRepository: []gax.CallOption{
164 gax.WithTimeout(60000 * time.Millisecond),
165 },
166 ListPackages: []gax.CallOption{
167 gax.WithTimeout(60000 * time.Millisecond),
168 },
169 GetPackage: []gax.CallOption{
170 gax.WithTimeout(60000 * time.Millisecond),
171 },
172 DeletePackage: []gax.CallOption{
173 gax.WithTimeout(60000 * time.Millisecond),
174 },
175 ListVersions: []gax.CallOption{
176 gax.WithTimeout(60000 * time.Millisecond),
177 },
178 GetVersion: []gax.CallOption{
179 gax.WithTimeout(60000 * time.Millisecond),
180 },
181 DeleteVersion: []gax.CallOption{
182 gax.WithTimeout(60000 * time.Millisecond),
183 },
184 BatchDeleteVersions: []gax.CallOption{
185 gax.WithTimeout(60000 * time.Millisecond),
186 },
187 UpdateVersion: []gax.CallOption{
188 gax.WithTimeout(60000 * time.Millisecond),
189 },
190 ListFiles: []gax.CallOption{
191 gax.WithTimeout(60000 * time.Millisecond),
192 },
193 GetFile: []gax.CallOption{
194 gax.WithTimeout(60000 * time.Millisecond),
195 },
196 DeleteFile: []gax.CallOption{
197 gax.WithTimeout(60000 * time.Millisecond),
198 },
199 UpdateFile: []gax.CallOption{
200 gax.WithTimeout(60000 * time.Millisecond),
201 },
202 ListTags: []gax.CallOption{
203 gax.WithTimeout(60000 * time.Millisecond),
204 },
205 GetTag: []gax.CallOption{
206 gax.WithTimeout(60000 * time.Millisecond),
207 },
208 CreateTag: []gax.CallOption{
209 gax.WithTimeout(60000 * time.Millisecond),
210 },
211 UpdateTag: []gax.CallOption{
212 gax.WithTimeout(60000 * time.Millisecond),
213 },
214 DeleteTag: []gax.CallOption{
215 gax.WithTimeout(60000 * time.Millisecond),
216 },
217 CreateRule: []gax.CallOption{
218 gax.WithTimeout(60000 * time.Millisecond),
219 },
220 ListRules: []gax.CallOption{
221 gax.WithTimeout(60000 * time.Millisecond),
222 },
223 GetRule: []gax.CallOption{
224 gax.WithTimeout(60000 * time.Millisecond),
225 },
226 UpdateRule: []gax.CallOption{
227 gax.WithTimeout(60000 * time.Millisecond),
228 },
229 DeleteRule: []gax.CallOption{
230 gax.WithTimeout(60000 * time.Millisecond),
231 },
232 SetIamPolicy: []gax.CallOption{
233 gax.WithTimeout(60000 * time.Millisecond),
234 },
235 GetIamPolicy: []gax.CallOption{
236 gax.WithTimeout(60000 * time.Millisecond),
237 },
238 TestIamPermissions: []gax.CallOption{
239 gax.WithTimeout(60000 * time.Millisecond),
240 },
241 GetProjectSettings: []gax.CallOption{
242 gax.WithTimeout(60000 * time.Millisecond),
243 },
244 UpdateProjectSettings: []gax.CallOption{
245 gax.WithTimeout(60000 * time.Millisecond),
246 },
247 GetVPCSCConfig: []gax.CallOption{
248 gax.WithTimeout(60000 * time.Millisecond),
249 },
250 UpdateVPCSCConfig: []gax.CallOption{
251 gax.WithTimeout(60000 * time.Millisecond),
252 },
253 UpdatePackage: []gax.CallOption{
254 gax.WithTimeout(60000 * time.Millisecond),
255 },
256 ListAttachments: []gax.CallOption{
257 gax.WithTimeout(60000 * time.Millisecond),
258 },
259 GetAttachment: []gax.CallOption{
260 gax.WithTimeout(60000 * time.Millisecond),
261 },
262 CreateAttachment: []gax.CallOption{
263 gax.WithTimeout(60000 * time.Millisecond),
264 },
265 DeleteAttachment: []gax.CallOption{
266 gax.WithTimeout(60000 * time.Millisecond),
267 },
268 GetLocation: []gax.CallOption{},
269 ListLocations: []gax.CallOption{},
270 GetOperation: []gax.CallOption{},
271 }
272 }
273
274 func defaultRESTCallOptions() *CallOptions {
275 return &CallOptions{
276 ListDockerImages: []gax.CallOption{
277 gax.WithTimeout(60000 * time.Millisecond),
278 },
279 GetDockerImage: []gax.CallOption{
280 gax.WithTimeout(60000 * time.Millisecond),
281 },
282 ListMavenArtifacts: []gax.CallOption{
283 gax.WithTimeout(60000 * time.Millisecond),
284 },
285 GetMavenArtifact: []gax.CallOption{
286 gax.WithTimeout(60000 * time.Millisecond),
287 },
288 ListNpmPackages: []gax.CallOption{
289 gax.WithTimeout(60000 * time.Millisecond),
290 },
291 GetNpmPackage: []gax.CallOption{
292 gax.WithTimeout(60000 * time.Millisecond),
293 },
294 ListPythonPackages: []gax.CallOption{
295 gax.WithTimeout(60000 * time.Millisecond),
296 },
297 GetPythonPackage: []gax.CallOption{
298 gax.WithTimeout(60000 * time.Millisecond),
299 },
300 ImportAptArtifacts: []gax.CallOption{
301 gax.WithTimeout(60000 * time.Millisecond),
302 },
303 ImportYumArtifacts: []gax.CallOption{
304 gax.WithTimeout(60000 * time.Millisecond),
305 },
306 ListRepositories: []gax.CallOption{
307 gax.WithTimeout(60000 * time.Millisecond),
308 },
309 GetRepository: []gax.CallOption{
310 gax.WithTimeout(60000 * time.Millisecond),
311 },
312 CreateRepository: []gax.CallOption{
313 gax.WithTimeout(60000 * time.Millisecond),
314 },
315 UpdateRepository: []gax.CallOption{
316 gax.WithTimeout(60000 * time.Millisecond),
317 },
318 DeleteRepository: []gax.CallOption{
319 gax.WithTimeout(60000 * time.Millisecond),
320 },
321 ListPackages: []gax.CallOption{
322 gax.WithTimeout(60000 * time.Millisecond),
323 },
324 GetPackage: []gax.CallOption{
325 gax.WithTimeout(60000 * time.Millisecond),
326 },
327 DeletePackage: []gax.CallOption{
328 gax.WithTimeout(60000 * time.Millisecond),
329 },
330 ListVersions: []gax.CallOption{
331 gax.WithTimeout(60000 * time.Millisecond),
332 },
333 GetVersion: []gax.CallOption{
334 gax.WithTimeout(60000 * time.Millisecond),
335 },
336 DeleteVersion: []gax.CallOption{
337 gax.WithTimeout(60000 * time.Millisecond),
338 },
339 BatchDeleteVersions: []gax.CallOption{
340 gax.WithTimeout(60000 * time.Millisecond),
341 },
342 UpdateVersion: []gax.CallOption{
343 gax.WithTimeout(60000 * time.Millisecond),
344 },
345 ListFiles: []gax.CallOption{
346 gax.WithTimeout(60000 * time.Millisecond),
347 },
348 GetFile: []gax.CallOption{
349 gax.WithTimeout(60000 * time.Millisecond),
350 },
351 DeleteFile: []gax.CallOption{
352 gax.WithTimeout(60000 * time.Millisecond),
353 },
354 UpdateFile: []gax.CallOption{
355 gax.WithTimeout(60000 * time.Millisecond),
356 },
357 ListTags: []gax.CallOption{
358 gax.WithTimeout(60000 * time.Millisecond),
359 },
360 GetTag: []gax.CallOption{
361 gax.WithTimeout(60000 * time.Millisecond),
362 },
363 CreateTag: []gax.CallOption{
364 gax.WithTimeout(60000 * time.Millisecond),
365 },
366 UpdateTag: []gax.CallOption{
367 gax.WithTimeout(60000 * time.Millisecond),
368 },
369 DeleteTag: []gax.CallOption{
370 gax.WithTimeout(60000 * time.Millisecond),
371 },
372 CreateRule: []gax.CallOption{
373 gax.WithTimeout(60000 * time.Millisecond),
374 },
375 ListRules: []gax.CallOption{
376 gax.WithTimeout(60000 * time.Millisecond),
377 },
378 GetRule: []gax.CallOption{
379 gax.WithTimeout(60000 * time.Millisecond),
380 },
381 UpdateRule: []gax.CallOption{
382 gax.WithTimeout(60000 * time.Millisecond),
383 },
384 DeleteRule: []gax.CallOption{
385 gax.WithTimeout(60000 * time.Millisecond),
386 },
387 SetIamPolicy: []gax.CallOption{
388 gax.WithTimeout(60000 * time.Millisecond),
389 },
390 GetIamPolicy: []gax.CallOption{
391 gax.WithTimeout(60000 * time.Millisecond),
392 },
393 TestIamPermissions: []gax.CallOption{
394 gax.WithTimeout(60000 * time.Millisecond),
395 },
396 GetProjectSettings: []gax.CallOption{
397 gax.WithTimeout(60000 * time.Millisecond),
398 },
399 UpdateProjectSettings: []gax.CallOption{
400 gax.WithTimeout(60000 * time.Millisecond),
401 },
402 GetVPCSCConfig: []gax.CallOption{
403 gax.WithTimeout(60000 * time.Millisecond),
404 },
405 UpdateVPCSCConfig: []gax.CallOption{
406 gax.WithTimeout(60000 * time.Millisecond),
407 },
408 UpdatePackage: []gax.CallOption{
409 gax.WithTimeout(60000 * time.Millisecond),
410 },
411 ListAttachments: []gax.CallOption{
412 gax.WithTimeout(60000 * time.Millisecond),
413 },
414 GetAttachment: []gax.CallOption{
415 gax.WithTimeout(60000 * time.Millisecond),
416 },
417 CreateAttachment: []gax.CallOption{
418 gax.WithTimeout(60000 * time.Millisecond),
419 },
420 DeleteAttachment: []gax.CallOption{
421 gax.WithTimeout(60000 * time.Millisecond),
422 },
423 GetLocation: []gax.CallOption{},
424 ListLocations: []gax.CallOption{},
425 GetOperation: []gax.CallOption{},
426 }
427 }
428
429 // internalClient is an interface that defines the methods available from Artifact Registry API.
430 type internalClient interface {
431 Close() error
432 setGoogleClientInfo(...string)
433 Connection() *grpc.ClientConn
434 ListDockerImages(context.Context, *artifactregistrypb.ListDockerImagesRequest, ...gax.CallOption) *DockerImageIterator
435 GetDockerImage(context.Context, *artifactregistrypb.GetDockerImageRequest, ...gax.CallOption) (*artifactregistrypb.DockerImage, error)
436 ListMavenArtifacts(context.Context, *artifactregistrypb.ListMavenArtifactsRequest, ...gax.CallOption) *MavenArtifactIterator
437 GetMavenArtifact(context.Context, *artifactregistrypb.GetMavenArtifactRequest, ...gax.CallOption) (*artifactregistrypb.MavenArtifact, error)
438 ListNpmPackages(context.Context, *artifactregistrypb.ListNpmPackagesRequest, ...gax.CallOption) *NpmPackageIterator
439 GetNpmPackage(context.Context, *artifactregistrypb.GetNpmPackageRequest, ...gax.CallOption) (*artifactregistrypb.NpmPackage, error)
440 ListPythonPackages(context.Context, *artifactregistrypb.ListPythonPackagesRequest, ...gax.CallOption) *PythonPackageIterator
441 GetPythonPackage(context.Context, *artifactregistrypb.GetPythonPackageRequest, ...gax.CallOption) (*artifactregistrypb.PythonPackage, error)
442 ImportAptArtifacts(context.Context, *artifactregistrypb.ImportAptArtifactsRequest, ...gax.CallOption) (*ImportAptArtifactsOperation, error)
443 ImportAptArtifactsOperation(name string) *ImportAptArtifactsOperation
444 ImportYumArtifacts(context.Context, *artifactregistrypb.ImportYumArtifactsRequest, ...gax.CallOption) (*ImportYumArtifactsOperation, error)
445 ImportYumArtifactsOperation(name string) *ImportYumArtifactsOperation
446 ListRepositories(context.Context, *artifactregistrypb.ListRepositoriesRequest, ...gax.CallOption) *RepositoryIterator
447 GetRepository(context.Context, *artifactregistrypb.GetRepositoryRequest, ...gax.CallOption) (*artifactregistrypb.Repository, error)
448 CreateRepository(context.Context, *artifactregistrypb.CreateRepositoryRequest, ...gax.CallOption) (*CreateRepositoryOperation, error)
449 CreateRepositoryOperation(name string) *CreateRepositoryOperation
450 UpdateRepository(context.Context, *artifactregistrypb.UpdateRepositoryRequest, ...gax.CallOption) (*artifactregistrypb.Repository, error)
451 DeleteRepository(context.Context, *artifactregistrypb.DeleteRepositoryRequest, ...gax.CallOption) (*DeleteRepositoryOperation, error)
452 DeleteRepositoryOperation(name string) *DeleteRepositoryOperation
453 ListPackages(context.Context, *artifactregistrypb.ListPackagesRequest, ...gax.CallOption) *PackageIterator
454 GetPackage(context.Context, *artifactregistrypb.GetPackageRequest, ...gax.CallOption) (*artifactregistrypb.Package, error)
455 DeletePackage(context.Context, *artifactregistrypb.DeletePackageRequest, ...gax.CallOption) (*DeletePackageOperation, error)
456 DeletePackageOperation(name string) *DeletePackageOperation
457 ListVersions(context.Context, *artifactregistrypb.ListVersionsRequest, ...gax.CallOption) *VersionIterator
458 GetVersion(context.Context, *artifactregistrypb.GetVersionRequest, ...gax.CallOption) (*artifactregistrypb.Version, error)
459 DeleteVersion(context.Context, *artifactregistrypb.DeleteVersionRequest, ...gax.CallOption) (*DeleteVersionOperation, error)
460 DeleteVersionOperation(name string) *DeleteVersionOperation
461 BatchDeleteVersions(context.Context, *artifactregistrypb.BatchDeleteVersionsRequest, ...gax.CallOption) (*BatchDeleteVersionsOperation, error)
462 BatchDeleteVersionsOperation(name string) *BatchDeleteVersionsOperation
463 UpdateVersion(context.Context, *artifactregistrypb.UpdateVersionRequest, ...gax.CallOption) (*artifactregistrypb.Version, error)
464 ListFiles(context.Context, *artifactregistrypb.ListFilesRequest, ...gax.CallOption) *FileIterator
465 GetFile(context.Context, *artifactregistrypb.GetFileRequest, ...gax.CallOption) (*artifactregistrypb.File, error)
466 DeleteFile(context.Context, *artifactregistrypb.DeleteFileRequest, ...gax.CallOption) (*DeleteFileOperation, error)
467 DeleteFileOperation(name string) *DeleteFileOperation
468 UpdateFile(context.Context, *artifactregistrypb.UpdateFileRequest, ...gax.CallOption) (*artifactregistrypb.File, error)
469 ListTags(context.Context, *artifactregistrypb.ListTagsRequest, ...gax.CallOption) *TagIterator
470 GetTag(context.Context, *artifactregistrypb.GetTagRequest, ...gax.CallOption) (*artifactregistrypb.Tag, error)
471 CreateTag(context.Context, *artifactregistrypb.CreateTagRequest, ...gax.CallOption) (*artifactregistrypb.Tag, error)
472 UpdateTag(context.Context, *artifactregistrypb.UpdateTagRequest, ...gax.CallOption) (*artifactregistrypb.Tag, error)
473 DeleteTag(context.Context, *artifactregistrypb.DeleteTagRequest, ...gax.CallOption) error
474 CreateRule(context.Context, *artifactregistrypb.CreateRuleRequest, ...gax.CallOption) (*artifactregistrypb.Rule, error)
475 ListRules(context.Context, *artifactregistrypb.ListRulesRequest, ...gax.CallOption) *RuleIterator
476 GetRule(context.Context, *artifactregistrypb.GetRuleRequest, ...gax.CallOption) (*artifactregistrypb.Rule, error)
477 UpdateRule(context.Context, *artifactregistrypb.UpdateRuleRequest, ...gax.CallOption) (*artifactregistrypb.Rule, error)
478 DeleteRule(context.Context, *artifactregistrypb.DeleteRuleRequest, ...gax.CallOption) error
479 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
480 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
481 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
482 GetProjectSettings(context.Context, *artifactregistrypb.GetProjectSettingsRequest, ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error)
483 UpdateProjectSettings(context.Context, *artifactregistrypb.UpdateProjectSettingsRequest, ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error)
484 GetVPCSCConfig(context.Context, *artifactregistrypb.GetVPCSCConfigRequest, ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error)
485 UpdateVPCSCConfig(context.Context, *artifactregistrypb.UpdateVPCSCConfigRequest, ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error)
486 UpdatePackage(context.Context, *artifactregistrypb.UpdatePackageRequest, ...gax.CallOption) (*artifactregistrypb.Package, error)
487 ListAttachments(context.Context, *artifactregistrypb.ListAttachmentsRequest, ...gax.CallOption) *AttachmentIterator
488 GetAttachment(context.Context, *artifactregistrypb.GetAttachmentRequest, ...gax.CallOption) (*artifactregistrypb.Attachment, error)
489 CreateAttachment(context.Context, *artifactregistrypb.CreateAttachmentRequest, ...gax.CallOption) (*CreateAttachmentOperation, error)
490 CreateAttachmentOperation(name string) *CreateAttachmentOperation
491 DeleteAttachment(context.Context, *artifactregistrypb.DeleteAttachmentRequest, ...gax.CallOption) (*DeleteAttachmentOperation, error)
492 DeleteAttachmentOperation(name string) *DeleteAttachmentOperation
493 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
494 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
495 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
496 }
497
498 // Client is a client for interacting with Artifact Registry API.
499 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
500 //
501 // The Artifact Registry API service.
502 //
503 // Artifact Registry is an artifact management system for storing artifacts
504 // from different package management systems.
505 //
506 // The resources managed by this API are:
507 //
508 // Repositories, which group packages and their data.
509 //
510 // Packages, which group versions and their tags.
511 //
512 // Versions, which are specific forms of a package.
513 //
514 // Tags, which represent alternative names for versions.
515 //
516 // Files, which contain content and are optionally associated with a Package
517 // or Version.
518 type Client struct {
519 // The internal transport-dependent client.
520 internalClient internalClient
521
522 // The call options for this service.
523 CallOptions *CallOptions
524
525 // LROClient is used internally to handle long-running operations.
526 // It is exposed so that its CallOptions can be modified if required.
527 // Users should not Close this client.
528 LROClient *lroauto.OperationsClient
529 }
530
531 // Wrapper methods routed to the internal client.
532
533 // Close closes the connection to the API service. The user should invoke this when
534 // the client is no longer required.
535 func (c *Client) Close() error {
536 return c.internalClient.Close()
537 }
538
539 // setGoogleClientInfo sets the name and version of the application in
540 // the `x-goog-api-client` header passed on each request. Intended for
541 // use by Google-written clients.
542 func (c *Client) setGoogleClientInfo(keyval ...string) {
543 c.internalClient.setGoogleClientInfo(keyval...)
544 }
545
546 // Connection returns a connection to the API service.
547 //
548 // Deprecated: Connections are now pooled so this method does not always
549 // return the same resource.
550 func (c *Client) Connection() *grpc.ClientConn {
551 return c.internalClient.Connection()
552 }
553
554 // ListDockerImages lists docker images.
555 func (c *Client) ListDockerImages(ctx context.Context, req *artifactregistrypb.ListDockerImagesRequest, opts ...gax.CallOption) *DockerImageIterator {
556 return c.internalClient.ListDockerImages(ctx, req, opts...)
557 }
558
559 // GetDockerImage gets a docker image.
560 func (c *Client) GetDockerImage(ctx context.Context, req *artifactregistrypb.GetDockerImageRequest, opts ...gax.CallOption) (*artifactregistrypb.DockerImage, error) {
561 return c.internalClient.GetDockerImage(ctx, req, opts...)
562 }
563
564 // ListMavenArtifacts lists maven artifacts.
565 func (c *Client) ListMavenArtifacts(ctx context.Context, req *artifactregistrypb.ListMavenArtifactsRequest, opts ...gax.CallOption) *MavenArtifactIterator {
566 return c.internalClient.ListMavenArtifacts(ctx, req, opts...)
567 }
568
569 // GetMavenArtifact gets a maven artifact.
570 func (c *Client) GetMavenArtifact(ctx context.Context, req *artifactregistrypb.GetMavenArtifactRequest, opts ...gax.CallOption) (*artifactregistrypb.MavenArtifact, error) {
571 return c.internalClient.GetMavenArtifact(ctx, req, opts...)
572 }
573
574 // ListNpmPackages lists npm packages.
575 func (c *Client) ListNpmPackages(ctx context.Context, req *artifactregistrypb.ListNpmPackagesRequest, opts ...gax.CallOption) *NpmPackageIterator {
576 return c.internalClient.ListNpmPackages(ctx, req, opts...)
577 }
578
579 // GetNpmPackage gets a npm package.
580 func (c *Client) GetNpmPackage(ctx context.Context, req *artifactregistrypb.GetNpmPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.NpmPackage, error) {
581 return c.internalClient.GetNpmPackage(ctx, req, opts...)
582 }
583
584 // ListPythonPackages lists python packages.
585 func (c *Client) ListPythonPackages(ctx context.Context, req *artifactregistrypb.ListPythonPackagesRequest, opts ...gax.CallOption) *PythonPackageIterator {
586 return c.internalClient.ListPythonPackages(ctx, req, opts...)
587 }
588
589 // GetPythonPackage gets a python package.
590 func (c *Client) GetPythonPackage(ctx context.Context, req *artifactregistrypb.GetPythonPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.PythonPackage, error) {
591 return c.internalClient.GetPythonPackage(ctx, req, opts...)
592 }
593
594 // ImportAptArtifacts imports Apt artifacts. The returned Operation will complete once the
595 // resources are imported. Package, Version, and File resources are created
596 // based on the imported artifacts. Imported artifacts that conflict with
597 // existing resources are ignored.
598 func (c *Client) ImportAptArtifacts(ctx context.Context, req *artifactregistrypb.ImportAptArtifactsRequest, opts ...gax.CallOption) (*ImportAptArtifactsOperation, error) {
599 return c.internalClient.ImportAptArtifacts(ctx, req, opts...)
600 }
601
602 // ImportAptArtifactsOperation returns a new ImportAptArtifactsOperation from a given name.
603 // The name must be that of a previously created ImportAptArtifactsOperation, possibly from a different process.
604 func (c *Client) ImportAptArtifactsOperation(name string) *ImportAptArtifactsOperation {
605 return c.internalClient.ImportAptArtifactsOperation(name)
606 }
607
608 // ImportYumArtifacts imports Yum (RPM) artifacts. The returned Operation will complete once the
609 // resources are imported. Package, Version, and File resources are created
610 // based on the imported artifacts. Imported artifacts that conflict with
611 // existing resources are ignored.
612 func (c *Client) ImportYumArtifacts(ctx context.Context, req *artifactregistrypb.ImportYumArtifactsRequest, opts ...gax.CallOption) (*ImportYumArtifactsOperation, error) {
613 return c.internalClient.ImportYumArtifacts(ctx, req, opts...)
614 }
615
616 // ImportYumArtifactsOperation returns a new ImportYumArtifactsOperation from a given name.
617 // The name must be that of a previously created ImportYumArtifactsOperation, possibly from a different process.
618 func (c *Client) ImportYumArtifactsOperation(name string) *ImportYumArtifactsOperation {
619 return c.internalClient.ImportYumArtifactsOperation(name)
620 }
621
622 // ListRepositories lists repositories.
623 func (c *Client) ListRepositories(ctx context.Context, req *artifactregistrypb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
624 return c.internalClient.ListRepositories(ctx, req, opts...)
625 }
626
627 // GetRepository gets a repository.
628 func (c *Client) GetRepository(ctx context.Context, req *artifactregistrypb.GetRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
629 return c.internalClient.GetRepository(ctx, req, opts...)
630 }
631
632 // CreateRepository creates a repository. The returned Operation will finish once the
633 // repository has been created. Its response will be the created Repository.
634 func (c *Client) CreateRepository(ctx context.Context, req *artifactregistrypb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
635 return c.internalClient.CreateRepository(ctx, req, opts...)
636 }
637
638 // CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
639 // The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
640 func (c *Client) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
641 return c.internalClient.CreateRepositoryOperation(name)
642 }
643
644 // UpdateRepository updates a repository.
645 func (c *Client) UpdateRepository(ctx context.Context, req *artifactregistrypb.UpdateRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
646 return c.internalClient.UpdateRepository(ctx, req, opts...)
647 }
648
649 // DeleteRepository deletes a repository and all of its contents. The returned Operation will
650 // finish once the repository has been deleted. It will not have any Operation
651 // metadata and will return a google.protobuf.Empty response.
652 func (c *Client) DeleteRepository(ctx context.Context, req *artifactregistrypb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
653 return c.internalClient.DeleteRepository(ctx, req, opts...)
654 }
655
656 // DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
657 // The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
658 func (c *Client) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
659 return c.internalClient.DeleteRepositoryOperation(name)
660 }
661
662 // ListPackages lists packages.
663 func (c *Client) ListPackages(ctx context.Context, req *artifactregistrypb.ListPackagesRequest, opts ...gax.CallOption) *PackageIterator {
664 return c.internalClient.ListPackages(ctx, req, opts...)
665 }
666
667 // GetPackage gets a package.
668 func (c *Client) GetPackage(ctx context.Context, req *artifactregistrypb.GetPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
669 return c.internalClient.GetPackage(ctx, req, opts...)
670 }
671
672 // DeletePackage deletes a package and all of its versions and tags. The returned operation
673 // will complete once the package has been deleted.
674 func (c *Client) DeletePackage(ctx context.Context, req *artifactregistrypb.DeletePackageRequest, opts ...gax.CallOption) (*DeletePackageOperation, error) {
675 return c.internalClient.DeletePackage(ctx, req, opts...)
676 }
677
678 // DeletePackageOperation returns a new DeletePackageOperation from a given name.
679 // The name must be that of a previously created DeletePackageOperation, possibly from a different process.
680 func (c *Client) DeletePackageOperation(name string) *DeletePackageOperation {
681 return c.internalClient.DeletePackageOperation(name)
682 }
683
684 // ListVersions lists versions.
685 func (c *Client) ListVersions(ctx context.Context, req *artifactregistrypb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
686 return c.internalClient.ListVersions(ctx, req, opts...)
687 }
688
689 // GetVersion gets a version
690 func (c *Client) GetVersion(ctx context.Context, req *artifactregistrypb.GetVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
691 return c.internalClient.GetVersion(ctx, req, opts...)
692 }
693
694 // DeleteVersion deletes a version and all of its content. The returned operation will
695 // complete once the version has been deleted.
696 func (c *Client) DeleteVersion(ctx context.Context, req *artifactregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
697 return c.internalClient.DeleteVersion(ctx, req, opts...)
698 }
699
700 // DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
701 // The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
702 func (c *Client) DeleteVersionOperation(name string) *DeleteVersionOperation {
703 return c.internalClient.DeleteVersionOperation(name)
704 }
705
706 // BatchDeleteVersions deletes multiple versions across a repository. The returned operation will
707 // complete once the versions have been deleted.
708 func (c *Client) BatchDeleteVersions(ctx context.Context, req *artifactregistrypb.BatchDeleteVersionsRequest, opts ...gax.CallOption) (*BatchDeleteVersionsOperation, error) {
709 return c.internalClient.BatchDeleteVersions(ctx, req, opts...)
710 }
711
712 // BatchDeleteVersionsOperation returns a new BatchDeleteVersionsOperation from a given name.
713 // The name must be that of a previously created BatchDeleteVersionsOperation, possibly from a different process.
714 func (c *Client) BatchDeleteVersionsOperation(name string) *BatchDeleteVersionsOperation {
715 return c.internalClient.BatchDeleteVersionsOperation(name)
716 }
717
718 // UpdateVersion updates a version.
719 func (c *Client) UpdateVersion(ctx context.Context, req *artifactregistrypb.UpdateVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
720 return c.internalClient.UpdateVersion(ctx, req, opts...)
721 }
722
723 // ListFiles lists files.
724 func (c *Client) ListFiles(ctx context.Context, req *artifactregistrypb.ListFilesRequest, opts ...gax.CallOption) *FileIterator {
725 return c.internalClient.ListFiles(ctx, req, opts...)
726 }
727
728 // GetFile gets a file.
729 func (c *Client) GetFile(ctx context.Context, req *artifactregistrypb.GetFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
730 return c.internalClient.GetFile(ctx, req, opts...)
731 }
732
733 // DeleteFile deletes a file and all of its content. It is only allowed on generic
734 // repositories. The returned operation will complete once the file has been
735 // deleted.
736 func (c *Client) DeleteFile(ctx context.Context, req *artifactregistrypb.DeleteFileRequest, opts ...gax.CallOption) (*DeleteFileOperation, error) {
737 return c.internalClient.DeleteFile(ctx, req, opts...)
738 }
739
740 // DeleteFileOperation returns a new DeleteFileOperation from a given name.
741 // The name must be that of a previously created DeleteFileOperation, possibly from a different process.
742 func (c *Client) DeleteFileOperation(name string) *DeleteFileOperation {
743 return c.internalClient.DeleteFileOperation(name)
744 }
745
746 // UpdateFile updates a file.
747 func (c *Client) UpdateFile(ctx context.Context, req *artifactregistrypb.UpdateFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
748 return c.internalClient.UpdateFile(ctx, req, opts...)
749 }
750
751 // ListTags lists tags.
752 func (c *Client) ListTags(ctx context.Context, req *artifactregistrypb.ListTagsRequest, opts ...gax.CallOption) *TagIterator {
753 return c.internalClient.ListTags(ctx, req, opts...)
754 }
755
756 // GetTag gets a tag.
757 func (c *Client) GetTag(ctx context.Context, req *artifactregistrypb.GetTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
758 return c.internalClient.GetTag(ctx, req, opts...)
759 }
760
761 // CreateTag creates a tag.
762 func (c *Client) CreateTag(ctx context.Context, req *artifactregistrypb.CreateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
763 return c.internalClient.CreateTag(ctx, req, opts...)
764 }
765
766 // UpdateTag updates a tag.
767 func (c *Client) UpdateTag(ctx context.Context, req *artifactregistrypb.UpdateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
768 return c.internalClient.UpdateTag(ctx, req, opts...)
769 }
770
771 // DeleteTag deletes a tag.
772 func (c *Client) DeleteTag(ctx context.Context, req *artifactregistrypb.DeleteTagRequest, opts ...gax.CallOption) error {
773 return c.internalClient.DeleteTag(ctx, req, opts...)
774 }
775
776 // CreateRule creates a rule.
777 func (c *Client) CreateRule(ctx context.Context, req *artifactregistrypb.CreateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
778 return c.internalClient.CreateRule(ctx, req, opts...)
779 }
780
781 // ListRules lists rules.
782 func (c *Client) ListRules(ctx context.Context, req *artifactregistrypb.ListRulesRequest, opts ...gax.CallOption) *RuleIterator {
783 return c.internalClient.ListRules(ctx, req, opts...)
784 }
785
786 // GetRule gets a rule.
787 func (c *Client) GetRule(ctx context.Context, req *artifactregistrypb.GetRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
788 return c.internalClient.GetRule(ctx, req, opts...)
789 }
790
791 // UpdateRule updates a rule.
792 func (c *Client) UpdateRule(ctx context.Context, req *artifactregistrypb.UpdateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
793 return c.internalClient.UpdateRule(ctx, req, opts...)
794 }
795
796 // DeleteRule deletes a rule.
797 func (c *Client) DeleteRule(ctx context.Context, req *artifactregistrypb.DeleteRuleRequest, opts ...gax.CallOption) error {
798 return c.internalClient.DeleteRule(ctx, req, opts...)
799 }
800
801 // SetIamPolicy updates the IAM policy for a given resource.
802 func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
803 return c.internalClient.SetIamPolicy(ctx, req, opts...)
804 }
805
806 // GetIamPolicy gets the IAM policy for a given resource.
807 func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
808 return c.internalClient.GetIamPolicy(ctx, req, opts...)
809 }
810
811 // TestIamPermissions tests if the caller has a list of permissions on a resource.
812 func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
813 return c.internalClient.TestIamPermissions(ctx, req, opts...)
814 }
815
816 // GetProjectSettings retrieves the Settings for the Project.
817 func (c *Client) GetProjectSettings(ctx context.Context, req *artifactregistrypb.GetProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
818 return c.internalClient.GetProjectSettings(ctx, req, opts...)
819 }
820
821 // UpdateProjectSettings updates the Settings for the Project.
822 func (c *Client) UpdateProjectSettings(ctx context.Context, req *artifactregistrypb.UpdateProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
823 return c.internalClient.UpdateProjectSettings(ctx, req, opts...)
824 }
825
826 // GetVPCSCConfig retrieves the VPCSC Config for the Project.
827 func (c *Client) GetVPCSCConfig(ctx context.Context, req *artifactregistrypb.GetVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
828 return c.internalClient.GetVPCSCConfig(ctx, req, opts...)
829 }
830
831 // UpdateVPCSCConfig updates the VPCSC Config for the Project.
832 func (c *Client) UpdateVPCSCConfig(ctx context.Context, req *artifactregistrypb.UpdateVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
833 return c.internalClient.UpdateVPCSCConfig(ctx, req, opts...)
834 }
835
836 // UpdatePackage updates a package.
837 func (c *Client) UpdatePackage(ctx context.Context, req *artifactregistrypb.UpdatePackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
838 return c.internalClient.UpdatePackage(ctx, req, opts...)
839 }
840
841 // ListAttachments lists attachments.
842 func (c *Client) ListAttachments(ctx context.Context, req *artifactregistrypb.ListAttachmentsRequest, opts ...gax.CallOption) *AttachmentIterator {
843 return c.internalClient.ListAttachments(ctx, req, opts...)
844 }
845
846 // GetAttachment gets an attachment.
847 func (c *Client) GetAttachment(ctx context.Context, req *artifactregistrypb.GetAttachmentRequest, opts ...gax.CallOption) (*artifactregistrypb.Attachment, error) {
848 return c.internalClient.GetAttachment(ctx, req, opts...)
849 }
850
851 // CreateAttachment creates an attachment. The returned Operation will finish once the
852 // attachment has been created. Its response will be the created attachment.
853 func (c *Client) CreateAttachment(ctx context.Context, req *artifactregistrypb.CreateAttachmentRequest, opts ...gax.CallOption) (*CreateAttachmentOperation, error) {
854 return c.internalClient.CreateAttachment(ctx, req, opts...)
855 }
856
857 // CreateAttachmentOperation returns a new CreateAttachmentOperation from a given name.
858 // The name must be that of a previously created CreateAttachmentOperation, possibly from a different process.
859 func (c *Client) CreateAttachmentOperation(name string) *CreateAttachmentOperation {
860 return c.internalClient.CreateAttachmentOperation(name)
861 }
862
863 // DeleteAttachment deletes an attachment. The returned Operation will
864 // finish once the attachments has been deleted. It will not have any
865 // Operation metadata and will return a google.protobuf.Empty response.
866 func (c *Client) DeleteAttachment(ctx context.Context, req *artifactregistrypb.DeleteAttachmentRequest, opts ...gax.CallOption) (*DeleteAttachmentOperation, error) {
867 return c.internalClient.DeleteAttachment(ctx, req, opts...)
868 }
869
870 // DeleteAttachmentOperation returns a new DeleteAttachmentOperation from a given name.
871 // The name must be that of a previously created DeleteAttachmentOperation, possibly from a different process.
872 func (c *Client) DeleteAttachmentOperation(name string) *DeleteAttachmentOperation {
873 return c.internalClient.DeleteAttachmentOperation(name)
874 }
875
876 // GetLocation gets information about a location.
877 func (c *Client) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
878 return c.internalClient.GetLocation(ctx, req, opts...)
879 }
880
881 // ListLocations lists information about the supported locations for this service.
882 func (c *Client) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
883 return c.internalClient.ListLocations(ctx, req, opts...)
884 }
885
886 // GetOperation is a utility method from google.longrunning.Operations.
887 func (c *Client) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
888 return c.internalClient.GetOperation(ctx, req, opts...)
889 }
890
891 // gRPCClient is a client for interacting with Artifact Registry API over gRPC transport.
892 //
893 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
894 type gRPCClient struct {
895 // Connection pool of gRPC connections to the service.
896 connPool gtransport.ConnPool
897
898 // Points back to the CallOptions field of the containing Client
899 CallOptions **CallOptions
900
901 // The gRPC API client.
902 client artifactregistrypb.ArtifactRegistryClient
903
904 // LROClient is used internally to handle long-running operations.
905 // It is exposed so that its CallOptions can be modified if required.
906 // Users should not Close this client.
907 LROClient **lroauto.OperationsClient
908
909 operationsClient longrunningpb.OperationsClient
910
911 locationsClient locationpb.LocationsClient
912
913 // The x-goog-* metadata to be sent with each request.
914 xGoogHeaders []string
915
916 logger *slog.Logger
917 }
918
919 // NewClient creates a new artifact registry client based on gRPC.
920 // The returned client must be Closed when it is done being used to clean up its underlying connections.
921 //
922 // The Artifact Registry API service.
923 //
924 // Artifact Registry is an artifact management system for storing artifacts
925 // from different package management systems.
926 //
927 // The resources managed by this API are:
928 //
929 // Repositories, which group packages and their data.
930 //
931 // Packages, which group versions and their tags.
932 //
933 // Versions, which are specific forms of a package.
934 //
935 // Tags, which represent alternative names for versions.
936 //
937 // Files, which contain content and are optionally associated with a Package
938 // or Version.
939 func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
940 clientOpts := defaultGRPCClientOptions()
941 if newClientHook != nil {
942 hookOpts, err := newClientHook(ctx, clientHookParams{})
943 if err != nil {
944 return nil, err
945 }
946 clientOpts = append(clientOpts, hookOpts...)
947 }
948
949 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
950 if err != nil {
951 return nil, err
952 }
953 client := Client{CallOptions: defaultCallOptions()}
954
955 c := &gRPCClient{
956 connPool: connPool,
957 client: artifactregistrypb.NewArtifactRegistryClient(connPool),
958 CallOptions: &client.CallOptions,
959 logger: internaloption.GetLogger(opts),
960 operationsClient: longrunningpb.NewOperationsClient(connPool),
961 locationsClient: locationpb.NewLocationsClient(connPool),
962 }
963 c.setGoogleClientInfo()
964
965 client.internalClient = c
966
967 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
968 if err != nil {
969 // This error "should not happen", since we are just reusing old connection pool
970 // and never actually need to dial.
971 // If this does happen, we could leak connp. However, we cannot close conn:
972 // If the user invoked the constructor with option.WithGRPCConn,
973 // we would close a connection that's still in use.
974 // TODO: investigate error conditions.
975 return nil, err
976 }
977 c.LROClient = &client.LROClient
978 return &client, nil
979 }
980
981 // Connection returns a connection to the API service.
982 //
983 // Deprecated: Connections are now pooled so this method does not always
984 // return the same resource.
985 func (c *gRPCClient) Connection() *grpc.ClientConn {
986 return c.connPool.Conn()
987 }
988
989 // setGoogleClientInfo sets the name and version of the application in
990 // the `x-goog-api-client` header passed on each request. Intended for
991 // use by Google-written clients.
992 func (c *gRPCClient) setGoogleClientInfo(keyval ...string) {
993 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
994 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
995 c.xGoogHeaders = []string{
996 "x-goog-api-client", gax.XGoogHeader(kv...),
997 }
998 }
999
1000 // Close closes the connection to the API service. The user should invoke this when
1001 // the client is no longer required.
1002 func (c *gRPCClient) Close() error {
1003 return c.connPool.Close()
1004 }
1005
1006 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
1007 type restClient struct {
1008 // The http endpoint to connect to.
1009 endpoint string
1010
1011 // The http client.
1012 httpClient *http.Client
1013
1014 // LROClient is used internally to handle long-running operations.
1015 // It is exposed so that its CallOptions can be modified if required.
1016 // Users should not Close this client.
1017 LROClient **lroauto.OperationsClient
1018
1019 // The x-goog-* headers to be sent with each request.
1020 xGoogHeaders []string
1021
1022 // Points back to the CallOptions field of the containing Client
1023 CallOptions **CallOptions
1024
1025 logger *slog.Logger
1026 }
1027
1028 // NewRESTClient creates a new artifact registry rest client.
1029 //
1030 // The Artifact Registry API service.
1031 //
1032 // Artifact Registry is an artifact management system for storing artifacts
1033 // from different package management systems.
1034 //
1035 // The resources managed by this API are:
1036 //
1037 // Repositories, which group packages and their data.
1038 //
1039 // Packages, which group versions and their tags.
1040 //
1041 // Versions, which are specific forms of a package.
1042 //
1043 // Tags, which represent alternative names for versions.
1044 //
1045 // Files, which contain content and are optionally associated with a Package
1046 // or Version.
1047 func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
1048 clientOpts := append(defaultRESTClientOptions(), opts...)
1049 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
1050 if err != nil {
1051 return nil, err
1052 }
1053
1054 callOpts := defaultRESTCallOptions()
1055 c := &restClient{
1056 endpoint: endpoint,
1057 httpClient: httpClient,
1058 CallOptions: &callOpts,
1059 logger: internaloption.GetLogger(opts),
1060 }
1061 c.setGoogleClientInfo()
1062
1063 lroOpts := []option.ClientOption{
1064 option.WithHTTPClient(httpClient),
1065 option.WithEndpoint(endpoint),
1066 }
1067 opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
1068 if err != nil {
1069 return nil, err
1070 }
1071 c.LROClient = &opClient
1072
1073 return &Client{internalClient: c, CallOptions: callOpts}, nil
1074 }
1075
1076 func defaultRESTClientOptions() []option.ClientOption {
1077 return []option.ClientOption{
1078 internaloption.WithDefaultEndpoint("https://artifactregistry.googleapis.com"),
1079 internaloption.WithDefaultEndpointTemplate("https://artifactregistry.UNIVERSE_DOMAIN"),
1080 internaloption.WithDefaultMTLSEndpoint("https://artifactregistry.mtls.googleapis.com"),
1081 internaloption.WithDefaultUniverseDomain("googleapis.com"),
1082 internaloption.WithDefaultAudience("https://artifactregistry.googleapis.com/"),
1083 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
1084 internaloption.EnableNewAuthLibrary(),
1085 }
1086 }
1087
1088 // setGoogleClientInfo sets the name and version of the application in
1089 // the `x-goog-api-client` header passed on each request. Intended for
1090 // use by Google-written clients.
1091 func (c *restClient) setGoogleClientInfo(keyval ...string) {
1092 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1093 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
1094 c.xGoogHeaders = []string{
1095 "x-goog-api-client", gax.XGoogHeader(kv...),
1096 }
1097 }
1098
1099 // Close closes the connection to the API service. The user should invoke this when
1100 // the client is no longer required.
1101 func (c *restClient) Close() error {
1102 // Replace httpClient with nil to force cleanup.
1103 c.httpClient = nil
1104 return nil
1105 }
1106
1107 // Connection returns a connection to the API service.
1108 //
1109 // Deprecated: This method always returns nil.
1110 func (c *restClient) Connection() *grpc.ClientConn {
1111 return nil
1112 }
1113 func (c *gRPCClient) ListDockerImages(ctx context.Context, req *artifactregistrypb.ListDockerImagesRequest, opts ...gax.CallOption) *DockerImageIterator {
1114 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1115
1116 hds = append(c.xGoogHeaders, hds...)
1117 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1118 opts = append((*c.CallOptions).ListDockerImages[0:len((*c.CallOptions).ListDockerImages):len((*c.CallOptions).ListDockerImages)], opts...)
1119 it := &DockerImageIterator{}
1120 req = proto.Clone(req).(*artifactregistrypb.ListDockerImagesRequest)
1121 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.DockerImage, string, error) {
1122 resp := &artifactregistrypb.ListDockerImagesResponse{}
1123 if pageToken != "" {
1124 req.PageToken = pageToken
1125 }
1126 if pageSize > math.MaxInt32 {
1127 req.PageSize = math.MaxInt32
1128 } else if pageSize != 0 {
1129 req.PageSize = int32(pageSize)
1130 }
1131 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1132 var err error
1133 resp, err = executeRPC(ctx, c.client.ListDockerImages, req, settings.GRPC, c.logger, "ListDockerImages")
1134 return err
1135 }, opts...)
1136 if err != nil {
1137 return nil, "", err
1138 }
1139
1140 it.Response = resp
1141 return resp.GetDockerImages(), resp.GetNextPageToken(), nil
1142 }
1143 fetch := func(pageSize int, pageToken string) (string, error) {
1144 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1145 if err != nil {
1146 return "", err
1147 }
1148 it.items = append(it.items, items...)
1149 return nextPageToken, nil
1150 }
1151
1152 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1153 it.pageInfo.MaxSize = int(req.GetPageSize())
1154 it.pageInfo.Token = req.GetPageToken()
1155
1156 return it
1157 }
1158
1159 func (c *gRPCClient) GetDockerImage(ctx context.Context, req *artifactregistrypb.GetDockerImageRequest, opts ...gax.CallOption) (*artifactregistrypb.DockerImage, error) {
1160 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1161
1162 hds = append(c.xGoogHeaders, hds...)
1163 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1164 opts = append((*c.CallOptions).GetDockerImage[0:len((*c.CallOptions).GetDockerImage):len((*c.CallOptions).GetDockerImage)], opts...)
1165 var resp *artifactregistrypb.DockerImage
1166 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1167 var err error
1168 resp, err = executeRPC(ctx, c.client.GetDockerImage, req, settings.GRPC, c.logger, "GetDockerImage")
1169 return err
1170 }, opts...)
1171 if err != nil {
1172 return nil, err
1173 }
1174 return resp, nil
1175 }
1176
1177 func (c *gRPCClient) ListMavenArtifacts(ctx context.Context, req *artifactregistrypb.ListMavenArtifactsRequest, opts ...gax.CallOption) *MavenArtifactIterator {
1178 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1179
1180 hds = append(c.xGoogHeaders, hds...)
1181 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1182 opts = append((*c.CallOptions).ListMavenArtifacts[0:len((*c.CallOptions).ListMavenArtifacts):len((*c.CallOptions).ListMavenArtifacts)], opts...)
1183 it := &MavenArtifactIterator{}
1184 req = proto.Clone(req).(*artifactregistrypb.ListMavenArtifactsRequest)
1185 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.MavenArtifact, string, error) {
1186 resp := &artifactregistrypb.ListMavenArtifactsResponse{}
1187 if pageToken != "" {
1188 req.PageToken = pageToken
1189 }
1190 if pageSize > math.MaxInt32 {
1191 req.PageSize = math.MaxInt32
1192 } else if pageSize != 0 {
1193 req.PageSize = int32(pageSize)
1194 }
1195 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1196 var err error
1197 resp, err = executeRPC(ctx, c.client.ListMavenArtifacts, req, settings.GRPC, c.logger, "ListMavenArtifacts")
1198 return err
1199 }, opts...)
1200 if err != nil {
1201 return nil, "", err
1202 }
1203
1204 it.Response = resp
1205 return resp.GetMavenArtifacts(), resp.GetNextPageToken(), nil
1206 }
1207 fetch := func(pageSize int, pageToken string) (string, error) {
1208 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1209 if err != nil {
1210 return "", err
1211 }
1212 it.items = append(it.items, items...)
1213 return nextPageToken, nil
1214 }
1215
1216 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1217 it.pageInfo.MaxSize = int(req.GetPageSize())
1218 it.pageInfo.Token = req.GetPageToken()
1219
1220 return it
1221 }
1222
1223 func (c *gRPCClient) GetMavenArtifact(ctx context.Context, req *artifactregistrypb.GetMavenArtifactRequest, opts ...gax.CallOption) (*artifactregistrypb.MavenArtifact, error) {
1224 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1225
1226 hds = append(c.xGoogHeaders, hds...)
1227 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1228 opts = append((*c.CallOptions).GetMavenArtifact[0:len((*c.CallOptions).GetMavenArtifact):len((*c.CallOptions).GetMavenArtifact)], opts...)
1229 var resp *artifactregistrypb.MavenArtifact
1230 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1231 var err error
1232 resp, err = executeRPC(ctx, c.client.GetMavenArtifact, req, settings.GRPC, c.logger, "GetMavenArtifact")
1233 return err
1234 }, opts...)
1235 if err != nil {
1236 return nil, err
1237 }
1238 return resp, nil
1239 }
1240
1241 func (c *gRPCClient) ListNpmPackages(ctx context.Context, req *artifactregistrypb.ListNpmPackagesRequest, opts ...gax.CallOption) *NpmPackageIterator {
1242 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1243
1244 hds = append(c.xGoogHeaders, hds...)
1245 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1246 opts = append((*c.CallOptions).ListNpmPackages[0:len((*c.CallOptions).ListNpmPackages):len((*c.CallOptions).ListNpmPackages)], opts...)
1247 it := &NpmPackageIterator{}
1248 req = proto.Clone(req).(*artifactregistrypb.ListNpmPackagesRequest)
1249 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.NpmPackage, string, error) {
1250 resp := &artifactregistrypb.ListNpmPackagesResponse{}
1251 if pageToken != "" {
1252 req.PageToken = pageToken
1253 }
1254 if pageSize > math.MaxInt32 {
1255 req.PageSize = math.MaxInt32
1256 } else if pageSize != 0 {
1257 req.PageSize = int32(pageSize)
1258 }
1259 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1260 var err error
1261 resp, err = executeRPC(ctx, c.client.ListNpmPackages, req, settings.GRPC, c.logger, "ListNpmPackages")
1262 return err
1263 }, opts...)
1264 if err != nil {
1265 return nil, "", err
1266 }
1267
1268 it.Response = resp
1269 return resp.GetNpmPackages(), resp.GetNextPageToken(), nil
1270 }
1271 fetch := func(pageSize int, pageToken string) (string, error) {
1272 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1273 if err != nil {
1274 return "", err
1275 }
1276 it.items = append(it.items, items...)
1277 return nextPageToken, nil
1278 }
1279
1280 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1281 it.pageInfo.MaxSize = int(req.GetPageSize())
1282 it.pageInfo.Token = req.GetPageToken()
1283
1284 return it
1285 }
1286
1287 func (c *gRPCClient) GetNpmPackage(ctx context.Context, req *artifactregistrypb.GetNpmPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.NpmPackage, error) {
1288 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1289
1290 hds = append(c.xGoogHeaders, hds...)
1291 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1292 opts = append((*c.CallOptions).GetNpmPackage[0:len((*c.CallOptions).GetNpmPackage):len((*c.CallOptions).GetNpmPackage)], opts...)
1293 var resp *artifactregistrypb.NpmPackage
1294 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1295 var err error
1296 resp, err = executeRPC(ctx, c.client.GetNpmPackage, req, settings.GRPC, c.logger, "GetNpmPackage")
1297 return err
1298 }, opts...)
1299 if err != nil {
1300 return nil, err
1301 }
1302 return resp, nil
1303 }
1304
1305 func (c *gRPCClient) ListPythonPackages(ctx context.Context, req *artifactregistrypb.ListPythonPackagesRequest, opts ...gax.CallOption) *PythonPackageIterator {
1306 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1307
1308 hds = append(c.xGoogHeaders, hds...)
1309 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1310 opts = append((*c.CallOptions).ListPythonPackages[0:len((*c.CallOptions).ListPythonPackages):len((*c.CallOptions).ListPythonPackages)], opts...)
1311 it := &PythonPackageIterator{}
1312 req = proto.Clone(req).(*artifactregistrypb.ListPythonPackagesRequest)
1313 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.PythonPackage, string, error) {
1314 resp := &artifactregistrypb.ListPythonPackagesResponse{}
1315 if pageToken != "" {
1316 req.PageToken = pageToken
1317 }
1318 if pageSize > math.MaxInt32 {
1319 req.PageSize = math.MaxInt32
1320 } else if pageSize != 0 {
1321 req.PageSize = int32(pageSize)
1322 }
1323 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1324 var err error
1325 resp, err = executeRPC(ctx, c.client.ListPythonPackages, req, settings.GRPC, c.logger, "ListPythonPackages")
1326 return err
1327 }, opts...)
1328 if err != nil {
1329 return nil, "", err
1330 }
1331
1332 it.Response = resp
1333 return resp.GetPythonPackages(), resp.GetNextPageToken(), nil
1334 }
1335 fetch := func(pageSize int, pageToken string) (string, error) {
1336 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1337 if err != nil {
1338 return "", err
1339 }
1340 it.items = append(it.items, items...)
1341 return nextPageToken, nil
1342 }
1343
1344 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1345 it.pageInfo.MaxSize = int(req.GetPageSize())
1346 it.pageInfo.Token = req.GetPageToken()
1347
1348 return it
1349 }
1350
1351 func (c *gRPCClient) GetPythonPackage(ctx context.Context, req *artifactregistrypb.GetPythonPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.PythonPackage, error) {
1352 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1353
1354 hds = append(c.xGoogHeaders, hds...)
1355 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1356 opts = append((*c.CallOptions).GetPythonPackage[0:len((*c.CallOptions).GetPythonPackage):len((*c.CallOptions).GetPythonPackage)], opts...)
1357 var resp *artifactregistrypb.PythonPackage
1358 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1359 var err error
1360 resp, err = executeRPC(ctx, c.client.GetPythonPackage, req, settings.GRPC, c.logger, "GetPythonPackage")
1361 return err
1362 }, opts...)
1363 if err != nil {
1364 return nil, err
1365 }
1366 return resp, nil
1367 }
1368
1369 func (c *gRPCClient) ImportAptArtifacts(ctx context.Context, req *artifactregistrypb.ImportAptArtifactsRequest, opts ...gax.CallOption) (*ImportAptArtifactsOperation, error) {
1370 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1371
1372 hds = append(c.xGoogHeaders, hds...)
1373 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1374 opts = append((*c.CallOptions).ImportAptArtifacts[0:len((*c.CallOptions).ImportAptArtifacts):len((*c.CallOptions).ImportAptArtifacts)], opts...)
1375 var resp *longrunningpb.Operation
1376 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1377 var err error
1378 resp, err = executeRPC(ctx, c.client.ImportAptArtifacts, req, settings.GRPC, c.logger, "ImportAptArtifacts")
1379 return err
1380 }, opts...)
1381 if err != nil {
1382 return nil, err
1383 }
1384 return &ImportAptArtifactsOperation{
1385 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1386 }, nil
1387 }
1388
1389 func (c *gRPCClient) ImportYumArtifacts(ctx context.Context, req *artifactregistrypb.ImportYumArtifactsRequest, opts ...gax.CallOption) (*ImportYumArtifactsOperation, error) {
1390 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1391
1392 hds = append(c.xGoogHeaders, hds...)
1393 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1394 opts = append((*c.CallOptions).ImportYumArtifacts[0:len((*c.CallOptions).ImportYumArtifacts):len((*c.CallOptions).ImportYumArtifacts)], opts...)
1395 var resp *longrunningpb.Operation
1396 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1397 var err error
1398 resp, err = executeRPC(ctx, c.client.ImportYumArtifacts, req, settings.GRPC, c.logger, "ImportYumArtifacts")
1399 return err
1400 }, opts...)
1401 if err != nil {
1402 return nil, err
1403 }
1404 return &ImportYumArtifactsOperation{
1405 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1406 }, nil
1407 }
1408
1409 func (c *gRPCClient) ListRepositories(ctx context.Context, req *artifactregistrypb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
1410 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1411
1412 hds = append(c.xGoogHeaders, hds...)
1413 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1414 opts = append((*c.CallOptions).ListRepositories[0:len((*c.CallOptions).ListRepositories):len((*c.CallOptions).ListRepositories)], opts...)
1415 it := &RepositoryIterator{}
1416 req = proto.Clone(req).(*artifactregistrypb.ListRepositoriesRequest)
1417 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Repository, string, error) {
1418 resp := &artifactregistrypb.ListRepositoriesResponse{}
1419 if pageToken != "" {
1420 req.PageToken = pageToken
1421 }
1422 if pageSize > math.MaxInt32 {
1423 req.PageSize = math.MaxInt32
1424 } else if pageSize != 0 {
1425 req.PageSize = int32(pageSize)
1426 }
1427 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1428 var err error
1429 resp, err = executeRPC(ctx, c.client.ListRepositories, req, settings.GRPC, c.logger, "ListRepositories")
1430 return err
1431 }, opts...)
1432 if err != nil {
1433 return nil, "", err
1434 }
1435
1436 it.Response = resp
1437 return resp.GetRepositories(), resp.GetNextPageToken(), nil
1438 }
1439 fetch := func(pageSize int, pageToken string) (string, error) {
1440 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1441 if err != nil {
1442 return "", err
1443 }
1444 it.items = append(it.items, items...)
1445 return nextPageToken, nil
1446 }
1447
1448 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1449 it.pageInfo.MaxSize = int(req.GetPageSize())
1450 it.pageInfo.Token = req.GetPageToken()
1451
1452 return it
1453 }
1454
1455 func (c *gRPCClient) GetRepository(ctx context.Context, req *artifactregistrypb.GetRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
1456 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1457
1458 hds = append(c.xGoogHeaders, hds...)
1459 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1460 opts = append((*c.CallOptions).GetRepository[0:len((*c.CallOptions).GetRepository):len((*c.CallOptions).GetRepository)], opts...)
1461 var resp *artifactregistrypb.Repository
1462 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1463 var err error
1464 resp, err = executeRPC(ctx, c.client.GetRepository, req, settings.GRPC, c.logger, "GetRepository")
1465 return err
1466 }, opts...)
1467 if err != nil {
1468 return nil, err
1469 }
1470 return resp, nil
1471 }
1472
1473 func (c *gRPCClient) CreateRepository(ctx context.Context, req *artifactregistrypb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
1474 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1475
1476 hds = append(c.xGoogHeaders, hds...)
1477 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1478 opts = append((*c.CallOptions).CreateRepository[0:len((*c.CallOptions).CreateRepository):len((*c.CallOptions).CreateRepository)], opts...)
1479 var resp *longrunningpb.Operation
1480 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1481 var err error
1482 resp, err = executeRPC(ctx, c.client.CreateRepository, req, settings.GRPC, c.logger, "CreateRepository")
1483 return err
1484 }, opts...)
1485 if err != nil {
1486 return nil, err
1487 }
1488 return &CreateRepositoryOperation{
1489 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1490 }, nil
1491 }
1492
1493 func (c *gRPCClient) UpdateRepository(ctx context.Context, req *artifactregistrypb.UpdateRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
1494 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository.name", url.QueryEscape(req.GetRepository().GetName()))}
1495
1496 hds = append(c.xGoogHeaders, hds...)
1497 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1498 opts = append((*c.CallOptions).UpdateRepository[0:len((*c.CallOptions).UpdateRepository):len((*c.CallOptions).UpdateRepository)], opts...)
1499 var resp *artifactregistrypb.Repository
1500 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1501 var err error
1502 resp, err = executeRPC(ctx, c.client.UpdateRepository, req, settings.GRPC, c.logger, "UpdateRepository")
1503 return err
1504 }, opts...)
1505 if err != nil {
1506 return nil, err
1507 }
1508 return resp, nil
1509 }
1510
1511 func (c *gRPCClient) DeleteRepository(ctx context.Context, req *artifactregistrypb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
1512 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1513
1514 hds = append(c.xGoogHeaders, hds...)
1515 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1516 opts = append((*c.CallOptions).DeleteRepository[0:len((*c.CallOptions).DeleteRepository):len((*c.CallOptions).DeleteRepository)], opts...)
1517 var resp *longrunningpb.Operation
1518 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1519 var err error
1520 resp, err = executeRPC(ctx, c.client.DeleteRepository, req, settings.GRPC, c.logger, "DeleteRepository")
1521 return err
1522 }, opts...)
1523 if err != nil {
1524 return nil, err
1525 }
1526 return &DeleteRepositoryOperation{
1527 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1528 }, nil
1529 }
1530
1531 func (c *gRPCClient) ListPackages(ctx context.Context, req *artifactregistrypb.ListPackagesRequest, opts ...gax.CallOption) *PackageIterator {
1532 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1533
1534 hds = append(c.xGoogHeaders, hds...)
1535 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1536 opts = append((*c.CallOptions).ListPackages[0:len((*c.CallOptions).ListPackages):len((*c.CallOptions).ListPackages)], opts...)
1537 it := &PackageIterator{}
1538 req = proto.Clone(req).(*artifactregistrypb.ListPackagesRequest)
1539 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Package, string, error) {
1540 resp := &artifactregistrypb.ListPackagesResponse{}
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.client.ListPackages, req, settings.GRPC, c.logger, "ListPackages")
1552 return err
1553 }, opts...)
1554 if err != nil {
1555 return nil, "", err
1556 }
1557
1558 it.Response = resp
1559 return resp.GetPackages(), 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 *gRPCClient) GetPackage(ctx context.Context, req *artifactregistrypb.GetPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, 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).GetPackage[0:len((*c.CallOptions).GetPackage):len((*c.CallOptions).GetPackage)], opts...)
1583 var resp *artifactregistrypb.Package
1584 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1585 var err error
1586 resp, err = executeRPC(ctx, c.client.GetPackage, req, settings.GRPC, c.logger, "GetPackage")
1587 return err
1588 }, opts...)
1589 if err != nil {
1590 return nil, err
1591 }
1592 return resp, nil
1593 }
1594
1595 func (c *gRPCClient) DeletePackage(ctx context.Context, req *artifactregistrypb.DeletePackageRequest, opts ...gax.CallOption) (*DeletePackageOperation, error) {
1596 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1597
1598 hds = append(c.xGoogHeaders, hds...)
1599 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1600 opts = append((*c.CallOptions).DeletePackage[0:len((*c.CallOptions).DeletePackage):len((*c.CallOptions).DeletePackage)], opts...)
1601 var resp *longrunningpb.Operation
1602 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1603 var err error
1604 resp, err = executeRPC(ctx, c.client.DeletePackage, req, settings.GRPC, c.logger, "DeletePackage")
1605 return err
1606 }, opts...)
1607 if err != nil {
1608 return nil, err
1609 }
1610 return &DeletePackageOperation{
1611 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1612 }, nil
1613 }
1614
1615 func (c *gRPCClient) ListVersions(ctx context.Context, req *artifactregistrypb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
1616 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1617
1618 hds = append(c.xGoogHeaders, hds...)
1619 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1620 opts = append((*c.CallOptions).ListVersions[0:len((*c.CallOptions).ListVersions):len((*c.CallOptions).ListVersions)], opts...)
1621 it := &VersionIterator{}
1622 req = proto.Clone(req).(*artifactregistrypb.ListVersionsRequest)
1623 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Version, string, error) {
1624 resp := &artifactregistrypb.ListVersionsResponse{}
1625 if pageToken != "" {
1626 req.PageToken = pageToken
1627 }
1628 if pageSize > math.MaxInt32 {
1629 req.PageSize = math.MaxInt32
1630 } else if pageSize != 0 {
1631 req.PageSize = int32(pageSize)
1632 }
1633 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1634 var err error
1635 resp, err = executeRPC(ctx, c.client.ListVersions, req, settings.GRPC, c.logger, "ListVersions")
1636 return err
1637 }, opts...)
1638 if err != nil {
1639 return nil, "", err
1640 }
1641
1642 it.Response = resp
1643 return resp.GetVersions(), resp.GetNextPageToken(), nil
1644 }
1645 fetch := func(pageSize int, pageToken string) (string, error) {
1646 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1647 if err != nil {
1648 return "", err
1649 }
1650 it.items = append(it.items, items...)
1651 return nextPageToken, nil
1652 }
1653
1654 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1655 it.pageInfo.MaxSize = int(req.GetPageSize())
1656 it.pageInfo.Token = req.GetPageToken()
1657
1658 return it
1659 }
1660
1661 func (c *gRPCClient) GetVersion(ctx context.Context, req *artifactregistrypb.GetVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
1662 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1663
1664 hds = append(c.xGoogHeaders, hds...)
1665 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1666 opts = append((*c.CallOptions).GetVersion[0:len((*c.CallOptions).GetVersion):len((*c.CallOptions).GetVersion)], opts...)
1667 var resp *artifactregistrypb.Version
1668 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1669 var err error
1670 resp, err = executeRPC(ctx, c.client.GetVersion, req, settings.GRPC, c.logger, "GetVersion")
1671 return err
1672 }, opts...)
1673 if err != nil {
1674 return nil, err
1675 }
1676 return resp, nil
1677 }
1678
1679 func (c *gRPCClient) DeleteVersion(ctx context.Context, req *artifactregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
1680 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1681
1682 hds = append(c.xGoogHeaders, hds...)
1683 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1684 opts = append((*c.CallOptions).DeleteVersion[0:len((*c.CallOptions).DeleteVersion):len((*c.CallOptions).DeleteVersion)], opts...)
1685 var resp *longrunningpb.Operation
1686 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1687 var err error
1688 resp, err = executeRPC(ctx, c.client.DeleteVersion, req, settings.GRPC, c.logger, "DeleteVersion")
1689 return err
1690 }, opts...)
1691 if err != nil {
1692 return nil, err
1693 }
1694 return &DeleteVersionOperation{
1695 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1696 }, nil
1697 }
1698
1699 func (c *gRPCClient) BatchDeleteVersions(ctx context.Context, req *artifactregistrypb.BatchDeleteVersionsRequest, opts ...gax.CallOption) (*BatchDeleteVersionsOperation, error) {
1700 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1701
1702 hds = append(c.xGoogHeaders, hds...)
1703 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1704 opts = append((*c.CallOptions).BatchDeleteVersions[0:len((*c.CallOptions).BatchDeleteVersions):len((*c.CallOptions).BatchDeleteVersions)], opts...)
1705 var resp *longrunningpb.Operation
1706 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1707 var err error
1708 resp, err = executeRPC(ctx, c.client.BatchDeleteVersions, req, settings.GRPC, c.logger, "BatchDeleteVersions")
1709 return err
1710 }, opts...)
1711 if err != nil {
1712 return nil, err
1713 }
1714 return &BatchDeleteVersionsOperation{
1715 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1716 }, nil
1717 }
1718
1719 func (c *gRPCClient) UpdateVersion(ctx context.Context, req *artifactregistrypb.UpdateVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
1720 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "version.name", url.QueryEscape(req.GetVersion().GetName()))}
1721
1722 hds = append(c.xGoogHeaders, hds...)
1723 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1724 opts = append((*c.CallOptions).UpdateVersion[0:len((*c.CallOptions).UpdateVersion):len((*c.CallOptions).UpdateVersion)], opts...)
1725 var resp *artifactregistrypb.Version
1726 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1727 var err error
1728 resp, err = executeRPC(ctx, c.client.UpdateVersion, req, settings.GRPC, c.logger, "UpdateVersion")
1729 return err
1730 }, opts...)
1731 if err != nil {
1732 return nil, err
1733 }
1734 return resp, nil
1735 }
1736
1737 func (c *gRPCClient) ListFiles(ctx context.Context, req *artifactregistrypb.ListFilesRequest, opts ...gax.CallOption) *FileIterator {
1738 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1739
1740 hds = append(c.xGoogHeaders, hds...)
1741 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1742 opts = append((*c.CallOptions).ListFiles[0:len((*c.CallOptions).ListFiles):len((*c.CallOptions).ListFiles)], opts...)
1743 it := &FileIterator{}
1744 req = proto.Clone(req).(*artifactregistrypb.ListFilesRequest)
1745 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.File, string, error) {
1746 resp := &artifactregistrypb.ListFilesResponse{}
1747 if pageToken != "" {
1748 req.PageToken = pageToken
1749 }
1750 if pageSize > math.MaxInt32 {
1751 req.PageSize = math.MaxInt32
1752 } else if pageSize != 0 {
1753 req.PageSize = int32(pageSize)
1754 }
1755 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1756 var err error
1757 resp, err = executeRPC(ctx, c.client.ListFiles, req, settings.GRPC, c.logger, "ListFiles")
1758 return err
1759 }, opts...)
1760 if err != nil {
1761 return nil, "", err
1762 }
1763
1764 it.Response = resp
1765 return resp.GetFiles(), resp.GetNextPageToken(), nil
1766 }
1767 fetch := func(pageSize int, pageToken string) (string, error) {
1768 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1769 if err != nil {
1770 return "", err
1771 }
1772 it.items = append(it.items, items...)
1773 return nextPageToken, nil
1774 }
1775
1776 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1777 it.pageInfo.MaxSize = int(req.GetPageSize())
1778 it.pageInfo.Token = req.GetPageToken()
1779
1780 return it
1781 }
1782
1783 func (c *gRPCClient) GetFile(ctx context.Context, req *artifactregistrypb.GetFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
1784 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1785
1786 hds = append(c.xGoogHeaders, hds...)
1787 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1788 opts = append((*c.CallOptions).GetFile[0:len((*c.CallOptions).GetFile):len((*c.CallOptions).GetFile)], opts...)
1789 var resp *artifactregistrypb.File
1790 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1791 var err error
1792 resp, err = executeRPC(ctx, c.client.GetFile, req, settings.GRPC, c.logger, "GetFile")
1793 return err
1794 }, opts...)
1795 if err != nil {
1796 return nil, err
1797 }
1798 return resp, nil
1799 }
1800
1801 func (c *gRPCClient) DeleteFile(ctx context.Context, req *artifactregistrypb.DeleteFileRequest, opts ...gax.CallOption) (*DeleteFileOperation, error) {
1802 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1803
1804 hds = append(c.xGoogHeaders, hds...)
1805 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1806 opts = append((*c.CallOptions).DeleteFile[0:len((*c.CallOptions).DeleteFile):len((*c.CallOptions).DeleteFile)], opts...)
1807 var resp *longrunningpb.Operation
1808 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1809 var err error
1810 resp, err = executeRPC(ctx, c.client.DeleteFile, req, settings.GRPC, c.logger, "DeleteFile")
1811 return err
1812 }, opts...)
1813 if err != nil {
1814 return nil, err
1815 }
1816 return &DeleteFileOperation{
1817 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
1818 }, nil
1819 }
1820
1821 func (c *gRPCClient) UpdateFile(ctx context.Context, req *artifactregistrypb.UpdateFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
1822 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "file.name", url.QueryEscape(req.GetFile().GetName()))}
1823
1824 hds = append(c.xGoogHeaders, hds...)
1825 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1826 opts = append((*c.CallOptions).UpdateFile[0:len((*c.CallOptions).UpdateFile):len((*c.CallOptions).UpdateFile)], opts...)
1827 var resp *artifactregistrypb.File
1828 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1829 var err error
1830 resp, err = executeRPC(ctx, c.client.UpdateFile, req, settings.GRPC, c.logger, "UpdateFile")
1831 return err
1832 }, opts...)
1833 if err != nil {
1834 return nil, err
1835 }
1836 return resp, nil
1837 }
1838
1839 func (c *gRPCClient) ListTags(ctx context.Context, req *artifactregistrypb.ListTagsRequest, opts ...gax.CallOption) *TagIterator {
1840 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1841
1842 hds = append(c.xGoogHeaders, hds...)
1843 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1844 opts = append((*c.CallOptions).ListTags[0:len((*c.CallOptions).ListTags):len((*c.CallOptions).ListTags)], opts...)
1845 it := &TagIterator{}
1846 req = proto.Clone(req).(*artifactregistrypb.ListTagsRequest)
1847 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Tag, string, error) {
1848 resp := &artifactregistrypb.ListTagsResponse{}
1849 if pageToken != "" {
1850 req.PageToken = pageToken
1851 }
1852 if pageSize > math.MaxInt32 {
1853 req.PageSize = math.MaxInt32
1854 } else if pageSize != 0 {
1855 req.PageSize = int32(pageSize)
1856 }
1857 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1858 var err error
1859 resp, err = executeRPC(ctx, c.client.ListTags, req, settings.GRPC, c.logger, "ListTags")
1860 return err
1861 }, opts...)
1862 if err != nil {
1863 return nil, "", err
1864 }
1865
1866 it.Response = resp
1867 return resp.GetTags(), resp.GetNextPageToken(), nil
1868 }
1869 fetch := func(pageSize int, pageToken string) (string, error) {
1870 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1871 if err != nil {
1872 return "", err
1873 }
1874 it.items = append(it.items, items...)
1875 return nextPageToken, nil
1876 }
1877
1878 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1879 it.pageInfo.MaxSize = int(req.GetPageSize())
1880 it.pageInfo.Token = req.GetPageToken()
1881
1882 return it
1883 }
1884
1885 func (c *gRPCClient) GetTag(ctx context.Context, req *artifactregistrypb.GetTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
1886 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1887
1888 hds = append(c.xGoogHeaders, hds...)
1889 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1890 opts = append((*c.CallOptions).GetTag[0:len((*c.CallOptions).GetTag):len((*c.CallOptions).GetTag)], opts...)
1891 var resp *artifactregistrypb.Tag
1892 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1893 var err error
1894 resp, err = executeRPC(ctx, c.client.GetTag, req, settings.GRPC, c.logger, "GetTag")
1895 return err
1896 }, opts...)
1897 if err != nil {
1898 return nil, err
1899 }
1900 return resp, nil
1901 }
1902
1903 func (c *gRPCClient) CreateTag(ctx context.Context, req *artifactregistrypb.CreateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
1904 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1905
1906 hds = append(c.xGoogHeaders, hds...)
1907 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1908 opts = append((*c.CallOptions).CreateTag[0:len((*c.CallOptions).CreateTag):len((*c.CallOptions).CreateTag)], opts...)
1909 var resp *artifactregistrypb.Tag
1910 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1911 var err error
1912 resp, err = executeRPC(ctx, c.client.CreateTag, req, settings.GRPC, c.logger, "CreateTag")
1913 return err
1914 }, opts...)
1915 if err != nil {
1916 return nil, err
1917 }
1918 return resp, nil
1919 }
1920
1921 func (c *gRPCClient) UpdateTag(ctx context.Context, req *artifactregistrypb.UpdateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
1922 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tag.name", url.QueryEscape(req.GetTag().GetName()))}
1923
1924 hds = append(c.xGoogHeaders, hds...)
1925 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1926 opts = append((*c.CallOptions).UpdateTag[0:len((*c.CallOptions).UpdateTag):len((*c.CallOptions).UpdateTag)], opts...)
1927 var resp *artifactregistrypb.Tag
1928 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1929 var err error
1930 resp, err = executeRPC(ctx, c.client.UpdateTag, req, settings.GRPC, c.logger, "UpdateTag")
1931 return err
1932 }, opts...)
1933 if err != nil {
1934 return nil, err
1935 }
1936 return resp, nil
1937 }
1938
1939 func (c *gRPCClient) DeleteTag(ctx context.Context, req *artifactregistrypb.DeleteTagRequest, opts ...gax.CallOption) error {
1940 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1941
1942 hds = append(c.xGoogHeaders, hds...)
1943 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1944 opts = append((*c.CallOptions).DeleteTag[0:len((*c.CallOptions).DeleteTag):len((*c.CallOptions).DeleteTag)], opts...)
1945 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1946 var err error
1947 _, err = executeRPC(ctx, c.client.DeleteTag, req, settings.GRPC, c.logger, "DeleteTag")
1948 return err
1949 }, opts...)
1950 return err
1951 }
1952
1953 func (c *gRPCClient) CreateRule(ctx context.Context, req *artifactregistrypb.CreateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
1954 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1955
1956 hds = append(c.xGoogHeaders, hds...)
1957 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1958 opts = append((*c.CallOptions).CreateRule[0:len((*c.CallOptions).CreateRule):len((*c.CallOptions).CreateRule)], opts...)
1959 var resp *artifactregistrypb.Rule
1960 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1961 var err error
1962 resp, err = executeRPC(ctx, c.client.CreateRule, req, settings.GRPC, c.logger, "CreateRule")
1963 return err
1964 }, opts...)
1965 if err != nil {
1966 return nil, err
1967 }
1968 return resp, nil
1969 }
1970
1971 func (c *gRPCClient) ListRules(ctx context.Context, req *artifactregistrypb.ListRulesRequest, opts ...gax.CallOption) *RuleIterator {
1972 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1973
1974 hds = append(c.xGoogHeaders, hds...)
1975 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1976 opts = append((*c.CallOptions).ListRules[0:len((*c.CallOptions).ListRules):len((*c.CallOptions).ListRules)], opts...)
1977 it := &RuleIterator{}
1978 req = proto.Clone(req).(*artifactregistrypb.ListRulesRequest)
1979 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Rule, string, error) {
1980 resp := &artifactregistrypb.ListRulesResponse{}
1981 if pageToken != "" {
1982 req.PageToken = pageToken
1983 }
1984 if pageSize > math.MaxInt32 {
1985 req.PageSize = math.MaxInt32
1986 } else if pageSize != 0 {
1987 req.PageSize = int32(pageSize)
1988 }
1989 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1990 var err error
1991 resp, err = executeRPC(ctx, c.client.ListRules, req, settings.GRPC, c.logger, "ListRules")
1992 return err
1993 }, opts...)
1994 if err != nil {
1995 return nil, "", err
1996 }
1997
1998 it.Response = resp
1999 return resp.GetRules(), resp.GetNextPageToken(), nil
2000 }
2001 fetch := func(pageSize int, pageToken string) (string, error) {
2002 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2003 if err != nil {
2004 return "", err
2005 }
2006 it.items = append(it.items, items...)
2007 return nextPageToken, nil
2008 }
2009
2010 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2011 it.pageInfo.MaxSize = int(req.GetPageSize())
2012 it.pageInfo.Token = req.GetPageToken()
2013
2014 return it
2015 }
2016
2017 func (c *gRPCClient) GetRule(ctx context.Context, req *artifactregistrypb.GetRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
2018 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2019
2020 hds = append(c.xGoogHeaders, hds...)
2021 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2022 opts = append((*c.CallOptions).GetRule[0:len((*c.CallOptions).GetRule):len((*c.CallOptions).GetRule)], opts...)
2023 var resp *artifactregistrypb.Rule
2024 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2025 var err error
2026 resp, err = executeRPC(ctx, c.client.GetRule, req, settings.GRPC, c.logger, "GetRule")
2027 return err
2028 }, opts...)
2029 if err != nil {
2030 return nil, err
2031 }
2032 return resp, nil
2033 }
2034
2035 func (c *gRPCClient) UpdateRule(ctx context.Context, req *artifactregistrypb.UpdateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
2036 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "rule.name", url.QueryEscape(req.GetRule().GetName()))}
2037
2038 hds = append(c.xGoogHeaders, hds...)
2039 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2040 opts = append((*c.CallOptions).UpdateRule[0:len((*c.CallOptions).UpdateRule):len((*c.CallOptions).UpdateRule)], opts...)
2041 var resp *artifactregistrypb.Rule
2042 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2043 var err error
2044 resp, err = executeRPC(ctx, c.client.UpdateRule, req, settings.GRPC, c.logger, "UpdateRule")
2045 return err
2046 }, opts...)
2047 if err != nil {
2048 return nil, err
2049 }
2050 return resp, nil
2051 }
2052
2053 func (c *gRPCClient) DeleteRule(ctx context.Context, req *artifactregistrypb.DeleteRuleRequest, opts ...gax.CallOption) error {
2054 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2055
2056 hds = append(c.xGoogHeaders, hds...)
2057 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2058 opts = append((*c.CallOptions).DeleteRule[0:len((*c.CallOptions).DeleteRule):len((*c.CallOptions).DeleteRule)], opts...)
2059 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2060 var err error
2061 _, err = executeRPC(ctx, c.client.DeleteRule, req, settings.GRPC, c.logger, "DeleteRule")
2062 return err
2063 }, opts...)
2064 return err
2065 }
2066
2067 func (c *gRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
2068 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2069
2070 hds = append(c.xGoogHeaders, hds...)
2071 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2072 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
2073 var resp *iampb.Policy
2074 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2075 var err error
2076 resp, err = executeRPC(ctx, c.client.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
2077 return err
2078 }, opts...)
2079 if err != nil {
2080 return nil, err
2081 }
2082 return resp, nil
2083 }
2084
2085 func (c *gRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
2086 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2087
2088 hds = append(c.xGoogHeaders, hds...)
2089 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2090 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
2091 var resp *iampb.Policy
2092 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2093 var err error
2094 resp, err = executeRPC(ctx, c.client.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
2095 return err
2096 }, opts...)
2097 if err != nil {
2098 return nil, err
2099 }
2100 return resp, nil
2101 }
2102
2103 func (c *gRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
2104 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2105
2106 hds = append(c.xGoogHeaders, hds...)
2107 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2108 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
2109 var resp *iampb.TestIamPermissionsResponse
2110 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2111 var err error
2112 resp, err = executeRPC(ctx, c.client.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
2113 return err
2114 }, opts...)
2115 if err != nil {
2116 return nil, err
2117 }
2118 return resp, nil
2119 }
2120
2121 func (c *gRPCClient) GetProjectSettings(ctx context.Context, req *artifactregistrypb.GetProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
2122 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2123
2124 hds = append(c.xGoogHeaders, hds...)
2125 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2126 opts = append((*c.CallOptions).GetProjectSettings[0:len((*c.CallOptions).GetProjectSettings):len((*c.CallOptions).GetProjectSettings)], opts...)
2127 var resp *artifactregistrypb.ProjectSettings
2128 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2129 var err error
2130 resp, err = executeRPC(ctx, c.client.GetProjectSettings, req, settings.GRPC, c.logger, "GetProjectSettings")
2131 return err
2132 }, opts...)
2133 if err != nil {
2134 return nil, err
2135 }
2136 return resp, nil
2137 }
2138
2139 func (c *gRPCClient) UpdateProjectSettings(ctx context.Context, req *artifactregistrypb.UpdateProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
2140 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project_settings.name", url.QueryEscape(req.GetProjectSettings().GetName()))}
2141
2142 hds = append(c.xGoogHeaders, hds...)
2143 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2144 opts = append((*c.CallOptions).UpdateProjectSettings[0:len((*c.CallOptions).UpdateProjectSettings):len((*c.CallOptions).UpdateProjectSettings)], opts...)
2145 var resp *artifactregistrypb.ProjectSettings
2146 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2147 var err error
2148 resp, err = executeRPC(ctx, c.client.UpdateProjectSettings, req, settings.GRPC, c.logger, "UpdateProjectSettings")
2149 return err
2150 }, opts...)
2151 if err != nil {
2152 return nil, err
2153 }
2154 return resp, nil
2155 }
2156
2157 func (c *gRPCClient) GetVPCSCConfig(ctx context.Context, req *artifactregistrypb.GetVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
2158 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2159
2160 hds = append(c.xGoogHeaders, hds...)
2161 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2162 opts = append((*c.CallOptions).GetVPCSCConfig[0:len((*c.CallOptions).GetVPCSCConfig):len((*c.CallOptions).GetVPCSCConfig)], opts...)
2163 var resp *artifactregistrypb.VPCSCConfig
2164 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2165 var err error
2166 resp, err = executeRPC(ctx, c.client.GetVPCSCConfig, req, settings.GRPC, c.logger, "GetVPCSCConfig")
2167 return err
2168 }, opts...)
2169 if err != nil {
2170 return nil, err
2171 }
2172 return resp, nil
2173 }
2174
2175 func (c *gRPCClient) UpdateVPCSCConfig(ctx context.Context, req *artifactregistrypb.UpdateVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
2176 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "vpcsc_config.name", url.QueryEscape(req.GetVpcscConfig().GetName()))}
2177
2178 hds = append(c.xGoogHeaders, hds...)
2179 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2180 opts = append((*c.CallOptions).UpdateVPCSCConfig[0:len((*c.CallOptions).UpdateVPCSCConfig):len((*c.CallOptions).UpdateVPCSCConfig)], opts...)
2181 var resp *artifactregistrypb.VPCSCConfig
2182 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2183 var err error
2184 resp, err = executeRPC(ctx, c.client.UpdateVPCSCConfig, req, settings.GRPC, c.logger, "UpdateVPCSCConfig")
2185 return err
2186 }, opts...)
2187 if err != nil {
2188 return nil, err
2189 }
2190 return resp, nil
2191 }
2192
2193 func (c *gRPCClient) UpdatePackage(ctx context.Context, req *artifactregistrypb.UpdatePackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
2194 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "package.name", url.QueryEscape(req.GetPackage().GetName()))}
2195
2196 hds = append(c.xGoogHeaders, hds...)
2197 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2198 opts = append((*c.CallOptions).UpdatePackage[0:len((*c.CallOptions).UpdatePackage):len((*c.CallOptions).UpdatePackage)], opts...)
2199 var resp *artifactregistrypb.Package
2200 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2201 var err error
2202 resp, err = executeRPC(ctx, c.client.UpdatePackage, req, settings.GRPC, c.logger, "UpdatePackage")
2203 return err
2204 }, opts...)
2205 if err != nil {
2206 return nil, err
2207 }
2208 return resp, nil
2209 }
2210
2211 func (c *gRPCClient) ListAttachments(ctx context.Context, req *artifactregistrypb.ListAttachmentsRequest, opts ...gax.CallOption) *AttachmentIterator {
2212 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2213
2214 hds = append(c.xGoogHeaders, hds...)
2215 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2216 opts = append((*c.CallOptions).ListAttachments[0:len((*c.CallOptions).ListAttachments):len((*c.CallOptions).ListAttachments)], opts...)
2217 it := &AttachmentIterator{}
2218 req = proto.Clone(req).(*artifactregistrypb.ListAttachmentsRequest)
2219 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Attachment, string, error) {
2220 resp := &artifactregistrypb.ListAttachmentsResponse{}
2221 if pageToken != "" {
2222 req.PageToken = pageToken
2223 }
2224 if pageSize > math.MaxInt32 {
2225 req.PageSize = math.MaxInt32
2226 } else if pageSize != 0 {
2227 req.PageSize = int32(pageSize)
2228 }
2229 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2230 var err error
2231 resp, err = executeRPC(ctx, c.client.ListAttachments, req, settings.GRPC, c.logger, "ListAttachments")
2232 return err
2233 }, opts...)
2234 if err != nil {
2235 return nil, "", err
2236 }
2237
2238 it.Response = resp
2239 return resp.GetAttachments(), resp.GetNextPageToken(), nil
2240 }
2241 fetch := func(pageSize int, pageToken string) (string, error) {
2242 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2243 if err != nil {
2244 return "", err
2245 }
2246 it.items = append(it.items, items...)
2247 return nextPageToken, nil
2248 }
2249
2250 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2251 it.pageInfo.MaxSize = int(req.GetPageSize())
2252 it.pageInfo.Token = req.GetPageToken()
2253
2254 return it
2255 }
2256
2257 func (c *gRPCClient) GetAttachment(ctx context.Context, req *artifactregistrypb.GetAttachmentRequest, opts ...gax.CallOption) (*artifactregistrypb.Attachment, error) {
2258 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2259
2260 hds = append(c.xGoogHeaders, hds...)
2261 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2262 opts = append((*c.CallOptions).GetAttachment[0:len((*c.CallOptions).GetAttachment):len((*c.CallOptions).GetAttachment)], opts...)
2263 var resp *artifactregistrypb.Attachment
2264 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2265 var err error
2266 resp, err = executeRPC(ctx, c.client.GetAttachment, req, settings.GRPC, c.logger, "GetAttachment")
2267 return err
2268 }, opts...)
2269 if err != nil {
2270 return nil, err
2271 }
2272 return resp, nil
2273 }
2274
2275 func (c *gRPCClient) CreateAttachment(ctx context.Context, req *artifactregistrypb.CreateAttachmentRequest, opts ...gax.CallOption) (*CreateAttachmentOperation, error) {
2276 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2277
2278 hds = append(c.xGoogHeaders, hds...)
2279 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2280 opts = append((*c.CallOptions).CreateAttachment[0:len((*c.CallOptions).CreateAttachment):len((*c.CallOptions).CreateAttachment)], opts...)
2281 var resp *longrunningpb.Operation
2282 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2283 var err error
2284 resp, err = executeRPC(ctx, c.client.CreateAttachment, req, settings.GRPC, c.logger, "CreateAttachment")
2285 return err
2286 }, opts...)
2287 if err != nil {
2288 return nil, err
2289 }
2290 return &CreateAttachmentOperation{
2291 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2292 }, nil
2293 }
2294
2295 func (c *gRPCClient) DeleteAttachment(ctx context.Context, req *artifactregistrypb.DeleteAttachmentRequest, opts ...gax.CallOption) (*DeleteAttachmentOperation, error) {
2296 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2297
2298 hds = append(c.xGoogHeaders, hds...)
2299 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2300 opts = append((*c.CallOptions).DeleteAttachment[0:len((*c.CallOptions).DeleteAttachment):len((*c.CallOptions).DeleteAttachment)], opts...)
2301 var resp *longrunningpb.Operation
2302 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2303 var err error
2304 resp, err = executeRPC(ctx, c.client.DeleteAttachment, req, settings.GRPC, c.logger, "DeleteAttachment")
2305 return err
2306 }, opts...)
2307 if err != nil {
2308 return nil, err
2309 }
2310 return &DeleteAttachmentOperation{
2311 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2312 }, nil
2313 }
2314
2315 func (c *gRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2316 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2317
2318 hds = append(c.xGoogHeaders, hds...)
2319 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2320 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2321 var resp *locationpb.Location
2322 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2323 var err error
2324 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
2325 return err
2326 }, opts...)
2327 if err != nil {
2328 return nil, err
2329 }
2330 return resp, nil
2331 }
2332
2333 func (c *gRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2334 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2335
2336 hds = append(c.xGoogHeaders, hds...)
2337 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2338 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
2339 it := &LocationIterator{}
2340 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2341 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2342 resp := &locationpb.ListLocationsResponse{}
2343 if pageToken != "" {
2344 req.PageToken = pageToken
2345 }
2346 if pageSize > math.MaxInt32 {
2347 req.PageSize = math.MaxInt32
2348 } else if pageSize != 0 {
2349 req.PageSize = int32(pageSize)
2350 }
2351 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2352 var err error
2353 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
2354 return err
2355 }, opts...)
2356 if err != nil {
2357 return nil, "", err
2358 }
2359
2360 it.Response = resp
2361 return resp.GetLocations(), resp.GetNextPageToken(), nil
2362 }
2363 fetch := func(pageSize int, pageToken string) (string, error) {
2364 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2365 if err != nil {
2366 return "", err
2367 }
2368 it.items = append(it.items, items...)
2369 return nextPageToken, nil
2370 }
2371
2372 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2373 it.pageInfo.MaxSize = int(req.GetPageSize())
2374 it.pageInfo.Token = req.GetPageToken()
2375
2376 return it
2377 }
2378
2379 func (c *gRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2380 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2381
2382 hds = append(c.xGoogHeaders, hds...)
2383 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2384 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2385 var resp *longrunningpb.Operation
2386 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2387 var err error
2388 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
2389 return err
2390 }, opts...)
2391 if err != nil {
2392 return nil, err
2393 }
2394 return resp, nil
2395 }
2396
2397 // ListDockerImages lists docker images.
2398 func (c *restClient) ListDockerImages(ctx context.Context, req *artifactregistrypb.ListDockerImagesRequest, opts ...gax.CallOption) *DockerImageIterator {
2399 it := &DockerImageIterator{}
2400 req = proto.Clone(req).(*artifactregistrypb.ListDockerImagesRequest)
2401 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2402 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.DockerImage, string, error) {
2403 resp := &artifactregistrypb.ListDockerImagesResponse{}
2404 if pageToken != "" {
2405 req.PageToken = pageToken
2406 }
2407 if pageSize > math.MaxInt32 {
2408 req.PageSize = math.MaxInt32
2409 } else if pageSize != 0 {
2410 req.PageSize = int32(pageSize)
2411 }
2412 baseUrl, err := url.Parse(c.endpoint)
2413 if err != nil {
2414 return nil, "", err
2415 }
2416 baseUrl.Path += fmt.Sprintf("/v1/%v/dockerImages", req.GetParent())
2417
2418 params := url.Values{}
2419 params.Add("$alt", "json;enum-encoding=int")
2420 if req.GetOrderBy() != "" {
2421 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2422 }
2423 if req.GetPageSize() != 0 {
2424 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2425 }
2426 if req.GetPageToken() != "" {
2427 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2428 }
2429
2430 baseUrl.RawQuery = params.Encode()
2431
2432 // Build HTTP headers from client and context metadata.
2433 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2434 headers := gax.BuildHeaders(ctx, hds...)
2435 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2436 if settings.Path != "" {
2437 baseUrl.Path = settings.Path
2438 }
2439 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2440 if err != nil {
2441 return err
2442 }
2443 httpReq.Header = headers
2444
2445 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListDockerImages")
2446 if err != nil {
2447 return err
2448 }
2449 if err := unm.Unmarshal(buf, resp); err != nil {
2450 return err
2451 }
2452
2453 return nil
2454 }, opts...)
2455 if e != nil {
2456 return nil, "", e
2457 }
2458 it.Response = resp
2459 return resp.GetDockerImages(), resp.GetNextPageToken(), nil
2460 }
2461
2462 fetch := func(pageSize int, pageToken string) (string, error) {
2463 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2464 if err != nil {
2465 return "", err
2466 }
2467 it.items = append(it.items, items...)
2468 return nextPageToken, nil
2469 }
2470
2471 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2472 it.pageInfo.MaxSize = int(req.GetPageSize())
2473 it.pageInfo.Token = req.GetPageToken()
2474
2475 return it
2476 }
2477
2478 // GetDockerImage gets a docker image.
2479 func (c *restClient) GetDockerImage(ctx context.Context, req *artifactregistrypb.GetDockerImageRequest, opts ...gax.CallOption) (*artifactregistrypb.DockerImage, error) {
2480 baseUrl, err := url.Parse(c.endpoint)
2481 if err != nil {
2482 return nil, err
2483 }
2484 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2485
2486 params := url.Values{}
2487 params.Add("$alt", "json;enum-encoding=int")
2488
2489 baseUrl.RawQuery = params.Encode()
2490
2491 // Build HTTP headers from client and context metadata.
2492 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2493
2494 hds = append(c.xGoogHeaders, hds...)
2495 hds = append(hds, "Content-Type", "application/json")
2496 headers := gax.BuildHeaders(ctx, hds...)
2497 opts = append((*c.CallOptions).GetDockerImage[0:len((*c.CallOptions).GetDockerImage):len((*c.CallOptions).GetDockerImage)], opts...)
2498 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2499 resp := &artifactregistrypb.DockerImage{}
2500 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2501 if settings.Path != "" {
2502 baseUrl.Path = settings.Path
2503 }
2504 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2505 if err != nil {
2506 return err
2507 }
2508 httpReq = httpReq.WithContext(ctx)
2509 httpReq.Header = headers
2510
2511 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetDockerImage")
2512 if err != nil {
2513 return err
2514 }
2515
2516 if err := unm.Unmarshal(buf, resp); err != nil {
2517 return err
2518 }
2519
2520 return nil
2521 }, opts...)
2522 if e != nil {
2523 return nil, e
2524 }
2525 return resp, nil
2526 }
2527
2528 // ListMavenArtifacts lists maven artifacts.
2529 func (c *restClient) ListMavenArtifacts(ctx context.Context, req *artifactregistrypb.ListMavenArtifactsRequest, opts ...gax.CallOption) *MavenArtifactIterator {
2530 it := &MavenArtifactIterator{}
2531 req = proto.Clone(req).(*artifactregistrypb.ListMavenArtifactsRequest)
2532 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2533 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.MavenArtifact, string, error) {
2534 resp := &artifactregistrypb.ListMavenArtifactsResponse{}
2535 if pageToken != "" {
2536 req.PageToken = pageToken
2537 }
2538 if pageSize > math.MaxInt32 {
2539 req.PageSize = math.MaxInt32
2540 } else if pageSize != 0 {
2541 req.PageSize = int32(pageSize)
2542 }
2543 baseUrl, err := url.Parse(c.endpoint)
2544 if err != nil {
2545 return nil, "", err
2546 }
2547 baseUrl.Path += fmt.Sprintf("/v1/%v/mavenArtifacts", req.GetParent())
2548
2549 params := url.Values{}
2550 params.Add("$alt", "json;enum-encoding=int")
2551 if req.GetPageSize() != 0 {
2552 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2553 }
2554 if req.GetPageToken() != "" {
2555 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2556 }
2557
2558 baseUrl.RawQuery = params.Encode()
2559
2560 // Build HTTP headers from client and context metadata.
2561 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2562 headers := gax.BuildHeaders(ctx, hds...)
2563 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2564 if settings.Path != "" {
2565 baseUrl.Path = settings.Path
2566 }
2567 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2568 if err != nil {
2569 return err
2570 }
2571 httpReq.Header = headers
2572
2573 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListMavenArtifacts")
2574 if err != nil {
2575 return err
2576 }
2577 if err := unm.Unmarshal(buf, resp); err != nil {
2578 return err
2579 }
2580
2581 return nil
2582 }, opts...)
2583 if e != nil {
2584 return nil, "", e
2585 }
2586 it.Response = resp
2587 return resp.GetMavenArtifacts(), resp.GetNextPageToken(), nil
2588 }
2589
2590 fetch := func(pageSize int, pageToken string) (string, error) {
2591 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2592 if err != nil {
2593 return "", err
2594 }
2595 it.items = append(it.items, items...)
2596 return nextPageToken, nil
2597 }
2598
2599 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2600 it.pageInfo.MaxSize = int(req.GetPageSize())
2601 it.pageInfo.Token = req.GetPageToken()
2602
2603 return it
2604 }
2605
2606 // GetMavenArtifact gets a maven artifact.
2607 func (c *restClient) GetMavenArtifact(ctx context.Context, req *artifactregistrypb.GetMavenArtifactRequest, opts ...gax.CallOption) (*artifactregistrypb.MavenArtifact, error) {
2608 baseUrl, err := url.Parse(c.endpoint)
2609 if err != nil {
2610 return nil, err
2611 }
2612 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2613
2614 params := url.Values{}
2615 params.Add("$alt", "json;enum-encoding=int")
2616
2617 baseUrl.RawQuery = params.Encode()
2618
2619 // Build HTTP headers from client and context metadata.
2620 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2621
2622 hds = append(c.xGoogHeaders, hds...)
2623 hds = append(hds, "Content-Type", "application/json")
2624 headers := gax.BuildHeaders(ctx, hds...)
2625 opts = append((*c.CallOptions).GetMavenArtifact[0:len((*c.CallOptions).GetMavenArtifact):len((*c.CallOptions).GetMavenArtifact)], opts...)
2626 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2627 resp := &artifactregistrypb.MavenArtifact{}
2628 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2629 if settings.Path != "" {
2630 baseUrl.Path = settings.Path
2631 }
2632 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2633 if err != nil {
2634 return err
2635 }
2636 httpReq = httpReq.WithContext(ctx)
2637 httpReq.Header = headers
2638
2639 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetMavenArtifact")
2640 if err != nil {
2641 return err
2642 }
2643
2644 if err := unm.Unmarshal(buf, resp); err != nil {
2645 return err
2646 }
2647
2648 return nil
2649 }, opts...)
2650 if e != nil {
2651 return nil, e
2652 }
2653 return resp, nil
2654 }
2655
2656 // ListNpmPackages lists npm packages.
2657 func (c *restClient) ListNpmPackages(ctx context.Context, req *artifactregistrypb.ListNpmPackagesRequest, opts ...gax.CallOption) *NpmPackageIterator {
2658 it := &NpmPackageIterator{}
2659 req = proto.Clone(req).(*artifactregistrypb.ListNpmPackagesRequest)
2660 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2661 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.NpmPackage, string, error) {
2662 resp := &artifactregistrypb.ListNpmPackagesResponse{}
2663 if pageToken != "" {
2664 req.PageToken = pageToken
2665 }
2666 if pageSize > math.MaxInt32 {
2667 req.PageSize = math.MaxInt32
2668 } else if pageSize != 0 {
2669 req.PageSize = int32(pageSize)
2670 }
2671 baseUrl, err := url.Parse(c.endpoint)
2672 if err != nil {
2673 return nil, "", err
2674 }
2675 baseUrl.Path += fmt.Sprintf("/v1/%v/npmPackages", req.GetParent())
2676
2677 params := url.Values{}
2678 params.Add("$alt", "json;enum-encoding=int")
2679 if req.GetPageSize() != 0 {
2680 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2681 }
2682 if req.GetPageToken() != "" {
2683 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2684 }
2685
2686 baseUrl.RawQuery = params.Encode()
2687
2688 // Build HTTP headers from client and context metadata.
2689 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2690 headers := gax.BuildHeaders(ctx, hds...)
2691 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2692 if settings.Path != "" {
2693 baseUrl.Path = settings.Path
2694 }
2695 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2696 if err != nil {
2697 return err
2698 }
2699 httpReq.Header = headers
2700
2701 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNpmPackages")
2702 if err != nil {
2703 return err
2704 }
2705 if err := unm.Unmarshal(buf, resp); err != nil {
2706 return err
2707 }
2708
2709 return nil
2710 }, opts...)
2711 if e != nil {
2712 return nil, "", e
2713 }
2714 it.Response = resp
2715 return resp.GetNpmPackages(), resp.GetNextPageToken(), nil
2716 }
2717
2718 fetch := func(pageSize int, pageToken string) (string, error) {
2719 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2720 if err != nil {
2721 return "", err
2722 }
2723 it.items = append(it.items, items...)
2724 return nextPageToken, nil
2725 }
2726
2727 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2728 it.pageInfo.MaxSize = int(req.GetPageSize())
2729 it.pageInfo.Token = req.GetPageToken()
2730
2731 return it
2732 }
2733
2734 // GetNpmPackage gets a npm package.
2735 func (c *restClient) GetNpmPackage(ctx context.Context, req *artifactregistrypb.GetNpmPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.NpmPackage, error) {
2736 baseUrl, err := url.Parse(c.endpoint)
2737 if err != nil {
2738 return nil, err
2739 }
2740 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2741
2742 params := url.Values{}
2743 params.Add("$alt", "json;enum-encoding=int")
2744
2745 baseUrl.RawQuery = params.Encode()
2746
2747 // Build HTTP headers from client and context metadata.
2748 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2749
2750 hds = append(c.xGoogHeaders, hds...)
2751 hds = append(hds, "Content-Type", "application/json")
2752 headers := gax.BuildHeaders(ctx, hds...)
2753 opts = append((*c.CallOptions).GetNpmPackage[0:len((*c.CallOptions).GetNpmPackage):len((*c.CallOptions).GetNpmPackage)], opts...)
2754 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2755 resp := &artifactregistrypb.NpmPackage{}
2756 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2757 if settings.Path != "" {
2758 baseUrl.Path = settings.Path
2759 }
2760 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2761 if err != nil {
2762 return err
2763 }
2764 httpReq = httpReq.WithContext(ctx)
2765 httpReq.Header = headers
2766
2767 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNpmPackage")
2768 if err != nil {
2769 return err
2770 }
2771
2772 if err := unm.Unmarshal(buf, resp); err != nil {
2773 return err
2774 }
2775
2776 return nil
2777 }, opts...)
2778 if e != nil {
2779 return nil, e
2780 }
2781 return resp, nil
2782 }
2783
2784 // ListPythonPackages lists python packages.
2785 func (c *restClient) ListPythonPackages(ctx context.Context, req *artifactregistrypb.ListPythonPackagesRequest, opts ...gax.CallOption) *PythonPackageIterator {
2786 it := &PythonPackageIterator{}
2787 req = proto.Clone(req).(*artifactregistrypb.ListPythonPackagesRequest)
2788 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2789 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.PythonPackage, string, error) {
2790 resp := &artifactregistrypb.ListPythonPackagesResponse{}
2791 if pageToken != "" {
2792 req.PageToken = pageToken
2793 }
2794 if pageSize > math.MaxInt32 {
2795 req.PageSize = math.MaxInt32
2796 } else if pageSize != 0 {
2797 req.PageSize = int32(pageSize)
2798 }
2799 baseUrl, err := url.Parse(c.endpoint)
2800 if err != nil {
2801 return nil, "", err
2802 }
2803 baseUrl.Path += fmt.Sprintf("/v1/%v/pythonPackages", req.GetParent())
2804
2805 params := url.Values{}
2806 params.Add("$alt", "json;enum-encoding=int")
2807 if req.GetPageSize() != 0 {
2808 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2809 }
2810 if req.GetPageToken() != "" {
2811 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2812 }
2813
2814 baseUrl.RawQuery = params.Encode()
2815
2816 // Build HTTP headers from client and context metadata.
2817 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2818 headers := gax.BuildHeaders(ctx, hds...)
2819 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2820 if settings.Path != "" {
2821 baseUrl.Path = settings.Path
2822 }
2823 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2824 if err != nil {
2825 return err
2826 }
2827 httpReq.Header = headers
2828
2829 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPythonPackages")
2830 if err != nil {
2831 return err
2832 }
2833 if err := unm.Unmarshal(buf, resp); err != nil {
2834 return err
2835 }
2836
2837 return nil
2838 }, opts...)
2839 if e != nil {
2840 return nil, "", e
2841 }
2842 it.Response = resp
2843 return resp.GetPythonPackages(), resp.GetNextPageToken(), nil
2844 }
2845
2846 fetch := func(pageSize int, pageToken string) (string, error) {
2847 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2848 if err != nil {
2849 return "", err
2850 }
2851 it.items = append(it.items, items...)
2852 return nextPageToken, nil
2853 }
2854
2855 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2856 it.pageInfo.MaxSize = int(req.GetPageSize())
2857 it.pageInfo.Token = req.GetPageToken()
2858
2859 return it
2860 }
2861
2862 // GetPythonPackage gets a python package.
2863 func (c *restClient) GetPythonPackage(ctx context.Context, req *artifactregistrypb.GetPythonPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.PythonPackage, error) {
2864 baseUrl, err := url.Parse(c.endpoint)
2865 if err != nil {
2866 return nil, err
2867 }
2868 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2869
2870 params := url.Values{}
2871 params.Add("$alt", "json;enum-encoding=int")
2872
2873 baseUrl.RawQuery = params.Encode()
2874
2875 // Build HTTP headers from client and context metadata.
2876 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2877
2878 hds = append(c.xGoogHeaders, hds...)
2879 hds = append(hds, "Content-Type", "application/json")
2880 headers := gax.BuildHeaders(ctx, hds...)
2881 opts = append((*c.CallOptions).GetPythonPackage[0:len((*c.CallOptions).GetPythonPackage):len((*c.CallOptions).GetPythonPackage)], opts...)
2882 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2883 resp := &artifactregistrypb.PythonPackage{}
2884 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2885 if settings.Path != "" {
2886 baseUrl.Path = settings.Path
2887 }
2888 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2889 if err != nil {
2890 return err
2891 }
2892 httpReq = httpReq.WithContext(ctx)
2893 httpReq.Header = headers
2894
2895 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPythonPackage")
2896 if err != nil {
2897 return err
2898 }
2899
2900 if err := unm.Unmarshal(buf, resp); err != nil {
2901 return err
2902 }
2903
2904 return nil
2905 }, opts...)
2906 if e != nil {
2907 return nil, e
2908 }
2909 return resp, nil
2910 }
2911
2912 // ImportAptArtifacts imports Apt artifacts. The returned Operation will complete once the
2913 // resources are imported. Package, Version, and File resources are created
2914 // based on the imported artifacts. Imported artifacts that conflict with
2915 // existing resources are ignored.
2916 func (c *restClient) ImportAptArtifacts(ctx context.Context, req *artifactregistrypb.ImportAptArtifactsRequest, opts ...gax.CallOption) (*ImportAptArtifactsOperation, error) {
2917 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2918 jsonReq, err := m.Marshal(req)
2919 if err != nil {
2920 return nil, err
2921 }
2922
2923 baseUrl, err := url.Parse(c.endpoint)
2924 if err != nil {
2925 return nil, err
2926 }
2927 baseUrl.Path += fmt.Sprintf("/v1/%v/aptArtifacts:import", req.GetParent())
2928
2929 params := url.Values{}
2930 params.Add("$alt", "json;enum-encoding=int")
2931
2932 baseUrl.RawQuery = params.Encode()
2933
2934 // Build HTTP headers from client and context metadata.
2935 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2936
2937 hds = append(c.xGoogHeaders, hds...)
2938 hds = append(hds, "Content-Type", "application/json")
2939 headers := gax.BuildHeaders(ctx, hds...)
2940 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2941 resp := &longrunningpb.Operation{}
2942 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2943 if settings.Path != "" {
2944 baseUrl.Path = settings.Path
2945 }
2946 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2947 if err != nil {
2948 return err
2949 }
2950 httpReq = httpReq.WithContext(ctx)
2951 httpReq.Header = headers
2952
2953 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportAptArtifacts")
2954 if err != nil {
2955 return err
2956 }
2957 if err := unm.Unmarshal(buf, resp); err != nil {
2958 return err
2959 }
2960
2961 return nil
2962 }, opts...)
2963 if e != nil {
2964 return nil, e
2965 }
2966
2967 override := fmt.Sprintf("/v1/%s", resp.GetName())
2968 return &ImportAptArtifactsOperation{
2969 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
2970 pollPath: override,
2971 }, nil
2972 }
2973
2974 // ImportYumArtifacts imports Yum (RPM) artifacts. The returned Operation will complete once the
2975 // resources are imported. Package, Version, and File resources are created
2976 // based on the imported artifacts. Imported artifacts that conflict with
2977 // existing resources are ignored.
2978 func (c *restClient) ImportYumArtifacts(ctx context.Context, req *artifactregistrypb.ImportYumArtifactsRequest, opts ...gax.CallOption) (*ImportYumArtifactsOperation, error) {
2979 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2980 jsonReq, err := m.Marshal(req)
2981 if err != nil {
2982 return nil, err
2983 }
2984
2985 baseUrl, err := url.Parse(c.endpoint)
2986 if err != nil {
2987 return nil, err
2988 }
2989 baseUrl.Path += fmt.Sprintf("/v1/%v/yumArtifacts:import", req.GetParent())
2990
2991 params := url.Values{}
2992 params.Add("$alt", "json;enum-encoding=int")
2993
2994 baseUrl.RawQuery = params.Encode()
2995
2996 // Build HTTP headers from client and context metadata.
2997 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2998
2999 hds = append(c.xGoogHeaders, hds...)
3000 hds = append(hds, "Content-Type", "application/json")
3001 headers := gax.BuildHeaders(ctx, hds...)
3002 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3003 resp := &longrunningpb.Operation{}
3004 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3005 if settings.Path != "" {
3006 baseUrl.Path = settings.Path
3007 }
3008 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3009 if err != nil {
3010 return err
3011 }
3012 httpReq = httpReq.WithContext(ctx)
3013 httpReq.Header = headers
3014
3015 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportYumArtifacts")
3016 if err != nil {
3017 return err
3018 }
3019 if err := unm.Unmarshal(buf, resp); err != nil {
3020 return err
3021 }
3022
3023 return nil
3024 }, opts...)
3025 if e != nil {
3026 return nil, e
3027 }
3028
3029 override := fmt.Sprintf("/v1/%s", resp.GetName())
3030 return &ImportYumArtifactsOperation{
3031 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3032 pollPath: override,
3033 }, nil
3034 }
3035
3036 // ListRepositories lists repositories.
3037 func (c *restClient) ListRepositories(ctx context.Context, req *artifactregistrypb.ListRepositoriesRequest, opts ...gax.CallOption) *RepositoryIterator {
3038 it := &RepositoryIterator{}
3039 req = proto.Clone(req).(*artifactregistrypb.ListRepositoriesRequest)
3040 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3041 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Repository, string, error) {
3042 resp := &artifactregistrypb.ListRepositoriesResponse{}
3043 if pageToken != "" {
3044 req.PageToken = pageToken
3045 }
3046 if pageSize > math.MaxInt32 {
3047 req.PageSize = math.MaxInt32
3048 } else if pageSize != 0 {
3049 req.PageSize = int32(pageSize)
3050 }
3051 baseUrl, err := url.Parse(c.endpoint)
3052 if err != nil {
3053 return nil, "", err
3054 }
3055 baseUrl.Path += fmt.Sprintf("/v1/%v/repositories", req.GetParent())
3056
3057 params := url.Values{}
3058 params.Add("$alt", "json;enum-encoding=int")
3059 if req.GetFilter() != "" {
3060 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3061 }
3062 if req.GetOrderBy() != "" {
3063 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3064 }
3065 if req.GetPageSize() != 0 {
3066 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3067 }
3068 if req.GetPageToken() != "" {
3069 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3070 }
3071
3072 baseUrl.RawQuery = params.Encode()
3073
3074 // Build HTTP headers from client and context metadata.
3075 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3076 headers := gax.BuildHeaders(ctx, hds...)
3077 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3078 if settings.Path != "" {
3079 baseUrl.Path = settings.Path
3080 }
3081 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3082 if err != nil {
3083 return err
3084 }
3085 httpReq.Header = headers
3086
3087 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListRepositories")
3088 if err != nil {
3089 return err
3090 }
3091 if err := unm.Unmarshal(buf, resp); err != nil {
3092 return err
3093 }
3094
3095 return nil
3096 }, opts...)
3097 if e != nil {
3098 return nil, "", e
3099 }
3100 it.Response = resp
3101 return resp.GetRepositories(), resp.GetNextPageToken(), nil
3102 }
3103
3104 fetch := func(pageSize int, pageToken string) (string, error) {
3105 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3106 if err != nil {
3107 return "", err
3108 }
3109 it.items = append(it.items, items...)
3110 return nextPageToken, nil
3111 }
3112
3113 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3114 it.pageInfo.MaxSize = int(req.GetPageSize())
3115 it.pageInfo.Token = req.GetPageToken()
3116
3117 return it
3118 }
3119
3120 // GetRepository gets a repository.
3121 func (c *restClient) GetRepository(ctx context.Context, req *artifactregistrypb.GetRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
3122 baseUrl, err := url.Parse(c.endpoint)
3123 if err != nil {
3124 return nil, err
3125 }
3126 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3127
3128 params := url.Values{}
3129 params.Add("$alt", "json;enum-encoding=int")
3130
3131 baseUrl.RawQuery = params.Encode()
3132
3133 // Build HTTP headers from client and context metadata.
3134 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3135
3136 hds = append(c.xGoogHeaders, hds...)
3137 hds = append(hds, "Content-Type", "application/json")
3138 headers := gax.BuildHeaders(ctx, hds...)
3139 opts = append((*c.CallOptions).GetRepository[0:len((*c.CallOptions).GetRepository):len((*c.CallOptions).GetRepository)], opts...)
3140 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3141 resp := &artifactregistrypb.Repository{}
3142 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3143 if settings.Path != "" {
3144 baseUrl.Path = settings.Path
3145 }
3146 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3147 if err != nil {
3148 return err
3149 }
3150 httpReq = httpReq.WithContext(ctx)
3151 httpReq.Header = headers
3152
3153 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetRepository")
3154 if err != nil {
3155 return err
3156 }
3157
3158 if err := unm.Unmarshal(buf, resp); err != nil {
3159 return err
3160 }
3161
3162 return nil
3163 }, opts...)
3164 if e != nil {
3165 return nil, e
3166 }
3167 return resp, nil
3168 }
3169
3170 // CreateRepository creates a repository. The returned Operation will finish once the
3171 // repository has been created. Its response will be the created Repository.
3172 func (c *restClient) CreateRepository(ctx context.Context, req *artifactregistrypb.CreateRepositoryRequest, opts ...gax.CallOption) (*CreateRepositoryOperation, error) {
3173 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3174 body := req.GetRepository()
3175 jsonReq, err := m.Marshal(body)
3176 if err != nil {
3177 return nil, err
3178 }
3179
3180 baseUrl, err := url.Parse(c.endpoint)
3181 if err != nil {
3182 return nil, err
3183 }
3184 baseUrl.Path += fmt.Sprintf("/v1/%v/repositories", req.GetParent())
3185
3186 params := url.Values{}
3187 params.Add("$alt", "json;enum-encoding=int")
3188 params.Add("repositoryId", fmt.Sprintf("%v", req.GetRepositoryId()))
3189
3190 baseUrl.RawQuery = params.Encode()
3191
3192 // Build HTTP headers from client and context metadata.
3193 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3194
3195 hds = append(c.xGoogHeaders, hds...)
3196 hds = append(hds, "Content-Type", "application/json")
3197 headers := gax.BuildHeaders(ctx, hds...)
3198 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3199 resp := &longrunningpb.Operation{}
3200 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3201 if settings.Path != "" {
3202 baseUrl.Path = settings.Path
3203 }
3204 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3205 if err != nil {
3206 return err
3207 }
3208 httpReq = httpReq.WithContext(ctx)
3209 httpReq.Header = headers
3210
3211 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateRepository")
3212 if err != nil {
3213 return err
3214 }
3215 if err := unm.Unmarshal(buf, resp); err != nil {
3216 return err
3217 }
3218
3219 return nil
3220 }, opts...)
3221 if e != nil {
3222 return nil, e
3223 }
3224
3225 override := fmt.Sprintf("/v1/%s", resp.GetName())
3226 return &CreateRepositoryOperation{
3227 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3228 pollPath: override,
3229 }, nil
3230 }
3231
3232 // UpdateRepository updates a repository.
3233 func (c *restClient) UpdateRepository(ctx context.Context, req *artifactregistrypb.UpdateRepositoryRequest, opts ...gax.CallOption) (*artifactregistrypb.Repository, error) {
3234 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3235 body := req.GetRepository()
3236 jsonReq, err := m.Marshal(body)
3237 if err != nil {
3238 return nil, err
3239 }
3240
3241 baseUrl, err := url.Parse(c.endpoint)
3242 if err != nil {
3243 return nil, err
3244 }
3245 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetRepository().GetName())
3246
3247 params := url.Values{}
3248 params.Add("$alt", "json;enum-encoding=int")
3249 if req.GetUpdateMask() != nil {
3250 field, err := protojson.Marshal(req.GetUpdateMask())
3251 if err != nil {
3252 return nil, err
3253 }
3254 params.Add("updateMask", string(field[1:len(field)-1]))
3255 }
3256
3257 baseUrl.RawQuery = params.Encode()
3258
3259 // Build HTTP headers from client and context metadata.
3260 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "repository.name", url.QueryEscape(req.GetRepository().GetName()))}
3261
3262 hds = append(c.xGoogHeaders, hds...)
3263 hds = append(hds, "Content-Type", "application/json")
3264 headers := gax.BuildHeaders(ctx, hds...)
3265 opts = append((*c.CallOptions).UpdateRepository[0:len((*c.CallOptions).UpdateRepository):len((*c.CallOptions).UpdateRepository)], opts...)
3266 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3267 resp := &artifactregistrypb.Repository{}
3268 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3269 if settings.Path != "" {
3270 baseUrl.Path = settings.Path
3271 }
3272 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
3273 if err != nil {
3274 return err
3275 }
3276 httpReq = httpReq.WithContext(ctx)
3277 httpReq.Header = headers
3278
3279 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateRepository")
3280 if err != nil {
3281 return err
3282 }
3283
3284 if err := unm.Unmarshal(buf, resp); err != nil {
3285 return err
3286 }
3287
3288 return nil
3289 }, opts...)
3290 if e != nil {
3291 return nil, e
3292 }
3293 return resp, nil
3294 }
3295
3296 // DeleteRepository deletes a repository and all of its contents. The returned Operation will
3297 // finish once the repository has been deleted. It will not have any Operation
3298 // metadata and will return a google.protobuf.Empty response.
3299 func (c *restClient) DeleteRepository(ctx context.Context, req *artifactregistrypb.DeleteRepositoryRequest, opts ...gax.CallOption) (*DeleteRepositoryOperation, error) {
3300 baseUrl, err := url.Parse(c.endpoint)
3301 if err != nil {
3302 return nil, err
3303 }
3304 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3305
3306 params := url.Values{}
3307 params.Add("$alt", "json;enum-encoding=int")
3308
3309 baseUrl.RawQuery = params.Encode()
3310
3311 // Build HTTP headers from client and context metadata.
3312 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3313
3314 hds = append(c.xGoogHeaders, hds...)
3315 hds = append(hds, "Content-Type", "application/json")
3316 headers := gax.BuildHeaders(ctx, hds...)
3317 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3318 resp := &longrunningpb.Operation{}
3319 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3320 if settings.Path != "" {
3321 baseUrl.Path = settings.Path
3322 }
3323 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3324 if err != nil {
3325 return err
3326 }
3327 httpReq = httpReq.WithContext(ctx)
3328 httpReq.Header = headers
3329
3330 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteRepository")
3331 if err != nil {
3332 return err
3333 }
3334 if err := unm.Unmarshal(buf, resp); err != nil {
3335 return err
3336 }
3337
3338 return nil
3339 }, opts...)
3340 if e != nil {
3341 return nil, e
3342 }
3343
3344 override := fmt.Sprintf("/v1/%s", resp.GetName())
3345 return &DeleteRepositoryOperation{
3346 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3347 pollPath: override,
3348 }, nil
3349 }
3350
3351 // ListPackages lists packages.
3352 func (c *restClient) ListPackages(ctx context.Context, req *artifactregistrypb.ListPackagesRequest, opts ...gax.CallOption) *PackageIterator {
3353 it := &PackageIterator{}
3354 req = proto.Clone(req).(*artifactregistrypb.ListPackagesRequest)
3355 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3356 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Package, string, error) {
3357 resp := &artifactregistrypb.ListPackagesResponse{}
3358 if pageToken != "" {
3359 req.PageToken = pageToken
3360 }
3361 if pageSize > math.MaxInt32 {
3362 req.PageSize = math.MaxInt32
3363 } else if pageSize != 0 {
3364 req.PageSize = int32(pageSize)
3365 }
3366 baseUrl, err := url.Parse(c.endpoint)
3367 if err != nil {
3368 return nil, "", err
3369 }
3370 baseUrl.Path += fmt.Sprintf("/v1/%v/packages", req.GetParent())
3371
3372 params := url.Values{}
3373 params.Add("$alt", "json;enum-encoding=int")
3374 if req.GetFilter() != "" {
3375 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3376 }
3377 if req.GetOrderBy() != "" {
3378 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3379 }
3380 if req.GetPageSize() != 0 {
3381 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3382 }
3383 if req.GetPageToken() != "" {
3384 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3385 }
3386
3387 baseUrl.RawQuery = params.Encode()
3388
3389 // Build HTTP headers from client and context metadata.
3390 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3391 headers := gax.BuildHeaders(ctx, hds...)
3392 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3393 if settings.Path != "" {
3394 baseUrl.Path = settings.Path
3395 }
3396 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3397 if err != nil {
3398 return err
3399 }
3400 httpReq.Header = headers
3401
3402 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListPackages")
3403 if err != nil {
3404 return err
3405 }
3406 if err := unm.Unmarshal(buf, resp); err != nil {
3407 return err
3408 }
3409
3410 return nil
3411 }, opts...)
3412 if e != nil {
3413 return nil, "", e
3414 }
3415 it.Response = resp
3416 return resp.GetPackages(), resp.GetNextPageToken(), nil
3417 }
3418
3419 fetch := func(pageSize int, pageToken string) (string, error) {
3420 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3421 if err != nil {
3422 return "", err
3423 }
3424 it.items = append(it.items, items...)
3425 return nextPageToken, nil
3426 }
3427
3428 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3429 it.pageInfo.MaxSize = int(req.GetPageSize())
3430 it.pageInfo.Token = req.GetPageToken()
3431
3432 return it
3433 }
3434
3435 // GetPackage gets a package.
3436 func (c *restClient) GetPackage(ctx context.Context, req *artifactregistrypb.GetPackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
3437 baseUrl, err := url.Parse(c.endpoint)
3438 if err != nil {
3439 return nil, err
3440 }
3441 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3442
3443 params := url.Values{}
3444 params.Add("$alt", "json;enum-encoding=int")
3445
3446 baseUrl.RawQuery = params.Encode()
3447
3448 // Build HTTP headers from client and context metadata.
3449 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3450
3451 hds = append(c.xGoogHeaders, hds...)
3452 hds = append(hds, "Content-Type", "application/json")
3453 headers := gax.BuildHeaders(ctx, hds...)
3454 opts = append((*c.CallOptions).GetPackage[0:len((*c.CallOptions).GetPackage):len((*c.CallOptions).GetPackage)], opts...)
3455 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3456 resp := &artifactregistrypb.Package{}
3457 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3458 if settings.Path != "" {
3459 baseUrl.Path = settings.Path
3460 }
3461 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3462 if err != nil {
3463 return err
3464 }
3465 httpReq = httpReq.WithContext(ctx)
3466 httpReq.Header = headers
3467
3468 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetPackage")
3469 if err != nil {
3470 return err
3471 }
3472
3473 if err := unm.Unmarshal(buf, resp); err != nil {
3474 return err
3475 }
3476
3477 return nil
3478 }, opts...)
3479 if e != nil {
3480 return nil, e
3481 }
3482 return resp, nil
3483 }
3484
3485 // DeletePackage deletes a package and all of its versions and tags. The returned operation
3486 // will complete once the package has been deleted.
3487 func (c *restClient) DeletePackage(ctx context.Context, req *artifactregistrypb.DeletePackageRequest, opts ...gax.CallOption) (*DeletePackageOperation, error) {
3488 baseUrl, err := url.Parse(c.endpoint)
3489 if err != nil {
3490 return nil, err
3491 }
3492 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3493
3494 params := url.Values{}
3495 params.Add("$alt", "json;enum-encoding=int")
3496
3497 baseUrl.RawQuery = params.Encode()
3498
3499 // Build HTTP headers from client and context metadata.
3500 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3501
3502 hds = append(c.xGoogHeaders, hds...)
3503 hds = append(hds, "Content-Type", "application/json")
3504 headers := gax.BuildHeaders(ctx, hds...)
3505 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3506 resp := &longrunningpb.Operation{}
3507 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3508 if settings.Path != "" {
3509 baseUrl.Path = settings.Path
3510 }
3511 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3512 if err != nil {
3513 return err
3514 }
3515 httpReq = httpReq.WithContext(ctx)
3516 httpReq.Header = headers
3517
3518 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeletePackage")
3519 if err != nil {
3520 return err
3521 }
3522 if err := unm.Unmarshal(buf, resp); err != nil {
3523 return err
3524 }
3525
3526 return nil
3527 }, opts...)
3528 if e != nil {
3529 return nil, e
3530 }
3531
3532 override := fmt.Sprintf("/v1/%s", resp.GetName())
3533 return &DeletePackageOperation{
3534 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3535 pollPath: override,
3536 }, nil
3537 }
3538
3539 // ListVersions lists versions.
3540 func (c *restClient) ListVersions(ctx context.Context, req *artifactregistrypb.ListVersionsRequest, opts ...gax.CallOption) *VersionIterator {
3541 it := &VersionIterator{}
3542 req = proto.Clone(req).(*artifactregistrypb.ListVersionsRequest)
3543 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3544 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Version, string, error) {
3545 resp := &artifactregistrypb.ListVersionsResponse{}
3546 if pageToken != "" {
3547 req.PageToken = pageToken
3548 }
3549 if pageSize > math.MaxInt32 {
3550 req.PageSize = math.MaxInt32
3551 } else if pageSize != 0 {
3552 req.PageSize = int32(pageSize)
3553 }
3554 baseUrl, err := url.Parse(c.endpoint)
3555 if err != nil {
3556 return nil, "", err
3557 }
3558 baseUrl.Path += fmt.Sprintf("/v1/%v/versions", req.GetParent())
3559
3560 params := url.Values{}
3561 params.Add("$alt", "json;enum-encoding=int")
3562 if req.GetFilter() != "" {
3563 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3564 }
3565 if req.GetOrderBy() != "" {
3566 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3567 }
3568 if req.GetPageSize() != 0 {
3569 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3570 }
3571 if req.GetPageToken() != "" {
3572 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3573 }
3574 if req.GetView() != 0 {
3575 params.Add("view", fmt.Sprintf("%v", req.GetView()))
3576 }
3577
3578 baseUrl.RawQuery = params.Encode()
3579
3580 // Build HTTP headers from client and context metadata.
3581 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3582 headers := gax.BuildHeaders(ctx, hds...)
3583 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3584 if settings.Path != "" {
3585 baseUrl.Path = settings.Path
3586 }
3587 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3588 if err != nil {
3589 return err
3590 }
3591 httpReq.Header = headers
3592
3593 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListVersions")
3594 if err != nil {
3595 return err
3596 }
3597 if err := unm.Unmarshal(buf, resp); err != nil {
3598 return err
3599 }
3600
3601 return nil
3602 }, opts...)
3603 if e != nil {
3604 return nil, "", e
3605 }
3606 it.Response = resp
3607 return resp.GetVersions(), resp.GetNextPageToken(), nil
3608 }
3609
3610 fetch := func(pageSize int, pageToken string) (string, error) {
3611 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3612 if err != nil {
3613 return "", err
3614 }
3615 it.items = append(it.items, items...)
3616 return nextPageToken, nil
3617 }
3618
3619 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3620 it.pageInfo.MaxSize = int(req.GetPageSize())
3621 it.pageInfo.Token = req.GetPageToken()
3622
3623 return it
3624 }
3625
3626 // GetVersion gets a version
3627 func (c *restClient) GetVersion(ctx context.Context, req *artifactregistrypb.GetVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
3628 baseUrl, err := url.Parse(c.endpoint)
3629 if err != nil {
3630 return nil, err
3631 }
3632 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3633
3634 params := url.Values{}
3635 params.Add("$alt", "json;enum-encoding=int")
3636 if req.GetView() != 0 {
3637 params.Add("view", fmt.Sprintf("%v", req.GetView()))
3638 }
3639
3640 baseUrl.RawQuery = params.Encode()
3641
3642 // Build HTTP headers from client and context metadata.
3643 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3644
3645 hds = append(c.xGoogHeaders, hds...)
3646 hds = append(hds, "Content-Type", "application/json")
3647 headers := gax.BuildHeaders(ctx, hds...)
3648 opts = append((*c.CallOptions).GetVersion[0:len((*c.CallOptions).GetVersion):len((*c.CallOptions).GetVersion)], opts...)
3649 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3650 resp := &artifactregistrypb.Version{}
3651 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3652 if settings.Path != "" {
3653 baseUrl.Path = settings.Path
3654 }
3655 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3656 if err != nil {
3657 return err
3658 }
3659 httpReq = httpReq.WithContext(ctx)
3660 httpReq.Header = headers
3661
3662 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetVersion")
3663 if err != nil {
3664 return err
3665 }
3666
3667 if err := unm.Unmarshal(buf, resp); err != nil {
3668 return err
3669 }
3670
3671 return nil
3672 }, opts...)
3673 if e != nil {
3674 return nil, e
3675 }
3676 return resp, nil
3677 }
3678
3679 // DeleteVersion deletes a version and all of its content. The returned operation will
3680 // complete once the version has been deleted.
3681 func (c *restClient) DeleteVersion(ctx context.Context, req *artifactregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*DeleteVersionOperation, error) {
3682 baseUrl, err := url.Parse(c.endpoint)
3683 if err != nil {
3684 return nil, err
3685 }
3686 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3687
3688 params := url.Values{}
3689 params.Add("$alt", "json;enum-encoding=int")
3690 if req.GetForce() {
3691 params.Add("force", fmt.Sprintf("%v", req.GetForce()))
3692 }
3693
3694 baseUrl.RawQuery = params.Encode()
3695
3696 // Build HTTP headers from client and context metadata.
3697 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3698
3699 hds = append(c.xGoogHeaders, hds...)
3700 hds = append(hds, "Content-Type", "application/json")
3701 headers := gax.BuildHeaders(ctx, hds...)
3702 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3703 resp := &longrunningpb.Operation{}
3704 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3705 if settings.Path != "" {
3706 baseUrl.Path = settings.Path
3707 }
3708 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3709 if err != nil {
3710 return err
3711 }
3712 httpReq = httpReq.WithContext(ctx)
3713 httpReq.Header = headers
3714
3715 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteVersion")
3716 if err != nil {
3717 return err
3718 }
3719 if err := unm.Unmarshal(buf, resp); err != nil {
3720 return err
3721 }
3722
3723 return nil
3724 }, opts...)
3725 if e != nil {
3726 return nil, e
3727 }
3728
3729 override := fmt.Sprintf("/v1/%s", resp.GetName())
3730 return &DeleteVersionOperation{
3731 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3732 pollPath: override,
3733 }, nil
3734 }
3735
3736 // BatchDeleteVersions deletes multiple versions across a repository. The returned operation will
3737 // complete once the versions have been deleted.
3738 func (c *restClient) BatchDeleteVersions(ctx context.Context, req *artifactregistrypb.BatchDeleteVersionsRequest, opts ...gax.CallOption) (*BatchDeleteVersionsOperation, error) {
3739 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3740 jsonReq, err := m.Marshal(req)
3741 if err != nil {
3742 return nil, err
3743 }
3744
3745 baseUrl, err := url.Parse(c.endpoint)
3746 if err != nil {
3747 return nil, err
3748 }
3749 baseUrl.Path += fmt.Sprintf("/v1/%v/versions:batchDelete", req.GetParent())
3750
3751 params := url.Values{}
3752 params.Add("$alt", "json;enum-encoding=int")
3753
3754 baseUrl.RawQuery = params.Encode()
3755
3756 // Build HTTP headers from client and context metadata.
3757 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3758
3759 hds = append(c.xGoogHeaders, hds...)
3760 hds = append(hds, "Content-Type", "application/json")
3761 headers := gax.BuildHeaders(ctx, hds...)
3762 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3763 resp := &longrunningpb.Operation{}
3764 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3765 if settings.Path != "" {
3766 baseUrl.Path = settings.Path
3767 }
3768 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3769 if err != nil {
3770 return err
3771 }
3772 httpReq = httpReq.WithContext(ctx)
3773 httpReq.Header = headers
3774
3775 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchDeleteVersions")
3776 if err != nil {
3777 return err
3778 }
3779 if err := unm.Unmarshal(buf, resp); err != nil {
3780 return err
3781 }
3782
3783 return nil
3784 }, opts...)
3785 if e != nil {
3786 return nil, e
3787 }
3788
3789 override := fmt.Sprintf("/v1/%s", resp.GetName())
3790 return &BatchDeleteVersionsOperation{
3791 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
3792 pollPath: override,
3793 }, nil
3794 }
3795
3796 // UpdateVersion updates a version.
3797 func (c *restClient) UpdateVersion(ctx context.Context, req *artifactregistrypb.UpdateVersionRequest, opts ...gax.CallOption) (*artifactregistrypb.Version, error) {
3798 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3799 body := req.GetVersion()
3800 jsonReq, err := m.Marshal(body)
3801 if err != nil {
3802 return nil, err
3803 }
3804
3805 baseUrl, err := url.Parse(c.endpoint)
3806 if err != nil {
3807 return nil, err
3808 }
3809 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetVersion().GetName())
3810
3811 params := url.Values{}
3812 params.Add("$alt", "json;enum-encoding=int")
3813 if req.GetUpdateMask() != nil {
3814 field, err := protojson.Marshal(req.GetUpdateMask())
3815 if err != nil {
3816 return nil, err
3817 }
3818 params.Add("updateMask", string(field[1:len(field)-1]))
3819 }
3820
3821 baseUrl.RawQuery = params.Encode()
3822
3823 // Build HTTP headers from client and context metadata.
3824 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "version.name", url.QueryEscape(req.GetVersion().GetName()))}
3825
3826 hds = append(c.xGoogHeaders, hds...)
3827 hds = append(hds, "Content-Type", "application/json")
3828 headers := gax.BuildHeaders(ctx, hds...)
3829 opts = append((*c.CallOptions).UpdateVersion[0:len((*c.CallOptions).UpdateVersion):len((*c.CallOptions).UpdateVersion)], opts...)
3830 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3831 resp := &artifactregistrypb.Version{}
3832 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3833 if settings.Path != "" {
3834 baseUrl.Path = settings.Path
3835 }
3836 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
3837 if err != nil {
3838 return err
3839 }
3840 httpReq = httpReq.WithContext(ctx)
3841 httpReq.Header = headers
3842
3843 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateVersion")
3844 if err != nil {
3845 return err
3846 }
3847
3848 if err := unm.Unmarshal(buf, resp); err != nil {
3849 return err
3850 }
3851
3852 return nil
3853 }, opts...)
3854 if e != nil {
3855 return nil, e
3856 }
3857 return resp, nil
3858 }
3859
3860 // ListFiles lists files.
3861 func (c *restClient) ListFiles(ctx context.Context, req *artifactregistrypb.ListFilesRequest, opts ...gax.CallOption) *FileIterator {
3862 it := &FileIterator{}
3863 req = proto.Clone(req).(*artifactregistrypb.ListFilesRequest)
3864 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3865 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.File, string, error) {
3866 resp := &artifactregistrypb.ListFilesResponse{}
3867 if pageToken != "" {
3868 req.PageToken = pageToken
3869 }
3870 if pageSize > math.MaxInt32 {
3871 req.PageSize = math.MaxInt32
3872 } else if pageSize != 0 {
3873 req.PageSize = int32(pageSize)
3874 }
3875 baseUrl, err := url.Parse(c.endpoint)
3876 if err != nil {
3877 return nil, "", err
3878 }
3879 baseUrl.Path += fmt.Sprintf("/v1/%v/files", req.GetParent())
3880
3881 params := url.Values{}
3882 params.Add("$alt", "json;enum-encoding=int")
3883 if req.GetFilter() != "" {
3884 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3885 }
3886 if req.GetOrderBy() != "" {
3887 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
3888 }
3889 if req.GetPageSize() != 0 {
3890 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3891 }
3892 if req.GetPageToken() != "" {
3893 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3894 }
3895
3896 baseUrl.RawQuery = params.Encode()
3897
3898 // Build HTTP headers from client and context metadata.
3899 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3900 headers := gax.BuildHeaders(ctx, hds...)
3901 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3902 if settings.Path != "" {
3903 baseUrl.Path = settings.Path
3904 }
3905 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3906 if err != nil {
3907 return err
3908 }
3909 httpReq.Header = headers
3910
3911 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListFiles")
3912 if err != nil {
3913 return err
3914 }
3915 if err := unm.Unmarshal(buf, resp); err != nil {
3916 return err
3917 }
3918
3919 return nil
3920 }, opts...)
3921 if e != nil {
3922 return nil, "", e
3923 }
3924 it.Response = resp
3925 return resp.GetFiles(), resp.GetNextPageToken(), nil
3926 }
3927
3928 fetch := func(pageSize int, pageToken string) (string, error) {
3929 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3930 if err != nil {
3931 return "", err
3932 }
3933 it.items = append(it.items, items...)
3934 return nextPageToken, nil
3935 }
3936
3937 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3938 it.pageInfo.MaxSize = int(req.GetPageSize())
3939 it.pageInfo.Token = req.GetPageToken()
3940
3941 return it
3942 }
3943
3944 // GetFile gets a file.
3945 func (c *restClient) GetFile(ctx context.Context, req *artifactregistrypb.GetFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
3946 baseUrl, err := url.Parse(c.endpoint)
3947 if err != nil {
3948 return nil, err
3949 }
3950 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3951
3952 params := url.Values{}
3953 params.Add("$alt", "json;enum-encoding=int")
3954
3955 baseUrl.RawQuery = params.Encode()
3956
3957 // Build HTTP headers from client and context metadata.
3958 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3959
3960 hds = append(c.xGoogHeaders, hds...)
3961 hds = append(hds, "Content-Type", "application/json")
3962 headers := gax.BuildHeaders(ctx, hds...)
3963 opts = append((*c.CallOptions).GetFile[0:len((*c.CallOptions).GetFile):len((*c.CallOptions).GetFile)], opts...)
3964 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3965 resp := &artifactregistrypb.File{}
3966 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3967 if settings.Path != "" {
3968 baseUrl.Path = settings.Path
3969 }
3970 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3971 if err != nil {
3972 return err
3973 }
3974 httpReq = httpReq.WithContext(ctx)
3975 httpReq.Header = headers
3976
3977 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetFile")
3978 if err != nil {
3979 return err
3980 }
3981
3982 if err := unm.Unmarshal(buf, resp); err != nil {
3983 return err
3984 }
3985
3986 return nil
3987 }, opts...)
3988 if e != nil {
3989 return nil, e
3990 }
3991 return resp, nil
3992 }
3993
3994 // DeleteFile deletes a file and all of its content. It is only allowed on generic
3995 // repositories. The returned operation will complete once the file has been
3996 // deleted.
3997 func (c *restClient) DeleteFile(ctx context.Context, req *artifactregistrypb.DeleteFileRequest, opts ...gax.CallOption) (*DeleteFileOperation, error) {
3998 baseUrl, err := url.Parse(c.endpoint)
3999 if err != nil {
4000 return nil, err
4001 }
4002 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4003
4004 params := url.Values{}
4005 params.Add("$alt", "json;enum-encoding=int")
4006
4007 baseUrl.RawQuery = params.Encode()
4008
4009 // Build HTTP headers from client and context metadata.
4010 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4011
4012 hds = append(c.xGoogHeaders, hds...)
4013 hds = append(hds, "Content-Type", "application/json")
4014 headers := gax.BuildHeaders(ctx, hds...)
4015 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4016 resp := &longrunningpb.Operation{}
4017 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4018 if settings.Path != "" {
4019 baseUrl.Path = settings.Path
4020 }
4021 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4022 if err != nil {
4023 return err
4024 }
4025 httpReq = httpReq.WithContext(ctx)
4026 httpReq.Header = headers
4027
4028 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteFile")
4029 if err != nil {
4030 return err
4031 }
4032 if err := unm.Unmarshal(buf, resp); err != nil {
4033 return err
4034 }
4035
4036 return nil
4037 }, opts...)
4038 if e != nil {
4039 return nil, e
4040 }
4041
4042 override := fmt.Sprintf("/v1/%s", resp.GetName())
4043 return &DeleteFileOperation{
4044 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
4045 pollPath: override,
4046 }, nil
4047 }
4048
4049 // UpdateFile updates a file.
4050 func (c *restClient) UpdateFile(ctx context.Context, req *artifactregistrypb.UpdateFileRequest, opts ...gax.CallOption) (*artifactregistrypb.File, error) {
4051 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4052 body := req.GetFile()
4053 jsonReq, err := m.Marshal(body)
4054 if err != nil {
4055 return nil, err
4056 }
4057
4058 baseUrl, err := url.Parse(c.endpoint)
4059 if err != nil {
4060 return nil, err
4061 }
4062 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetFile().GetName())
4063
4064 params := url.Values{}
4065 params.Add("$alt", "json;enum-encoding=int")
4066 if req.GetUpdateMask() != nil {
4067 field, err := protojson.Marshal(req.GetUpdateMask())
4068 if err != nil {
4069 return nil, err
4070 }
4071 params.Add("updateMask", string(field[1:len(field)-1]))
4072 }
4073
4074 baseUrl.RawQuery = params.Encode()
4075
4076 // Build HTTP headers from client and context metadata.
4077 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "file.name", url.QueryEscape(req.GetFile().GetName()))}
4078
4079 hds = append(c.xGoogHeaders, hds...)
4080 hds = append(hds, "Content-Type", "application/json")
4081 headers := gax.BuildHeaders(ctx, hds...)
4082 opts = append((*c.CallOptions).UpdateFile[0:len((*c.CallOptions).UpdateFile):len((*c.CallOptions).UpdateFile)], opts...)
4083 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4084 resp := &artifactregistrypb.File{}
4085 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4086 if settings.Path != "" {
4087 baseUrl.Path = settings.Path
4088 }
4089 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4090 if err != nil {
4091 return err
4092 }
4093 httpReq = httpReq.WithContext(ctx)
4094 httpReq.Header = headers
4095
4096 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateFile")
4097 if err != nil {
4098 return err
4099 }
4100
4101 if err := unm.Unmarshal(buf, resp); err != nil {
4102 return err
4103 }
4104
4105 return nil
4106 }, opts...)
4107 if e != nil {
4108 return nil, e
4109 }
4110 return resp, nil
4111 }
4112
4113 // ListTags lists tags.
4114 func (c *restClient) ListTags(ctx context.Context, req *artifactregistrypb.ListTagsRequest, opts ...gax.CallOption) *TagIterator {
4115 it := &TagIterator{}
4116 req = proto.Clone(req).(*artifactregistrypb.ListTagsRequest)
4117 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4118 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Tag, string, error) {
4119 resp := &artifactregistrypb.ListTagsResponse{}
4120 if pageToken != "" {
4121 req.PageToken = pageToken
4122 }
4123 if pageSize > math.MaxInt32 {
4124 req.PageSize = math.MaxInt32
4125 } else if pageSize != 0 {
4126 req.PageSize = int32(pageSize)
4127 }
4128 baseUrl, err := url.Parse(c.endpoint)
4129 if err != nil {
4130 return nil, "", err
4131 }
4132 baseUrl.Path += fmt.Sprintf("/v1/%v/tags", req.GetParent())
4133
4134 params := url.Values{}
4135 params.Add("$alt", "json;enum-encoding=int")
4136 if req.GetFilter() != "" {
4137 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4138 }
4139 if req.GetPageSize() != 0 {
4140 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4141 }
4142 if req.GetPageToken() != "" {
4143 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4144 }
4145
4146 baseUrl.RawQuery = params.Encode()
4147
4148 // Build HTTP headers from client and context metadata.
4149 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4150 headers := gax.BuildHeaders(ctx, hds...)
4151 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4152 if settings.Path != "" {
4153 baseUrl.Path = settings.Path
4154 }
4155 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4156 if err != nil {
4157 return err
4158 }
4159 httpReq.Header = headers
4160
4161 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListTags")
4162 if err != nil {
4163 return err
4164 }
4165 if err := unm.Unmarshal(buf, resp); err != nil {
4166 return err
4167 }
4168
4169 return nil
4170 }, opts...)
4171 if e != nil {
4172 return nil, "", e
4173 }
4174 it.Response = resp
4175 return resp.GetTags(), resp.GetNextPageToken(), nil
4176 }
4177
4178 fetch := func(pageSize int, pageToken string) (string, error) {
4179 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4180 if err != nil {
4181 return "", err
4182 }
4183 it.items = append(it.items, items...)
4184 return nextPageToken, nil
4185 }
4186
4187 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4188 it.pageInfo.MaxSize = int(req.GetPageSize())
4189 it.pageInfo.Token = req.GetPageToken()
4190
4191 return it
4192 }
4193
4194 // GetTag gets a tag.
4195 func (c *restClient) GetTag(ctx context.Context, req *artifactregistrypb.GetTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
4196 baseUrl, err := url.Parse(c.endpoint)
4197 if err != nil {
4198 return nil, err
4199 }
4200 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4201
4202 params := url.Values{}
4203 params.Add("$alt", "json;enum-encoding=int")
4204
4205 baseUrl.RawQuery = params.Encode()
4206
4207 // Build HTTP headers from client and context metadata.
4208 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4209
4210 hds = append(c.xGoogHeaders, hds...)
4211 hds = append(hds, "Content-Type", "application/json")
4212 headers := gax.BuildHeaders(ctx, hds...)
4213 opts = append((*c.CallOptions).GetTag[0:len((*c.CallOptions).GetTag):len((*c.CallOptions).GetTag)], opts...)
4214 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4215 resp := &artifactregistrypb.Tag{}
4216 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4217 if settings.Path != "" {
4218 baseUrl.Path = settings.Path
4219 }
4220 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4221 if err != nil {
4222 return err
4223 }
4224 httpReq = httpReq.WithContext(ctx)
4225 httpReq.Header = headers
4226
4227 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetTag")
4228 if err != nil {
4229 return err
4230 }
4231
4232 if err := unm.Unmarshal(buf, resp); err != nil {
4233 return err
4234 }
4235
4236 return nil
4237 }, opts...)
4238 if e != nil {
4239 return nil, e
4240 }
4241 return resp, nil
4242 }
4243
4244 // CreateTag creates a tag.
4245 func (c *restClient) CreateTag(ctx context.Context, req *artifactregistrypb.CreateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
4246 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4247 body := req.GetTag()
4248 jsonReq, err := m.Marshal(body)
4249 if err != nil {
4250 return nil, err
4251 }
4252
4253 baseUrl, err := url.Parse(c.endpoint)
4254 if err != nil {
4255 return nil, err
4256 }
4257 baseUrl.Path += fmt.Sprintf("/v1/%v/tags", req.GetParent())
4258
4259 params := url.Values{}
4260 params.Add("$alt", "json;enum-encoding=int")
4261 if req.GetTagId() != "" {
4262 params.Add("tagId", fmt.Sprintf("%v", req.GetTagId()))
4263 }
4264
4265 baseUrl.RawQuery = params.Encode()
4266
4267 // Build HTTP headers from client and context metadata.
4268 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4269
4270 hds = append(c.xGoogHeaders, hds...)
4271 hds = append(hds, "Content-Type", "application/json")
4272 headers := gax.BuildHeaders(ctx, hds...)
4273 opts = append((*c.CallOptions).CreateTag[0:len((*c.CallOptions).CreateTag):len((*c.CallOptions).CreateTag)], opts...)
4274 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4275 resp := &artifactregistrypb.Tag{}
4276 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4277 if settings.Path != "" {
4278 baseUrl.Path = settings.Path
4279 }
4280 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4281 if err != nil {
4282 return err
4283 }
4284 httpReq = httpReq.WithContext(ctx)
4285 httpReq.Header = headers
4286
4287 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateTag")
4288 if err != nil {
4289 return err
4290 }
4291
4292 if err := unm.Unmarshal(buf, resp); err != nil {
4293 return err
4294 }
4295
4296 return nil
4297 }, opts...)
4298 if e != nil {
4299 return nil, e
4300 }
4301 return resp, nil
4302 }
4303
4304 // UpdateTag updates a tag.
4305 func (c *restClient) UpdateTag(ctx context.Context, req *artifactregistrypb.UpdateTagRequest, opts ...gax.CallOption) (*artifactregistrypb.Tag, error) {
4306 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4307 body := req.GetTag()
4308 jsonReq, err := m.Marshal(body)
4309 if err != nil {
4310 return nil, err
4311 }
4312
4313 baseUrl, err := url.Parse(c.endpoint)
4314 if err != nil {
4315 return nil, err
4316 }
4317 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetTag().GetName())
4318
4319 params := url.Values{}
4320 params.Add("$alt", "json;enum-encoding=int")
4321 if req.GetUpdateMask() != nil {
4322 field, err := protojson.Marshal(req.GetUpdateMask())
4323 if err != nil {
4324 return nil, err
4325 }
4326 params.Add("updateMask", string(field[1:len(field)-1]))
4327 }
4328
4329 baseUrl.RawQuery = params.Encode()
4330
4331 // Build HTTP headers from client and context metadata.
4332 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "tag.name", url.QueryEscape(req.GetTag().GetName()))}
4333
4334 hds = append(c.xGoogHeaders, hds...)
4335 hds = append(hds, "Content-Type", "application/json")
4336 headers := gax.BuildHeaders(ctx, hds...)
4337 opts = append((*c.CallOptions).UpdateTag[0:len((*c.CallOptions).UpdateTag):len((*c.CallOptions).UpdateTag)], opts...)
4338 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4339 resp := &artifactregistrypb.Tag{}
4340 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4341 if settings.Path != "" {
4342 baseUrl.Path = settings.Path
4343 }
4344 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4345 if err != nil {
4346 return err
4347 }
4348 httpReq = httpReq.WithContext(ctx)
4349 httpReq.Header = headers
4350
4351 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateTag")
4352 if err != nil {
4353 return err
4354 }
4355
4356 if err := unm.Unmarshal(buf, resp); err != nil {
4357 return err
4358 }
4359
4360 return nil
4361 }, opts...)
4362 if e != nil {
4363 return nil, e
4364 }
4365 return resp, nil
4366 }
4367
4368 // DeleteTag deletes a tag.
4369 func (c *restClient) DeleteTag(ctx context.Context, req *artifactregistrypb.DeleteTagRequest, opts ...gax.CallOption) error {
4370 baseUrl, err := url.Parse(c.endpoint)
4371 if err != nil {
4372 return err
4373 }
4374 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4375
4376 params := url.Values{}
4377 params.Add("$alt", "json;enum-encoding=int")
4378
4379 baseUrl.RawQuery = params.Encode()
4380
4381 // Build HTTP headers from client and context metadata.
4382 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4383
4384 hds = append(c.xGoogHeaders, hds...)
4385 hds = append(hds, "Content-Type", "application/json")
4386 headers := gax.BuildHeaders(ctx, hds...)
4387 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4388 if settings.Path != "" {
4389 baseUrl.Path = settings.Path
4390 }
4391 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4392 if err != nil {
4393 return err
4394 }
4395 httpReq = httpReq.WithContext(ctx)
4396 httpReq.Header = headers
4397
4398 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteTag")
4399 return err
4400 }, opts...)
4401 }
4402
4403 // CreateRule creates a rule.
4404 func (c *restClient) CreateRule(ctx context.Context, req *artifactregistrypb.CreateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
4405 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4406 body := req.GetRule()
4407 jsonReq, err := m.Marshal(body)
4408 if err != nil {
4409 return nil, err
4410 }
4411
4412 baseUrl, err := url.Parse(c.endpoint)
4413 if err != nil {
4414 return nil, err
4415 }
4416 baseUrl.Path += fmt.Sprintf("/v1/%v/rules", req.GetParent())
4417
4418 params := url.Values{}
4419 params.Add("$alt", "json;enum-encoding=int")
4420 if req.GetRuleId() != "" {
4421 params.Add("ruleId", fmt.Sprintf("%v", req.GetRuleId()))
4422 }
4423
4424 baseUrl.RawQuery = params.Encode()
4425
4426 // Build HTTP headers from client and context metadata.
4427 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
4428
4429 hds = append(c.xGoogHeaders, hds...)
4430 hds = append(hds, "Content-Type", "application/json")
4431 headers := gax.BuildHeaders(ctx, hds...)
4432 opts = append((*c.CallOptions).CreateRule[0:len((*c.CallOptions).CreateRule):len((*c.CallOptions).CreateRule)], opts...)
4433 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4434 resp := &artifactregistrypb.Rule{}
4435 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4436 if settings.Path != "" {
4437 baseUrl.Path = settings.Path
4438 }
4439 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4440 if err != nil {
4441 return err
4442 }
4443 httpReq = httpReq.WithContext(ctx)
4444 httpReq.Header = headers
4445
4446 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateRule")
4447 if err != nil {
4448 return err
4449 }
4450
4451 if err := unm.Unmarshal(buf, resp); err != nil {
4452 return err
4453 }
4454
4455 return nil
4456 }, opts...)
4457 if e != nil {
4458 return nil, e
4459 }
4460 return resp, nil
4461 }
4462
4463 // ListRules lists rules.
4464 func (c *restClient) ListRules(ctx context.Context, req *artifactregistrypb.ListRulesRequest, opts ...gax.CallOption) *RuleIterator {
4465 it := &RuleIterator{}
4466 req = proto.Clone(req).(*artifactregistrypb.ListRulesRequest)
4467 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4468 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Rule, string, error) {
4469 resp := &artifactregistrypb.ListRulesResponse{}
4470 if pageToken != "" {
4471 req.PageToken = pageToken
4472 }
4473 if pageSize > math.MaxInt32 {
4474 req.PageSize = math.MaxInt32
4475 } else if pageSize != 0 {
4476 req.PageSize = int32(pageSize)
4477 }
4478 baseUrl, err := url.Parse(c.endpoint)
4479 if err != nil {
4480 return nil, "", err
4481 }
4482 baseUrl.Path += fmt.Sprintf("/v1/%v/rules", req.GetParent())
4483
4484 params := url.Values{}
4485 params.Add("$alt", "json;enum-encoding=int")
4486 if req.GetPageSize() != 0 {
4487 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4488 }
4489 if req.GetPageToken() != "" {
4490 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4491 }
4492
4493 baseUrl.RawQuery = params.Encode()
4494
4495 // Build HTTP headers from client and context metadata.
4496 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4497 headers := gax.BuildHeaders(ctx, hds...)
4498 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4499 if settings.Path != "" {
4500 baseUrl.Path = settings.Path
4501 }
4502 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4503 if err != nil {
4504 return err
4505 }
4506 httpReq.Header = headers
4507
4508 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListRules")
4509 if err != nil {
4510 return err
4511 }
4512 if err := unm.Unmarshal(buf, resp); err != nil {
4513 return err
4514 }
4515
4516 return nil
4517 }, opts...)
4518 if e != nil {
4519 return nil, "", e
4520 }
4521 it.Response = resp
4522 return resp.GetRules(), resp.GetNextPageToken(), nil
4523 }
4524
4525 fetch := func(pageSize int, pageToken string) (string, error) {
4526 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4527 if err != nil {
4528 return "", err
4529 }
4530 it.items = append(it.items, items...)
4531 return nextPageToken, nil
4532 }
4533
4534 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4535 it.pageInfo.MaxSize = int(req.GetPageSize())
4536 it.pageInfo.Token = req.GetPageToken()
4537
4538 return it
4539 }
4540
4541 // GetRule gets a rule.
4542 func (c *restClient) GetRule(ctx context.Context, req *artifactregistrypb.GetRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
4543 baseUrl, err := url.Parse(c.endpoint)
4544 if err != nil {
4545 return nil, err
4546 }
4547 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4548
4549 params := url.Values{}
4550 params.Add("$alt", "json;enum-encoding=int")
4551
4552 baseUrl.RawQuery = params.Encode()
4553
4554 // Build HTTP headers from client and context metadata.
4555 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4556
4557 hds = append(c.xGoogHeaders, hds...)
4558 hds = append(hds, "Content-Type", "application/json")
4559 headers := gax.BuildHeaders(ctx, hds...)
4560 opts = append((*c.CallOptions).GetRule[0:len((*c.CallOptions).GetRule):len((*c.CallOptions).GetRule)], opts...)
4561 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4562 resp := &artifactregistrypb.Rule{}
4563 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4564 if settings.Path != "" {
4565 baseUrl.Path = settings.Path
4566 }
4567 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4568 if err != nil {
4569 return err
4570 }
4571 httpReq = httpReq.WithContext(ctx)
4572 httpReq.Header = headers
4573
4574 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetRule")
4575 if err != nil {
4576 return err
4577 }
4578
4579 if err := unm.Unmarshal(buf, resp); err != nil {
4580 return err
4581 }
4582
4583 return nil
4584 }, opts...)
4585 if e != nil {
4586 return nil, e
4587 }
4588 return resp, nil
4589 }
4590
4591 // UpdateRule updates a rule.
4592 func (c *restClient) UpdateRule(ctx context.Context, req *artifactregistrypb.UpdateRuleRequest, opts ...gax.CallOption) (*artifactregistrypb.Rule, error) {
4593 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4594 body := req.GetRule()
4595 jsonReq, err := m.Marshal(body)
4596 if err != nil {
4597 return nil, err
4598 }
4599
4600 baseUrl, err := url.Parse(c.endpoint)
4601 if err != nil {
4602 return nil, err
4603 }
4604 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetRule().GetName())
4605
4606 params := url.Values{}
4607 params.Add("$alt", "json;enum-encoding=int")
4608 if req.GetUpdateMask() != nil {
4609 field, err := protojson.Marshal(req.GetUpdateMask())
4610 if err != nil {
4611 return nil, err
4612 }
4613 params.Add("updateMask", string(field[1:len(field)-1]))
4614 }
4615
4616 baseUrl.RawQuery = params.Encode()
4617
4618 // Build HTTP headers from client and context metadata.
4619 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "rule.name", url.QueryEscape(req.GetRule().GetName()))}
4620
4621 hds = append(c.xGoogHeaders, hds...)
4622 hds = append(hds, "Content-Type", "application/json")
4623 headers := gax.BuildHeaders(ctx, hds...)
4624 opts = append((*c.CallOptions).UpdateRule[0:len((*c.CallOptions).UpdateRule):len((*c.CallOptions).UpdateRule)], opts...)
4625 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4626 resp := &artifactregistrypb.Rule{}
4627 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4628 if settings.Path != "" {
4629 baseUrl.Path = settings.Path
4630 }
4631 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4632 if err != nil {
4633 return err
4634 }
4635 httpReq = httpReq.WithContext(ctx)
4636 httpReq.Header = headers
4637
4638 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateRule")
4639 if err != nil {
4640 return err
4641 }
4642
4643 if err := unm.Unmarshal(buf, resp); err != nil {
4644 return err
4645 }
4646
4647 return nil
4648 }, opts...)
4649 if e != nil {
4650 return nil, e
4651 }
4652 return resp, nil
4653 }
4654
4655 // DeleteRule deletes a rule.
4656 func (c *restClient) DeleteRule(ctx context.Context, req *artifactregistrypb.DeleteRuleRequest, opts ...gax.CallOption) error {
4657 baseUrl, err := url.Parse(c.endpoint)
4658 if err != nil {
4659 return err
4660 }
4661 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4662
4663 params := url.Values{}
4664 params.Add("$alt", "json;enum-encoding=int")
4665
4666 baseUrl.RawQuery = params.Encode()
4667
4668 // Build HTTP headers from client and context metadata.
4669 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4670
4671 hds = append(c.xGoogHeaders, hds...)
4672 hds = append(hds, "Content-Type", "application/json")
4673 headers := gax.BuildHeaders(ctx, hds...)
4674 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4675 if settings.Path != "" {
4676 baseUrl.Path = settings.Path
4677 }
4678 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
4679 if err != nil {
4680 return err
4681 }
4682 httpReq = httpReq.WithContext(ctx)
4683 httpReq.Header = headers
4684
4685 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteRule")
4686 return err
4687 }, opts...)
4688 }
4689
4690 // SetIamPolicy updates the IAM policy for a given resource.
4691 func (c *restClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
4692 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4693 jsonReq, err := m.Marshal(req)
4694 if err != nil {
4695 return nil, err
4696 }
4697
4698 baseUrl, err := url.Parse(c.endpoint)
4699 if err != nil {
4700 return nil, err
4701 }
4702 baseUrl.Path += fmt.Sprintf("/v1/%v:setIamPolicy", req.GetResource())
4703
4704 params := url.Values{}
4705 params.Add("$alt", "json;enum-encoding=int")
4706
4707 baseUrl.RawQuery = params.Encode()
4708
4709 // Build HTTP headers from client and context metadata.
4710 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4711
4712 hds = append(c.xGoogHeaders, hds...)
4713 hds = append(hds, "Content-Type", "application/json")
4714 headers := gax.BuildHeaders(ctx, hds...)
4715 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
4716 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4717 resp := &iampb.Policy{}
4718 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4719 if settings.Path != "" {
4720 baseUrl.Path = settings.Path
4721 }
4722 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4723 if err != nil {
4724 return err
4725 }
4726 httpReq = httpReq.WithContext(ctx)
4727 httpReq.Header = headers
4728
4729 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
4730 if err != nil {
4731 return err
4732 }
4733
4734 if err := unm.Unmarshal(buf, resp); err != nil {
4735 return err
4736 }
4737
4738 return nil
4739 }, opts...)
4740 if e != nil {
4741 return nil, e
4742 }
4743 return resp, nil
4744 }
4745
4746 // GetIamPolicy gets the IAM policy for a given resource.
4747 func (c *restClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
4748 baseUrl, err := url.Parse(c.endpoint)
4749 if err != nil {
4750 return nil, err
4751 }
4752 baseUrl.Path += fmt.Sprintf("/v1/%v:getIamPolicy", req.GetResource())
4753
4754 params := url.Values{}
4755 params.Add("$alt", "json;enum-encoding=int")
4756 if req.GetOptions().GetRequestedPolicyVersion() != 0 {
4757 params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
4758 }
4759
4760 baseUrl.RawQuery = params.Encode()
4761
4762 // Build HTTP headers from client and context metadata.
4763 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4764
4765 hds = append(c.xGoogHeaders, hds...)
4766 hds = append(hds, "Content-Type", "application/json")
4767 headers := gax.BuildHeaders(ctx, hds...)
4768 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
4769 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4770 resp := &iampb.Policy{}
4771 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4772 if settings.Path != "" {
4773 baseUrl.Path = settings.Path
4774 }
4775 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4776 if err != nil {
4777 return err
4778 }
4779 httpReq = httpReq.WithContext(ctx)
4780 httpReq.Header = headers
4781
4782 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
4783 if err != nil {
4784 return err
4785 }
4786
4787 if err := unm.Unmarshal(buf, resp); err != nil {
4788 return err
4789 }
4790
4791 return nil
4792 }, opts...)
4793 if e != nil {
4794 return nil, e
4795 }
4796 return resp, nil
4797 }
4798
4799 // TestIamPermissions tests if the caller has a list of permissions on a resource.
4800 func (c *restClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
4801 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4802 jsonReq, err := m.Marshal(req)
4803 if err != nil {
4804 return nil, err
4805 }
4806
4807 baseUrl, err := url.Parse(c.endpoint)
4808 if err != nil {
4809 return nil, err
4810 }
4811 baseUrl.Path += fmt.Sprintf("/v1/%v:testIamPermissions", req.GetResource())
4812
4813 params := url.Values{}
4814 params.Add("$alt", "json;enum-encoding=int")
4815
4816 baseUrl.RawQuery = params.Encode()
4817
4818 // Build HTTP headers from client and context metadata.
4819 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4820
4821 hds = append(c.xGoogHeaders, hds...)
4822 hds = append(hds, "Content-Type", "application/json")
4823 headers := gax.BuildHeaders(ctx, hds...)
4824 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
4825 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4826 resp := &iampb.TestIamPermissionsResponse{}
4827 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4828 if settings.Path != "" {
4829 baseUrl.Path = settings.Path
4830 }
4831 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4832 if err != nil {
4833 return err
4834 }
4835 httpReq = httpReq.WithContext(ctx)
4836 httpReq.Header = headers
4837
4838 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
4839 if err != nil {
4840 return err
4841 }
4842
4843 if err := unm.Unmarshal(buf, resp); err != nil {
4844 return err
4845 }
4846
4847 return nil
4848 }, opts...)
4849 if e != nil {
4850 return nil, e
4851 }
4852 return resp, nil
4853 }
4854
4855 // GetProjectSettings retrieves the Settings for the Project.
4856 func (c *restClient) GetProjectSettings(ctx context.Context, req *artifactregistrypb.GetProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
4857 baseUrl, err := url.Parse(c.endpoint)
4858 if err != nil {
4859 return nil, err
4860 }
4861 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4862
4863 params := url.Values{}
4864 params.Add("$alt", "json;enum-encoding=int")
4865
4866 baseUrl.RawQuery = params.Encode()
4867
4868 // Build HTTP headers from client and context metadata.
4869 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4870
4871 hds = append(c.xGoogHeaders, hds...)
4872 hds = append(hds, "Content-Type", "application/json")
4873 headers := gax.BuildHeaders(ctx, hds...)
4874 opts = append((*c.CallOptions).GetProjectSettings[0:len((*c.CallOptions).GetProjectSettings):len((*c.CallOptions).GetProjectSettings)], opts...)
4875 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4876 resp := &artifactregistrypb.ProjectSettings{}
4877 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4878 if settings.Path != "" {
4879 baseUrl.Path = settings.Path
4880 }
4881 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4882 if err != nil {
4883 return err
4884 }
4885 httpReq = httpReq.WithContext(ctx)
4886 httpReq.Header = headers
4887
4888 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetProjectSettings")
4889 if err != nil {
4890 return err
4891 }
4892
4893 if err := unm.Unmarshal(buf, resp); err != nil {
4894 return err
4895 }
4896
4897 return nil
4898 }, opts...)
4899 if e != nil {
4900 return nil, e
4901 }
4902 return resp, nil
4903 }
4904
4905 // UpdateProjectSettings updates the Settings for the Project.
4906 func (c *restClient) UpdateProjectSettings(ctx context.Context, req *artifactregistrypb.UpdateProjectSettingsRequest, opts ...gax.CallOption) (*artifactregistrypb.ProjectSettings, error) {
4907 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4908 body := req.GetProjectSettings()
4909 jsonReq, err := m.Marshal(body)
4910 if err != nil {
4911 return nil, err
4912 }
4913
4914 baseUrl, err := url.Parse(c.endpoint)
4915 if err != nil {
4916 return nil, err
4917 }
4918 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetProjectSettings().GetName())
4919
4920 params := url.Values{}
4921 params.Add("$alt", "json;enum-encoding=int")
4922 if req.GetUpdateMask() != nil {
4923 field, err := protojson.Marshal(req.GetUpdateMask())
4924 if err != nil {
4925 return nil, err
4926 }
4927 params.Add("updateMask", string(field[1:len(field)-1]))
4928 }
4929
4930 baseUrl.RawQuery = params.Encode()
4931
4932 // Build HTTP headers from client and context metadata.
4933 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "project_settings.name", url.QueryEscape(req.GetProjectSettings().GetName()))}
4934
4935 hds = append(c.xGoogHeaders, hds...)
4936 hds = append(hds, "Content-Type", "application/json")
4937 headers := gax.BuildHeaders(ctx, hds...)
4938 opts = append((*c.CallOptions).UpdateProjectSettings[0:len((*c.CallOptions).UpdateProjectSettings):len((*c.CallOptions).UpdateProjectSettings)], opts...)
4939 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4940 resp := &artifactregistrypb.ProjectSettings{}
4941 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4942 if settings.Path != "" {
4943 baseUrl.Path = settings.Path
4944 }
4945 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
4946 if err != nil {
4947 return err
4948 }
4949 httpReq = httpReq.WithContext(ctx)
4950 httpReq.Header = headers
4951
4952 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateProjectSettings")
4953 if err != nil {
4954 return err
4955 }
4956
4957 if err := unm.Unmarshal(buf, resp); err != nil {
4958 return err
4959 }
4960
4961 return nil
4962 }, opts...)
4963 if e != nil {
4964 return nil, e
4965 }
4966 return resp, nil
4967 }
4968
4969 // GetVPCSCConfig retrieves the VPCSC Config for the Project.
4970 func (c *restClient) GetVPCSCConfig(ctx context.Context, req *artifactregistrypb.GetVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
4971 baseUrl, err := url.Parse(c.endpoint)
4972 if err != nil {
4973 return nil, err
4974 }
4975 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4976
4977 params := url.Values{}
4978 params.Add("$alt", "json;enum-encoding=int")
4979
4980 baseUrl.RawQuery = params.Encode()
4981
4982 // Build HTTP headers from client and context metadata.
4983 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4984
4985 hds = append(c.xGoogHeaders, hds...)
4986 hds = append(hds, "Content-Type", "application/json")
4987 headers := gax.BuildHeaders(ctx, hds...)
4988 opts = append((*c.CallOptions).GetVPCSCConfig[0:len((*c.CallOptions).GetVPCSCConfig):len((*c.CallOptions).GetVPCSCConfig)], opts...)
4989 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4990 resp := &artifactregistrypb.VPCSCConfig{}
4991 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4992 if settings.Path != "" {
4993 baseUrl.Path = settings.Path
4994 }
4995 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4996 if err != nil {
4997 return err
4998 }
4999 httpReq = httpReq.WithContext(ctx)
5000 httpReq.Header = headers
5001
5002 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetVPCSCConfig")
5003 if err != nil {
5004 return err
5005 }
5006
5007 if err := unm.Unmarshal(buf, resp); err != nil {
5008 return err
5009 }
5010
5011 return nil
5012 }, opts...)
5013 if e != nil {
5014 return nil, e
5015 }
5016 return resp, nil
5017 }
5018
5019 // UpdateVPCSCConfig updates the VPCSC Config for the Project.
5020 func (c *restClient) UpdateVPCSCConfig(ctx context.Context, req *artifactregistrypb.UpdateVPCSCConfigRequest, opts ...gax.CallOption) (*artifactregistrypb.VPCSCConfig, error) {
5021 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5022 body := req.GetVpcscConfig()
5023 jsonReq, err := m.Marshal(body)
5024 if err != nil {
5025 return nil, err
5026 }
5027
5028 baseUrl, err := url.Parse(c.endpoint)
5029 if err != nil {
5030 return nil, err
5031 }
5032 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetVpcscConfig().GetName())
5033
5034 params := url.Values{}
5035 params.Add("$alt", "json;enum-encoding=int")
5036 if req.GetUpdateMask() != nil {
5037 field, err := protojson.Marshal(req.GetUpdateMask())
5038 if err != nil {
5039 return nil, err
5040 }
5041 params.Add("updateMask", string(field[1:len(field)-1]))
5042 }
5043
5044 baseUrl.RawQuery = params.Encode()
5045
5046 // Build HTTP headers from client and context metadata.
5047 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "vpcsc_config.name", url.QueryEscape(req.GetVpcscConfig().GetName()))}
5048
5049 hds = append(c.xGoogHeaders, hds...)
5050 hds = append(hds, "Content-Type", "application/json")
5051 headers := gax.BuildHeaders(ctx, hds...)
5052 opts = append((*c.CallOptions).UpdateVPCSCConfig[0:len((*c.CallOptions).UpdateVPCSCConfig):len((*c.CallOptions).UpdateVPCSCConfig)], opts...)
5053 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5054 resp := &artifactregistrypb.VPCSCConfig{}
5055 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5056 if settings.Path != "" {
5057 baseUrl.Path = settings.Path
5058 }
5059 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
5060 if err != nil {
5061 return err
5062 }
5063 httpReq = httpReq.WithContext(ctx)
5064 httpReq.Header = headers
5065
5066 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateVPCSCConfig")
5067 if err != nil {
5068 return err
5069 }
5070
5071 if err := unm.Unmarshal(buf, resp); err != nil {
5072 return err
5073 }
5074
5075 return nil
5076 }, opts...)
5077 if e != nil {
5078 return nil, e
5079 }
5080 return resp, nil
5081 }
5082
5083 // UpdatePackage updates a package.
5084 func (c *restClient) UpdatePackage(ctx context.Context, req *artifactregistrypb.UpdatePackageRequest, opts ...gax.CallOption) (*artifactregistrypb.Package, error) {
5085 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5086 body := req.GetPackage()
5087 jsonReq, err := m.Marshal(body)
5088 if err != nil {
5089 return nil, err
5090 }
5091
5092 baseUrl, err := url.Parse(c.endpoint)
5093 if err != nil {
5094 return nil, err
5095 }
5096 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetPackage().GetName())
5097
5098 params := url.Values{}
5099 params.Add("$alt", "json;enum-encoding=int")
5100 if req.GetUpdateMask() != nil {
5101 field, err := protojson.Marshal(req.GetUpdateMask())
5102 if err != nil {
5103 return nil, err
5104 }
5105 params.Add("updateMask", string(field[1:len(field)-1]))
5106 }
5107
5108 baseUrl.RawQuery = params.Encode()
5109
5110 // Build HTTP headers from client and context metadata.
5111 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "package.name", url.QueryEscape(req.GetPackage().GetName()))}
5112
5113 hds = append(c.xGoogHeaders, hds...)
5114 hds = append(hds, "Content-Type", "application/json")
5115 headers := gax.BuildHeaders(ctx, hds...)
5116 opts = append((*c.CallOptions).UpdatePackage[0:len((*c.CallOptions).UpdatePackage):len((*c.CallOptions).UpdatePackage)], opts...)
5117 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5118 resp := &artifactregistrypb.Package{}
5119 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5120 if settings.Path != "" {
5121 baseUrl.Path = settings.Path
5122 }
5123 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
5124 if err != nil {
5125 return err
5126 }
5127 httpReq = httpReq.WithContext(ctx)
5128 httpReq.Header = headers
5129
5130 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdatePackage")
5131 if err != nil {
5132 return err
5133 }
5134
5135 if err := unm.Unmarshal(buf, resp); err != nil {
5136 return err
5137 }
5138
5139 return nil
5140 }, opts...)
5141 if e != nil {
5142 return nil, e
5143 }
5144 return resp, nil
5145 }
5146
5147 // ListAttachments lists attachments.
5148 func (c *restClient) ListAttachments(ctx context.Context, req *artifactregistrypb.ListAttachmentsRequest, opts ...gax.CallOption) *AttachmentIterator {
5149 it := &AttachmentIterator{}
5150 req = proto.Clone(req).(*artifactregistrypb.ListAttachmentsRequest)
5151 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5152 it.InternalFetch = func(pageSize int, pageToken string) ([]*artifactregistrypb.Attachment, string, error) {
5153 resp := &artifactregistrypb.ListAttachmentsResponse{}
5154 if pageToken != "" {
5155 req.PageToken = pageToken
5156 }
5157 if pageSize > math.MaxInt32 {
5158 req.PageSize = math.MaxInt32
5159 } else if pageSize != 0 {
5160 req.PageSize = int32(pageSize)
5161 }
5162 baseUrl, err := url.Parse(c.endpoint)
5163 if err != nil {
5164 return nil, "", err
5165 }
5166 baseUrl.Path += fmt.Sprintf("/v1/%v/attachments", req.GetParent())
5167
5168 params := url.Values{}
5169 params.Add("$alt", "json;enum-encoding=int")
5170 if req.GetFilter() != "" {
5171 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
5172 }
5173 if req.GetPageSize() != 0 {
5174 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
5175 }
5176 if req.GetPageToken() != "" {
5177 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
5178 }
5179
5180 baseUrl.RawQuery = params.Encode()
5181
5182 // Build HTTP headers from client and context metadata.
5183 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
5184 headers := gax.BuildHeaders(ctx, hds...)
5185 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5186 if settings.Path != "" {
5187 baseUrl.Path = settings.Path
5188 }
5189 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5190 if err != nil {
5191 return err
5192 }
5193 httpReq.Header = headers
5194
5195 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListAttachments")
5196 if err != nil {
5197 return err
5198 }
5199 if err := unm.Unmarshal(buf, resp); err != nil {
5200 return err
5201 }
5202
5203 return nil
5204 }, opts...)
5205 if e != nil {
5206 return nil, "", e
5207 }
5208 it.Response = resp
5209 return resp.GetAttachments(), resp.GetNextPageToken(), nil
5210 }
5211
5212 fetch := func(pageSize int, pageToken string) (string, error) {
5213 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
5214 if err != nil {
5215 return "", err
5216 }
5217 it.items = append(it.items, items...)
5218 return nextPageToken, nil
5219 }
5220
5221 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5222 it.pageInfo.MaxSize = int(req.GetPageSize())
5223 it.pageInfo.Token = req.GetPageToken()
5224
5225 return it
5226 }
5227
5228 // GetAttachment gets an attachment.
5229 func (c *restClient) GetAttachment(ctx context.Context, req *artifactregistrypb.GetAttachmentRequest, opts ...gax.CallOption) (*artifactregistrypb.Attachment, error) {
5230 baseUrl, err := url.Parse(c.endpoint)
5231 if err != nil {
5232 return nil, err
5233 }
5234 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5235
5236 params := url.Values{}
5237 params.Add("$alt", "json;enum-encoding=int")
5238
5239 baseUrl.RawQuery = params.Encode()
5240
5241 // Build HTTP headers from client and context metadata.
5242 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5243
5244 hds = append(c.xGoogHeaders, hds...)
5245 hds = append(hds, "Content-Type", "application/json")
5246 headers := gax.BuildHeaders(ctx, hds...)
5247 opts = append((*c.CallOptions).GetAttachment[0:len((*c.CallOptions).GetAttachment):len((*c.CallOptions).GetAttachment)], opts...)
5248 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5249 resp := &artifactregistrypb.Attachment{}
5250 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5251 if settings.Path != "" {
5252 baseUrl.Path = settings.Path
5253 }
5254 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5255 if err != nil {
5256 return err
5257 }
5258 httpReq = httpReq.WithContext(ctx)
5259 httpReq.Header = headers
5260
5261 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetAttachment")
5262 if err != nil {
5263 return err
5264 }
5265
5266 if err := unm.Unmarshal(buf, resp); err != nil {
5267 return err
5268 }
5269
5270 return nil
5271 }, opts...)
5272 if e != nil {
5273 return nil, e
5274 }
5275 return resp, nil
5276 }
5277
5278 // CreateAttachment creates an attachment. The returned Operation will finish once the
5279 // attachment has been created. Its response will be the created attachment.
5280 func (c *restClient) CreateAttachment(ctx context.Context, req *artifactregistrypb.CreateAttachmentRequest, opts ...gax.CallOption) (*CreateAttachmentOperation, error) {
5281 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
5282 body := req.GetAttachment()
5283 jsonReq, err := m.Marshal(body)
5284 if err != nil {
5285 return nil, err
5286 }
5287
5288 baseUrl, err := url.Parse(c.endpoint)
5289 if err != nil {
5290 return nil, err
5291 }
5292 baseUrl.Path += fmt.Sprintf("/v1/%v/attachments", req.GetParent())
5293
5294 params := url.Values{}
5295 params.Add("$alt", "json;enum-encoding=int")
5296 params.Add("attachmentId", fmt.Sprintf("%v", req.GetAttachmentId()))
5297
5298 baseUrl.RawQuery = params.Encode()
5299
5300 // Build HTTP headers from client and context metadata.
5301 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
5302
5303 hds = append(c.xGoogHeaders, hds...)
5304 hds = append(hds, "Content-Type", "application/json")
5305 headers := gax.BuildHeaders(ctx, hds...)
5306 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5307 resp := &longrunningpb.Operation{}
5308 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5309 if settings.Path != "" {
5310 baseUrl.Path = settings.Path
5311 }
5312 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
5313 if err != nil {
5314 return err
5315 }
5316 httpReq = httpReq.WithContext(ctx)
5317 httpReq.Header = headers
5318
5319 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateAttachment")
5320 if err != nil {
5321 return err
5322 }
5323 if err := unm.Unmarshal(buf, resp); err != nil {
5324 return err
5325 }
5326
5327 return nil
5328 }, opts...)
5329 if e != nil {
5330 return nil, e
5331 }
5332
5333 override := fmt.Sprintf("/v1/%s", resp.GetName())
5334 return &CreateAttachmentOperation{
5335 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
5336 pollPath: override,
5337 }, nil
5338 }
5339
5340 // DeleteAttachment deletes an attachment. The returned Operation will
5341 // finish once the attachments has been deleted. It will not have any
5342 // Operation metadata and will return a google.protobuf.Empty response.
5343 func (c *restClient) DeleteAttachment(ctx context.Context, req *artifactregistrypb.DeleteAttachmentRequest, opts ...gax.CallOption) (*DeleteAttachmentOperation, error) {
5344 baseUrl, err := url.Parse(c.endpoint)
5345 if err != nil {
5346 return nil, err
5347 }
5348 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5349
5350 params := url.Values{}
5351 params.Add("$alt", "json;enum-encoding=int")
5352
5353 baseUrl.RawQuery = params.Encode()
5354
5355 // Build HTTP headers from client and context metadata.
5356 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5357
5358 hds = append(c.xGoogHeaders, hds...)
5359 hds = append(hds, "Content-Type", "application/json")
5360 headers := gax.BuildHeaders(ctx, hds...)
5361 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5362 resp := &longrunningpb.Operation{}
5363 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5364 if settings.Path != "" {
5365 baseUrl.Path = settings.Path
5366 }
5367 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
5368 if err != nil {
5369 return err
5370 }
5371 httpReq = httpReq.WithContext(ctx)
5372 httpReq.Header = headers
5373
5374 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteAttachment")
5375 if err != nil {
5376 return err
5377 }
5378 if err := unm.Unmarshal(buf, resp); err != nil {
5379 return err
5380 }
5381
5382 return nil
5383 }, opts...)
5384 if e != nil {
5385 return nil, e
5386 }
5387
5388 override := fmt.Sprintf("/v1/%s", resp.GetName())
5389 return &DeleteAttachmentOperation{
5390 lro: longrunning.InternalNewOperation(*c.LROClient, resp),
5391 pollPath: override,
5392 }, nil
5393 }
5394
5395 // GetLocation gets information about a location.
5396 func (c *restClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
5397 baseUrl, err := url.Parse(c.endpoint)
5398 if err != nil {
5399 return nil, err
5400 }
5401 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5402
5403 params := url.Values{}
5404 params.Add("$alt", "json;enum-encoding=int")
5405
5406 baseUrl.RawQuery = params.Encode()
5407
5408 // Build HTTP headers from client and context metadata.
5409 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5410
5411 hds = append(c.xGoogHeaders, hds...)
5412 hds = append(hds, "Content-Type", "application/json")
5413 headers := gax.BuildHeaders(ctx, hds...)
5414 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
5415 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5416 resp := &locationpb.Location{}
5417 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5418 if settings.Path != "" {
5419 baseUrl.Path = settings.Path
5420 }
5421 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5422 if err != nil {
5423 return err
5424 }
5425 httpReq = httpReq.WithContext(ctx)
5426 httpReq.Header = headers
5427
5428 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
5429 if err != nil {
5430 return err
5431 }
5432
5433 if err := unm.Unmarshal(buf, resp); err != nil {
5434 return err
5435 }
5436
5437 return nil
5438 }, opts...)
5439 if e != nil {
5440 return nil, e
5441 }
5442 return resp, nil
5443 }
5444
5445 // ListLocations lists information about the supported locations for this service.
5446 func (c *restClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
5447 it := &LocationIterator{}
5448 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
5449 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5450 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
5451 resp := &locationpb.ListLocationsResponse{}
5452 if pageToken != "" {
5453 req.PageToken = pageToken
5454 }
5455 if pageSize > math.MaxInt32 {
5456 req.PageSize = math.MaxInt32
5457 } else if pageSize != 0 {
5458 req.PageSize = int32(pageSize)
5459 }
5460 baseUrl, err := url.Parse(c.endpoint)
5461 if err != nil {
5462 return nil, "", err
5463 }
5464 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
5465
5466 params := url.Values{}
5467 params.Add("$alt", "json;enum-encoding=int")
5468 if req.GetFilter() != "" {
5469 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
5470 }
5471 if req.GetPageSize() != 0 {
5472 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
5473 }
5474 if req.GetPageToken() != "" {
5475 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
5476 }
5477
5478 baseUrl.RawQuery = params.Encode()
5479
5480 // Build HTTP headers from client and context metadata.
5481 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
5482 headers := gax.BuildHeaders(ctx, hds...)
5483 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5484 if settings.Path != "" {
5485 baseUrl.Path = settings.Path
5486 }
5487 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5488 if err != nil {
5489 return err
5490 }
5491 httpReq.Header = headers
5492
5493 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
5494 if err != nil {
5495 return err
5496 }
5497 if err := unm.Unmarshal(buf, resp); err != nil {
5498 return err
5499 }
5500
5501 return nil
5502 }, opts...)
5503 if e != nil {
5504 return nil, "", e
5505 }
5506 it.Response = resp
5507 return resp.GetLocations(), resp.GetNextPageToken(), nil
5508 }
5509
5510 fetch := func(pageSize int, pageToken string) (string, error) {
5511 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
5512 if err != nil {
5513 return "", err
5514 }
5515 it.items = append(it.items, items...)
5516 return nextPageToken, nil
5517 }
5518
5519 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
5520 it.pageInfo.MaxSize = int(req.GetPageSize())
5521 it.pageInfo.Token = req.GetPageToken()
5522
5523 return it
5524 }
5525
5526 // GetOperation is a utility method from google.longrunning.Operations.
5527 func (c *restClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
5528 baseUrl, err := url.Parse(c.endpoint)
5529 if err != nil {
5530 return nil, err
5531 }
5532 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
5533
5534 params := url.Values{}
5535 params.Add("$alt", "json;enum-encoding=int")
5536
5537 baseUrl.RawQuery = params.Encode()
5538
5539 // Build HTTP headers from client and context metadata.
5540 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
5541
5542 hds = append(c.xGoogHeaders, hds...)
5543 hds = append(hds, "Content-Type", "application/json")
5544 headers := gax.BuildHeaders(ctx, hds...)
5545 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
5546 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
5547 resp := &longrunningpb.Operation{}
5548 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
5549 if settings.Path != "" {
5550 baseUrl.Path = settings.Path
5551 }
5552 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
5553 if err != nil {
5554 return err
5555 }
5556 httpReq = httpReq.WithContext(ctx)
5557 httpReq.Header = headers
5558
5559 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
5560 if err != nil {
5561 return err
5562 }
5563
5564 if err := unm.Unmarshal(buf, resp); err != nil {
5565 return err
5566 }
5567
5568 return nil
5569 }, opts...)
5570 if e != nil {
5571 return nil, e
5572 }
5573 return resp, nil
5574 }
5575
5576 // BatchDeleteVersionsOperation returns a new BatchDeleteVersionsOperation from a given name.
5577 // The name must be that of a previously created BatchDeleteVersionsOperation, possibly from a different process.
5578 func (c *gRPCClient) BatchDeleteVersionsOperation(name string) *BatchDeleteVersionsOperation {
5579 return &BatchDeleteVersionsOperation{
5580 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5581 }
5582 }
5583
5584 // BatchDeleteVersionsOperation returns a new BatchDeleteVersionsOperation from a given name.
5585 // The name must be that of a previously created BatchDeleteVersionsOperation, possibly from a different process.
5586 func (c *restClient) BatchDeleteVersionsOperation(name string) *BatchDeleteVersionsOperation {
5587 override := fmt.Sprintf("/v1/%s", name)
5588 return &BatchDeleteVersionsOperation{
5589 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5590 pollPath: override,
5591 }
5592 }
5593
5594 // CreateAttachmentOperation returns a new CreateAttachmentOperation from a given name.
5595 // The name must be that of a previously created CreateAttachmentOperation, possibly from a different process.
5596 func (c *gRPCClient) CreateAttachmentOperation(name string) *CreateAttachmentOperation {
5597 return &CreateAttachmentOperation{
5598 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5599 }
5600 }
5601
5602 // CreateAttachmentOperation returns a new CreateAttachmentOperation from a given name.
5603 // The name must be that of a previously created CreateAttachmentOperation, possibly from a different process.
5604 func (c *restClient) CreateAttachmentOperation(name string) *CreateAttachmentOperation {
5605 override := fmt.Sprintf("/v1/%s", name)
5606 return &CreateAttachmentOperation{
5607 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5608 pollPath: override,
5609 }
5610 }
5611
5612 // CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
5613 // The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
5614 func (c *gRPCClient) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
5615 return &CreateRepositoryOperation{
5616 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5617 }
5618 }
5619
5620 // CreateRepositoryOperation returns a new CreateRepositoryOperation from a given name.
5621 // The name must be that of a previously created CreateRepositoryOperation, possibly from a different process.
5622 func (c *restClient) CreateRepositoryOperation(name string) *CreateRepositoryOperation {
5623 override := fmt.Sprintf("/v1/%s", name)
5624 return &CreateRepositoryOperation{
5625 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5626 pollPath: override,
5627 }
5628 }
5629
5630 // DeleteAttachmentOperation returns a new DeleteAttachmentOperation from a given name.
5631 // The name must be that of a previously created DeleteAttachmentOperation, possibly from a different process.
5632 func (c *gRPCClient) DeleteAttachmentOperation(name string) *DeleteAttachmentOperation {
5633 return &DeleteAttachmentOperation{
5634 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5635 }
5636 }
5637
5638 // DeleteAttachmentOperation returns a new DeleteAttachmentOperation from a given name.
5639 // The name must be that of a previously created DeleteAttachmentOperation, possibly from a different process.
5640 func (c *restClient) DeleteAttachmentOperation(name string) *DeleteAttachmentOperation {
5641 override := fmt.Sprintf("/v1/%s", name)
5642 return &DeleteAttachmentOperation{
5643 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5644 pollPath: override,
5645 }
5646 }
5647
5648 // DeleteFileOperation returns a new DeleteFileOperation from a given name.
5649 // The name must be that of a previously created DeleteFileOperation, possibly from a different process.
5650 func (c *gRPCClient) DeleteFileOperation(name string) *DeleteFileOperation {
5651 return &DeleteFileOperation{
5652 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5653 }
5654 }
5655
5656 // DeleteFileOperation returns a new DeleteFileOperation from a given name.
5657 // The name must be that of a previously created DeleteFileOperation, possibly from a different process.
5658 func (c *restClient) DeleteFileOperation(name string) *DeleteFileOperation {
5659 override := fmt.Sprintf("/v1/%s", name)
5660 return &DeleteFileOperation{
5661 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5662 pollPath: override,
5663 }
5664 }
5665
5666 // DeletePackageOperation returns a new DeletePackageOperation from a given name.
5667 // The name must be that of a previously created DeletePackageOperation, possibly from a different process.
5668 func (c *gRPCClient) DeletePackageOperation(name string) *DeletePackageOperation {
5669 return &DeletePackageOperation{
5670 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5671 }
5672 }
5673
5674 // DeletePackageOperation returns a new DeletePackageOperation from a given name.
5675 // The name must be that of a previously created DeletePackageOperation, possibly from a different process.
5676 func (c *restClient) DeletePackageOperation(name string) *DeletePackageOperation {
5677 override := fmt.Sprintf("/v1/%s", name)
5678 return &DeletePackageOperation{
5679 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5680 pollPath: override,
5681 }
5682 }
5683
5684 // DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
5685 // The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
5686 func (c *gRPCClient) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
5687 return &DeleteRepositoryOperation{
5688 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5689 }
5690 }
5691
5692 // DeleteRepositoryOperation returns a new DeleteRepositoryOperation from a given name.
5693 // The name must be that of a previously created DeleteRepositoryOperation, possibly from a different process.
5694 func (c *restClient) DeleteRepositoryOperation(name string) *DeleteRepositoryOperation {
5695 override := fmt.Sprintf("/v1/%s", name)
5696 return &DeleteRepositoryOperation{
5697 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5698 pollPath: override,
5699 }
5700 }
5701
5702 // DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
5703 // The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
5704 func (c *gRPCClient) DeleteVersionOperation(name string) *DeleteVersionOperation {
5705 return &DeleteVersionOperation{
5706 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5707 }
5708 }
5709
5710 // DeleteVersionOperation returns a new DeleteVersionOperation from a given name.
5711 // The name must be that of a previously created DeleteVersionOperation, possibly from a different process.
5712 func (c *restClient) DeleteVersionOperation(name string) *DeleteVersionOperation {
5713 override := fmt.Sprintf("/v1/%s", name)
5714 return &DeleteVersionOperation{
5715 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5716 pollPath: override,
5717 }
5718 }
5719
5720 // ImportAptArtifactsOperation returns a new ImportAptArtifactsOperation from a given name.
5721 // The name must be that of a previously created ImportAptArtifactsOperation, possibly from a different process.
5722 func (c *gRPCClient) ImportAptArtifactsOperation(name string) *ImportAptArtifactsOperation {
5723 return &ImportAptArtifactsOperation{
5724 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5725 }
5726 }
5727
5728 // ImportAptArtifactsOperation returns a new ImportAptArtifactsOperation from a given name.
5729 // The name must be that of a previously created ImportAptArtifactsOperation, possibly from a different process.
5730 func (c *restClient) ImportAptArtifactsOperation(name string) *ImportAptArtifactsOperation {
5731 override := fmt.Sprintf("/v1/%s", name)
5732 return &ImportAptArtifactsOperation{
5733 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5734 pollPath: override,
5735 }
5736 }
5737
5738 // ImportYumArtifactsOperation returns a new ImportYumArtifactsOperation from a given name.
5739 // The name must be that of a previously created ImportYumArtifactsOperation, possibly from a different process.
5740 func (c *gRPCClient) ImportYumArtifactsOperation(name string) *ImportYumArtifactsOperation {
5741 return &ImportYumArtifactsOperation{
5742 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5743 }
5744 }
5745
5746 // ImportYumArtifactsOperation returns a new ImportYumArtifactsOperation from a given name.
5747 // The name must be that of a previously created ImportYumArtifactsOperation, possibly from a different process.
5748 func (c *restClient) ImportYumArtifactsOperation(name string) *ImportYumArtifactsOperation {
5749 override := fmt.Sprintf("/v1/%s", name)
5750 return &ImportYumArtifactsOperation{
5751 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
5752 pollPath: override,
5753 }
5754 }