1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package kms
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "io"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 iampb "cloud.google.com/go/iam/apiv1/iampb"
30 kmspb "cloud.google.com/go/kms/apiv1/kmspb"
31 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
32 gax "github.com/googleapis/gax-go/v2"
33 "google.golang.org/api/googleapi"
34 "google.golang.org/api/iterator"
35 "google.golang.org/api/option"
36 "google.golang.org/api/option/internaloption"
37 gtransport "google.golang.org/api/transport/grpc"
38 httptransport "google.golang.org/api/transport/http"
39 locationpb "google.golang.org/genproto/googleapis/cloud/location"
40 "google.golang.org/grpc"
41 "google.golang.org/grpc/codes"
42 "google.golang.org/protobuf/encoding/protojson"
43 "google.golang.org/protobuf/proto"
44 )
45
46 var newKeyManagementClientHook clientHook
47
48
49 type KeyManagementCallOptions struct {
50 ListKeyRings []gax.CallOption
51 ListCryptoKeys []gax.CallOption
52 ListCryptoKeyVersions []gax.CallOption
53 ListImportJobs []gax.CallOption
54 GetKeyRing []gax.CallOption
55 GetCryptoKey []gax.CallOption
56 GetCryptoKeyVersion []gax.CallOption
57 GetPublicKey []gax.CallOption
58 GetImportJob []gax.CallOption
59 CreateKeyRing []gax.CallOption
60 CreateCryptoKey []gax.CallOption
61 CreateCryptoKeyVersion []gax.CallOption
62 ImportCryptoKeyVersion []gax.CallOption
63 CreateImportJob []gax.CallOption
64 UpdateCryptoKey []gax.CallOption
65 UpdateCryptoKeyVersion []gax.CallOption
66 UpdateCryptoKeyPrimaryVersion []gax.CallOption
67 DestroyCryptoKeyVersion []gax.CallOption
68 RestoreCryptoKeyVersion []gax.CallOption
69 Encrypt []gax.CallOption
70 Decrypt []gax.CallOption
71 RawEncrypt []gax.CallOption
72 RawDecrypt []gax.CallOption
73 AsymmetricSign []gax.CallOption
74 AsymmetricDecrypt []gax.CallOption
75 MacSign []gax.CallOption
76 MacVerify []gax.CallOption
77 GenerateRandomBytes []gax.CallOption
78 GetLocation []gax.CallOption
79 ListLocations []gax.CallOption
80 GetIamPolicy []gax.CallOption
81 SetIamPolicy []gax.CallOption
82 TestIamPermissions []gax.CallOption
83 GetOperation []gax.CallOption
84 }
85
86 func defaultKeyManagementGRPCClientOptions() []option.ClientOption {
87 return []option.ClientOption{
88 internaloption.WithDefaultEndpoint("cloudkms.googleapis.com:443"),
89 internaloption.WithDefaultEndpointTemplate("cloudkms.UNIVERSE_DOMAIN:443"),
90 internaloption.WithDefaultMTLSEndpoint("cloudkms.mtls.googleapis.com:443"),
91 internaloption.WithDefaultUniverseDomain("googleapis.com"),
92 internaloption.WithDefaultAudience("https://cloudkms.googleapis.com/"),
93 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
94 internaloption.EnableJwtWithScope(),
95 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
96 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
97 }
98 }
99
100 func defaultKeyManagementCallOptions() *KeyManagementCallOptions {
101 return &KeyManagementCallOptions{
102 ListKeyRings: []gax.CallOption{
103 gax.WithTimeout(60000 * time.Millisecond),
104 gax.WithRetry(func() gax.Retryer {
105 return gax.OnCodes([]codes.Code{
106 codes.Unavailable,
107 codes.DeadlineExceeded,
108 }, gax.Backoff{
109 Initial: 100 * time.Millisecond,
110 Max: 60000 * time.Millisecond,
111 Multiplier: 1.30,
112 })
113 }),
114 },
115 ListCryptoKeys: []gax.CallOption{
116 gax.WithTimeout(60000 * time.Millisecond),
117 gax.WithRetry(func() gax.Retryer {
118 return gax.OnCodes([]codes.Code{
119 codes.Unavailable,
120 codes.DeadlineExceeded,
121 }, gax.Backoff{
122 Initial: 100 * time.Millisecond,
123 Max: 60000 * time.Millisecond,
124 Multiplier: 1.30,
125 })
126 }),
127 },
128 ListCryptoKeyVersions: []gax.CallOption{
129 gax.WithTimeout(60000 * time.Millisecond),
130 gax.WithRetry(func() gax.Retryer {
131 return gax.OnCodes([]codes.Code{
132 codes.Unavailable,
133 codes.DeadlineExceeded,
134 }, gax.Backoff{
135 Initial: 100 * time.Millisecond,
136 Max: 60000 * time.Millisecond,
137 Multiplier: 1.30,
138 })
139 }),
140 },
141 ListImportJobs: []gax.CallOption{
142 gax.WithTimeout(60000 * time.Millisecond),
143 gax.WithRetry(func() gax.Retryer {
144 return gax.OnCodes([]codes.Code{
145 codes.Unavailable,
146 codes.DeadlineExceeded,
147 }, gax.Backoff{
148 Initial: 100 * time.Millisecond,
149 Max: 60000 * time.Millisecond,
150 Multiplier: 1.30,
151 })
152 }),
153 },
154 GetKeyRing: []gax.CallOption{
155 gax.WithTimeout(60000 * time.Millisecond),
156 gax.WithRetry(func() gax.Retryer {
157 return gax.OnCodes([]codes.Code{
158 codes.Unavailable,
159 codes.DeadlineExceeded,
160 }, gax.Backoff{
161 Initial: 100 * time.Millisecond,
162 Max: 60000 * time.Millisecond,
163 Multiplier: 1.30,
164 })
165 }),
166 },
167 GetCryptoKey: []gax.CallOption{
168 gax.WithTimeout(60000 * time.Millisecond),
169 gax.WithRetry(func() gax.Retryer {
170 return gax.OnCodes([]codes.Code{
171 codes.Unavailable,
172 codes.DeadlineExceeded,
173 }, gax.Backoff{
174 Initial: 100 * time.Millisecond,
175 Max: 60000 * time.Millisecond,
176 Multiplier: 1.30,
177 })
178 }),
179 },
180 GetCryptoKeyVersion: []gax.CallOption{
181 gax.WithTimeout(60000 * time.Millisecond),
182 gax.WithRetry(func() gax.Retryer {
183 return gax.OnCodes([]codes.Code{
184 codes.Unavailable,
185 codes.DeadlineExceeded,
186 }, gax.Backoff{
187 Initial: 100 * time.Millisecond,
188 Max: 60000 * time.Millisecond,
189 Multiplier: 1.30,
190 })
191 }),
192 },
193 GetPublicKey: []gax.CallOption{
194 gax.WithTimeout(60000 * time.Millisecond),
195 gax.WithRetry(func() gax.Retryer {
196 return gax.OnCodes([]codes.Code{
197 codes.Unavailable,
198 codes.DeadlineExceeded,
199 }, gax.Backoff{
200 Initial: 100 * time.Millisecond,
201 Max: 60000 * time.Millisecond,
202 Multiplier: 1.30,
203 })
204 }),
205 },
206 GetImportJob: []gax.CallOption{
207 gax.WithTimeout(60000 * time.Millisecond),
208 gax.WithRetry(func() gax.Retryer {
209 return gax.OnCodes([]codes.Code{
210 codes.Unavailable,
211 codes.DeadlineExceeded,
212 }, gax.Backoff{
213 Initial: 100 * time.Millisecond,
214 Max: 60000 * time.Millisecond,
215 Multiplier: 1.30,
216 })
217 }),
218 },
219 CreateKeyRing: []gax.CallOption{
220 gax.WithTimeout(60000 * time.Millisecond),
221 gax.WithRetry(func() gax.Retryer {
222 return gax.OnCodes([]codes.Code{
223 codes.Unavailable,
224 codes.DeadlineExceeded,
225 }, gax.Backoff{
226 Initial: 100 * time.Millisecond,
227 Max: 60000 * time.Millisecond,
228 Multiplier: 1.30,
229 })
230 }),
231 },
232 CreateCryptoKey: []gax.CallOption{
233 gax.WithTimeout(60000 * time.Millisecond),
234 gax.WithRetry(func() gax.Retryer {
235 return gax.OnCodes([]codes.Code{
236 codes.Unavailable,
237 codes.DeadlineExceeded,
238 }, gax.Backoff{
239 Initial: 100 * time.Millisecond,
240 Max: 60000 * time.Millisecond,
241 Multiplier: 1.30,
242 })
243 }),
244 },
245 CreateCryptoKeyVersion: []gax.CallOption{
246 gax.WithTimeout(60000 * time.Millisecond),
247 },
248 ImportCryptoKeyVersion: []gax.CallOption{
249 gax.WithTimeout(60000 * time.Millisecond),
250 },
251 CreateImportJob: []gax.CallOption{
252 gax.WithTimeout(60000 * time.Millisecond),
253 gax.WithRetry(func() gax.Retryer {
254 return gax.OnCodes([]codes.Code{
255 codes.Unavailable,
256 codes.DeadlineExceeded,
257 }, gax.Backoff{
258 Initial: 100 * time.Millisecond,
259 Max: 60000 * time.Millisecond,
260 Multiplier: 1.30,
261 })
262 }),
263 },
264 UpdateCryptoKey: []gax.CallOption{
265 gax.WithTimeout(60000 * time.Millisecond),
266 gax.WithRetry(func() gax.Retryer {
267 return gax.OnCodes([]codes.Code{
268 codes.Unavailable,
269 codes.DeadlineExceeded,
270 }, gax.Backoff{
271 Initial: 100 * time.Millisecond,
272 Max: 60000 * time.Millisecond,
273 Multiplier: 1.30,
274 })
275 }),
276 },
277 UpdateCryptoKeyVersion: []gax.CallOption{
278 gax.WithTimeout(60000 * time.Millisecond),
279 gax.WithRetry(func() gax.Retryer {
280 return gax.OnCodes([]codes.Code{
281 codes.Unavailable,
282 codes.DeadlineExceeded,
283 }, gax.Backoff{
284 Initial: 100 * time.Millisecond,
285 Max: 60000 * time.Millisecond,
286 Multiplier: 1.30,
287 })
288 }),
289 },
290 UpdateCryptoKeyPrimaryVersion: []gax.CallOption{
291 gax.WithTimeout(60000 * time.Millisecond),
292 gax.WithRetry(func() gax.Retryer {
293 return gax.OnCodes([]codes.Code{
294 codes.Unavailable,
295 codes.DeadlineExceeded,
296 }, gax.Backoff{
297 Initial: 100 * time.Millisecond,
298 Max: 60000 * time.Millisecond,
299 Multiplier: 1.30,
300 })
301 }),
302 },
303 DestroyCryptoKeyVersion: []gax.CallOption{
304 gax.WithTimeout(60000 * time.Millisecond),
305 gax.WithRetry(func() gax.Retryer {
306 return gax.OnCodes([]codes.Code{
307 codes.Unavailable,
308 codes.DeadlineExceeded,
309 }, gax.Backoff{
310 Initial: 100 * time.Millisecond,
311 Max: 60000 * time.Millisecond,
312 Multiplier: 1.30,
313 })
314 }),
315 },
316 RestoreCryptoKeyVersion: []gax.CallOption{
317 gax.WithTimeout(60000 * time.Millisecond),
318 gax.WithRetry(func() gax.Retryer {
319 return gax.OnCodes([]codes.Code{
320 codes.Unavailable,
321 codes.DeadlineExceeded,
322 }, gax.Backoff{
323 Initial: 100 * time.Millisecond,
324 Max: 60000 * time.Millisecond,
325 Multiplier: 1.30,
326 })
327 }),
328 },
329 Encrypt: []gax.CallOption{
330 gax.WithTimeout(60000 * time.Millisecond),
331 gax.WithRetry(func() gax.Retryer {
332 return gax.OnCodes([]codes.Code{
333 codes.Unavailable,
334 codes.DeadlineExceeded,
335 }, gax.Backoff{
336 Initial: 100 * time.Millisecond,
337 Max: 60000 * time.Millisecond,
338 Multiplier: 1.30,
339 })
340 }),
341 },
342 Decrypt: []gax.CallOption{
343 gax.WithTimeout(60000 * time.Millisecond),
344 gax.WithRetry(func() gax.Retryer {
345 return gax.OnCodes([]codes.Code{
346 codes.Unavailable,
347 codes.DeadlineExceeded,
348 }, gax.Backoff{
349 Initial: 100 * time.Millisecond,
350 Max: 60000 * time.Millisecond,
351 Multiplier: 1.30,
352 })
353 }),
354 },
355 RawEncrypt: []gax.CallOption{},
356 RawDecrypt: []gax.CallOption{},
357 AsymmetricSign: []gax.CallOption{
358 gax.WithTimeout(60000 * time.Millisecond),
359 gax.WithRetry(func() gax.Retryer {
360 return gax.OnCodes([]codes.Code{
361 codes.Unavailable,
362 codes.DeadlineExceeded,
363 }, gax.Backoff{
364 Initial: 100 * time.Millisecond,
365 Max: 60000 * time.Millisecond,
366 Multiplier: 1.30,
367 })
368 }),
369 },
370 AsymmetricDecrypt: []gax.CallOption{
371 gax.WithTimeout(60000 * time.Millisecond),
372 gax.WithRetry(func() gax.Retryer {
373 return gax.OnCodes([]codes.Code{
374 codes.Unavailable,
375 codes.DeadlineExceeded,
376 }, gax.Backoff{
377 Initial: 100 * time.Millisecond,
378 Max: 60000 * time.Millisecond,
379 Multiplier: 1.30,
380 })
381 }),
382 },
383 MacSign: []gax.CallOption{
384 gax.WithTimeout(60000 * time.Millisecond),
385 gax.WithRetry(func() gax.Retryer {
386 return gax.OnCodes([]codes.Code{
387 codes.Unavailable,
388 codes.DeadlineExceeded,
389 }, gax.Backoff{
390 Initial: 100 * time.Millisecond,
391 Max: 60000 * time.Millisecond,
392 Multiplier: 1.30,
393 })
394 }),
395 },
396 MacVerify: []gax.CallOption{
397 gax.WithTimeout(60000 * time.Millisecond),
398 gax.WithRetry(func() gax.Retryer {
399 return gax.OnCodes([]codes.Code{
400 codes.Unavailable,
401 codes.DeadlineExceeded,
402 }, gax.Backoff{
403 Initial: 100 * time.Millisecond,
404 Max: 60000 * time.Millisecond,
405 Multiplier: 1.30,
406 })
407 }),
408 },
409 GenerateRandomBytes: []gax.CallOption{
410 gax.WithTimeout(60000 * time.Millisecond),
411 gax.WithRetry(func() gax.Retryer {
412 return gax.OnCodes([]codes.Code{
413 codes.Unavailable,
414 codes.DeadlineExceeded,
415 }, gax.Backoff{
416 Initial: 100 * time.Millisecond,
417 Max: 60000 * time.Millisecond,
418 Multiplier: 1.30,
419 })
420 }),
421 },
422 GetLocation: []gax.CallOption{},
423 ListLocations: []gax.CallOption{},
424 GetIamPolicy: []gax.CallOption{},
425 SetIamPolicy: []gax.CallOption{},
426 TestIamPermissions: []gax.CallOption{},
427 GetOperation: []gax.CallOption{},
428 }
429 }
430
431 func defaultKeyManagementRESTCallOptions() *KeyManagementCallOptions {
432 return &KeyManagementCallOptions{
433 ListKeyRings: []gax.CallOption{
434 gax.WithTimeout(60000 * 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 http.StatusGatewayTimeout)
443 }),
444 },
445 ListCryptoKeys: []gax.CallOption{
446 gax.WithTimeout(60000 * time.Millisecond),
447 gax.WithRetry(func() gax.Retryer {
448 return gax.OnHTTPCodes(gax.Backoff{
449 Initial: 100 * time.Millisecond,
450 Max: 60000 * time.Millisecond,
451 Multiplier: 1.30,
452 },
453 http.StatusServiceUnavailable,
454 http.StatusGatewayTimeout)
455 }),
456 },
457 ListCryptoKeyVersions: []gax.CallOption{
458 gax.WithTimeout(60000 * time.Millisecond),
459 gax.WithRetry(func() gax.Retryer {
460 return gax.OnHTTPCodes(gax.Backoff{
461 Initial: 100 * time.Millisecond,
462 Max: 60000 * time.Millisecond,
463 Multiplier: 1.30,
464 },
465 http.StatusServiceUnavailable,
466 http.StatusGatewayTimeout)
467 }),
468 },
469 ListImportJobs: []gax.CallOption{
470 gax.WithTimeout(60000 * time.Millisecond),
471 gax.WithRetry(func() gax.Retryer {
472 return gax.OnHTTPCodes(gax.Backoff{
473 Initial: 100 * time.Millisecond,
474 Max: 60000 * time.Millisecond,
475 Multiplier: 1.30,
476 },
477 http.StatusServiceUnavailable,
478 http.StatusGatewayTimeout)
479 }),
480 },
481 GetKeyRing: []gax.CallOption{
482 gax.WithTimeout(60000 * time.Millisecond),
483 gax.WithRetry(func() gax.Retryer {
484 return gax.OnHTTPCodes(gax.Backoff{
485 Initial: 100 * time.Millisecond,
486 Max: 60000 * time.Millisecond,
487 Multiplier: 1.30,
488 },
489 http.StatusServiceUnavailable,
490 http.StatusGatewayTimeout)
491 }),
492 },
493 GetCryptoKey: []gax.CallOption{
494 gax.WithTimeout(60000 * time.Millisecond),
495 gax.WithRetry(func() gax.Retryer {
496 return gax.OnHTTPCodes(gax.Backoff{
497 Initial: 100 * time.Millisecond,
498 Max: 60000 * time.Millisecond,
499 Multiplier: 1.30,
500 },
501 http.StatusServiceUnavailable,
502 http.StatusGatewayTimeout)
503 }),
504 },
505 GetCryptoKeyVersion: []gax.CallOption{
506 gax.WithTimeout(60000 * time.Millisecond),
507 gax.WithRetry(func() gax.Retryer {
508 return gax.OnHTTPCodes(gax.Backoff{
509 Initial: 100 * time.Millisecond,
510 Max: 60000 * time.Millisecond,
511 Multiplier: 1.30,
512 },
513 http.StatusServiceUnavailable,
514 http.StatusGatewayTimeout)
515 }),
516 },
517 GetPublicKey: []gax.CallOption{
518 gax.WithTimeout(60000 * time.Millisecond),
519 gax.WithRetry(func() gax.Retryer {
520 return gax.OnHTTPCodes(gax.Backoff{
521 Initial: 100 * time.Millisecond,
522 Max: 60000 * time.Millisecond,
523 Multiplier: 1.30,
524 },
525 http.StatusServiceUnavailable,
526 http.StatusGatewayTimeout)
527 }),
528 },
529 GetImportJob: []gax.CallOption{
530 gax.WithTimeout(60000 * time.Millisecond),
531 gax.WithRetry(func() gax.Retryer {
532 return gax.OnHTTPCodes(gax.Backoff{
533 Initial: 100 * time.Millisecond,
534 Max: 60000 * time.Millisecond,
535 Multiplier: 1.30,
536 },
537 http.StatusServiceUnavailable,
538 http.StatusGatewayTimeout)
539 }),
540 },
541 CreateKeyRing: []gax.CallOption{
542 gax.WithTimeout(60000 * time.Millisecond),
543 gax.WithRetry(func() gax.Retryer {
544 return gax.OnHTTPCodes(gax.Backoff{
545 Initial: 100 * time.Millisecond,
546 Max: 60000 * time.Millisecond,
547 Multiplier: 1.30,
548 },
549 http.StatusServiceUnavailable,
550 http.StatusGatewayTimeout)
551 }),
552 },
553 CreateCryptoKey: []gax.CallOption{
554 gax.WithTimeout(60000 * time.Millisecond),
555 gax.WithRetry(func() gax.Retryer {
556 return gax.OnHTTPCodes(gax.Backoff{
557 Initial: 100 * time.Millisecond,
558 Max: 60000 * time.Millisecond,
559 Multiplier: 1.30,
560 },
561 http.StatusServiceUnavailable,
562 http.StatusGatewayTimeout)
563 }),
564 },
565 CreateCryptoKeyVersion: []gax.CallOption{
566 gax.WithTimeout(60000 * time.Millisecond),
567 },
568 ImportCryptoKeyVersion: []gax.CallOption{
569 gax.WithTimeout(60000 * time.Millisecond),
570 },
571 CreateImportJob: []gax.CallOption{
572 gax.WithTimeout(60000 * time.Millisecond),
573 gax.WithRetry(func() gax.Retryer {
574 return gax.OnHTTPCodes(gax.Backoff{
575 Initial: 100 * time.Millisecond,
576 Max: 60000 * time.Millisecond,
577 Multiplier: 1.30,
578 },
579 http.StatusServiceUnavailable,
580 http.StatusGatewayTimeout)
581 }),
582 },
583 UpdateCryptoKey: []gax.CallOption{
584 gax.WithTimeout(60000 * time.Millisecond),
585 gax.WithRetry(func() gax.Retryer {
586 return gax.OnHTTPCodes(gax.Backoff{
587 Initial: 100 * time.Millisecond,
588 Max: 60000 * time.Millisecond,
589 Multiplier: 1.30,
590 },
591 http.StatusServiceUnavailable,
592 http.StatusGatewayTimeout)
593 }),
594 },
595 UpdateCryptoKeyVersion: []gax.CallOption{
596 gax.WithTimeout(60000 * time.Millisecond),
597 gax.WithRetry(func() gax.Retryer {
598 return gax.OnHTTPCodes(gax.Backoff{
599 Initial: 100 * time.Millisecond,
600 Max: 60000 * time.Millisecond,
601 Multiplier: 1.30,
602 },
603 http.StatusServiceUnavailable,
604 http.StatusGatewayTimeout)
605 }),
606 },
607 UpdateCryptoKeyPrimaryVersion: []gax.CallOption{
608 gax.WithTimeout(60000 * time.Millisecond),
609 gax.WithRetry(func() gax.Retryer {
610 return gax.OnHTTPCodes(gax.Backoff{
611 Initial: 100 * time.Millisecond,
612 Max: 60000 * time.Millisecond,
613 Multiplier: 1.30,
614 },
615 http.StatusServiceUnavailable,
616 http.StatusGatewayTimeout)
617 }),
618 },
619 DestroyCryptoKeyVersion: []gax.CallOption{
620 gax.WithTimeout(60000 * time.Millisecond),
621 gax.WithRetry(func() gax.Retryer {
622 return gax.OnHTTPCodes(gax.Backoff{
623 Initial: 100 * time.Millisecond,
624 Max: 60000 * time.Millisecond,
625 Multiplier: 1.30,
626 },
627 http.StatusServiceUnavailable,
628 http.StatusGatewayTimeout)
629 }),
630 },
631 RestoreCryptoKeyVersion: []gax.CallOption{
632 gax.WithTimeout(60000 * time.Millisecond),
633 gax.WithRetry(func() gax.Retryer {
634 return gax.OnHTTPCodes(gax.Backoff{
635 Initial: 100 * time.Millisecond,
636 Max: 60000 * time.Millisecond,
637 Multiplier: 1.30,
638 },
639 http.StatusServiceUnavailable,
640 http.StatusGatewayTimeout)
641 }),
642 },
643 Encrypt: []gax.CallOption{
644 gax.WithTimeout(60000 * time.Millisecond),
645 gax.WithRetry(func() gax.Retryer {
646 return gax.OnHTTPCodes(gax.Backoff{
647 Initial: 100 * time.Millisecond,
648 Max: 60000 * time.Millisecond,
649 Multiplier: 1.30,
650 },
651 http.StatusServiceUnavailable,
652 http.StatusGatewayTimeout)
653 }),
654 },
655 Decrypt: []gax.CallOption{
656 gax.WithTimeout(60000 * time.Millisecond),
657 gax.WithRetry(func() gax.Retryer {
658 return gax.OnHTTPCodes(gax.Backoff{
659 Initial: 100 * time.Millisecond,
660 Max: 60000 * time.Millisecond,
661 Multiplier: 1.30,
662 },
663 http.StatusServiceUnavailable,
664 http.StatusGatewayTimeout)
665 }),
666 },
667 RawEncrypt: []gax.CallOption{},
668 RawDecrypt: []gax.CallOption{},
669 AsymmetricSign: []gax.CallOption{
670 gax.WithTimeout(60000 * time.Millisecond),
671 gax.WithRetry(func() gax.Retryer {
672 return gax.OnHTTPCodes(gax.Backoff{
673 Initial: 100 * time.Millisecond,
674 Max: 60000 * time.Millisecond,
675 Multiplier: 1.30,
676 },
677 http.StatusServiceUnavailable,
678 http.StatusGatewayTimeout)
679 }),
680 },
681 AsymmetricDecrypt: []gax.CallOption{
682 gax.WithTimeout(60000 * time.Millisecond),
683 gax.WithRetry(func() gax.Retryer {
684 return gax.OnHTTPCodes(gax.Backoff{
685 Initial: 100 * time.Millisecond,
686 Max: 60000 * time.Millisecond,
687 Multiplier: 1.30,
688 },
689 http.StatusServiceUnavailable,
690 http.StatusGatewayTimeout)
691 }),
692 },
693 MacSign: []gax.CallOption{
694 gax.WithTimeout(60000 * time.Millisecond),
695 gax.WithRetry(func() gax.Retryer {
696 return gax.OnHTTPCodes(gax.Backoff{
697 Initial: 100 * time.Millisecond,
698 Max: 60000 * time.Millisecond,
699 Multiplier: 1.30,
700 },
701 http.StatusServiceUnavailable,
702 http.StatusGatewayTimeout)
703 }),
704 },
705 MacVerify: []gax.CallOption{
706 gax.WithTimeout(60000 * time.Millisecond),
707 gax.WithRetry(func() gax.Retryer {
708 return gax.OnHTTPCodes(gax.Backoff{
709 Initial: 100 * time.Millisecond,
710 Max: 60000 * time.Millisecond,
711 Multiplier: 1.30,
712 },
713 http.StatusServiceUnavailable,
714 http.StatusGatewayTimeout)
715 }),
716 },
717 GenerateRandomBytes: []gax.CallOption{
718 gax.WithTimeout(60000 * time.Millisecond),
719 gax.WithRetry(func() gax.Retryer {
720 return gax.OnHTTPCodes(gax.Backoff{
721 Initial: 100 * time.Millisecond,
722 Max: 60000 * time.Millisecond,
723 Multiplier: 1.30,
724 },
725 http.StatusServiceUnavailable,
726 http.StatusGatewayTimeout)
727 }),
728 },
729 GetLocation: []gax.CallOption{},
730 ListLocations: []gax.CallOption{},
731 GetIamPolicy: []gax.CallOption{},
732 SetIamPolicy: []gax.CallOption{},
733 TestIamPermissions: []gax.CallOption{},
734 GetOperation: []gax.CallOption{},
735 }
736 }
737
738
739 type internalKeyManagementClient interface {
740 Close() error
741 setGoogleClientInfo(...string)
742 Connection() *grpc.ClientConn
743 ListKeyRings(context.Context, *kmspb.ListKeyRingsRequest, ...gax.CallOption) *KeyRingIterator
744 ListCryptoKeys(context.Context, *kmspb.ListCryptoKeysRequest, ...gax.CallOption) *CryptoKeyIterator
745 ListCryptoKeyVersions(context.Context, *kmspb.ListCryptoKeyVersionsRequest, ...gax.CallOption) *CryptoKeyVersionIterator
746 ListImportJobs(context.Context, *kmspb.ListImportJobsRequest, ...gax.CallOption) *ImportJobIterator
747 GetKeyRing(context.Context, *kmspb.GetKeyRingRequest, ...gax.CallOption) (*kmspb.KeyRing, error)
748 GetCryptoKey(context.Context, *kmspb.GetCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
749 GetCryptoKeyVersion(context.Context, *kmspb.GetCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
750 GetPublicKey(context.Context, *kmspb.GetPublicKeyRequest, ...gax.CallOption) (*kmspb.PublicKey, error)
751 GetImportJob(context.Context, *kmspb.GetImportJobRequest, ...gax.CallOption) (*kmspb.ImportJob, error)
752 CreateKeyRing(context.Context, *kmspb.CreateKeyRingRequest, ...gax.CallOption) (*kmspb.KeyRing, error)
753 CreateCryptoKey(context.Context, *kmspb.CreateCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
754 CreateCryptoKeyVersion(context.Context, *kmspb.CreateCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
755 ImportCryptoKeyVersion(context.Context, *kmspb.ImportCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
756 CreateImportJob(context.Context, *kmspb.CreateImportJobRequest, ...gax.CallOption) (*kmspb.ImportJob, error)
757 UpdateCryptoKey(context.Context, *kmspb.UpdateCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
758 UpdateCryptoKeyVersion(context.Context, *kmspb.UpdateCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
759 UpdateCryptoKeyPrimaryVersion(context.Context, *kmspb.UpdateCryptoKeyPrimaryVersionRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
760 DestroyCryptoKeyVersion(context.Context, *kmspb.DestroyCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
761 RestoreCryptoKeyVersion(context.Context, *kmspb.RestoreCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
762 Encrypt(context.Context, *kmspb.EncryptRequest, ...gax.CallOption) (*kmspb.EncryptResponse, error)
763 Decrypt(context.Context, *kmspb.DecryptRequest, ...gax.CallOption) (*kmspb.DecryptResponse, error)
764 RawEncrypt(context.Context, *kmspb.RawEncryptRequest, ...gax.CallOption) (*kmspb.RawEncryptResponse, error)
765 RawDecrypt(context.Context, *kmspb.RawDecryptRequest, ...gax.CallOption) (*kmspb.RawDecryptResponse, error)
766 AsymmetricSign(context.Context, *kmspb.AsymmetricSignRequest, ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error)
767 AsymmetricDecrypt(context.Context, *kmspb.AsymmetricDecryptRequest, ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error)
768 MacSign(context.Context, *kmspb.MacSignRequest, ...gax.CallOption) (*kmspb.MacSignResponse, error)
769 MacVerify(context.Context, *kmspb.MacVerifyRequest, ...gax.CallOption) (*kmspb.MacVerifyResponse, error)
770 GenerateRandomBytes(context.Context, *kmspb.GenerateRandomBytesRequest, ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error)
771 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
772 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
773 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
774 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
775 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
776 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
777 }
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797 type KeyManagementClient struct {
798
799 internalClient internalKeyManagementClient
800
801
802 CallOptions *KeyManagementCallOptions
803 }
804
805
806
807
808
809 func (c *KeyManagementClient) Close() error {
810 return c.internalClient.Close()
811 }
812
813
814
815
816 func (c *KeyManagementClient) setGoogleClientInfo(keyval ...string) {
817 c.internalClient.setGoogleClientInfo(keyval...)
818 }
819
820
821
822
823
824 func (c *KeyManagementClient) Connection() *grpc.ClientConn {
825 return c.internalClient.Connection()
826 }
827
828
829 func (c *KeyManagementClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator {
830 return c.internalClient.ListKeyRings(ctx, req, opts...)
831 }
832
833
834 func (c *KeyManagementClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator {
835 return c.internalClient.ListCryptoKeys(ctx, req, opts...)
836 }
837
838
839 func (c *KeyManagementClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator {
840 return c.internalClient.ListCryptoKeyVersions(ctx, req, opts...)
841 }
842
843
844 func (c *KeyManagementClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator {
845 return c.internalClient.ListImportJobs(ctx, req, opts...)
846 }
847
848
849 func (c *KeyManagementClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
850 return c.internalClient.GetKeyRing(ctx, req, opts...)
851 }
852
853
854
855
856 func (c *KeyManagementClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
857 return c.internalClient.GetCryptoKey(ctx, req, opts...)
858 }
859
860
861
862 func (c *KeyManagementClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
863 return c.internalClient.GetCryptoKeyVersion(ctx, req, opts...)
864 }
865
866
867
868
869
870
871
872 func (c *KeyManagementClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error) {
873 return c.internalClient.GetPublicKey(ctx, req, opts...)
874 }
875
876
877 func (c *KeyManagementClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
878 return c.internalClient.GetImportJob(ctx, req, opts...)
879 }
880
881
882
883 func (c *KeyManagementClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
884 return c.internalClient.CreateKeyRing(ctx, req, opts...)
885 }
886
887
888
889
890
891
892
893 func (c *KeyManagementClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
894 return c.internalClient.CreateCryptoKey(ctx, req, opts...)
895 }
896
897
898
899
900
901
902
903 func (c *KeyManagementClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
904 return c.internalClient.CreateCryptoKeyVersion(ctx, req, opts...)
905 }
906
907
908
909
910
911
912
913
914
915 func (c *KeyManagementClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
916 return c.internalClient.ImportCryptoKeyVersion(ctx, req, opts...)
917 }
918
919
920
921
922
923
924 func (c *KeyManagementClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
925 return c.internalClient.CreateImportJob(ctx, req, opts...)
926 }
927
928
929 func (c *KeyManagementClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
930 return c.internalClient.UpdateCryptoKey(ctx, req, opts...)
931 }
932
933
934
935
936
937
938
939
940
941
942
943
944
945 func (c *KeyManagementClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
946 return c.internalClient.UpdateCryptoKeyVersion(ctx, req, opts...)
947 }
948
949
950
951
952
953
954
955 func (c *KeyManagementClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
956 return c.internalClient.UpdateCryptoKeyPrimaryVersion(ctx, req, opts...)
957 }
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980 func (c *KeyManagementClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
981 return c.internalClient.DestroyCryptoKeyVersion(ctx, req, opts...)
982 }
983
984
985
986
987
988
989
990
991
992
993 func (c *KeyManagementClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
994 return c.internalClient.RestoreCryptoKeyVersion(ctx, req, opts...)
995 }
996
997
998
999
1000
1001 func (c *KeyManagementClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error) {
1002 return c.internalClient.Encrypt(ctx, req, opts...)
1003 }
1004
1005
1006
1007
1008
1009 func (c *KeyManagementClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error) {
1010 return c.internalClient.Decrypt(ctx, req, opts...)
1011 }
1012
1013
1014
1015
1016
1017
1018
1019 func (c *KeyManagementClient) RawEncrypt(ctx context.Context, req *kmspb.RawEncryptRequest, opts ...gax.CallOption) (*kmspb.RawEncryptResponse, error) {
1020 return c.internalClient.RawEncrypt(ctx, req, opts...)
1021 }
1022
1023
1024
1025
1026
1027 func (c *KeyManagementClient) RawDecrypt(ctx context.Context, req *kmspb.RawDecryptRequest, opts ...gax.CallOption) (*kmspb.RawDecryptResponse, error) {
1028 return c.internalClient.RawDecrypt(ctx, req, opts...)
1029 }
1030
1031
1032
1033
1034
1035
1036 func (c *KeyManagementClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error) {
1037 return c.internalClient.AsymmetricSign(ctx, req, opts...)
1038 }
1039
1040
1041
1042
1043
1044
1045 func (c *KeyManagementClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error) {
1046 return c.internalClient.AsymmetricDecrypt(ctx, req, opts...)
1047 }
1048
1049
1050
1051
1052 func (c *KeyManagementClient) MacSign(ctx context.Context, req *kmspb.MacSignRequest, opts ...gax.CallOption) (*kmspb.MacSignResponse, error) {
1053 return c.internalClient.MacSign(ctx, req, opts...)
1054 }
1055
1056
1057
1058
1059
1060 func (c *KeyManagementClient) MacVerify(ctx context.Context, req *kmspb.MacVerifyRequest, opts ...gax.CallOption) (*kmspb.MacVerifyResponse, error) {
1061 return c.internalClient.MacVerify(ctx, req, opts...)
1062 }
1063
1064
1065
1066 func (c *KeyManagementClient) GenerateRandomBytes(ctx context.Context, req *kmspb.GenerateRandomBytesRequest, opts ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) {
1067 return c.internalClient.GenerateRandomBytes(ctx, req, opts...)
1068 }
1069
1070
1071 func (c *KeyManagementClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1072 return c.internalClient.GetLocation(ctx, req, opts...)
1073 }
1074
1075
1076 func (c *KeyManagementClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1077 return c.internalClient.ListLocations(ctx, req, opts...)
1078 }
1079
1080
1081
1082 func (c *KeyManagementClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1083 return c.internalClient.GetIamPolicy(ctx, req, opts...)
1084 }
1085
1086
1087
1088
1089
1090
1091 func (c *KeyManagementClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1092 return c.internalClient.SetIamPolicy(ctx, req, opts...)
1093 }
1094
1095
1096
1097
1098
1099
1100
1101
1102 func (c *KeyManagementClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1103 return c.internalClient.TestIamPermissions(ctx, req, opts...)
1104 }
1105
1106
1107 func (c *KeyManagementClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1108 return c.internalClient.GetOperation(ctx, req, opts...)
1109 }
1110
1111
1112
1113
1114 type keyManagementGRPCClient struct {
1115
1116 connPool gtransport.ConnPool
1117
1118
1119 CallOptions **KeyManagementCallOptions
1120
1121
1122 keyManagementClient kmspb.KeyManagementServiceClient
1123
1124 operationsClient longrunningpb.OperationsClient
1125
1126 iamPolicyClient iampb.IAMPolicyClient
1127
1128 locationsClient locationpb.LocationsClient
1129
1130
1131 xGoogHeaders []string
1132 }
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152 func NewKeyManagementClient(ctx context.Context, opts ...option.ClientOption) (*KeyManagementClient, error) {
1153 clientOpts := defaultKeyManagementGRPCClientOptions()
1154 if newKeyManagementClientHook != nil {
1155 hookOpts, err := newKeyManagementClientHook(ctx, clientHookParams{})
1156 if err != nil {
1157 return nil, err
1158 }
1159 clientOpts = append(clientOpts, hookOpts...)
1160 }
1161
1162 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
1163 if err != nil {
1164 return nil, err
1165 }
1166 client := KeyManagementClient{CallOptions: defaultKeyManagementCallOptions()}
1167
1168 c := &keyManagementGRPCClient{
1169 connPool: connPool,
1170 keyManagementClient: kmspb.NewKeyManagementServiceClient(connPool),
1171 CallOptions: &client.CallOptions,
1172 operationsClient: longrunningpb.NewOperationsClient(connPool),
1173 iamPolicyClient: iampb.NewIAMPolicyClient(connPool),
1174 locationsClient: locationpb.NewLocationsClient(connPool),
1175 }
1176 c.setGoogleClientInfo()
1177
1178 client.internalClient = c
1179
1180 return &client, nil
1181 }
1182
1183
1184
1185
1186
1187 func (c *keyManagementGRPCClient) Connection() *grpc.ClientConn {
1188 return c.connPool.Conn()
1189 }
1190
1191
1192
1193
1194 func (c *keyManagementGRPCClient) setGoogleClientInfo(keyval ...string) {
1195 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1196 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version)
1197 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
1198 }
1199
1200
1201
1202 func (c *keyManagementGRPCClient) Close() error {
1203 return c.connPool.Close()
1204 }
1205
1206
1207 type keyManagementRESTClient struct {
1208
1209 endpoint string
1210
1211
1212 httpClient *http.Client
1213
1214
1215 xGoogHeaders []string
1216
1217
1218 CallOptions **KeyManagementCallOptions
1219 }
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238 func NewKeyManagementRESTClient(ctx context.Context, opts ...option.ClientOption) (*KeyManagementClient, error) {
1239 clientOpts := append(defaultKeyManagementRESTClientOptions(), opts...)
1240 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
1241 if err != nil {
1242 return nil, err
1243 }
1244
1245 callOpts := defaultKeyManagementRESTCallOptions()
1246 c := &keyManagementRESTClient{
1247 endpoint: endpoint,
1248 httpClient: httpClient,
1249 CallOptions: &callOpts,
1250 }
1251 c.setGoogleClientInfo()
1252
1253 return &KeyManagementClient{internalClient: c, CallOptions: callOpts}, nil
1254 }
1255
1256 func defaultKeyManagementRESTClientOptions() []option.ClientOption {
1257 return []option.ClientOption{
1258 internaloption.WithDefaultEndpoint("https://cloudkms.googleapis.com"),
1259 internaloption.WithDefaultEndpointTemplate("https://cloudkms.UNIVERSE_DOMAIN"),
1260 internaloption.WithDefaultMTLSEndpoint("https://cloudkms.mtls.googleapis.com"),
1261 internaloption.WithDefaultUniverseDomain("googleapis.com"),
1262 internaloption.WithDefaultAudience("https://cloudkms.googleapis.com/"),
1263 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
1264 }
1265 }
1266
1267
1268
1269
1270 func (c *keyManagementRESTClient) setGoogleClientInfo(keyval ...string) {
1271 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
1272 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN")
1273 c.xGoogHeaders = []string{"x-goog-api-client", gax.XGoogHeader(kv...)}
1274 }
1275
1276
1277
1278 func (c *keyManagementRESTClient) Close() error {
1279
1280 c.httpClient = nil
1281 return nil
1282 }
1283
1284
1285
1286
1287 func (c *keyManagementRESTClient) Connection() *grpc.ClientConn {
1288 return nil
1289 }
1290 func (c *keyManagementGRPCClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator {
1291 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1292
1293 hds = append(c.xGoogHeaders, hds...)
1294 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1295 opts = append((*c.CallOptions).ListKeyRings[0:len((*c.CallOptions).ListKeyRings):len((*c.CallOptions).ListKeyRings)], opts...)
1296 it := &KeyRingIterator{}
1297 req = proto.Clone(req).(*kmspb.ListKeyRingsRequest)
1298 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.KeyRing, string, error) {
1299 resp := &kmspb.ListKeyRingsResponse{}
1300 if pageToken != "" {
1301 req.PageToken = pageToken
1302 }
1303 if pageSize > math.MaxInt32 {
1304 req.PageSize = math.MaxInt32
1305 } else if pageSize != 0 {
1306 req.PageSize = int32(pageSize)
1307 }
1308 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1309 var err error
1310 resp, err = c.keyManagementClient.ListKeyRings(ctx, req, settings.GRPC...)
1311 return err
1312 }, opts...)
1313 if err != nil {
1314 return nil, "", err
1315 }
1316
1317 it.Response = resp
1318 return resp.GetKeyRings(), resp.GetNextPageToken(), nil
1319 }
1320 fetch := func(pageSize int, pageToken string) (string, error) {
1321 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1322 if err != nil {
1323 return "", err
1324 }
1325 it.items = append(it.items, items...)
1326 return nextPageToken, nil
1327 }
1328
1329 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1330 it.pageInfo.MaxSize = int(req.GetPageSize())
1331 it.pageInfo.Token = req.GetPageToken()
1332
1333 return it
1334 }
1335
1336 func (c *keyManagementGRPCClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator {
1337 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1338
1339 hds = append(c.xGoogHeaders, hds...)
1340 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1341 opts = append((*c.CallOptions).ListCryptoKeys[0:len((*c.CallOptions).ListCryptoKeys):len((*c.CallOptions).ListCryptoKeys)], opts...)
1342 it := &CryptoKeyIterator{}
1343 req = proto.Clone(req).(*kmspb.ListCryptoKeysRequest)
1344 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKey, string, error) {
1345 resp := &kmspb.ListCryptoKeysResponse{}
1346 if pageToken != "" {
1347 req.PageToken = pageToken
1348 }
1349 if pageSize > math.MaxInt32 {
1350 req.PageSize = math.MaxInt32
1351 } else if pageSize != 0 {
1352 req.PageSize = int32(pageSize)
1353 }
1354 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1355 var err error
1356 resp, err = c.keyManagementClient.ListCryptoKeys(ctx, req, settings.GRPC...)
1357 return err
1358 }, opts...)
1359 if err != nil {
1360 return nil, "", err
1361 }
1362
1363 it.Response = resp
1364 return resp.GetCryptoKeys(), resp.GetNextPageToken(), nil
1365 }
1366 fetch := func(pageSize int, pageToken string) (string, error) {
1367 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1368 if err != nil {
1369 return "", err
1370 }
1371 it.items = append(it.items, items...)
1372 return nextPageToken, nil
1373 }
1374
1375 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1376 it.pageInfo.MaxSize = int(req.GetPageSize())
1377 it.pageInfo.Token = req.GetPageToken()
1378
1379 return it
1380 }
1381
1382 func (c *keyManagementGRPCClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator {
1383 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1384
1385 hds = append(c.xGoogHeaders, hds...)
1386 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1387 opts = append((*c.CallOptions).ListCryptoKeyVersions[0:len((*c.CallOptions).ListCryptoKeyVersions):len((*c.CallOptions).ListCryptoKeyVersions)], opts...)
1388 it := &CryptoKeyVersionIterator{}
1389 req = proto.Clone(req).(*kmspb.ListCryptoKeyVersionsRequest)
1390 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKeyVersion, string, error) {
1391 resp := &kmspb.ListCryptoKeyVersionsResponse{}
1392 if pageToken != "" {
1393 req.PageToken = pageToken
1394 }
1395 if pageSize > math.MaxInt32 {
1396 req.PageSize = math.MaxInt32
1397 } else if pageSize != 0 {
1398 req.PageSize = int32(pageSize)
1399 }
1400 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1401 var err error
1402 resp, err = c.keyManagementClient.ListCryptoKeyVersions(ctx, req, settings.GRPC...)
1403 return err
1404 }, opts...)
1405 if err != nil {
1406 return nil, "", err
1407 }
1408
1409 it.Response = resp
1410 return resp.GetCryptoKeyVersions(), resp.GetNextPageToken(), nil
1411 }
1412 fetch := func(pageSize int, pageToken string) (string, error) {
1413 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1414 if err != nil {
1415 return "", err
1416 }
1417 it.items = append(it.items, items...)
1418 return nextPageToken, nil
1419 }
1420
1421 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1422 it.pageInfo.MaxSize = int(req.GetPageSize())
1423 it.pageInfo.Token = req.GetPageToken()
1424
1425 return it
1426 }
1427
1428 func (c *keyManagementGRPCClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator {
1429 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1430
1431 hds = append(c.xGoogHeaders, hds...)
1432 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1433 opts = append((*c.CallOptions).ListImportJobs[0:len((*c.CallOptions).ListImportJobs):len((*c.CallOptions).ListImportJobs)], opts...)
1434 it := &ImportJobIterator{}
1435 req = proto.Clone(req).(*kmspb.ListImportJobsRequest)
1436 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.ImportJob, string, error) {
1437 resp := &kmspb.ListImportJobsResponse{}
1438 if pageToken != "" {
1439 req.PageToken = pageToken
1440 }
1441 if pageSize > math.MaxInt32 {
1442 req.PageSize = math.MaxInt32
1443 } else if pageSize != 0 {
1444 req.PageSize = int32(pageSize)
1445 }
1446 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1447 var err error
1448 resp, err = c.keyManagementClient.ListImportJobs(ctx, req, settings.GRPC...)
1449 return err
1450 }, opts...)
1451 if err != nil {
1452 return nil, "", err
1453 }
1454
1455 it.Response = resp
1456 return resp.GetImportJobs(), resp.GetNextPageToken(), nil
1457 }
1458 fetch := func(pageSize int, pageToken string) (string, error) {
1459 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1460 if err != nil {
1461 return "", err
1462 }
1463 it.items = append(it.items, items...)
1464 return nextPageToken, nil
1465 }
1466
1467 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1468 it.pageInfo.MaxSize = int(req.GetPageSize())
1469 it.pageInfo.Token = req.GetPageToken()
1470
1471 return it
1472 }
1473
1474 func (c *keyManagementGRPCClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
1475 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1476
1477 hds = append(c.xGoogHeaders, hds...)
1478 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1479 opts = append((*c.CallOptions).GetKeyRing[0:len((*c.CallOptions).GetKeyRing):len((*c.CallOptions).GetKeyRing)], opts...)
1480 var resp *kmspb.KeyRing
1481 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1482 var err error
1483 resp, err = c.keyManagementClient.GetKeyRing(ctx, req, settings.GRPC...)
1484 return err
1485 }, opts...)
1486 if err != nil {
1487 return nil, err
1488 }
1489 return resp, nil
1490 }
1491
1492 func (c *keyManagementGRPCClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1493 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1494
1495 hds = append(c.xGoogHeaders, hds...)
1496 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1497 opts = append((*c.CallOptions).GetCryptoKey[0:len((*c.CallOptions).GetCryptoKey):len((*c.CallOptions).GetCryptoKey)], opts...)
1498 var resp *kmspb.CryptoKey
1499 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1500 var err error
1501 resp, err = c.keyManagementClient.GetCryptoKey(ctx, req, settings.GRPC...)
1502 return err
1503 }, opts...)
1504 if err != nil {
1505 return nil, err
1506 }
1507 return resp, nil
1508 }
1509
1510 func (c *keyManagementGRPCClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1511 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1512
1513 hds = append(c.xGoogHeaders, hds...)
1514 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1515 opts = append((*c.CallOptions).GetCryptoKeyVersion[0:len((*c.CallOptions).GetCryptoKeyVersion):len((*c.CallOptions).GetCryptoKeyVersion)], opts...)
1516 var resp *kmspb.CryptoKeyVersion
1517 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1518 var err error
1519 resp, err = c.keyManagementClient.GetCryptoKeyVersion(ctx, req, settings.GRPC...)
1520 return err
1521 }, opts...)
1522 if err != nil {
1523 return nil, err
1524 }
1525 return resp, nil
1526 }
1527
1528 func (c *keyManagementGRPCClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error) {
1529 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1530
1531 hds = append(c.xGoogHeaders, hds...)
1532 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1533 opts = append((*c.CallOptions).GetPublicKey[0:len((*c.CallOptions).GetPublicKey):len((*c.CallOptions).GetPublicKey)], opts...)
1534 var resp *kmspb.PublicKey
1535 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1536 var err error
1537 resp, err = c.keyManagementClient.GetPublicKey(ctx, req, settings.GRPC...)
1538 return err
1539 }, opts...)
1540 if err != nil {
1541 return nil, err
1542 }
1543 return resp, nil
1544 }
1545
1546 func (c *keyManagementGRPCClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
1547 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1548
1549 hds = append(c.xGoogHeaders, hds...)
1550 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1551 opts = append((*c.CallOptions).GetImportJob[0:len((*c.CallOptions).GetImportJob):len((*c.CallOptions).GetImportJob)], opts...)
1552 var resp *kmspb.ImportJob
1553 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1554 var err error
1555 resp, err = c.keyManagementClient.GetImportJob(ctx, req, settings.GRPC...)
1556 return err
1557 }, opts...)
1558 if err != nil {
1559 return nil, err
1560 }
1561 return resp, nil
1562 }
1563
1564 func (c *keyManagementGRPCClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
1565 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1566
1567 hds = append(c.xGoogHeaders, hds...)
1568 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1569 opts = append((*c.CallOptions).CreateKeyRing[0:len((*c.CallOptions).CreateKeyRing):len((*c.CallOptions).CreateKeyRing)], opts...)
1570 var resp *kmspb.KeyRing
1571 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1572 var err error
1573 resp, err = c.keyManagementClient.CreateKeyRing(ctx, req, settings.GRPC...)
1574 return err
1575 }, opts...)
1576 if err != nil {
1577 return nil, err
1578 }
1579 return resp, nil
1580 }
1581
1582 func (c *keyManagementGRPCClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1583 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1584
1585 hds = append(c.xGoogHeaders, hds...)
1586 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1587 opts = append((*c.CallOptions).CreateCryptoKey[0:len((*c.CallOptions).CreateCryptoKey):len((*c.CallOptions).CreateCryptoKey)], opts...)
1588 var resp *kmspb.CryptoKey
1589 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1590 var err error
1591 resp, err = c.keyManagementClient.CreateCryptoKey(ctx, req, settings.GRPC...)
1592 return err
1593 }, opts...)
1594 if err != nil {
1595 return nil, err
1596 }
1597 return resp, nil
1598 }
1599
1600 func (c *keyManagementGRPCClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1601 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1602
1603 hds = append(c.xGoogHeaders, hds...)
1604 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1605 opts = append((*c.CallOptions).CreateCryptoKeyVersion[0:len((*c.CallOptions).CreateCryptoKeyVersion):len((*c.CallOptions).CreateCryptoKeyVersion)], opts...)
1606 var resp *kmspb.CryptoKeyVersion
1607 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1608 var err error
1609 resp, err = c.keyManagementClient.CreateCryptoKeyVersion(ctx, req, settings.GRPC...)
1610 return err
1611 }, opts...)
1612 if err != nil {
1613 return nil, err
1614 }
1615 return resp, nil
1616 }
1617
1618 func (c *keyManagementGRPCClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1619 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1620
1621 hds = append(c.xGoogHeaders, hds...)
1622 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1623 opts = append((*c.CallOptions).ImportCryptoKeyVersion[0:len((*c.CallOptions).ImportCryptoKeyVersion):len((*c.CallOptions).ImportCryptoKeyVersion)], opts...)
1624 var resp *kmspb.CryptoKeyVersion
1625 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1626 var err error
1627 resp, err = c.keyManagementClient.ImportCryptoKeyVersion(ctx, req, settings.GRPC...)
1628 return err
1629 }, opts...)
1630 if err != nil {
1631 return nil, err
1632 }
1633 return resp, nil
1634 }
1635
1636 func (c *keyManagementGRPCClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
1637 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1638
1639 hds = append(c.xGoogHeaders, hds...)
1640 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1641 opts = append((*c.CallOptions).CreateImportJob[0:len((*c.CallOptions).CreateImportJob):len((*c.CallOptions).CreateImportJob)], opts...)
1642 var resp *kmspb.ImportJob
1643 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1644 var err error
1645 resp, err = c.keyManagementClient.CreateImportJob(ctx, req, settings.GRPC...)
1646 return err
1647 }, opts...)
1648 if err != nil {
1649 return nil, err
1650 }
1651 return resp, nil
1652 }
1653
1654 func (c *keyManagementGRPCClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1655 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key.name", url.QueryEscape(req.GetCryptoKey().GetName()))}
1656
1657 hds = append(c.xGoogHeaders, hds...)
1658 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1659 opts = append((*c.CallOptions).UpdateCryptoKey[0:len((*c.CallOptions).UpdateCryptoKey):len((*c.CallOptions).UpdateCryptoKey)], opts...)
1660 var resp *kmspb.CryptoKey
1661 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1662 var err error
1663 resp, err = c.keyManagementClient.UpdateCryptoKey(ctx, req, settings.GRPC...)
1664 return err
1665 }, opts...)
1666 if err != nil {
1667 return nil, err
1668 }
1669 return resp, nil
1670 }
1671
1672 func (c *keyManagementGRPCClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1673 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key_version.name", url.QueryEscape(req.GetCryptoKeyVersion().GetName()))}
1674
1675 hds = append(c.xGoogHeaders, hds...)
1676 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1677 opts = append((*c.CallOptions).UpdateCryptoKeyVersion[0:len((*c.CallOptions).UpdateCryptoKeyVersion):len((*c.CallOptions).UpdateCryptoKeyVersion)], opts...)
1678 var resp *kmspb.CryptoKeyVersion
1679 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1680 var err error
1681 resp, err = c.keyManagementClient.UpdateCryptoKeyVersion(ctx, req, settings.GRPC...)
1682 return err
1683 }, opts...)
1684 if err != nil {
1685 return nil, err
1686 }
1687 return resp, nil
1688 }
1689
1690 func (c *keyManagementGRPCClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1691 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1692
1693 hds = append(c.xGoogHeaders, hds...)
1694 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1695 opts = append((*c.CallOptions).UpdateCryptoKeyPrimaryVersion[0:len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion):len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion)], opts...)
1696 var resp *kmspb.CryptoKey
1697 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1698 var err error
1699 resp, err = c.keyManagementClient.UpdateCryptoKeyPrimaryVersion(ctx, req, settings.GRPC...)
1700 return err
1701 }, opts...)
1702 if err != nil {
1703 return nil, err
1704 }
1705 return resp, nil
1706 }
1707
1708 func (c *keyManagementGRPCClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1709 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1710
1711 hds = append(c.xGoogHeaders, hds...)
1712 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1713 opts = append((*c.CallOptions).DestroyCryptoKeyVersion[0:len((*c.CallOptions).DestroyCryptoKeyVersion):len((*c.CallOptions).DestroyCryptoKeyVersion)], opts...)
1714 var resp *kmspb.CryptoKeyVersion
1715 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1716 var err error
1717 resp, err = c.keyManagementClient.DestroyCryptoKeyVersion(ctx, req, settings.GRPC...)
1718 return err
1719 }, opts...)
1720 if err != nil {
1721 return nil, err
1722 }
1723 return resp, nil
1724 }
1725
1726 func (c *keyManagementGRPCClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1727 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1728
1729 hds = append(c.xGoogHeaders, hds...)
1730 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1731 opts = append((*c.CallOptions).RestoreCryptoKeyVersion[0:len((*c.CallOptions).RestoreCryptoKeyVersion):len((*c.CallOptions).RestoreCryptoKeyVersion)], opts...)
1732 var resp *kmspb.CryptoKeyVersion
1733 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1734 var err error
1735 resp, err = c.keyManagementClient.RestoreCryptoKeyVersion(ctx, req, settings.GRPC...)
1736 return err
1737 }, opts...)
1738 if err != nil {
1739 return nil, err
1740 }
1741 return resp, nil
1742 }
1743
1744 func (c *keyManagementGRPCClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error) {
1745 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1746
1747 hds = append(c.xGoogHeaders, hds...)
1748 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1749 opts = append((*c.CallOptions).Encrypt[0:len((*c.CallOptions).Encrypt):len((*c.CallOptions).Encrypt)], opts...)
1750 var resp *kmspb.EncryptResponse
1751 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1752 var err error
1753 resp, err = c.keyManagementClient.Encrypt(ctx, req, settings.GRPC...)
1754 return err
1755 }, opts...)
1756 if err != nil {
1757 return nil, err
1758 }
1759 return resp, nil
1760 }
1761
1762 func (c *keyManagementGRPCClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error) {
1763 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1764
1765 hds = append(c.xGoogHeaders, hds...)
1766 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1767 opts = append((*c.CallOptions).Decrypt[0:len((*c.CallOptions).Decrypt):len((*c.CallOptions).Decrypt)], opts...)
1768 var resp *kmspb.DecryptResponse
1769 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1770 var err error
1771 resp, err = c.keyManagementClient.Decrypt(ctx, req, settings.GRPC...)
1772 return err
1773 }, opts...)
1774 if err != nil {
1775 return nil, err
1776 }
1777 return resp, nil
1778 }
1779
1780 func (c *keyManagementGRPCClient) RawEncrypt(ctx context.Context, req *kmspb.RawEncryptRequest, opts ...gax.CallOption) (*kmspb.RawEncryptResponse, error) {
1781 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1782
1783 hds = append(c.xGoogHeaders, hds...)
1784 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1785 opts = append((*c.CallOptions).RawEncrypt[0:len((*c.CallOptions).RawEncrypt):len((*c.CallOptions).RawEncrypt)], opts...)
1786 var resp *kmspb.RawEncryptResponse
1787 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1788 var err error
1789 resp, err = c.keyManagementClient.RawEncrypt(ctx, req, settings.GRPC...)
1790 return err
1791 }, opts...)
1792 if err != nil {
1793 return nil, err
1794 }
1795 return resp, nil
1796 }
1797
1798 func (c *keyManagementGRPCClient) RawDecrypt(ctx context.Context, req *kmspb.RawDecryptRequest, opts ...gax.CallOption) (*kmspb.RawDecryptResponse, error) {
1799 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1800
1801 hds = append(c.xGoogHeaders, hds...)
1802 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1803 opts = append((*c.CallOptions).RawDecrypt[0:len((*c.CallOptions).RawDecrypt):len((*c.CallOptions).RawDecrypt)], opts...)
1804 var resp *kmspb.RawDecryptResponse
1805 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1806 var err error
1807 resp, err = c.keyManagementClient.RawDecrypt(ctx, req, settings.GRPC...)
1808 return err
1809 }, opts...)
1810 if err != nil {
1811 return nil, err
1812 }
1813 return resp, nil
1814 }
1815
1816 func (c *keyManagementGRPCClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error) {
1817 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1818
1819 hds = append(c.xGoogHeaders, hds...)
1820 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1821 opts = append((*c.CallOptions).AsymmetricSign[0:len((*c.CallOptions).AsymmetricSign):len((*c.CallOptions).AsymmetricSign)], opts...)
1822 var resp *kmspb.AsymmetricSignResponse
1823 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1824 var err error
1825 resp, err = c.keyManagementClient.AsymmetricSign(ctx, req, settings.GRPC...)
1826 return err
1827 }, opts...)
1828 if err != nil {
1829 return nil, err
1830 }
1831 return resp, nil
1832 }
1833
1834 func (c *keyManagementGRPCClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error) {
1835 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1836
1837 hds = append(c.xGoogHeaders, hds...)
1838 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1839 opts = append((*c.CallOptions).AsymmetricDecrypt[0:len((*c.CallOptions).AsymmetricDecrypt):len((*c.CallOptions).AsymmetricDecrypt)], opts...)
1840 var resp *kmspb.AsymmetricDecryptResponse
1841 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1842 var err error
1843 resp, err = c.keyManagementClient.AsymmetricDecrypt(ctx, req, settings.GRPC...)
1844 return err
1845 }, opts...)
1846 if err != nil {
1847 return nil, err
1848 }
1849 return resp, nil
1850 }
1851
1852 func (c *keyManagementGRPCClient) MacSign(ctx context.Context, req *kmspb.MacSignRequest, opts ...gax.CallOption) (*kmspb.MacSignResponse, error) {
1853 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1854
1855 hds = append(c.xGoogHeaders, hds...)
1856 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1857 opts = append((*c.CallOptions).MacSign[0:len((*c.CallOptions).MacSign):len((*c.CallOptions).MacSign)], opts...)
1858 var resp *kmspb.MacSignResponse
1859 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1860 var err error
1861 resp, err = c.keyManagementClient.MacSign(ctx, req, settings.GRPC...)
1862 return err
1863 }, opts...)
1864 if err != nil {
1865 return nil, err
1866 }
1867 return resp, nil
1868 }
1869
1870 func (c *keyManagementGRPCClient) MacVerify(ctx context.Context, req *kmspb.MacVerifyRequest, opts ...gax.CallOption) (*kmspb.MacVerifyResponse, error) {
1871 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1872
1873 hds = append(c.xGoogHeaders, hds...)
1874 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1875 opts = append((*c.CallOptions).MacVerify[0:len((*c.CallOptions).MacVerify):len((*c.CallOptions).MacVerify)], opts...)
1876 var resp *kmspb.MacVerifyResponse
1877 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1878 var err error
1879 resp, err = c.keyManagementClient.MacVerify(ctx, req, settings.GRPC...)
1880 return err
1881 }, opts...)
1882 if err != nil {
1883 return nil, err
1884 }
1885 return resp, nil
1886 }
1887
1888 func (c *keyManagementGRPCClient) GenerateRandomBytes(ctx context.Context, req *kmspb.GenerateRandomBytesRequest, opts ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) {
1889 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
1890
1891 hds = append(c.xGoogHeaders, hds...)
1892 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1893 opts = append((*c.CallOptions).GenerateRandomBytes[0:len((*c.CallOptions).GenerateRandomBytes):len((*c.CallOptions).GenerateRandomBytes)], opts...)
1894 var resp *kmspb.GenerateRandomBytesResponse
1895 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1896 var err error
1897 resp, err = c.keyManagementClient.GenerateRandomBytes(ctx, req, settings.GRPC...)
1898 return err
1899 }, opts...)
1900 if err != nil {
1901 return nil, err
1902 }
1903 return resp, nil
1904 }
1905
1906 func (c *keyManagementGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1907 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1908
1909 hds = append(c.xGoogHeaders, hds...)
1910 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1911 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1912 var resp *locationpb.Location
1913 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1914 var err error
1915 resp, err = c.locationsClient.GetLocation(ctx, req, settings.GRPC...)
1916 return err
1917 }, opts...)
1918 if err != nil {
1919 return nil, err
1920 }
1921 return resp, nil
1922 }
1923
1924 func (c *keyManagementGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1925 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1926
1927 hds = append(c.xGoogHeaders, hds...)
1928 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1929 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1930 it := &LocationIterator{}
1931 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1932 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1933 resp := &locationpb.ListLocationsResponse{}
1934 if pageToken != "" {
1935 req.PageToken = pageToken
1936 }
1937 if pageSize > math.MaxInt32 {
1938 req.PageSize = math.MaxInt32
1939 } else if pageSize != 0 {
1940 req.PageSize = int32(pageSize)
1941 }
1942 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1943 var err error
1944 resp, err = c.locationsClient.ListLocations(ctx, req, settings.GRPC...)
1945 return err
1946 }, opts...)
1947 if err != nil {
1948 return nil, "", err
1949 }
1950
1951 it.Response = resp
1952 return resp.GetLocations(), resp.GetNextPageToken(), nil
1953 }
1954 fetch := func(pageSize int, pageToken string) (string, error) {
1955 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1956 if err != nil {
1957 return "", err
1958 }
1959 it.items = append(it.items, items...)
1960 return nextPageToken, nil
1961 }
1962
1963 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1964 it.pageInfo.MaxSize = int(req.GetPageSize())
1965 it.pageInfo.Token = req.GetPageToken()
1966
1967 return it
1968 }
1969
1970 func (c *keyManagementGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1971 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1972
1973 hds = append(c.xGoogHeaders, hds...)
1974 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1975 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1976 var resp *iampb.Policy
1977 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1978 var err error
1979 resp, err = c.iamPolicyClient.GetIamPolicy(ctx, req, settings.GRPC...)
1980 return err
1981 }, opts...)
1982 if err != nil {
1983 return nil, err
1984 }
1985 return resp, nil
1986 }
1987
1988 func (c *keyManagementGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1989 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1990
1991 hds = append(c.xGoogHeaders, hds...)
1992 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1993 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1994 var resp *iampb.Policy
1995 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1996 var err error
1997 resp, err = c.iamPolicyClient.SetIamPolicy(ctx, req, settings.GRPC...)
1998 return err
1999 }, opts...)
2000 if err != nil {
2001 return nil, err
2002 }
2003 return resp, nil
2004 }
2005
2006 func (c *keyManagementGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
2007 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
2008
2009 hds = append(c.xGoogHeaders, hds...)
2010 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2011 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
2012 var resp *iampb.TestIamPermissionsResponse
2013 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2014 var err error
2015 resp, err = c.iamPolicyClient.TestIamPermissions(ctx, req, settings.GRPC...)
2016 return err
2017 }, opts...)
2018 if err != nil {
2019 return nil, err
2020 }
2021 return resp, nil
2022 }
2023
2024 func (c *keyManagementGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
2025 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2026
2027 hds = append(c.xGoogHeaders, hds...)
2028 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
2029 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
2030 var resp *longrunningpb.Operation
2031 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2032 var err error
2033 resp, err = c.operationsClient.GetOperation(ctx, req, settings.GRPC...)
2034 return err
2035 }, opts...)
2036 if err != nil {
2037 return nil, err
2038 }
2039 return resp, nil
2040 }
2041
2042
2043 func (c *keyManagementRESTClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator {
2044 it := &KeyRingIterator{}
2045 req = proto.Clone(req).(*kmspb.ListKeyRingsRequest)
2046 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2047 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.KeyRing, string, error) {
2048 resp := &kmspb.ListKeyRingsResponse{}
2049 if pageToken != "" {
2050 req.PageToken = pageToken
2051 }
2052 if pageSize > math.MaxInt32 {
2053 req.PageSize = math.MaxInt32
2054 } else if pageSize != 0 {
2055 req.PageSize = int32(pageSize)
2056 }
2057 baseUrl, err := url.Parse(c.endpoint)
2058 if err != nil {
2059 return nil, "", err
2060 }
2061 baseUrl.Path += fmt.Sprintf("/v1/%v/keyRings", req.GetParent())
2062
2063 params := url.Values{}
2064 params.Add("$alt", "json;enum-encoding=int")
2065 if req.GetFilter() != "" {
2066 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2067 }
2068 if req.GetOrderBy() != "" {
2069 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2070 }
2071 if req.GetPageSize() != 0 {
2072 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2073 }
2074 if req.GetPageToken() != "" {
2075 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2076 }
2077
2078 baseUrl.RawQuery = params.Encode()
2079
2080
2081 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2082 headers := gax.BuildHeaders(ctx, hds...)
2083 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2084 if settings.Path != "" {
2085 baseUrl.Path = settings.Path
2086 }
2087 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2088 if err != nil {
2089 return err
2090 }
2091 httpReq.Header = headers
2092
2093 httpRsp, err := c.httpClient.Do(httpReq)
2094 if err != nil {
2095 return err
2096 }
2097 defer httpRsp.Body.Close()
2098
2099 if err = googleapi.CheckResponse(httpRsp); err != nil {
2100 return err
2101 }
2102
2103 buf, err := io.ReadAll(httpRsp.Body)
2104 if err != nil {
2105 return err
2106 }
2107
2108 if err := unm.Unmarshal(buf, resp); err != nil {
2109 return err
2110 }
2111
2112 return nil
2113 }, opts...)
2114 if e != nil {
2115 return nil, "", e
2116 }
2117 it.Response = resp
2118 return resp.GetKeyRings(), resp.GetNextPageToken(), nil
2119 }
2120
2121 fetch := func(pageSize int, pageToken string) (string, error) {
2122 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2123 if err != nil {
2124 return "", err
2125 }
2126 it.items = append(it.items, items...)
2127 return nextPageToken, nil
2128 }
2129
2130 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2131 it.pageInfo.MaxSize = int(req.GetPageSize())
2132 it.pageInfo.Token = req.GetPageToken()
2133
2134 return it
2135 }
2136
2137
2138 func (c *keyManagementRESTClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator {
2139 it := &CryptoKeyIterator{}
2140 req = proto.Clone(req).(*kmspb.ListCryptoKeysRequest)
2141 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2142 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKey, string, error) {
2143 resp := &kmspb.ListCryptoKeysResponse{}
2144 if pageToken != "" {
2145 req.PageToken = pageToken
2146 }
2147 if pageSize > math.MaxInt32 {
2148 req.PageSize = math.MaxInt32
2149 } else if pageSize != 0 {
2150 req.PageSize = int32(pageSize)
2151 }
2152 baseUrl, err := url.Parse(c.endpoint)
2153 if err != nil {
2154 return nil, "", err
2155 }
2156 baseUrl.Path += fmt.Sprintf("/v1/%v/cryptoKeys", req.GetParent())
2157
2158 params := url.Values{}
2159 params.Add("$alt", "json;enum-encoding=int")
2160 if req.GetFilter() != "" {
2161 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2162 }
2163 if req.GetOrderBy() != "" {
2164 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2165 }
2166 if req.GetPageSize() != 0 {
2167 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2168 }
2169 if req.GetPageToken() != "" {
2170 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2171 }
2172 if req.GetVersionView() != 0 {
2173 params.Add("versionView", fmt.Sprintf("%v", req.GetVersionView()))
2174 }
2175
2176 baseUrl.RawQuery = params.Encode()
2177
2178
2179 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2180 headers := gax.BuildHeaders(ctx, hds...)
2181 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2182 if settings.Path != "" {
2183 baseUrl.Path = settings.Path
2184 }
2185 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2186 if err != nil {
2187 return err
2188 }
2189 httpReq.Header = headers
2190
2191 httpRsp, err := c.httpClient.Do(httpReq)
2192 if err != nil {
2193 return err
2194 }
2195 defer httpRsp.Body.Close()
2196
2197 if err = googleapi.CheckResponse(httpRsp); err != nil {
2198 return err
2199 }
2200
2201 buf, err := io.ReadAll(httpRsp.Body)
2202 if err != nil {
2203 return err
2204 }
2205
2206 if err := unm.Unmarshal(buf, resp); err != nil {
2207 return err
2208 }
2209
2210 return nil
2211 }, opts...)
2212 if e != nil {
2213 return nil, "", e
2214 }
2215 it.Response = resp
2216 return resp.GetCryptoKeys(), resp.GetNextPageToken(), nil
2217 }
2218
2219 fetch := func(pageSize int, pageToken string) (string, error) {
2220 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2221 if err != nil {
2222 return "", err
2223 }
2224 it.items = append(it.items, items...)
2225 return nextPageToken, nil
2226 }
2227
2228 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2229 it.pageInfo.MaxSize = int(req.GetPageSize())
2230 it.pageInfo.Token = req.GetPageToken()
2231
2232 return it
2233 }
2234
2235
2236 func (c *keyManagementRESTClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator {
2237 it := &CryptoKeyVersionIterator{}
2238 req = proto.Clone(req).(*kmspb.ListCryptoKeyVersionsRequest)
2239 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2240 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKeyVersion, string, error) {
2241 resp := &kmspb.ListCryptoKeyVersionsResponse{}
2242 if pageToken != "" {
2243 req.PageToken = pageToken
2244 }
2245 if pageSize > math.MaxInt32 {
2246 req.PageSize = math.MaxInt32
2247 } else if pageSize != 0 {
2248 req.PageSize = int32(pageSize)
2249 }
2250 baseUrl, err := url.Parse(c.endpoint)
2251 if err != nil {
2252 return nil, "", err
2253 }
2254 baseUrl.Path += fmt.Sprintf("/v1/%v/cryptoKeyVersions", req.GetParent())
2255
2256 params := url.Values{}
2257 params.Add("$alt", "json;enum-encoding=int")
2258 if req.GetFilter() != "" {
2259 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2260 }
2261 if req.GetOrderBy() != "" {
2262 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2263 }
2264 if req.GetPageSize() != 0 {
2265 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2266 }
2267 if req.GetPageToken() != "" {
2268 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2269 }
2270 if req.GetView() != 0 {
2271 params.Add("view", fmt.Sprintf("%v", req.GetView()))
2272 }
2273
2274 baseUrl.RawQuery = params.Encode()
2275
2276
2277 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2278 headers := gax.BuildHeaders(ctx, hds...)
2279 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2280 if settings.Path != "" {
2281 baseUrl.Path = settings.Path
2282 }
2283 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2284 if err != nil {
2285 return err
2286 }
2287 httpReq.Header = headers
2288
2289 httpRsp, err := c.httpClient.Do(httpReq)
2290 if err != nil {
2291 return err
2292 }
2293 defer httpRsp.Body.Close()
2294
2295 if err = googleapi.CheckResponse(httpRsp); err != nil {
2296 return err
2297 }
2298
2299 buf, err := io.ReadAll(httpRsp.Body)
2300 if err != nil {
2301 return err
2302 }
2303
2304 if err := unm.Unmarshal(buf, resp); err != nil {
2305 return err
2306 }
2307
2308 return nil
2309 }, opts...)
2310 if e != nil {
2311 return nil, "", e
2312 }
2313 it.Response = resp
2314 return resp.GetCryptoKeyVersions(), resp.GetNextPageToken(), nil
2315 }
2316
2317 fetch := func(pageSize int, pageToken string) (string, error) {
2318 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2319 if err != nil {
2320 return "", err
2321 }
2322 it.items = append(it.items, items...)
2323 return nextPageToken, nil
2324 }
2325
2326 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2327 it.pageInfo.MaxSize = int(req.GetPageSize())
2328 it.pageInfo.Token = req.GetPageToken()
2329
2330 return it
2331 }
2332
2333
2334 func (c *keyManagementRESTClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator {
2335 it := &ImportJobIterator{}
2336 req = proto.Clone(req).(*kmspb.ListImportJobsRequest)
2337 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2338 it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.ImportJob, string, error) {
2339 resp := &kmspb.ListImportJobsResponse{}
2340 if pageToken != "" {
2341 req.PageToken = pageToken
2342 }
2343 if pageSize > math.MaxInt32 {
2344 req.PageSize = math.MaxInt32
2345 } else if pageSize != 0 {
2346 req.PageSize = int32(pageSize)
2347 }
2348 baseUrl, err := url.Parse(c.endpoint)
2349 if err != nil {
2350 return nil, "", err
2351 }
2352 baseUrl.Path += fmt.Sprintf("/v1/%v/importJobs", req.GetParent())
2353
2354 params := url.Values{}
2355 params.Add("$alt", "json;enum-encoding=int")
2356 if req.GetFilter() != "" {
2357 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2358 }
2359 if req.GetOrderBy() != "" {
2360 params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
2361 }
2362 if req.GetPageSize() != 0 {
2363 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2364 }
2365 if req.GetPageToken() != "" {
2366 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2367 }
2368
2369 baseUrl.RawQuery = params.Encode()
2370
2371
2372 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2373 headers := gax.BuildHeaders(ctx, hds...)
2374 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2375 if settings.Path != "" {
2376 baseUrl.Path = settings.Path
2377 }
2378 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2379 if err != nil {
2380 return err
2381 }
2382 httpReq.Header = headers
2383
2384 httpRsp, err := c.httpClient.Do(httpReq)
2385 if err != nil {
2386 return err
2387 }
2388 defer httpRsp.Body.Close()
2389
2390 if err = googleapi.CheckResponse(httpRsp); err != nil {
2391 return err
2392 }
2393
2394 buf, err := io.ReadAll(httpRsp.Body)
2395 if err != nil {
2396 return err
2397 }
2398
2399 if err := unm.Unmarshal(buf, resp); err != nil {
2400 return err
2401 }
2402
2403 return nil
2404 }, opts...)
2405 if e != nil {
2406 return nil, "", e
2407 }
2408 it.Response = resp
2409 return resp.GetImportJobs(), resp.GetNextPageToken(), nil
2410 }
2411
2412 fetch := func(pageSize int, pageToken string) (string, error) {
2413 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2414 if err != nil {
2415 return "", err
2416 }
2417 it.items = append(it.items, items...)
2418 return nextPageToken, nil
2419 }
2420
2421 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2422 it.pageInfo.MaxSize = int(req.GetPageSize())
2423 it.pageInfo.Token = req.GetPageToken()
2424
2425 return it
2426 }
2427
2428
2429 func (c *keyManagementRESTClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
2430 baseUrl, err := url.Parse(c.endpoint)
2431 if err != nil {
2432 return nil, err
2433 }
2434 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2435
2436 params := url.Values{}
2437 params.Add("$alt", "json;enum-encoding=int")
2438
2439 baseUrl.RawQuery = params.Encode()
2440
2441
2442 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2443
2444 hds = append(c.xGoogHeaders, hds...)
2445 hds = append(hds, "Content-Type", "application/json")
2446 headers := gax.BuildHeaders(ctx, hds...)
2447 opts = append((*c.CallOptions).GetKeyRing[0:len((*c.CallOptions).GetKeyRing):len((*c.CallOptions).GetKeyRing)], opts...)
2448 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2449 resp := &kmspb.KeyRing{}
2450 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2451 if settings.Path != "" {
2452 baseUrl.Path = settings.Path
2453 }
2454 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2455 if err != nil {
2456 return err
2457 }
2458 httpReq = httpReq.WithContext(ctx)
2459 httpReq.Header = headers
2460
2461 httpRsp, err := c.httpClient.Do(httpReq)
2462 if err != nil {
2463 return err
2464 }
2465 defer httpRsp.Body.Close()
2466
2467 if err = googleapi.CheckResponse(httpRsp); err != nil {
2468 return err
2469 }
2470
2471 buf, err := io.ReadAll(httpRsp.Body)
2472 if err != nil {
2473 return err
2474 }
2475
2476 if err := unm.Unmarshal(buf, resp); err != nil {
2477 return err
2478 }
2479
2480 return nil
2481 }, opts...)
2482 if e != nil {
2483 return nil, e
2484 }
2485 return resp, nil
2486 }
2487
2488
2489
2490
2491 func (c *keyManagementRESTClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
2492 baseUrl, err := url.Parse(c.endpoint)
2493 if err != nil {
2494 return nil, err
2495 }
2496 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2497
2498 params := url.Values{}
2499 params.Add("$alt", "json;enum-encoding=int")
2500
2501 baseUrl.RawQuery = params.Encode()
2502
2503
2504 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2505
2506 hds = append(c.xGoogHeaders, hds...)
2507 hds = append(hds, "Content-Type", "application/json")
2508 headers := gax.BuildHeaders(ctx, hds...)
2509 opts = append((*c.CallOptions).GetCryptoKey[0:len((*c.CallOptions).GetCryptoKey):len((*c.CallOptions).GetCryptoKey)], opts...)
2510 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2511 resp := &kmspb.CryptoKey{}
2512 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2513 if settings.Path != "" {
2514 baseUrl.Path = settings.Path
2515 }
2516 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2517 if err != nil {
2518 return err
2519 }
2520 httpReq = httpReq.WithContext(ctx)
2521 httpReq.Header = headers
2522
2523 httpRsp, err := c.httpClient.Do(httpReq)
2524 if err != nil {
2525 return err
2526 }
2527 defer httpRsp.Body.Close()
2528
2529 if err = googleapi.CheckResponse(httpRsp); err != nil {
2530 return err
2531 }
2532
2533 buf, err := io.ReadAll(httpRsp.Body)
2534 if err != nil {
2535 return err
2536 }
2537
2538 if err := unm.Unmarshal(buf, resp); err != nil {
2539 return err
2540 }
2541
2542 return nil
2543 }, opts...)
2544 if e != nil {
2545 return nil, e
2546 }
2547 return resp, nil
2548 }
2549
2550
2551
2552 func (c *keyManagementRESTClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
2553 baseUrl, err := url.Parse(c.endpoint)
2554 if err != nil {
2555 return nil, err
2556 }
2557 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2558
2559 params := url.Values{}
2560 params.Add("$alt", "json;enum-encoding=int")
2561
2562 baseUrl.RawQuery = params.Encode()
2563
2564
2565 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2566
2567 hds = append(c.xGoogHeaders, hds...)
2568 hds = append(hds, "Content-Type", "application/json")
2569 headers := gax.BuildHeaders(ctx, hds...)
2570 opts = append((*c.CallOptions).GetCryptoKeyVersion[0:len((*c.CallOptions).GetCryptoKeyVersion):len((*c.CallOptions).GetCryptoKeyVersion)], opts...)
2571 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2572 resp := &kmspb.CryptoKeyVersion{}
2573 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2574 if settings.Path != "" {
2575 baseUrl.Path = settings.Path
2576 }
2577 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2578 if err != nil {
2579 return err
2580 }
2581 httpReq = httpReq.WithContext(ctx)
2582 httpReq.Header = headers
2583
2584 httpRsp, err := c.httpClient.Do(httpReq)
2585 if err != nil {
2586 return err
2587 }
2588 defer httpRsp.Body.Close()
2589
2590 if err = googleapi.CheckResponse(httpRsp); err != nil {
2591 return err
2592 }
2593
2594 buf, err := io.ReadAll(httpRsp.Body)
2595 if err != nil {
2596 return err
2597 }
2598
2599 if err := unm.Unmarshal(buf, resp); err != nil {
2600 return err
2601 }
2602
2603 return nil
2604 }, opts...)
2605 if e != nil {
2606 return nil, e
2607 }
2608 return resp, nil
2609 }
2610
2611
2612
2613
2614
2615
2616
2617 func (c *keyManagementRESTClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error) {
2618 baseUrl, err := url.Parse(c.endpoint)
2619 if err != nil {
2620 return nil, err
2621 }
2622 baseUrl.Path += fmt.Sprintf("/v1/%v/publicKey", req.GetName())
2623
2624 params := url.Values{}
2625 params.Add("$alt", "json;enum-encoding=int")
2626
2627 baseUrl.RawQuery = params.Encode()
2628
2629
2630 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2631
2632 hds = append(c.xGoogHeaders, hds...)
2633 hds = append(hds, "Content-Type", "application/json")
2634 headers := gax.BuildHeaders(ctx, hds...)
2635 opts = append((*c.CallOptions).GetPublicKey[0:len((*c.CallOptions).GetPublicKey):len((*c.CallOptions).GetPublicKey)], opts...)
2636 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2637 resp := &kmspb.PublicKey{}
2638 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2639 if settings.Path != "" {
2640 baseUrl.Path = settings.Path
2641 }
2642 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2643 if err != nil {
2644 return err
2645 }
2646 httpReq = httpReq.WithContext(ctx)
2647 httpReq.Header = headers
2648
2649 httpRsp, err := c.httpClient.Do(httpReq)
2650 if err != nil {
2651 return err
2652 }
2653 defer httpRsp.Body.Close()
2654
2655 if err = googleapi.CheckResponse(httpRsp); err != nil {
2656 return err
2657 }
2658
2659 buf, err := io.ReadAll(httpRsp.Body)
2660 if err != nil {
2661 return err
2662 }
2663
2664 if err := unm.Unmarshal(buf, resp); err != nil {
2665 return err
2666 }
2667
2668 return nil
2669 }, opts...)
2670 if e != nil {
2671 return nil, e
2672 }
2673 return resp, nil
2674 }
2675
2676
2677 func (c *keyManagementRESTClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
2678 baseUrl, err := url.Parse(c.endpoint)
2679 if err != nil {
2680 return nil, err
2681 }
2682 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2683
2684 params := url.Values{}
2685 params.Add("$alt", "json;enum-encoding=int")
2686
2687 baseUrl.RawQuery = params.Encode()
2688
2689
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).GetImportJob[0:len((*c.CallOptions).GetImportJob):len((*c.CallOptions).GetImportJob)], opts...)
2696 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2697 resp := &kmspb.ImportJob{}
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 httpRsp, err := c.httpClient.Do(httpReq)
2710 if err != nil {
2711 return err
2712 }
2713 defer httpRsp.Body.Close()
2714
2715 if err = googleapi.CheckResponse(httpRsp); err != nil {
2716 return err
2717 }
2718
2719 buf, err := io.ReadAll(httpRsp.Body)
2720 if err != nil {
2721 return err
2722 }
2723
2724 if err := unm.Unmarshal(buf, resp); err != nil {
2725 return err
2726 }
2727
2728 return nil
2729 }, opts...)
2730 if e != nil {
2731 return nil, e
2732 }
2733 return resp, nil
2734 }
2735
2736
2737
2738 func (c *keyManagementRESTClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
2739 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2740 body := req.GetKeyRing()
2741 jsonReq, err := m.Marshal(body)
2742 if err != nil {
2743 return nil, err
2744 }
2745
2746 baseUrl, err := url.Parse(c.endpoint)
2747 if err != nil {
2748 return nil, err
2749 }
2750 baseUrl.Path += fmt.Sprintf("/v1/%v/keyRings", req.GetParent())
2751
2752 params := url.Values{}
2753 params.Add("$alt", "json;enum-encoding=int")
2754 params.Add("keyRingId", fmt.Sprintf("%v", req.GetKeyRingId()))
2755
2756 baseUrl.RawQuery = params.Encode()
2757
2758
2759 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2760
2761 hds = append(c.xGoogHeaders, hds...)
2762 hds = append(hds, "Content-Type", "application/json")
2763 headers := gax.BuildHeaders(ctx, hds...)
2764 opts = append((*c.CallOptions).CreateKeyRing[0:len((*c.CallOptions).CreateKeyRing):len((*c.CallOptions).CreateKeyRing)], opts...)
2765 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2766 resp := &kmspb.KeyRing{}
2767 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2768 if settings.Path != "" {
2769 baseUrl.Path = settings.Path
2770 }
2771 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2772 if err != nil {
2773 return err
2774 }
2775 httpReq = httpReq.WithContext(ctx)
2776 httpReq.Header = headers
2777
2778 httpRsp, err := c.httpClient.Do(httpReq)
2779 if err != nil {
2780 return err
2781 }
2782 defer httpRsp.Body.Close()
2783
2784 if err = googleapi.CheckResponse(httpRsp); err != nil {
2785 return err
2786 }
2787
2788 buf, err := io.ReadAll(httpRsp.Body)
2789 if err != nil {
2790 return err
2791 }
2792
2793 if err := unm.Unmarshal(buf, resp); err != nil {
2794 return err
2795 }
2796
2797 return nil
2798 }, opts...)
2799 if e != nil {
2800 return nil, e
2801 }
2802 return resp, nil
2803 }
2804
2805
2806
2807
2808
2809
2810
2811 func (c *keyManagementRESTClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
2812 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2813 body := req.GetCryptoKey()
2814 jsonReq, err := m.Marshal(body)
2815 if err != nil {
2816 return nil, err
2817 }
2818
2819 baseUrl, err := url.Parse(c.endpoint)
2820 if err != nil {
2821 return nil, err
2822 }
2823 baseUrl.Path += fmt.Sprintf("/v1/%v/cryptoKeys", req.GetParent())
2824
2825 params := url.Values{}
2826 params.Add("$alt", "json;enum-encoding=int")
2827 params.Add("cryptoKeyId", fmt.Sprintf("%v", req.GetCryptoKeyId()))
2828 if req.GetSkipInitialVersionCreation() {
2829 params.Add("skipInitialVersionCreation", fmt.Sprintf("%v", req.GetSkipInitialVersionCreation()))
2830 }
2831
2832 baseUrl.RawQuery = params.Encode()
2833
2834
2835 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2836
2837 hds = append(c.xGoogHeaders, hds...)
2838 hds = append(hds, "Content-Type", "application/json")
2839 headers := gax.BuildHeaders(ctx, hds...)
2840 opts = append((*c.CallOptions).CreateCryptoKey[0:len((*c.CallOptions).CreateCryptoKey):len((*c.CallOptions).CreateCryptoKey)], opts...)
2841 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2842 resp := &kmspb.CryptoKey{}
2843 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2844 if settings.Path != "" {
2845 baseUrl.Path = settings.Path
2846 }
2847 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2848 if err != nil {
2849 return err
2850 }
2851 httpReq = httpReq.WithContext(ctx)
2852 httpReq.Header = headers
2853
2854 httpRsp, err := c.httpClient.Do(httpReq)
2855 if err != nil {
2856 return err
2857 }
2858 defer httpRsp.Body.Close()
2859
2860 if err = googleapi.CheckResponse(httpRsp); err != nil {
2861 return err
2862 }
2863
2864 buf, err := io.ReadAll(httpRsp.Body)
2865 if err != nil {
2866 return err
2867 }
2868
2869 if err := unm.Unmarshal(buf, resp); err != nil {
2870 return err
2871 }
2872
2873 return nil
2874 }, opts...)
2875 if e != nil {
2876 return nil, e
2877 }
2878 return resp, nil
2879 }
2880
2881
2882
2883
2884
2885
2886
2887 func (c *keyManagementRESTClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
2888 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2889 body := req.GetCryptoKeyVersion()
2890 jsonReq, err := m.Marshal(body)
2891 if err != nil {
2892 return nil, err
2893 }
2894
2895 baseUrl, err := url.Parse(c.endpoint)
2896 if err != nil {
2897 return nil, err
2898 }
2899 baseUrl.Path += fmt.Sprintf("/v1/%v/cryptoKeyVersions", req.GetParent())
2900
2901 params := url.Values{}
2902 params.Add("$alt", "json;enum-encoding=int")
2903
2904 baseUrl.RawQuery = params.Encode()
2905
2906
2907 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2908
2909 hds = append(c.xGoogHeaders, hds...)
2910 hds = append(hds, "Content-Type", "application/json")
2911 headers := gax.BuildHeaders(ctx, hds...)
2912 opts = append((*c.CallOptions).CreateCryptoKeyVersion[0:len((*c.CallOptions).CreateCryptoKeyVersion):len((*c.CallOptions).CreateCryptoKeyVersion)], opts...)
2913 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2914 resp := &kmspb.CryptoKeyVersion{}
2915 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2916 if settings.Path != "" {
2917 baseUrl.Path = settings.Path
2918 }
2919 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2920 if err != nil {
2921 return err
2922 }
2923 httpReq = httpReq.WithContext(ctx)
2924 httpReq.Header = headers
2925
2926 httpRsp, err := c.httpClient.Do(httpReq)
2927 if err != nil {
2928 return err
2929 }
2930 defer httpRsp.Body.Close()
2931
2932 if err = googleapi.CheckResponse(httpRsp); err != nil {
2933 return err
2934 }
2935
2936 buf, err := io.ReadAll(httpRsp.Body)
2937 if err != nil {
2938 return err
2939 }
2940
2941 if err := unm.Unmarshal(buf, resp); err != nil {
2942 return err
2943 }
2944
2945 return nil
2946 }, opts...)
2947 if e != nil {
2948 return nil, e
2949 }
2950 return resp, nil
2951 }
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961 func (c *keyManagementRESTClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
2962 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2963 jsonReq, err := m.Marshal(req)
2964 if err != nil {
2965 return nil, err
2966 }
2967
2968 baseUrl, err := url.Parse(c.endpoint)
2969 if err != nil {
2970 return nil, err
2971 }
2972 baseUrl.Path += fmt.Sprintf("/v1/%v/cryptoKeyVersions:import", req.GetParent())
2973
2974 params := url.Values{}
2975 params.Add("$alt", "json;enum-encoding=int")
2976
2977 baseUrl.RawQuery = params.Encode()
2978
2979
2980 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2981
2982 hds = append(c.xGoogHeaders, hds...)
2983 hds = append(hds, "Content-Type", "application/json")
2984 headers := gax.BuildHeaders(ctx, hds...)
2985 opts = append((*c.CallOptions).ImportCryptoKeyVersion[0:len((*c.CallOptions).ImportCryptoKeyVersion):len((*c.CallOptions).ImportCryptoKeyVersion)], opts...)
2986 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2987 resp := &kmspb.CryptoKeyVersion{}
2988 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2989 if settings.Path != "" {
2990 baseUrl.Path = settings.Path
2991 }
2992 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2993 if err != nil {
2994 return err
2995 }
2996 httpReq = httpReq.WithContext(ctx)
2997 httpReq.Header = headers
2998
2999 httpRsp, err := c.httpClient.Do(httpReq)
3000 if err != nil {
3001 return err
3002 }
3003 defer httpRsp.Body.Close()
3004
3005 if err = googleapi.CheckResponse(httpRsp); err != nil {
3006 return err
3007 }
3008
3009 buf, err := io.ReadAll(httpRsp.Body)
3010 if err != nil {
3011 return err
3012 }
3013
3014 if err := unm.Unmarshal(buf, resp); err != nil {
3015 return err
3016 }
3017
3018 return nil
3019 }, opts...)
3020 if e != nil {
3021 return nil, e
3022 }
3023 return resp, nil
3024 }
3025
3026
3027
3028
3029
3030
3031 func (c *keyManagementRESTClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
3032 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3033 body := req.GetImportJob()
3034 jsonReq, err := m.Marshal(body)
3035 if err != nil {
3036 return nil, err
3037 }
3038
3039 baseUrl, err := url.Parse(c.endpoint)
3040 if err != nil {
3041 return nil, err
3042 }
3043 baseUrl.Path += fmt.Sprintf("/v1/%v/importJobs", req.GetParent())
3044
3045 params := url.Values{}
3046 params.Add("$alt", "json;enum-encoding=int")
3047 params.Add("importJobId", fmt.Sprintf("%v", req.GetImportJobId()))
3048
3049 baseUrl.RawQuery = params.Encode()
3050
3051
3052 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
3053
3054 hds = append(c.xGoogHeaders, hds...)
3055 hds = append(hds, "Content-Type", "application/json")
3056 headers := gax.BuildHeaders(ctx, hds...)
3057 opts = append((*c.CallOptions).CreateImportJob[0:len((*c.CallOptions).CreateImportJob):len((*c.CallOptions).CreateImportJob)], opts...)
3058 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3059 resp := &kmspb.ImportJob{}
3060 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3061 if settings.Path != "" {
3062 baseUrl.Path = settings.Path
3063 }
3064 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3065 if err != nil {
3066 return err
3067 }
3068 httpReq = httpReq.WithContext(ctx)
3069 httpReq.Header = headers
3070
3071 httpRsp, err := c.httpClient.Do(httpReq)
3072 if err != nil {
3073 return err
3074 }
3075 defer httpRsp.Body.Close()
3076
3077 if err = googleapi.CheckResponse(httpRsp); err != nil {
3078 return err
3079 }
3080
3081 buf, err := io.ReadAll(httpRsp.Body)
3082 if err != nil {
3083 return err
3084 }
3085
3086 if err := unm.Unmarshal(buf, resp); err != nil {
3087 return err
3088 }
3089
3090 return nil
3091 }, opts...)
3092 if e != nil {
3093 return nil, e
3094 }
3095 return resp, nil
3096 }
3097
3098
3099 func (c *keyManagementRESTClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
3100 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3101 body := req.GetCryptoKey()
3102 jsonReq, err := m.Marshal(body)
3103 if err != nil {
3104 return nil, err
3105 }
3106
3107 baseUrl, err := url.Parse(c.endpoint)
3108 if err != nil {
3109 return nil, err
3110 }
3111 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetCryptoKey().GetName())
3112
3113 params := url.Values{}
3114 params.Add("$alt", "json;enum-encoding=int")
3115 if req.GetUpdateMask() != nil {
3116 updateMask, err := protojson.Marshal(req.GetUpdateMask())
3117 if err != nil {
3118 return nil, err
3119 }
3120 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
3121 }
3122
3123 baseUrl.RawQuery = params.Encode()
3124
3125
3126 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key.name", url.QueryEscape(req.GetCryptoKey().GetName()))}
3127
3128 hds = append(c.xGoogHeaders, hds...)
3129 hds = append(hds, "Content-Type", "application/json")
3130 headers := gax.BuildHeaders(ctx, hds...)
3131 opts = append((*c.CallOptions).UpdateCryptoKey[0:len((*c.CallOptions).UpdateCryptoKey):len((*c.CallOptions).UpdateCryptoKey)], opts...)
3132 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3133 resp := &kmspb.CryptoKey{}
3134 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3135 if settings.Path != "" {
3136 baseUrl.Path = settings.Path
3137 }
3138 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
3139 if err != nil {
3140 return err
3141 }
3142 httpReq = httpReq.WithContext(ctx)
3143 httpReq.Header = headers
3144
3145 httpRsp, err := c.httpClient.Do(httpReq)
3146 if err != nil {
3147 return err
3148 }
3149 defer httpRsp.Body.Close()
3150
3151 if err = googleapi.CheckResponse(httpRsp); err != nil {
3152 return err
3153 }
3154
3155 buf, err := io.ReadAll(httpRsp.Body)
3156 if err != nil {
3157 return err
3158 }
3159
3160 if err := unm.Unmarshal(buf, resp); err != nil {
3161 return err
3162 }
3163
3164 return nil
3165 }, opts...)
3166 if e != nil {
3167 return nil, e
3168 }
3169 return resp, nil
3170 }
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184 func (c *keyManagementRESTClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
3185 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3186 body := req.GetCryptoKeyVersion()
3187 jsonReq, err := m.Marshal(body)
3188 if err != nil {
3189 return nil, err
3190 }
3191
3192 baseUrl, err := url.Parse(c.endpoint)
3193 if err != nil {
3194 return nil, err
3195 }
3196 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetCryptoKeyVersion().GetName())
3197
3198 params := url.Values{}
3199 params.Add("$alt", "json;enum-encoding=int")
3200 if req.GetUpdateMask() != nil {
3201 updateMask, err := protojson.Marshal(req.GetUpdateMask())
3202 if err != nil {
3203 return nil, err
3204 }
3205 params.Add("updateMask", string(updateMask[1:len(updateMask)-1]))
3206 }
3207
3208 baseUrl.RawQuery = params.Encode()
3209
3210
3211 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key_version.name", url.QueryEscape(req.GetCryptoKeyVersion().GetName()))}
3212
3213 hds = append(c.xGoogHeaders, hds...)
3214 hds = append(hds, "Content-Type", "application/json")
3215 headers := gax.BuildHeaders(ctx, hds...)
3216 opts = append((*c.CallOptions).UpdateCryptoKeyVersion[0:len((*c.CallOptions).UpdateCryptoKeyVersion):len((*c.CallOptions).UpdateCryptoKeyVersion)], opts...)
3217 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3218 resp := &kmspb.CryptoKeyVersion{}
3219 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3220 if settings.Path != "" {
3221 baseUrl.Path = settings.Path
3222 }
3223 httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
3224 if err != nil {
3225 return err
3226 }
3227 httpReq = httpReq.WithContext(ctx)
3228 httpReq.Header = headers
3229
3230 httpRsp, err := c.httpClient.Do(httpReq)
3231 if err != nil {
3232 return err
3233 }
3234 defer httpRsp.Body.Close()
3235
3236 if err = googleapi.CheckResponse(httpRsp); err != nil {
3237 return err
3238 }
3239
3240 buf, err := io.ReadAll(httpRsp.Body)
3241 if err != nil {
3242 return err
3243 }
3244
3245 if err := unm.Unmarshal(buf, resp); err != nil {
3246 return err
3247 }
3248
3249 return nil
3250 }, opts...)
3251 if e != nil {
3252 return nil, e
3253 }
3254 return resp, nil
3255 }
3256
3257
3258
3259
3260
3261
3262
3263 func (c *keyManagementRESTClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
3264 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3265 jsonReq, err := m.Marshal(req)
3266 if err != nil {
3267 return nil, err
3268 }
3269
3270 baseUrl, err := url.Parse(c.endpoint)
3271 if err != nil {
3272 return nil, err
3273 }
3274 baseUrl.Path += fmt.Sprintf("/v1/%v:updatePrimaryVersion", req.GetName())
3275
3276 params := url.Values{}
3277 params.Add("$alt", "json;enum-encoding=int")
3278
3279 baseUrl.RawQuery = params.Encode()
3280
3281
3282 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3283
3284 hds = append(c.xGoogHeaders, hds...)
3285 hds = append(hds, "Content-Type", "application/json")
3286 headers := gax.BuildHeaders(ctx, hds...)
3287 opts = append((*c.CallOptions).UpdateCryptoKeyPrimaryVersion[0:len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion):len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion)], opts...)
3288 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3289 resp := &kmspb.CryptoKey{}
3290 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3291 if settings.Path != "" {
3292 baseUrl.Path = settings.Path
3293 }
3294 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3295 if err != nil {
3296 return err
3297 }
3298 httpReq = httpReq.WithContext(ctx)
3299 httpReq.Header = headers
3300
3301 httpRsp, err := c.httpClient.Do(httpReq)
3302 if err != nil {
3303 return err
3304 }
3305 defer httpRsp.Body.Close()
3306
3307 if err = googleapi.CheckResponse(httpRsp); err != nil {
3308 return err
3309 }
3310
3311 buf, err := io.ReadAll(httpRsp.Body)
3312 if err != nil {
3313 return err
3314 }
3315
3316 if err := unm.Unmarshal(buf, resp); err != nil {
3317 return err
3318 }
3319
3320 return nil
3321 }, opts...)
3322 if e != nil {
3323 return nil, e
3324 }
3325 return resp, nil
3326 }
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349 func (c *keyManagementRESTClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
3350 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3351 jsonReq, err := m.Marshal(req)
3352 if err != nil {
3353 return nil, err
3354 }
3355
3356 baseUrl, err := url.Parse(c.endpoint)
3357 if err != nil {
3358 return nil, err
3359 }
3360 baseUrl.Path += fmt.Sprintf("/v1/%v:destroy", req.GetName())
3361
3362 params := url.Values{}
3363 params.Add("$alt", "json;enum-encoding=int")
3364
3365 baseUrl.RawQuery = params.Encode()
3366
3367
3368 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3369
3370 hds = append(c.xGoogHeaders, hds...)
3371 hds = append(hds, "Content-Type", "application/json")
3372 headers := gax.BuildHeaders(ctx, hds...)
3373 opts = append((*c.CallOptions).DestroyCryptoKeyVersion[0:len((*c.CallOptions).DestroyCryptoKeyVersion):len((*c.CallOptions).DestroyCryptoKeyVersion)], opts...)
3374 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3375 resp := &kmspb.CryptoKeyVersion{}
3376 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3377 if settings.Path != "" {
3378 baseUrl.Path = settings.Path
3379 }
3380 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3381 if err != nil {
3382 return err
3383 }
3384 httpReq = httpReq.WithContext(ctx)
3385 httpReq.Header = headers
3386
3387 httpRsp, err := c.httpClient.Do(httpReq)
3388 if err != nil {
3389 return err
3390 }
3391 defer httpRsp.Body.Close()
3392
3393 if err = googleapi.CheckResponse(httpRsp); err != nil {
3394 return err
3395 }
3396
3397 buf, err := io.ReadAll(httpRsp.Body)
3398 if err != nil {
3399 return err
3400 }
3401
3402 if err := unm.Unmarshal(buf, resp); err != nil {
3403 return err
3404 }
3405
3406 return nil
3407 }, opts...)
3408 if e != nil {
3409 return nil, e
3410 }
3411 return resp, nil
3412 }
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423 func (c *keyManagementRESTClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
3424 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3425 jsonReq, err := m.Marshal(req)
3426 if err != nil {
3427 return nil, err
3428 }
3429
3430 baseUrl, err := url.Parse(c.endpoint)
3431 if err != nil {
3432 return nil, err
3433 }
3434 baseUrl.Path += fmt.Sprintf("/v1/%v:restore", req.GetName())
3435
3436 params := url.Values{}
3437 params.Add("$alt", "json;enum-encoding=int")
3438
3439 baseUrl.RawQuery = params.Encode()
3440
3441
3442 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3443
3444 hds = append(c.xGoogHeaders, hds...)
3445 hds = append(hds, "Content-Type", "application/json")
3446 headers := gax.BuildHeaders(ctx, hds...)
3447 opts = append((*c.CallOptions).RestoreCryptoKeyVersion[0:len((*c.CallOptions).RestoreCryptoKeyVersion):len((*c.CallOptions).RestoreCryptoKeyVersion)], opts...)
3448 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3449 resp := &kmspb.CryptoKeyVersion{}
3450 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3451 if settings.Path != "" {
3452 baseUrl.Path = settings.Path
3453 }
3454 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3455 if err != nil {
3456 return err
3457 }
3458 httpReq = httpReq.WithContext(ctx)
3459 httpReq.Header = headers
3460
3461 httpRsp, err := c.httpClient.Do(httpReq)
3462 if err != nil {
3463 return err
3464 }
3465 defer httpRsp.Body.Close()
3466
3467 if err = googleapi.CheckResponse(httpRsp); err != nil {
3468 return err
3469 }
3470
3471 buf, err := io.ReadAll(httpRsp.Body)
3472 if err != nil {
3473 return err
3474 }
3475
3476 if err := unm.Unmarshal(buf, resp); err != nil {
3477 return err
3478 }
3479
3480 return nil
3481 }, opts...)
3482 if e != nil {
3483 return nil, e
3484 }
3485 return resp, nil
3486 }
3487
3488
3489
3490
3491
3492 func (c *keyManagementRESTClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error) {
3493 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3494 jsonReq, err := m.Marshal(req)
3495 if err != nil {
3496 return nil, err
3497 }
3498
3499 baseUrl, err := url.Parse(c.endpoint)
3500 if err != nil {
3501 return nil, err
3502 }
3503 baseUrl.Path += fmt.Sprintf("/v1/%v:encrypt", req.GetName())
3504
3505 params := url.Values{}
3506 params.Add("$alt", "json;enum-encoding=int")
3507
3508 baseUrl.RawQuery = params.Encode()
3509
3510
3511 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3512
3513 hds = append(c.xGoogHeaders, hds...)
3514 hds = append(hds, "Content-Type", "application/json")
3515 headers := gax.BuildHeaders(ctx, hds...)
3516 opts = append((*c.CallOptions).Encrypt[0:len((*c.CallOptions).Encrypt):len((*c.CallOptions).Encrypt)], opts...)
3517 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3518 resp := &kmspb.EncryptResponse{}
3519 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3520 if settings.Path != "" {
3521 baseUrl.Path = settings.Path
3522 }
3523 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3524 if err != nil {
3525 return err
3526 }
3527 httpReq = httpReq.WithContext(ctx)
3528 httpReq.Header = headers
3529
3530 httpRsp, err := c.httpClient.Do(httpReq)
3531 if err != nil {
3532 return err
3533 }
3534 defer httpRsp.Body.Close()
3535
3536 if err = googleapi.CheckResponse(httpRsp); err != nil {
3537 return err
3538 }
3539
3540 buf, err := io.ReadAll(httpRsp.Body)
3541 if err != nil {
3542 return err
3543 }
3544
3545 if err := unm.Unmarshal(buf, resp); err != nil {
3546 return err
3547 }
3548
3549 return nil
3550 }, opts...)
3551 if e != nil {
3552 return nil, e
3553 }
3554 return resp, nil
3555 }
3556
3557
3558
3559
3560
3561 func (c *keyManagementRESTClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error) {
3562 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3563 jsonReq, err := m.Marshal(req)
3564 if err != nil {
3565 return nil, err
3566 }
3567
3568 baseUrl, err := url.Parse(c.endpoint)
3569 if err != nil {
3570 return nil, err
3571 }
3572 baseUrl.Path += fmt.Sprintf("/v1/%v:decrypt", req.GetName())
3573
3574 params := url.Values{}
3575 params.Add("$alt", "json;enum-encoding=int")
3576
3577 baseUrl.RawQuery = params.Encode()
3578
3579
3580 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3581
3582 hds = append(c.xGoogHeaders, hds...)
3583 hds = append(hds, "Content-Type", "application/json")
3584 headers := gax.BuildHeaders(ctx, hds...)
3585 opts = append((*c.CallOptions).Decrypt[0:len((*c.CallOptions).Decrypt):len((*c.CallOptions).Decrypt)], opts...)
3586 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3587 resp := &kmspb.DecryptResponse{}
3588 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3589 if settings.Path != "" {
3590 baseUrl.Path = settings.Path
3591 }
3592 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3593 if err != nil {
3594 return err
3595 }
3596 httpReq = httpReq.WithContext(ctx)
3597 httpReq.Header = headers
3598
3599 httpRsp, err := c.httpClient.Do(httpReq)
3600 if err != nil {
3601 return err
3602 }
3603 defer httpRsp.Body.Close()
3604
3605 if err = googleapi.CheckResponse(httpRsp); err != nil {
3606 return err
3607 }
3608
3609 buf, err := io.ReadAll(httpRsp.Body)
3610 if err != nil {
3611 return err
3612 }
3613
3614 if err := unm.Unmarshal(buf, resp); err != nil {
3615 return err
3616 }
3617
3618 return nil
3619 }, opts...)
3620 if e != nil {
3621 return nil, e
3622 }
3623 return resp, nil
3624 }
3625
3626
3627
3628
3629
3630
3631
3632 func (c *keyManagementRESTClient) RawEncrypt(ctx context.Context, req *kmspb.RawEncryptRequest, opts ...gax.CallOption) (*kmspb.RawEncryptResponse, error) {
3633 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3634 jsonReq, err := m.Marshal(req)
3635 if err != nil {
3636 return nil, err
3637 }
3638
3639 baseUrl, err := url.Parse(c.endpoint)
3640 if err != nil {
3641 return nil, err
3642 }
3643 baseUrl.Path += fmt.Sprintf("/v1/%v:rawEncrypt", req.GetName())
3644
3645 params := url.Values{}
3646 params.Add("$alt", "json;enum-encoding=int")
3647
3648 baseUrl.RawQuery = params.Encode()
3649
3650
3651 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3652
3653 hds = append(c.xGoogHeaders, hds...)
3654 hds = append(hds, "Content-Type", "application/json")
3655 headers := gax.BuildHeaders(ctx, hds...)
3656 opts = append((*c.CallOptions).RawEncrypt[0:len((*c.CallOptions).RawEncrypt):len((*c.CallOptions).RawEncrypt)], opts...)
3657 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3658 resp := &kmspb.RawEncryptResponse{}
3659 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3660 if settings.Path != "" {
3661 baseUrl.Path = settings.Path
3662 }
3663 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3664 if err != nil {
3665 return err
3666 }
3667 httpReq = httpReq.WithContext(ctx)
3668 httpReq.Header = headers
3669
3670 httpRsp, err := c.httpClient.Do(httpReq)
3671 if err != nil {
3672 return err
3673 }
3674 defer httpRsp.Body.Close()
3675
3676 if err = googleapi.CheckResponse(httpRsp); err != nil {
3677 return err
3678 }
3679
3680 buf, err := io.ReadAll(httpRsp.Body)
3681 if err != nil {
3682 return err
3683 }
3684
3685 if err := unm.Unmarshal(buf, resp); err != nil {
3686 return err
3687 }
3688
3689 return nil
3690 }, opts...)
3691 if e != nil {
3692 return nil, e
3693 }
3694 return resp, nil
3695 }
3696
3697
3698
3699
3700
3701 func (c *keyManagementRESTClient) RawDecrypt(ctx context.Context, req *kmspb.RawDecryptRequest, opts ...gax.CallOption) (*kmspb.RawDecryptResponse, error) {
3702 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3703 jsonReq, err := m.Marshal(req)
3704 if err != nil {
3705 return nil, err
3706 }
3707
3708 baseUrl, err := url.Parse(c.endpoint)
3709 if err != nil {
3710 return nil, err
3711 }
3712 baseUrl.Path += fmt.Sprintf("/v1/%v:rawDecrypt", req.GetName())
3713
3714 params := url.Values{}
3715 params.Add("$alt", "json;enum-encoding=int")
3716
3717 baseUrl.RawQuery = params.Encode()
3718
3719
3720 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3721
3722 hds = append(c.xGoogHeaders, hds...)
3723 hds = append(hds, "Content-Type", "application/json")
3724 headers := gax.BuildHeaders(ctx, hds...)
3725 opts = append((*c.CallOptions).RawDecrypt[0:len((*c.CallOptions).RawDecrypt):len((*c.CallOptions).RawDecrypt)], opts...)
3726 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3727 resp := &kmspb.RawDecryptResponse{}
3728 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3729 if settings.Path != "" {
3730 baseUrl.Path = settings.Path
3731 }
3732 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3733 if err != nil {
3734 return err
3735 }
3736 httpReq = httpReq.WithContext(ctx)
3737 httpReq.Header = headers
3738
3739 httpRsp, err := c.httpClient.Do(httpReq)
3740 if err != nil {
3741 return err
3742 }
3743 defer httpRsp.Body.Close()
3744
3745 if err = googleapi.CheckResponse(httpRsp); err != nil {
3746 return err
3747 }
3748
3749 buf, err := io.ReadAll(httpRsp.Body)
3750 if err != nil {
3751 return err
3752 }
3753
3754 if err := unm.Unmarshal(buf, resp); err != nil {
3755 return err
3756 }
3757
3758 return nil
3759 }, opts...)
3760 if e != nil {
3761 return nil, e
3762 }
3763 return resp, nil
3764 }
3765
3766
3767
3768
3769
3770
3771 func (c *keyManagementRESTClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error) {
3772 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3773 jsonReq, err := m.Marshal(req)
3774 if err != nil {
3775 return nil, err
3776 }
3777
3778 baseUrl, err := url.Parse(c.endpoint)
3779 if err != nil {
3780 return nil, err
3781 }
3782 baseUrl.Path += fmt.Sprintf("/v1/%v:asymmetricSign", req.GetName())
3783
3784 params := url.Values{}
3785 params.Add("$alt", "json;enum-encoding=int")
3786
3787 baseUrl.RawQuery = params.Encode()
3788
3789
3790 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3791
3792 hds = append(c.xGoogHeaders, hds...)
3793 hds = append(hds, "Content-Type", "application/json")
3794 headers := gax.BuildHeaders(ctx, hds...)
3795 opts = append((*c.CallOptions).AsymmetricSign[0:len((*c.CallOptions).AsymmetricSign):len((*c.CallOptions).AsymmetricSign)], opts...)
3796 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3797 resp := &kmspb.AsymmetricSignResponse{}
3798 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3799 if settings.Path != "" {
3800 baseUrl.Path = settings.Path
3801 }
3802 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3803 if err != nil {
3804 return err
3805 }
3806 httpReq = httpReq.WithContext(ctx)
3807 httpReq.Header = headers
3808
3809 httpRsp, err := c.httpClient.Do(httpReq)
3810 if err != nil {
3811 return err
3812 }
3813 defer httpRsp.Body.Close()
3814
3815 if err = googleapi.CheckResponse(httpRsp); err != nil {
3816 return err
3817 }
3818
3819 buf, err := io.ReadAll(httpRsp.Body)
3820 if err != nil {
3821 return err
3822 }
3823
3824 if err := unm.Unmarshal(buf, resp); err != nil {
3825 return err
3826 }
3827
3828 return nil
3829 }, opts...)
3830 if e != nil {
3831 return nil, e
3832 }
3833 return resp, nil
3834 }
3835
3836
3837
3838
3839
3840
3841 func (c *keyManagementRESTClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error) {
3842 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3843 jsonReq, err := m.Marshal(req)
3844 if err != nil {
3845 return nil, err
3846 }
3847
3848 baseUrl, err := url.Parse(c.endpoint)
3849 if err != nil {
3850 return nil, err
3851 }
3852 baseUrl.Path += fmt.Sprintf("/v1/%v:asymmetricDecrypt", req.GetName())
3853
3854 params := url.Values{}
3855 params.Add("$alt", "json;enum-encoding=int")
3856
3857 baseUrl.RawQuery = params.Encode()
3858
3859
3860 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3861
3862 hds = append(c.xGoogHeaders, hds...)
3863 hds = append(hds, "Content-Type", "application/json")
3864 headers := gax.BuildHeaders(ctx, hds...)
3865 opts = append((*c.CallOptions).AsymmetricDecrypt[0:len((*c.CallOptions).AsymmetricDecrypt):len((*c.CallOptions).AsymmetricDecrypt)], opts...)
3866 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3867 resp := &kmspb.AsymmetricDecryptResponse{}
3868 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3869 if settings.Path != "" {
3870 baseUrl.Path = settings.Path
3871 }
3872 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3873 if err != nil {
3874 return err
3875 }
3876 httpReq = httpReq.WithContext(ctx)
3877 httpReq.Header = headers
3878
3879 httpRsp, err := c.httpClient.Do(httpReq)
3880 if err != nil {
3881 return err
3882 }
3883 defer httpRsp.Body.Close()
3884
3885 if err = googleapi.CheckResponse(httpRsp); err != nil {
3886 return err
3887 }
3888
3889 buf, err := io.ReadAll(httpRsp.Body)
3890 if err != nil {
3891 return err
3892 }
3893
3894 if err := unm.Unmarshal(buf, resp); err != nil {
3895 return err
3896 }
3897
3898 return nil
3899 }, opts...)
3900 if e != nil {
3901 return nil, e
3902 }
3903 return resp, nil
3904 }
3905
3906
3907
3908
3909 func (c *keyManagementRESTClient) MacSign(ctx context.Context, req *kmspb.MacSignRequest, opts ...gax.CallOption) (*kmspb.MacSignResponse, error) {
3910 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3911 jsonReq, err := m.Marshal(req)
3912 if err != nil {
3913 return nil, err
3914 }
3915
3916 baseUrl, err := url.Parse(c.endpoint)
3917 if err != nil {
3918 return nil, err
3919 }
3920 baseUrl.Path += fmt.Sprintf("/v1/%v:macSign", req.GetName())
3921
3922 params := url.Values{}
3923 params.Add("$alt", "json;enum-encoding=int")
3924
3925 baseUrl.RawQuery = params.Encode()
3926
3927
3928 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3929
3930 hds = append(c.xGoogHeaders, hds...)
3931 hds = append(hds, "Content-Type", "application/json")
3932 headers := gax.BuildHeaders(ctx, hds...)
3933 opts = append((*c.CallOptions).MacSign[0:len((*c.CallOptions).MacSign):len((*c.CallOptions).MacSign)], opts...)
3934 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3935 resp := &kmspb.MacSignResponse{}
3936 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3937 if settings.Path != "" {
3938 baseUrl.Path = settings.Path
3939 }
3940 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
3941 if err != nil {
3942 return err
3943 }
3944 httpReq = httpReq.WithContext(ctx)
3945 httpReq.Header = headers
3946
3947 httpRsp, err := c.httpClient.Do(httpReq)
3948 if err != nil {
3949 return err
3950 }
3951 defer httpRsp.Body.Close()
3952
3953 if err = googleapi.CheckResponse(httpRsp); err != nil {
3954 return err
3955 }
3956
3957 buf, err := io.ReadAll(httpRsp.Body)
3958 if err != nil {
3959 return err
3960 }
3961
3962 if err := unm.Unmarshal(buf, resp); err != nil {
3963 return err
3964 }
3965
3966 return nil
3967 }, opts...)
3968 if e != nil {
3969 return nil, e
3970 }
3971 return resp, nil
3972 }
3973
3974
3975
3976
3977
3978 func (c *keyManagementRESTClient) MacVerify(ctx context.Context, req *kmspb.MacVerifyRequest, opts ...gax.CallOption) (*kmspb.MacVerifyResponse, error) {
3979 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
3980 jsonReq, err := m.Marshal(req)
3981 if err != nil {
3982 return nil, err
3983 }
3984
3985 baseUrl, err := url.Parse(c.endpoint)
3986 if err != nil {
3987 return nil, err
3988 }
3989 baseUrl.Path += fmt.Sprintf("/v1/%v:macVerify", req.GetName())
3990
3991 params := url.Values{}
3992 params.Add("$alt", "json;enum-encoding=int")
3993
3994 baseUrl.RawQuery = params.Encode()
3995
3996
3997 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3998
3999 hds = append(c.xGoogHeaders, hds...)
4000 hds = append(hds, "Content-Type", "application/json")
4001 headers := gax.BuildHeaders(ctx, hds...)
4002 opts = append((*c.CallOptions).MacVerify[0:len((*c.CallOptions).MacVerify):len((*c.CallOptions).MacVerify)], opts...)
4003 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4004 resp := &kmspb.MacVerifyResponse{}
4005 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4006 if settings.Path != "" {
4007 baseUrl.Path = settings.Path
4008 }
4009 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4010 if err != nil {
4011 return err
4012 }
4013 httpReq = httpReq.WithContext(ctx)
4014 httpReq.Header = headers
4015
4016 httpRsp, err := c.httpClient.Do(httpReq)
4017 if err != nil {
4018 return err
4019 }
4020 defer httpRsp.Body.Close()
4021
4022 if err = googleapi.CheckResponse(httpRsp); err != nil {
4023 return err
4024 }
4025
4026 buf, err := io.ReadAll(httpRsp.Body)
4027 if err != nil {
4028 return err
4029 }
4030
4031 if err := unm.Unmarshal(buf, resp); err != nil {
4032 return err
4033 }
4034
4035 return nil
4036 }, opts...)
4037 if e != nil {
4038 return nil, e
4039 }
4040 return resp, nil
4041 }
4042
4043
4044
4045 func (c *keyManagementRESTClient) GenerateRandomBytes(ctx context.Context, req *kmspb.GenerateRandomBytesRequest, opts ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) {
4046 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4047 jsonReq, err := m.Marshal(req)
4048 if err != nil {
4049 return nil, err
4050 }
4051
4052 baseUrl, err := url.Parse(c.endpoint)
4053 if err != nil {
4054 return nil, err
4055 }
4056 baseUrl.Path += fmt.Sprintf("/v1/%v:generateRandomBytes", req.GetLocation())
4057
4058 params := url.Values{}
4059 params.Add("$alt", "json;enum-encoding=int")
4060
4061 baseUrl.RawQuery = params.Encode()
4062
4063
4064 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation()))}
4065
4066 hds = append(c.xGoogHeaders, hds...)
4067 hds = append(hds, "Content-Type", "application/json")
4068 headers := gax.BuildHeaders(ctx, hds...)
4069 opts = append((*c.CallOptions).GenerateRandomBytes[0:len((*c.CallOptions).GenerateRandomBytes):len((*c.CallOptions).GenerateRandomBytes)], opts...)
4070 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4071 resp := &kmspb.GenerateRandomBytesResponse{}
4072 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4073 if settings.Path != "" {
4074 baseUrl.Path = settings.Path
4075 }
4076 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4077 if err != nil {
4078 return err
4079 }
4080 httpReq = httpReq.WithContext(ctx)
4081 httpReq.Header = headers
4082
4083 httpRsp, err := c.httpClient.Do(httpReq)
4084 if err != nil {
4085 return err
4086 }
4087 defer httpRsp.Body.Close()
4088
4089 if err = googleapi.CheckResponse(httpRsp); err != nil {
4090 return err
4091 }
4092
4093 buf, err := io.ReadAll(httpRsp.Body)
4094 if err != nil {
4095 return err
4096 }
4097
4098 if err := unm.Unmarshal(buf, resp); err != nil {
4099 return err
4100 }
4101
4102 return nil
4103 }, opts...)
4104 if e != nil {
4105 return nil, e
4106 }
4107 return resp, nil
4108 }
4109
4110
4111 func (c *keyManagementRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
4112 baseUrl, err := url.Parse(c.endpoint)
4113 if err != nil {
4114 return nil, err
4115 }
4116 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4117
4118 params := url.Values{}
4119 params.Add("$alt", "json;enum-encoding=int")
4120
4121 baseUrl.RawQuery = params.Encode()
4122
4123
4124 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4125
4126 hds = append(c.xGoogHeaders, hds...)
4127 hds = append(hds, "Content-Type", "application/json")
4128 headers := gax.BuildHeaders(ctx, hds...)
4129 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
4130 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4131 resp := &locationpb.Location{}
4132 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4133 if settings.Path != "" {
4134 baseUrl.Path = settings.Path
4135 }
4136 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4137 if err != nil {
4138 return err
4139 }
4140 httpReq = httpReq.WithContext(ctx)
4141 httpReq.Header = headers
4142
4143 httpRsp, err := c.httpClient.Do(httpReq)
4144 if err != nil {
4145 return err
4146 }
4147 defer httpRsp.Body.Close()
4148
4149 if err = googleapi.CheckResponse(httpRsp); err != nil {
4150 return err
4151 }
4152
4153 buf, err := io.ReadAll(httpRsp.Body)
4154 if err != nil {
4155 return err
4156 }
4157
4158 if err := unm.Unmarshal(buf, resp); err != nil {
4159 return err
4160 }
4161
4162 return nil
4163 }, opts...)
4164 if e != nil {
4165 return nil, e
4166 }
4167 return resp, nil
4168 }
4169
4170
4171 func (c *keyManagementRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
4172 it := &LocationIterator{}
4173 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
4174 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4175 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
4176 resp := &locationpb.ListLocationsResponse{}
4177 if pageToken != "" {
4178 req.PageToken = pageToken
4179 }
4180 if pageSize > math.MaxInt32 {
4181 req.PageSize = math.MaxInt32
4182 } else if pageSize != 0 {
4183 req.PageSize = int32(pageSize)
4184 }
4185 baseUrl, err := url.Parse(c.endpoint)
4186 if err != nil {
4187 return nil, "", err
4188 }
4189 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
4190
4191 params := url.Values{}
4192 params.Add("$alt", "json;enum-encoding=int")
4193 if req.GetFilter() != "" {
4194 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
4195 }
4196 if req.GetPageSize() != 0 {
4197 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
4198 }
4199 if req.GetPageToken() != "" {
4200 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
4201 }
4202
4203 baseUrl.RawQuery = params.Encode()
4204
4205
4206 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
4207 headers := gax.BuildHeaders(ctx, hds...)
4208 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4209 if settings.Path != "" {
4210 baseUrl.Path = settings.Path
4211 }
4212 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4213 if err != nil {
4214 return err
4215 }
4216 httpReq.Header = headers
4217
4218 httpRsp, err := c.httpClient.Do(httpReq)
4219 if err != nil {
4220 return err
4221 }
4222 defer httpRsp.Body.Close()
4223
4224 if err = googleapi.CheckResponse(httpRsp); err != nil {
4225 return err
4226 }
4227
4228 buf, err := io.ReadAll(httpRsp.Body)
4229 if err != nil {
4230 return err
4231 }
4232
4233 if err := unm.Unmarshal(buf, resp); err != nil {
4234 return err
4235 }
4236
4237 return nil
4238 }, opts...)
4239 if e != nil {
4240 return nil, "", e
4241 }
4242 it.Response = resp
4243 return resp.GetLocations(), resp.GetNextPageToken(), nil
4244 }
4245
4246 fetch := func(pageSize int, pageToken string) (string, error) {
4247 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
4248 if err != nil {
4249 return "", err
4250 }
4251 it.items = append(it.items, items...)
4252 return nextPageToken, nil
4253 }
4254
4255 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
4256 it.pageInfo.MaxSize = int(req.GetPageSize())
4257 it.pageInfo.Token = req.GetPageToken()
4258
4259 return it
4260 }
4261
4262
4263
4264 func (c *keyManagementRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
4265 baseUrl, err := url.Parse(c.endpoint)
4266 if err != nil {
4267 return nil, err
4268 }
4269 baseUrl.Path += fmt.Sprintf("/v1/%v:getIamPolicy", req.GetResource())
4270
4271 params := url.Values{}
4272 params.Add("$alt", "json;enum-encoding=int")
4273 if req.GetOptions().GetRequestedPolicyVersion() != 0 {
4274 params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
4275 }
4276
4277 baseUrl.RawQuery = params.Encode()
4278
4279
4280 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4281
4282 hds = append(c.xGoogHeaders, hds...)
4283 hds = append(hds, "Content-Type", "application/json")
4284 headers := gax.BuildHeaders(ctx, hds...)
4285 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
4286 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4287 resp := &iampb.Policy{}
4288 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4289 if settings.Path != "" {
4290 baseUrl.Path = settings.Path
4291 }
4292 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4293 if err != nil {
4294 return err
4295 }
4296 httpReq = httpReq.WithContext(ctx)
4297 httpReq.Header = headers
4298
4299 httpRsp, err := c.httpClient.Do(httpReq)
4300 if err != nil {
4301 return err
4302 }
4303 defer httpRsp.Body.Close()
4304
4305 if err = googleapi.CheckResponse(httpRsp); err != nil {
4306 return err
4307 }
4308
4309 buf, err := io.ReadAll(httpRsp.Body)
4310 if err != nil {
4311 return err
4312 }
4313
4314 if err := unm.Unmarshal(buf, resp); err != nil {
4315 return err
4316 }
4317
4318 return nil
4319 }, opts...)
4320 if e != nil {
4321 return nil, e
4322 }
4323 return resp, nil
4324 }
4325
4326
4327
4328
4329
4330
4331 func (c *keyManagementRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
4332 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4333 jsonReq, err := m.Marshal(req)
4334 if err != nil {
4335 return nil, err
4336 }
4337
4338 baseUrl, err := url.Parse(c.endpoint)
4339 if err != nil {
4340 return nil, err
4341 }
4342 baseUrl.Path += fmt.Sprintf("/v1/%v:setIamPolicy", req.GetResource())
4343
4344 params := url.Values{}
4345 params.Add("$alt", "json;enum-encoding=int")
4346
4347 baseUrl.RawQuery = params.Encode()
4348
4349
4350 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4351
4352 hds = append(c.xGoogHeaders, hds...)
4353 hds = append(hds, "Content-Type", "application/json")
4354 headers := gax.BuildHeaders(ctx, hds...)
4355 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
4356 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4357 resp := &iampb.Policy{}
4358 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4359 if settings.Path != "" {
4360 baseUrl.Path = settings.Path
4361 }
4362 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4363 if err != nil {
4364 return err
4365 }
4366 httpReq = httpReq.WithContext(ctx)
4367 httpReq.Header = headers
4368
4369 httpRsp, err := c.httpClient.Do(httpReq)
4370 if err != nil {
4371 return err
4372 }
4373 defer httpRsp.Body.Close()
4374
4375 if err = googleapi.CheckResponse(httpRsp); err != nil {
4376 return err
4377 }
4378
4379 buf, err := io.ReadAll(httpRsp.Body)
4380 if err != nil {
4381 return err
4382 }
4383
4384 if err := unm.Unmarshal(buf, resp); err != nil {
4385 return err
4386 }
4387
4388 return nil
4389 }, opts...)
4390 if e != nil {
4391 return nil, e
4392 }
4393 return resp, nil
4394 }
4395
4396
4397
4398
4399
4400
4401
4402
4403 func (c *keyManagementRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
4404 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
4405 jsonReq, err := m.Marshal(req)
4406 if err != nil {
4407 return nil, err
4408 }
4409
4410 baseUrl, err := url.Parse(c.endpoint)
4411 if err != nil {
4412 return nil, err
4413 }
4414 baseUrl.Path += fmt.Sprintf("/v1/%v:testIamPermissions", req.GetResource())
4415
4416 params := url.Values{}
4417 params.Add("$alt", "json;enum-encoding=int")
4418
4419 baseUrl.RawQuery = params.Encode()
4420
4421
4422 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
4423
4424 hds = append(c.xGoogHeaders, hds...)
4425 hds = append(hds, "Content-Type", "application/json")
4426 headers := gax.BuildHeaders(ctx, hds...)
4427 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
4428 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4429 resp := &iampb.TestIamPermissionsResponse{}
4430 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4431 if settings.Path != "" {
4432 baseUrl.Path = settings.Path
4433 }
4434 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
4435 if err != nil {
4436 return err
4437 }
4438 httpReq = httpReq.WithContext(ctx)
4439 httpReq.Header = headers
4440
4441 httpRsp, err := c.httpClient.Do(httpReq)
4442 if err != nil {
4443 return err
4444 }
4445 defer httpRsp.Body.Close()
4446
4447 if err = googleapi.CheckResponse(httpRsp); err != nil {
4448 return err
4449 }
4450
4451 buf, err := io.ReadAll(httpRsp.Body)
4452 if err != nil {
4453 return err
4454 }
4455
4456 if err := unm.Unmarshal(buf, resp); err != nil {
4457 return err
4458 }
4459
4460 return nil
4461 }, opts...)
4462 if e != nil {
4463 return nil, e
4464 }
4465 return resp, nil
4466 }
4467
4468
4469 func (c *keyManagementRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
4470 baseUrl, err := url.Parse(c.endpoint)
4471 if err != nil {
4472 return nil, err
4473 }
4474 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
4475
4476 params := url.Values{}
4477 params.Add("$alt", "json;enum-encoding=int")
4478
4479 baseUrl.RawQuery = params.Encode()
4480
4481
4482 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
4483
4484 hds = append(c.xGoogHeaders, hds...)
4485 hds = append(hds, "Content-Type", "application/json")
4486 headers := gax.BuildHeaders(ctx, hds...)
4487 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
4488 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
4489 resp := &longrunningpb.Operation{}
4490 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
4491 if settings.Path != "" {
4492 baseUrl.Path = settings.Path
4493 }
4494 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
4495 if err != nil {
4496 return err
4497 }
4498 httpReq = httpReq.WithContext(ctx)
4499 httpReq.Header = headers
4500
4501 httpRsp, err := c.httpClient.Do(httpReq)
4502 if err != nil {
4503 return err
4504 }
4505 defer httpRsp.Body.Close()
4506
4507 if err = googleapi.CheckResponse(httpRsp); err != nil {
4508 return err
4509 }
4510
4511 buf, err := io.ReadAll(httpRsp.Body)
4512 if err != nil {
4513 return err
4514 }
4515
4516 if err := unm.Unmarshal(buf, resp); err != nil {
4517 return err
4518 }
4519
4520 return nil
4521 }, opts...)
4522 if e != nil {
4523 return nil, e
4524 }
4525 return resp, nil
4526 }
4527
View as plain text