Debian Codegraph @

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