1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17package kms
18
19import (
20	"context"
21	"fmt"
22	"math"
23	"net/url"
24	"time"
25
26	gax "github.com/googleapis/gax-go/v2"
27	"google.golang.org/api/iterator"
28	"google.golang.org/api/option"
29	"google.golang.org/api/option/internaloption"
30	gtransport "google.golang.org/api/transport/grpc"
31	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
32	iampb "google.golang.org/genproto/googleapis/iam/v1"
33	"google.golang.org/grpc"
34	"google.golang.org/grpc/codes"
35	"google.golang.org/grpc/metadata"
36	"google.golang.org/protobuf/proto"
37)
38
39var newKeyManagementClientHook clientHook
40
41// KeyManagementCallOptions contains the retry settings for each method of KeyManagementClient.
42type KeyManagementCallOptions struct {
43	ListKeyRings                  []gax.CallOption
44	ListCryptoKeys                []gax.CallOption
45	ListCryptoKeyVersions         []gax.CallOption
46	ListImportJobs                []gax.CallOption
47	GetKeyRing                    []gax.CallOption
48	GetCryptoKey                  []gax.CallOption
49	GetCryptoKeyVersion           []gax.CallOption
50	GetPublicKey                  []gax.CallOption
51	GetImportJob                  []gax.CallOption
52	CreateKeyRing                 []gax.CallOption
53	CreateCryptoKey               []gax.CallOption
54	CreateCryptoKeyVersion        []gax.CallOption
55	ImportCryptoKeyVersion        []gax.CallOption
56	CreateImportJob               []gax.CallOption
57	UpdateCryptoKey               []gax.CallOption
58	UpdateCryptoKeyVersion        []gax.CallOption
59	UpdateCryptoKeyPrimaryVersion []gax.CallOption
60	DestroyCryptoKeyVersion       []gax.CallOption
61	RestoreCryptoKeyVersion       []gax.CallOption
62	Encrypt                       []gax.CallOption
63	Decrypt                       []gax.CallOption
64	AsymmetricSign                []gax.CallOption
65	AsymmetricDecrypt             []gax.CallOption
66	MacSign                       []gax.CallOption
67	MacVerify                     []gax.CallOption
68	GenerateRandomBytes           []gax.CallOption
69	GetIamPolicy                  []gax.CallOption
70	SetIamPolicy                  []gax.CallOption
71	TestIamPermissions            []gax.CallOption
72}
73
74func defaultKeyManagementGRPCClientOptions() []option.ClientOption {
75	return []option.ClientOption{
76		internaloption.WithDefaultEndpoint("cloudkms.googleapis.com:443"),
77		internaloption.WithDefaultMTLSEndpoint("cloudkms.mtls.googleapis.com:443"),
78		internaloption.WithDefaultAudience("https://cloudkms.googleapis.com/"),
79		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
80		internaloption.EnableJwtWithScope(),
81		option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
82		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
83			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
84	}
85}
86
87func defaultKeyManagementCallOptions() *KeyManagementCallOptions {
88	return &KeyManagementCallOptions{
89		ListKeyRings: []gax.CallOption{
90			gax.WithRetry(func() gax.Retryer {
91				return gax.OnCodes([]codes.Code{
92					codes.Unavailable,
93					codes.DeadlineExceeded,
94				}, gax.Backoff{
95					Initial:    100 * time.Millisecond,
96					Max:        60000 * time.Millisecond,
97					Multiplier: 1.30,
98				})
99			}),
100		},
101		ListCryptoKeys: []gax.CallOption{
102			gax.WithRetry(func() gax.Retryer {
103				return gax.OnCodes([]codes.Code{
104					codes.Unavailable,
105					codes.DeadlineExceeded,
106				}, gax.Backoff{
107					Initial:    100 * time.Millisecond,
108					Max:        60000 * time.Millisecond,
109					Multiplier: 1.30,
110				})
111			}),
112		},
113		ListCryptoKeyVersions: []gax.CallOption{
114			gax.WithRetry(func() gax.Retryer {
115				return gax.OnCodes([]codes.Code{
116					codes.Unavailable,
117					codes.DeadlineExceeded,
118				}, gax.Backoff{
119					Initial:    100 * time.Millisecond,
120					Max:        60000 * time.Millisecond,
121					Multiplier: 1.30,
122				})
123			}),
124		},
125		ListImportJobs: []gax.CallOption{
126			gax.WithRetry(func() gax.Retryer {
127				return gax.OnCodes([]codes.Code{
128					codes.Unavailable,
129					codes.DeadlineExceeded,
130				}, gax.Backoff{
131					Initial:    100 * time.Millisecond,
132					Max:        60000 * time.Millisecond,
133					Multiplier: 1.30,
134				})
135			}),
136		},
137		GetKeyRing: []gax.CallOption{
138			gax.WithRetry(func() gax.Retryer {
139				return gax.OnCodes([]codes.Code{
140					codes.Unavailable,
141					codes.DeadlineExceeded,
142				}, gax.Backoff{
143					Initial:    100 * time.Millisecond,
144					Max:        60000 * time.Millisecond,
145					Multiplier: 1.30,
146				})
147			}),
148		},
149		GetCryptoKey: []gax.CallOption{
150			gax.WithRetry(func() gax.Retryer {
151				return gax.OnCodes([]codes.Code{
152					codes.Unavailable,
153					codes.DeadlineExceeded,
154				}, gax.Backoff{
155					Initial:    100 * time.Millisecond,
156					Max:        60000 * time.Millisecond,
157					Multiplier: 1.30,
158				})
159			}),
160		},
161		GetCryptoKeyVersion: []gax.CallOption{
162			gax.WithRetry(func() gax.Retryer {
163				return gax.OnCodes([]codes.Code{
164					codes.Unavailable,
165					codes.DeadlineExceeded,
166				}, gax.Backoff{
167					Initial:    100 * time.Millisecond,
168					Max:        60000 * time.Millisecond,
169					Multiplier: 1.30,
170				})
171			}),
172		},
173		GetPublicKey: []gax.CallOption{
174			gax.WithRetry(func() gax.Retryer {
175				return gax.OnCodes([]codes.Code{
176					codes.Unavailable,
177					codes.DeadlineExceeded,
178				}, gax.Backoff{
179					Initial:    100 * time.Millisecond,
180					Max:        60000 * time.Millisecond,
181					Multiplier: 1.30,
182				})
183			}),
184		},
185		GetImportJob: []gax.CallOption{
186			gax.WithRetry(func() gax.Retryer {
187				return gax.OnCodes([]codes.Code{
188					codes.Unavailable,
189					codes.DeadlineExceeded,
190				}, gax.Backoff{
191					Initial:    100 * time.Millisecond,
192					Max:        60000 * time.Millisecond,
193					Multiplier: 1.30,
194				})
195			}),
196		},
197		CreateKeyRing: []gax.CallOption{
198			gax.WithRetry(func() gax.Retryer {
199				return gax.OnCodes([]codes.Code{
200					codes.Unavailable,
201					codes.DeadlineExceeded,
202				}, gax.Backoff{
203					Initial:    100 * time.Millisecond,
204					Max:        60000 * time.Millisecond,
205					Multiplier: 1.30,
206				})
207			}),
208		},
209		CreateCryptoKey: []gax.CallOption{
210			gax.WithRetry(func() gax.Retryer {
211				return gax.OnCodes([]codes.Code{
212					codes.Unavailable,
213					codes.DeadlineExceeded,
214				}, gax.Backoff{
215					Initial:    100 * time.Millisecond,
216					Max:        60000 * time.Millisecond,
217					Multiplier: 1.30,
218				})
219			}),
220		},
221		CreateCryptoKeyVersion: []gax.CallOption{},
222		ImportCryptoKeyVersion: []gax.CallOption{},
223		CreateImportJob: []gax.CallOption{
224			gax.WithRetry(func() gax.Retryer {
225				return gax.OnCodes([]codes.Code{
226					codes.Unavailable,
227					codes.DeadlineExceeded,
228				}, gax.Backoff{
229					Initial:    100 * time.Millisecond,
230					Max:        60000 * time.Millisecond,
231					Multiplier: 1.30,
232				})
233			}),
234		},
235		UpdateCryptoKey: []gax.CallOption{
236			gax.WithRetry(func() gax.Retryer {
237				return gax.OnCodes([]codes.Code{
238					codes.Unavailable,
239					codes.DeadlineExceeded,
240				}, gax.Backoff{
241					Initial:    100 * time.Millisecond,
242					Max:        60000 * time.Millisecond,
243					Multiplier: 1.30,
244				})
245			}),
246		},
247		UpdateCryptoKeyVersion: []gax.CallOption{
248			gax.WithRetry(func() gax.Retryer {
249				return gax.OnCodes([]codes.Code{
250					codes.Unavailable,
251					codes.DeadlineExceeded,
252				}, gax.Backoff{
253					Initial:    100 * time.Millisecond,
254					Max:        60000 * time.Millisecond,
255					Multiplier: 1.30,
256				})
257			}),
258		},
259		UpdateCryptoKeyPrimaryVersion: []gax.CallOption{
260			gax.WithRetry(func() gax.Retryer {
261				return gax.OnCodes([]codes.Code{
262					codes.Unavailable,
263					codes.DeadlineExceeded,
264				}, gax.Backoff{
265					Initial:    100 * time.Millisecond,
266					Max:        60000 * time.Millisecond,
267					Multiplier: 1.30,
268				})
269			}),
270		},
271		DestroyCryptoKeyVersion: []gax.CallOption{
272			gax.WithRetry(func() gax.Retryer {
273				return gax.OnCodes([]codes.Code{
274					codes.Unavailable,
275					codes.DeadlineExceeded,
276				}, gax.Backoff{
277					Initial:    100 * time.Millisecond,
278					Max:        60000 * time.Millisecond,
279					Multiplier: 1.30,
280				})
281			}),
282		},
283		RestoreCryptoKeyVersion: []gax.CallOption{
284			gax.WithRetry(func() gax.Retryer {
285				return gax.OnCodes([]codes.Code{
286					codes.Unavailable,
287					codes.DeadlineExceeded,
288				}, gax.Backoff{
289					Initial:    100 * time.Millisecond,
290					Max:        60000 * time.Millisecond,
291					Multiplier: 1.30,
292				})
293			}),
294		},
295		Encrypt: []gax.CallOption{
296			gax.WithRetry(func() gax.Retryer {
297				return gax.OnCodes([]codes.Code{
298					codes.Unavailable,
299					codes.DeadlineExceeded,
300				}, gax.Backoff{
301					Initial:    100 * time.Millisecond,
302					Max:        60000 * time.Millisecond,
303					Multiplier: 1.30,
304				})
305			}),
306		},
307		Decrypt: []gax.CallOption{
308			gax.WithRetry(func() gax.Retryer {
309				return gax.OnCodes([]codes.Code{
310					codes.Unavailable,
311					codes.DeadlineExceeded,
312				}, gax.Backoff{
313					Initial:    100 * time.Millisecond,
314					Max:        60000 * time.Millisecond,
315					Multiplier: 1.30,
316				})
317			}),
318		},
319		AsymmetricSign: []gax.CallOption{
320			gax.WithRetry(func() gax.Retryer {
321				return gax.OnCodes([]codes.Code{
322					codes.Unavailable,
323					codes.DeadlineExceeded,
324				}, gax.Backoff{
325					Initial:    100 * time.Millisecond,
326					Max:        60000 * time.Millisecond,
327					Multiplier: 1.30,
328				})
329			}),
330		},
331		AsymmetricDecrypt: []gax.CallOption{
332			gax.WithRetry(func() gax.Retryer {
333				return gax.OnCodes([]codes.Code{
334					codes.Unavailable,
335					codes.DeadlineExceeded,
336				}, gax.Backoff{
337					Initial:    100 * time.Millisecond,
338					Max:        60000 * time.Millisecond,
339					Multiplier: 1.30,
340				})
341			}),
342		},
343		MacSign: []gax.CallOption{
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		MacVerify: []gax.CallOption{
356			gax.WithRetry(func() gax.Retryer {
357				return gax.OnCodes([]codes.Code{
358					codes.Unavailable,
359					codes.DeadlineExceeded,
360				}, gax.Backoff{
361					Initial:    100 * time.Millisecond,
362					Max:        60000 * time.Millisecond,
363					Multiplier: 1.30,
364				})
365			}),
366		},
367		GenerateRandomBytes: []gax.CallOption{
368			gax.WithRetry(func() gax.Retryer {
369				return gax.OnCodes([]codes.Code{
370					codes.Unavailable,
371					codes.DeadlineExceeded,
372				}, gax.Backoff{
373					Initial:    100 * time.Millisecond,
374					Max:        60000 * time.Millisecond,
375					Multiplier: 1.30,
376				})
377			}),
378		},
379		GetIamPolicy:       []gax.CallOption{},
380		SetIamPolicy:       []gax.CallOption{},
381		TestIamPermissions: []gax.CallOption{},
382	}
383}
384
385// internalKeyManagementClient is an interface that defines the methods availaible from Cloud Key Management Service (KMS) API.
386type internalKeyManagementClient interface {
387	Close() error
388	setGoogleClientInfo(...string)
389	Connection() *grpc.ClientConn
390	ListKeyRings(context.Context, *kmspb.ListKeyRingsRequest, ...gax.CallOption) *KeyRingIterator
391	ListCryptoKeys(context.Context, *kmspb.ListCryptoKeysRequest, ...gax.CallOption) *CryptoKeyIterator
392	ListCryptoKeyVersions(context.Context, *kmspb.ListCryptoKeyVersionsRequest, ...gax.CallOption) *CryptoKeyVersionIterator
393	ListImportJobs(context.Context, *kmspb.ListImportJobsRequest, ...gax.CallOption) *ImportJobIterator
394	GetKeyRing(context.Context, *kmspb.GetKeyRingRequest, ...gax.CallOption) (*kmspb.KeyRing, error)
395	GetCryptoKey(context.Context, *kmspb.GetCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
396	GetCryptoKeyVersion(context.Context, *kmspb.GetCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
397	GetPublicKey(context.Context, *kmspb.GetPublicKeyRequest, ...gax.CallOption) (*kmspb.PublicKey, error)
398	GetImportJob(context.Context, *kmspb.GetImportJobRequest, ...gax.CallOption) (*kmspb.ImportJob, error)
399	CreateKeyRing(context.Context, *kmspb.CreateKeyRingRequest, ...gax.CallOption) (*kmspb.KeyRing, error)
400	CreateCryptoKey(context.Context, *kmspb.CreateCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
401	CreateCryptoKeyVersion(context.Context, *kmspb.CreateCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
402	ImportCryptoKeyVersion(context.Context, *kmspb.ImportCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
403	CreateImportJob(context.Context, *kmspb.CreateImportJobRequest, ...gax.CallOption) (*kmspb.ImportJob, error)
404	UpdateCryptoKey(context.Context, *kmspb.UpdateCryptoKeyRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
405	UpdateCryptoKeyVersion(context.Context, *kmspb.UpdateCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
406	UpdateCryptoKeyPrimaryVersion(context.Context, *kmspb.UpdateCryptoKeyPrimaryVersionRequest, ...gax.CallOption) (*kmspb.CryptoKey, error)
407	DestroyCryptoKeyVersion(context.Context, *kmspb.DestroyCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
408	RestoreCryptoKeyVersion(context.Context, *kmspb.RestoreCryptoKeyVersionRequest, ...gax.CallOption) (*kmspb.CryptoKeyVersion, error)
409	Encrypt(context.Context, *kmspb.EncryptRequest, ...gax.CallOption) (*kmspb.EncryptResponse, error)
410	Decrypt(context.Context, *kmspb.DecryptRequest, ...gax.CallOption) (*kmspb.DecryptResponse, error)
411	AsymmetricSign(context.Context, *kmspb.AsymmetricSignRequest, ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error)
412	AsymmetricDecrypt(context.Context, *kmspb.AsymmetricDecryptRequest, ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error)
413	MacSign(context.Context, *kmspb.MacSignRequest, ...gax.CallOption) (*kmspb.MacSignResponse, error)
414	MacVerify(context.Context, *kmspb.MacVerifyRequest, ...gax.CallOption) (*kmspb.MacVerifyResponse, error)
415	GenerateRandomBytes(context.Context, *kmspb.GenerateRandomBytesRequest, ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error)
416	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
417	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
418	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
419}
420
421// KeyManagementClient is a client for interacting with Cloud Key Management Service (KMS) API.
422// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
423//
424// Google Cloud Key Management Service
425//
426// Manages cryptographic keys and operations using those keys. Implements a REST
427// model with the following objects:
428//
429//   KeyRing
430//
431//   CryptoKey
432//
433//   CryptoKeyVersion
434//
435//   ImportJob
436//
437// If you are using manual gRPC libraries, see
438// Using gRPC with Cloud KMS (at https://cloud.google.com/kms/docs/grpc).
439type KeyManagementClient struct {
440	// The internal transport-dependent client.
441	internalClient internalKeyManagementClient
442
443	// The call options for this service.
444	CallOptions *KeyManagementCallOptions
445}
446
447// Wrapper methods routed to the internal client.
448
449// Close closes the connection to the API service. The user should invoke this when
450// the client is no longer required.
451func (c *KeyManagementClient) Close() error {
452	return c.internalClient.Close()
453}
454
455// setGoogleClientInfo sets the name and version of the application in
456// the `x-goog-api-client` header passed on each request. Intended for
457// use by Google-written clients.
458func (c *KeyManagementClient) setGoogleClientInfo(keyval ...string) {
459	c.internalClient.setGoogleClientInfo(keyval...)
460}
461
462// Connection returns a connection to the API service.
463//
464// Deprecated.
465func (c *KeyManagementClient) Connection() *grpc.ClientConn {
466	return c.internalClient.Connection()
467}
468
469// ListKeyRings lists KeyRings.
470func (c *KeyManagementClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator {
471	return c.internalClient.ListKeyRings(ctx, req, opts...)
472}
473
474// ListCryptoKeys lists CryptoKeys.
475func (c *KeyManagementClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator {
476	return c.internalClient.ListCryptoKeys(ctx, req, opts...)
477}
478
479// ListCryptoKeyVersions lists CryptoKeyVersions.
480func (c *KeyManagementClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator {
481	return c.internalClient.ListCryptoKeyVersions(ctx, req, opts...)
482}
483
484// ListImportJobs lists ImportJobs.
485func (c *KeyManagementClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator {
486	return c.internalClient.ListImportJobs(ctx, req, opts...)
487}
488
489// GetKeyRing returns metadata for a given KeyRing.
490func (c *KeyManagementClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
491	return c.internalClient.GetKeyRing(ctx, req, opts...)
492}
493
494// GetCryptoKey returns metadata for a given CryptoKey, as well as its
495// primary CryptoKeyVersion.
496func (c *KeyManagementClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
497	return c.internalClient.GetCryptoKey(ctx, req, opts...)
498}
499
500// GetCryptoKeyVersion returns metadata for a given CryptoKeyVersion.
501func (c *KeyManagementClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
502	return c.internalClient.GetCryptoKeyVersion(ctx, req, opts...)
503}
504
505// GetPublicKey returns the public key for the given CryptoKeyVersion. The
506// CryptoKey.purpose must be
507// ASYMMETRIC_SIGN or
508// ASYMMETRIC_DECRYPT.
509func (c *KeyManagementClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error) {
510	return c.internalClient.GetPublicKey(ctx, req, opts...)
511}
512
513// GetImportJob returns metadata for a given ImportJob.
514func (c *KeyManagementClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
515	return c.internalClient.GetImportJob(ctx, req, opts...)
516}
517
518// CreateKeyRing create a new KeyRing in a given Project and Location.
519func (c *KeyManagementClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
520	return c.internalClient.CreateKeyRing(ctx, req, opts...)
521}
522
523// CreateCryptoKey create a new CryptoKey within a KeyRing.
524//
525// CryptoKey.purpose and
526// CryptoKey.version_template.algorithm
527// are required.
528func (c *KeyManagementClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
529	return c.internalClient.CreateCryptoKey(ctx, req, opts...)
530}
531
532// CreateCryptoKeyVersion create a new CryptoKeyVersion in a CryptoKey.
533//
534// The server will assign the next sequential id. If unset,
535// state will be set to
536// ENABLED.
537func (c *KeyManagementClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
538	return c.internalClient.CreateCryptoKeyVersion(ctx, req, opts...)
539}
540
541// ImportCryptoKeyVersion import wrapped key material into a CryptoKeyVersion.
542//
543// All requests must specify a CryptoKey. If a CryptoKeyVersion is
544// additionally specified in the request, key material will be reimported into
545// that version. Otherwise, a new version will be created, and will be
546// assigned the next sequential id within the CryptoKey.
547func (c *KeyManagementClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
548	return c.internalClient.ImportCryptoKeyVersion(ctx, req, opts...)
549}
550
551// CreateImportJob create a new ImportJob within a KeyRing.
552//
553// ImportJob.import_method is required.
554func (c *KeyManagementClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
555	return c.internalClient.CreateImportJob(ctx, req, opts...)
556}
557
558// UpdateCryptoKey update a CryptoKey.
559func (c *KeyManagementClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
560	return c.internalClient.UpdateCryptoKey(ctx, req, opts...)
561}
562
563// UpdateCryptoKeyVersion update a CryptoKeyVersion's metadata.
564//
565// state may be changed between
566// ENABLED and
567// DISABLED using this
568// method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to
569// move between other states.
570func (c *KeyManagementClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
571	return c.internalClient.UpdateCryptoKeyVersion(ctx, req, opts...)
572}
573
574// UpdateCryptoKeyPrimaryVersion update the version of a CryptoKey that will be used in Encrypt.
575//
576// Returns an error if called on a key whose purpose is not
577// ENCRYPT_DECRYPT.
578func (c *KeyManagementClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
579	return c.internalClient.UpdateCryptoKeyPrimaryVersion(ctx, req, opts...)
580}
581
582// DestroyCryptoKeyVersion schedule a CryptoKeyVersion for destruction.
583//
584// Upon calling this method, CryptoKeyVersion.state will be set to
585// DESTROY_SCHEDULED,
586// and destroy_time will be set to the time
587// destroy_scheduled_duration in the
588// future. At that time, the state will
589// automatically change to
590// DESTROYED, and the key
591// material will be irrevocably destroyed.
592//
593// Before the destroy_time is reached,
594// RestoreCryptoKeyVersion may be called to reverse the process.
595func (c *KeyManagementClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
596	return c.internalClient.DestroyCryptoKeyVersion(ctx, req, opts...)
597}
598
599// RestoreCryptoKeyVersion restore a CryptoKeyVersion in the
600// DESTROY_SCHEDULED
601// state.
602//
603// Upon restoration of the CryptoKeyVersion, state
604// will be set to DISABLED,
605// and destroy_time will be cleared.
606func (c *KeyManagementClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
607	return c.internalClient.RestoreCryptoKeyVersion(ctx, req, opts...)
608}
609
610// Encrypt encrypts data, so that it can only be recovered by a call to Decrypt.
611// The CryptoKey.purpose must be
612// ENCRYPT_DECRYPT.
613func (c *KeyManagementClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error) {
614	return c.internalClient.Encrypt(ctx, req, opts...)
615}
616
617// Decrypt decrypts data that was protected by Encrypt. The CryptoKey.purpose
618// must be ENCRYPT_DECRYPT.
619func (c *KeyManagementClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error) {
620	return c.internalClient.Decrypt(ctx, req, opts...)
621}
622
623// AsymmetricSign signs data using a CryptoKeyVersion with CryptoKey.purpose
624// ASYMMETRIC_SIGN, producing a signature that can be verified with the public
625// key retrieved from GetPublicKey.
626func (c *KeyManagementClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error) {
627	return c.internalClient.AsymmetricSign(ctx, req, opts...)
628}
629
630// AsymmetricDecrypt decrypts data that was encrypted with a public key retrieved from
631// GetPublicKey corresponding to a CryptoKeyVersion with
632// CryptoKey.purpose ASYMMETRIC_DECRYPT.
633func (c *KeyManagementClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error) {
634	return c.internalClient.AsymmetricDecrypt(ctx, req, opts...)
635}
636
637// MacSign signs data using a CryptoKeyVersion with CryptoKey.purpose
638// MAC, producing a tag that can be verified by another source with the
639// same key.
640func (c *KeyManagementClient) MacSign(ctx context.Context, req *kmspb.MacSignRequest, opts ...gax.CallOption) (*kmspb.MacSignResponse, error) {
641	return c.internalClient.MacSign(ctx, req, opts...)
642}
643
644// MacVerify verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose
645// MAC, and returns a response that indicates whether or not the verification
646// was successful.
647func (c *KeyManagementClient) MacVerify(ctx context.Context, req *kmspb.MacVerifyRequest, opts ...gax.CallOption) (*kmspb.MacVerifyResponse, error) {
648	return c.internalClient.MacVerify(ctx, req, opts...)
649}
650
651// GenerateRandomBytes generate random bytes using the Cloud KMS randomness source in the provided
652// location.
653func (c *KeyManagementClient) GenerateRandomBytes(ctx context.Context, req *kmspb.GenerateRandomBytesRequest, opts ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) {
654	return c.internalClient.GenerateRandomBytes(ctx, req, opts...)
655}
656
657// GetIamPolicy gets the access control policy for a resource. Returns an empty policy
658// if the resource exists and does not have a policy set.
659func (c *KeyManagementClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
660	return c.internalClient.GetIamPolicy(ctx, req, opts...)
661}
662
663// SetIamPolicy sets the access control policy on the specified resource. Replaces
664// any existing policy.
665//
666// Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
667// errors.
668func (c *KeyManagementClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
669	return c.internalClient.SetIamPolicy(ctx, req, opts...)
670}
671
672// TestIamPermissions returns permissions that a caller has on the specified resource. If the
673// resource does not exist, this will return an empty set of
674// permissions, not a NOT_FOUND error.
675//
676// Note: This operation is designed to be used for building
677// permission-aware UIs and command-line tools, not for authorization
678// checking. This operation may “fail open” without warning.
679func (c *KeyManagementClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
680	return c.internalClient.TestIamPermissions(ctx, req, opts...)
681}
682
683// keyManagementGRPCClient is a client for interacting with Cloud Key Management Service (KMS) API over gRPC transport.
684//
685// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
686type keyManagementGRPCClient struct {
687	// Connection pool of gRPC connections to the service.
688	connPool gtransport.ConnPool
689
690	// flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE
691	disableDeadlines bool
692
693	// Points back to the CallOptions field of the containing KeyManagementClient
694	CallOptions **KeyManagementCallOptions
695
696	// The gRPC API client.
697	keyManagementClient kmspb.KeyManagementServiceClient
698
699	iamPolicyClient iampb.IAMPolicyClient
700
701	// The x-goog-* metadata to be sent with each request.
702	xGoogMetadata metadata.MD
703}
704
705// NewKeyManagementClient creates a new key management service client based on gRPC.
706// The returned client must be Closed when it is done being used to clean up its underlying connections.
707//
708// Google Cloud Key Management Service
709//
710// Manages cryptographic keys and operations using those keys. Implements a REST
711// model with the following objects:
712//
713//   KeyRing
714//
715//   CryptoKey
716//
717//   CryptoKeyVersion
718//
719//   ImportJob
720//
721// If you are using manual gRPC libraries, see
722// Using gRPC with Cloud KMS (at https://cloud.google.com/kms/docs/grpc).
723func NewKeyManagementClient(ctx context.Context, opts ...option.ClientOption) (*KeyManagementClient, error) {
724	clientOpts := defaultKeyManagementGRPCClientOptions()
725	if newKeyManagementClientHook != nil {
726		hookOpts, err := newKeyManagementClientHook(ctx, clientHookParams{})
727		if err != nil {
728			return nil, err
729		}
730		clientOpts = append(clientOpts, hookOpts...)
731	}
732
733	disableDeadlines, err := checkDisableDeadlines()
734	if err != nil {
735		return nil, err
736	}
737
738	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
739	if err != nil {
740		return nil, err
741	}
742	client := KeyManagementClient{CallOptions: defaultKeyManagementCallOptions()}
743
744	c := &keyManagementGRPCClient{
745		connPool:            connPool,
746		disableDeadlines:    disableDeadlines,
747		keyManagementClient: kmspb.NewKeyManagementServiceClient(connPool),
748		CallOptions:         &client.CallOptions,
749		iamPolicyClient:     iampb.NewIAMPolicyClient(connPool),
750	}
751	c.setGoogleClientInfo()
752
753	client.internalClient = c
754
755	return &client, nil
756}
757
758// Connection returns a connection to the API service.
759//
760// Deprecated.
761func (c *keyManagementGRPCClient) Connection() *grpc.ClientConn {
762	return c.connPool.Conn()
763}
764
765// setGoogleClientInfo sets the name and version of the application in
766// the `x-goog-api-client` header passed on each request. Intended for
767// use by Google-written clients.
768func (c *keyManagementGRPCClient) setGoogleClientInfo(keyval ...string) {
769	kv := append([]string{"gl-go", versionGo()}, keyval...)
770	kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
771	c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
772}
773
774// Close closes the connection to the API service. The user should invoke this when
775// the client is no longer required.
776func (c *keyManagementGRPCClient) Close() error {
777	return c.connPool.Close()
778}
779
780func (c *keyManagementGRPCClient) ListKeyRings(ctx context.Context, req *kmspb.ListKeyRingsRequest, opts ...gax.CallOption) *KeyRingIterator {
781	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
782	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
783	opts = append((*c.CallOptions).ListKeyRings[0:len((*c.CallOptions).ListKeyRings):len((*c.CallOptions).ListKeyRings)], opts...)
784	it := &KeyRingIterator{}
785	req = proto.Clone(req).(*kmspb.ListKeyRingsRequest)
786	it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.KeyRing, string, error) {
787		resp := &kmspb.ListKeyRingsResponse{}
788		if pageToken != "" {
789			req.PageToken = pageToken
790		}
791		if pageSize > math.MaxInt32 {
792			req.PageSize = math.MaxInt32
793		} else if pageSize != 0 {
794			req.PageSize = int32(pageSize)
795		}
796		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
797			var err error
798			resp, err = c.keyManagementClient.ListKeyRings(ctx, req, settings.GRPC...)
799			return err
800		}, opts...)
801		if err != nil {
802			return nil, "", err
803		}
804
805		it.Response = resp
806		return resp.GetKeyRings(), resp.GetNextPageToken(), nil
807	}
808	fetch := func(pageSize int, pageToken string) (string, error) {
809		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
810		if err != nil {
811			return "", err
812		}
813		it.items = append(it.items, items...)
814		return nextPageToken, nil
815	}
816
817	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
818	it.pageInfo.MaxSize = int(req.GetPageSize())
819	it.pageInfo.Token = req.GetPageToken()
820
821	return it
822}
823
824func (c *keyManagementGRPCClient) ListCryptoKeys(ctx context.Context, req *kmspb.ListCryptoKeysRequest, opts ...gax.CallOption) *CryptoKeyIterator {
825	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
826	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
827	opts = append((*c.CallOptions).ListCryptoKeys[0:len((*c.CallOptions).ListCryptoKeys):len((*c.CallOptions).ListCryptoKeys)], opts...)
828	it := &CryptoKeyIterator{}
829	req = proto.Clone(req).(*kmspb.ListCryptoKeysRequest)
830	it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKey, string, error) {
831		resp := &kmspb.ListCryptoKeysResponse{}
832		if pageToken != "" {
833			req.PageToken = pageToken
834		}
835		if pageSize > math.MaxInt32 {
836			req.PageSize = math.MaxInt32
837		} else if pageSize != 0 {
838			req.PageSize = int32(pageSize)
839		}
840		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
841			var err error
842			resp, err = c.keyManagementClient.ListCryptoKeys(ctx, req, settings.GRPC...)
843			return err
844		}, opts...)
845		if err != nil {
846			return nil, "", err
847		}
848
849		it.Response = resp
850		return resp.GetCryptoKeys(), resp.GetNextPageToken(), nil
851	}
852	fetch := func(pageSize int, pageToken string) (string, error) {
853		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
854		if err != nil {
855			return "", err
856		}
857		it.items = append(it.items, items...)
858		return nextPageToken, nil
859	}
860
861	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
862	it.pageInfo.MaxSize = int(req.GetPageSize())
863	it.pageInfo.Token = req.GetPageToken()
864
865	return it
866}
867
868func (c *keyManagementGRPCClient) ListCryptoKeyVersions(ctx context.Context, req *kmspb.ListCryptoKeyVersionsRequest, opts ...gax.CallOption) *CryptoKeyVersionIterator {
869	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
870	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
871	opts = append((*c.CallOptions).ListCryptoKeyVersions[0:len((*c.CallOptions).ListCryptoKeyVersions):len((*c.CallOptions).ListCryptoKeyVersions)], opts...)
872	it := &CryptoKeyVersionIterator{}
873	req = proto.Clone(req).(*kmspb.ListCryptoKeyVersionsRequest)
874	it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.CryptoKeyVersion, string, error) {
875		resp := &kmspb.ListCryptoKeyVersionsResponse{}
876		if pageToken != "" {
877			req.PageToken = pageToken
878		}
879		if pageSize > math.MaxInt32 {
880			req.PageSize = math.MaxInt32
881		} else if pageSize != 0 {
882			req.PageSize = int32(pageSize)
883		}
884		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
885			var err error
886			resp, err = c.keyManagementClient.ListCryptoKeyVersions(ctx, req, settings.GRPC...)
887			return err
888		}, opts...)
889		if err != nil {
890			return nil, "", err
891		}
892
893		it.Response = resp
894		return resp.GetCryptoKeyVersions(), resp.GetNextPageToken(), nil
895	}
896	fetch := func(pageSize int, pageToken string) (string, error) {
897		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
898		if err != nil {
899			return "", err
900		}
901		it.items = append(it.items, items...)
902		return nextPageToken, nil
903	}
904
905	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
906	it.pageInfo.MaxSize = int(req.GetPageSize())
907	it.pageInfo.Token = req.GetPageToken()
908
909	return it
910}
911
912func (c *keyManagementGRPCClient) ListImportJobs(ctx context.Context, req *kmspb.ListImportJobsRequest, opts ...gax.CallOption) *ImportJobIterator {
913	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
914	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
915	opts = append((*c.CallOptions).ListImportJobs[0:len((*c.CallOptions).ListImportJobs):len((*c.CallOptions).ListImportJobs)], opts...)
916	it := &ImportJobIterator{}
917	req = proto.Clone(req).(*kmspb.ListImportJobsRequest)
918	it.InternalFetch = func(pageSize int, pageToken string) ([]*kmspb.ImportJob, string, error) {
919		resp := &kmspb.ListImportJobsResponse{}
920		if pageToken != "" {
921			req.PageToken = pageToken
922		}
923		if pageSize > math.MaxInt32 {
924			req.PageSize = math.MaxInt32
925		} else if pageSize != 0 {
926			req.PageSize = int32(pageSize)
927		}
928		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
929			var err error
930			resp, err = c.keyManagementClient.ListImportJobs(ctx, req, settings.GRPC...)
931			return err
932		}, opts...)
933		if err != nil {
934			return nil, "", err
935		}
936
937		it.Response = resp
938		return resp.GetImportJobs(), resp.GetNextPageToken(), nil
939	}
940	fetch := func(pageSize int, pageToken string) (string, error) {
941		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
942		if err != nil {
943			return "", err
944		}
945		it.items = append(it.items, items...)
946		return nextPageToken, nil
947	}
948
949	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
950	it.pageInfo.MaxSize = int(req.GetPageSize())
951	it.pageInfo.Token = req.GetPageToken()
952
953	return it
954}
955
956func (c *keyManagementGRPCClient) GetKeyRing(ctx context.Context, req *kmspb.GetKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
957	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
958		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
959		defer cancel()
960		ctx = cctx
961	}
962	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
963	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
964	opts = append((*c.CallOptions).GetKeyRing[0:len((*c.CallOptions).GetKeyRing):len((*c.CallOptions).GetKeyRing)], opts...)
965	var resp *kmspb.KeyRing
966	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
967		var err error
968		resp, err = c.keyManagementClient.GetKeyRing(ctx, req, settings.GRPC...)
969		return err
970	}, opts...)
971	if err != nil {
972		return nil, err
973	}
974	return resp, nil
975}
976
977func (c *keyManagementGRPCClient) GetCryptoKey(ctx context.Context, req *kmspb.GetCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
978	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
979		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
980		defer cancel()
981		ctx = cctx
982	}
983	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
984	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
985	opts = append((*c.CallOptions).GetCryptoKey[0:len((*c.CallOptions).GetCryptoKey):len((*c.CallOptions).GetCryptoKey)], opts...)
986	var resp *kmspb.CryptoKey
987	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
988		var err error
989		resp, err = c.keyManagementClient.GetCryptoKey(ctx, req, settings.GRPC...)
990		return err
991	}, opts...)
992	if err != nil {
993		return nil, err
994	}
995	return resp, nil
996}
997
998func (c *keyManagementGRPCClient) GetCryptoKeyVersion(ctx context.Context, req *kmspb.GetCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
999	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1000		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1001		defer cancel()
1002		ctx = cctx
1003	}
1004	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1005	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1006	opts = append((*c.CallOptions).GetCryptoKeyVersion[0:len((*c.CallOptions).GetCryptoKeyVersion):len((*c.CallOptions).GetCryptoKeyVersion)], opts...)
1007	var resp *kmspb.CryptoKeyVersion
1008	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1009		var err error
1010		resp, err = c.keyManagementClient.GetCryptoKeyVersion(ctx, req, settings.GRPC...)
1011		return err
1012	}, opts...)
1013	if err != nil {
1014		return nil, err
1015	}
1016	return resp, nil
1017}
1018
1019func (c *keyManagementGRPCClient) GetPublicKey(ctx context.Context, req *kmspb.GetPublicKeyRequest, opts ...gax.CallOption) (*kmspb.PublicKey, error) {
1020	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1021		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1022		defer cancel()
1023		ctx = cctx
1024	}
1025	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1026	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1027	opts = append((*c.CallOptions).GetPublicKey[0:len((*c.CallOptions).GetPublicKey):len((*c.CallOptions).GetPublicKey)], opts...)
1028	var resp *kmspb.PublicKey
1029	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1030		var err error
1031		resp, err = c.keyManagementClient.GetPublicKey(ctx, req, settings.GRPC...)
1032		return err
1033	}, opts...)
1034	if err != nil {
1035		return nil, err
1036	}
1037	return resp, nil
1038}
1039
1040func (c *keyManagementGRPCClient) GetImportJob(ctx context.Context, req *kmspb.GetImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
1041	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1042		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1043		defer cancel()
1044		ctx = cctx
1045	}
1046	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1047	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1048	opts = append((*c.CallOptions).GetImportJob[0:len((*c.CallOptions).GetImportJob):len((*c.CallOptions).GetImportJob)], opts...)
1049	var resp *kmspb.ImportJob
1050	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1051		var err error
1052		resp, err = c.keyManagementClient.GetImportJob(ctx, req, settings.GRPC...)
1053		return err
1054	}, opts...)
1055	if err != nil {
1056		return nil, err
1057	}
1058	return resp, nil
1059}
1060
1061func (c *keyManagementGRPCClient) CreateKeyRing(ctx context.Context, req *kmspb.CreateKeyRingRequest, opts ...gax.CallOption) (*kmspb.KeyRing, error) {
1062	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1063		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1064		defer cancel()
1065		ctx = cctx
1066	}
1067	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1068	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1069	opts = append((*c.CallOptions).CreateKeyRing[0:len((*c.CallOptions).CreateKeyRing):len((*c.CallOptions).CreateKeyRing)], opts...)
1070	var resp *kmspb.KeyRing
1071	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1072		var err error
1073		resp, err = c.keyManagementClient.CreateKeyRing(ctx, req, settings.GRPC...)
1074		return err
1075	}, opts...)
1076	if err != nil {
1077		return nil, err
1078	}
1079	return resp, nil
1080}
1081
1082func (c *keyManagementGRPCClient) CreateCryptoKey(ctx context.Context, req *kmspb.CreateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1083	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1084		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1085		defer cancel()
1086		ctx = cctx
1087	}
1088	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1089	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1090	opts = append((*c.CallOptions).CreateCryptoKey[0:len((*c.CallOptions).CreateCryptoKey):len((*c.CallOptions).CreateCryptoKey)], opts...)
1091	var resp *kmspb.CryptoKey
1092	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1093		var err error
1094		resp, err = c.keyManagementClient.CreateCryptoKey(ctx, req, settings.GRPC...)
1095		return err
1096	}, opts...)
1097	if err != nil {
1098		return nil, err
1099	}
1100	return resp, nil
1101}
1102
1103func (c *keyManagementGRPCClient) CreateCryptoKeyVersion(ctx context.Context, req *kmspb.CreateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1104	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1105		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1106		defer cancel()
1107		ctx = cctx
1108	}
1109	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1110	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1111	opts = append((*c.CallOptions).CreateCryptoKeyVersion[0:len((*c.CallOptions).CreateCryptoKeyVersion):len((*c.CallOptions).CreateCryptoKeyVersion)], opts...)
1112	var resp *kmspb.CryptoKeyVersion
1113	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1114		var err error
1115		resp, err = c.keyManagementClient.CreateCryptoKeyVersion(ctx, req, settings.GRPC...)
1116		return err
1117	}, opts...)
1118	if err != nil {
1119		return nil, err
1120	}
1121	return resp, nil
1122}
1123
1124func (c *keyManagementGRPCClient) ImportCryptoKeyVersion(ctx context.Context, req *kmspb.ImportCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1125	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1126		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1127		defer cancel()
1128		ctx = cctx
1129	}
1130	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1131	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1132	opts = append((*c.CallOptions).ImportCryptoKeyVersion[0:len((*c.CallOptions).ImportCryptoKeyVersion):len((*c.CallOptions).ImportCryptoKeyVersion)], opts...)
1133	var resp *kmspb.CryptoKeyVersion
1134	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1135		var err error
1136		resp, err = c.keyManagementClient.ImportCryptoKeyVersion(ctx, req, settings.GRPC...)
1137		return err
1138	}, opts...)
1139	if err != nil {
1140		return nil, err
1141	}
1142	return resp, nil
1143}
1144
1145func (c *keyManagementGRPCClient) CreateImportJob(ctx context.Context, req *kmspb.CreateImportJobRequest, opts ...gax.CallOption) (*kmspb.ImportJob, error) {
1146	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1147		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1148		defer cancel()
1149		ctx = cctx
1150	}
1151	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
1152	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1153	opts = append((*c.CallOptions).CreateImportJob[0:len((*c.CallOptions).CreateImportJob):len((*c.CallOptions).CreateImportJob)], opts...)
1154	var resp *kmspb.ImportJob
1155	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1156		var err error
1157		resp, err = c.keyManagementClient.CreateImportJob(ctx, req, settings.GRPC...)
1158		return err
1159	}, opts...)
1160	if err != nil {
1161		return nil, err
1162	}
1163	return resp, nil
1164}
1165
1166func (c *keyManagementGRPCClient) UpdateCryptoKey(ctx context.Context, req *kmspb.UpdateCryptoKeyRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1167	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1168		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1169		defer cancel()
1170		ctx = cctx
1171	}
1172	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key.name", url.QueryEscape(req.GetCryptoKey().GetName())))
1173	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1174	opts = append((*c.CallOptions).UpdateCryptoKey[0:len((*c.CallOptions).UpdateCryptoKey):len((*c.CallOptions).UpdateCryptoKey)], opts...)
1175	var resp *kmspb.CryptoKey
1176	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1177		var err error
1178		resp, err = c.keyManagementClient.UpdateCryptoKey(ctx, req, settings.GRPC...)
1179		return err
1180	}, opts...)
1181	if err != nil {
1182		return nil, err
1183	}
1184	return resp, nil
1185}
1186
1187func (c *keyManagementGRPCClient) UpdateCryptoKeyVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1188	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1189		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1190		defer cancel()
1191		ctx = cctx
1192	}
1193	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "crypto_key_version.name", url.QueryEscape(req.GetCryptoKeyVersion().GetName())))
1194	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1195	opts = append((*c.CallOptions).UpdateCryptoKeyVersion[0:len((*c.CallOptions).UpdateCryptoKeyVersion):len((*c.CallOptions).UpdateCryptoKeyVersion)], opts...)
1196	var resp *kmspb.CryptoKeyVersion
1197	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1198		var err error
1199		resp, err = c.keyManagementClient.UpdateCryptoKeyVersion(ctx, req, settings.GRPC...)
1200		return err
1201	}, opts...)
1202	if err != nil {
1203		return nil, err
1204	}
1205	return resp, nil
1206}
1207
1208func (c *keyManagementGRPCClient) UpdateCryptoKeyPrimaryVersion(ctx context.Context, req *kmspb.UpdateCryptoKeyPrimaryVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKey, error) {
1209	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1210		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1211		defer cancel()
1212		ctx = cctx
1213	}
1214	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1215	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1216	opts = append((*c.CallOptions).UpdateCryptoKeyPrimaryVersion[0:len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion):len((*c.CallOptions).UpdateCryptoKeyPrimaryVersion)], opts...)
1217	var resp *kmspb.CryptoKey
1218	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1219		var err error
1220		resp, err = c.keyManagementClient.UpdateCryptoKeyPrimaryVersion(ctx, req, settings.GRPC...)
1221		return err
1222	}, opts...)
1223	if err != nil {
1224		return nil, err
1225	}
1226	return resp, nil
1227}
1228
1229func (c *keyManagementGRPCClient) DestroyCryptoKeyVersion(ctx context.Context, req *kmspb.DestroyCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1230	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1231		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1232		defer cancel()
1233		ctx = cctx
1234	}
1235	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1236	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1237	opts = append((*c.CallOptions).DestroyCryptoKeyVersion[0:len((*c.CallOptions).DestroyCryptoKeyVersion):len((*c.CallOptions).DestroyCryptoKeyVersion)], opts...)
1238	var resp *kmspb.CryptoKeyVersion
1239	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1240		var err error
1241		resp, err = c.keyManagementClient.DestroyCryptoKeyVersion(ctx, req, settings.GRPC...)
1242		return err
1243	}, opts...)
1244	if err != nil {
1245		return nil, err
1246	}
1247	return resp, nil
1248}
1249
1250func (c *keyManagementGRPCClient) RestoreCryptoKeyVersion(ctx context.Context, req *kmspb.RestoreCryptoKeyVersionRequest, opts ...gax.CallOption) (*kmspb.CryptoKeyVersion, error) {
1251	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1252		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1253		defer cancel()
1254		ctx = cctx
1255	}
1256	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1257	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1258	opts = append((*c.CallOptions).RestoreCryptoKeyVersion[0:len((*c.CallOptions).RestoreCryptoKeyVersion):len((*c.CallOptions).RestoreCryptoKeyVersion)], opts...)
1259	var resp *kmspb.CryptoKeyVersion
1260	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1261		var err error
1262		resp, err = c.keyManagementClient.RestoreCryptoKeyVersion(ctx, req, settings.GRPC...)
1263		return err
1264	}, opts...)
1265	if err != nil {
1266		return nil, err
1267	}
1268	return resp, nil
1269}
1270
1271func (c *keyManagementGRPCClient) Encrypt(ctx context.Context, req *kmspb.EncryptRequest, opts ...gax.CallOption) (*kmspb.EncryptResponse, error) {
1272	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1273		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1274		defer cancel()
1275		ctx = cctx
1276	}
1277	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1278	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1279	opts = append((*c.CallOptions).Encrypt[0:len((*c.CallOptions).Encrypt):len((*c.CallOptions).Encrypt)], opts...)
1280	var resp *kmspb.EncryptResponse
1281	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1282		var err error
1283		resp, err = c.keyManagementClient.Encrypt(ctx, req, settings.GRPC...)
1284		return err
1285	}, opts...)
1286	if err != nil {
1287		return nil, err
1288	}
1289	return resp, nil
1290}
1291
1292func (c *keyManagementGRPCClient) Decrypt(ctx context.Context, req *kmspb.DecryptRequest, opts ...gax.CallOption) (*kmspb.DecryptResponse, error) {
1293	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1294		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1295		defer cancel()
1296		ctx = cctx
1297	}
1298	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1299	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1300	opts = append((*c.CallOptions).Decrypt[0:len((*c.CallOptions).Decrypt):len((*c.CallOptions).Decrypt)], opts...)
1301	var resp *kmspb.DecryptResponse
1302	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1303		var err error
1304		resp, err = c.keyManagementClient.Decrypt(ctx, req, settings.GRPC...)
1305		return err
1306	}, opts...)
1307	if err != nil {
1308		return nil, err
1309	}
1310	return resp, nil
1311}
1312
1313func (c *keyManagementGRPCClient) AsymmetricSign(ctx context.Context, req *kmspb.AsymmetricSignRequest, opts ...gax.CallOption) (*kmspb.AsymmetricSignResponse, error) {
1314	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1315		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1316		defer cancel()
1317		ctx = cctx
1318	}
1319	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1320	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1321	opts = append((*c.CallOptions).AsymmetricSign[0:len((*c.CallOptions).AsymmetricSign):len((*c.CallOptions).AsymmetricSign)], opts...)
1322	var resp *kmspb.AsymmetricSignResponse
1323	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1324		var err error
1325		resp, err = c.keyManagementClient.AsymmetricSign(ctx, req, settings.GRPC...)
1326		return err
1327	}, opts...)
1328	if err != nil {
1329		return nil, err
1330	}
1331	return resp, nil
1332}
1333
1334func (c *keyManagementGRPCClient) AsymmetricDecrypt(ctx context.Context, req *kmspb.AsymmetricDecryptRequest, opts ...gax.CallOption) (*kmspb.AsymmetricDecryptResponse, error) {
1335	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1336		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1337		defer cancel()
1338		ctx = cctx
1339	}
1340	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1341	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1342	opts = append((*c.CallOptions).AsymmetricDecrypt[0:len((*c.CallOptions).AsymmetricDecrypt):len((*c.CallOptions).AsymmetricDecrypt)], opts...)
1343	var resp *kmspb.AsymmetricDecryptResponse
1344	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1345		var err error
1346		resp, err = c.keyManagementClient.AsymmetricDecrypt(ctx, req, settings.GRPC...)
1347		return err
1348	}, opts...)
1349	if err != nil {
1350		return nil, err
1351	}
1352	return resp, nil
1353}
1354
1355func (c *keyManagementGRPCClient) MacSign(ctx context.Context, req *kmspb.MacSignRequest, opts ...gax.CallOption) (*kmspb.MacSignResponse, error) {
1356	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1357		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1358		defer cancel()
1359		ctx = cctx
1360	}
1361	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1362	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1363	opts = append((*c.CallOptions).MacSign[0:len((*c.CallOptions).MacSign):len((*c.CallOptions).MacSign)], opts...)
1364	var resp *kmspb.MacSignResponse
1365	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1366		var err error
1367		resp, err = c.keyManagementClient.MacSign(ctx, req, settings.GRPC...)
1368		return err
1369	}, opts...)
1370	if err != nil {
1371		return nil, err
1372	}
1373	return resp, nil
1374}
1375
1376func (c *keyManagementGRPCClient) MacVerify(ctx context.Context, req *kmspb.MacVerifyRequest, opts ...gax.CallOption) (*kmspb.MacVerifyResponse, error) {
1377	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1378		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1379		defer cancel()
1380		ctx = cctx
1381	}
1382	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
1383	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1384	opts = append((*c.CallOptions).MacVerify[0:len((*c.CallOptions).MacVerify):len((*c.CallOptions).MacVerify)], opts...)
1385	var resp *kmspb.MacVerifyResponse
1386	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1387		var err error
1388		resp, err = c.keyManagementClient.MacVerify(ctx, req, settings.GRPC...)
1389		return err
1390	}, opts...)
1391	if err != nil {
1392		return nil, err
1393	}
1394	return resp, nil
1395}
1396
1397func (c *keyManagementGRPCClient) GenerateRandomBytes(ctx context.Context, req *kmspb.GenerateRandomBytesRequest, opts ...gax.CallOption) (*kmspb.GenerateRandomBytesResponse, error) {
1398	if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines {
1399		cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond)
1400		defer cancel()
1401		ctx = cctx
1402	}
1403	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "location", url.QueryEscape(req.GetLocation())))
1404	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
1405	opts = append((*c.CallOptions).GenerateRandomBytes[0:len((*c.CallOptions).GenerateRandomBytes):len((*c.CallOptions).GenerateRandomBytes)], opts...)
1406	var resp *kmspb.GenerateRandomBytesResponse
1407	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1408		var err error
1409		resp, err = c.keyManagementClient.GenerateRandomBytes(ctx, req, settings.GRPC...)
1410		return err
1411	}, opts...)
1412	if err != nil {
1413		return nil, err
1414	}
1415	return resp, nil
1416}
1417
1418func (c *keyManagementGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1419	ctx = insertMetadata(ctx, c.xGoogMetadata)
1420	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1421	var resp *iampb.Policy
1422	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1423		var err error
1424		resp, err = c.iamPolicyClient.GetIamPolicy(ctx, req, settings.GRPC...)
1425		return err
1426	}, opts...)
1427	if err != nil {
1428		return nil, err
1429	}
1430	return resp, nil
1431}
1432
1433func (c *keyManagementGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1434	ctx = insertMetadata(ctx, c.xGoogMetadata)
1435	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1436	var resp *iampb.Policy
1437	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1438		var err error
1439		resp, err = c.iamPolicyClient.SetIamPolicy(ctx, req, settings.GRPC...)
1440		return err
1441	}, opts...)
1442	if err != nil {
1443		return nil, err
1444	}
1445	return resp, nil
1446}
1447
1448func (c *keyManagementGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1449	ctx = insertMetadata(ctx, c.xGoogMetadata)
1450	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1451	var resp *iampb.TestIamPermissionsResponse
1452	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1453		var err error
1454		resp, err = c.iamPolicyClient.TestIamPermissions(ctx, req, settings.GRPC...)
1455		return err
1456	}, opts...)
1457	if err != nil {
1458		return nil, err
1459	}
1460	return resp, nil
1461}
1462
1463// CryptoKeyIterator manages a stream of *kmspb.CryptoKey.
1464type CryptoKeyIterator struct {
1465	items    []*kmspb.CryptoKey
1466	pageInfo *iterator.PageInfo
1467	nextFunc func() error
1468
1469	// Response is the raw response for the current page.
1470	// It must be cast to the RPC response type.
1471	// Calling Next() or InternalFetch() updates this value.
1472	Response interface{}
1473
1474	// InternalFetch is for use by the Google Cloud Libraries only.
1475	// It is not part of the stable interface of this package.
1476	//
1477	// InternalFetch returns results from a single call to the underlying RPC.
1478	// The number of results is no greater than pageSize.
1479	// If there are no more results, nextPageToken is empty and err is nil.
1480	InternalFetch func(pageSize int, pageToken string) (results []*kmspb.CryptoKey, nextPageToken string, err error)
1481}
1482
1483// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1484func (it *CryptoKeyIterator) PageInfo() *iterator.PageInfo {
1485	return it.pageInfo
1486}
1487
1488// Next returns the next result. Its second return value is iterator.Done if there are no more
1489// results. Once Next returns Done, all subsequent calls will return Done.
1490func (it *CryptoKeyIterator) Next() (*kmspb.CryptoKey, error) {
1491	var item *kmspb.CryptoKey
1492	if err := it.nextFunc(); err != nil {
1493		return item, err
1494	}
1495	item = it.items[0]
1496	it.items = it.items[1:]
1497	return item, nil
1498}
1499
1500func (it *CryptoKeyIterator) bufLen() int {
1501	return len(it.items)
1502}
1503
1504func (it *CryptoKeyIterator) takeBuf() interface{} {
1505	b := it.items
1506	it.items = nil
1507	return b
1508}
1509
1510// CryptoKeyVersionIterator manages a stream of *kmspb.CryptoKeyVersion.
1511type CryptoKeyVersionIterator struct {
1512	items    []*kmspb.CryptoKeyVersion
1513	pageInfo *iterator.PageInfo
1514	nextFunc func() error
1515
1516	// Response is the raw response for the current page.
1517	// It must be cast to the RPC response type.
1518	// Calling Next() or InternalFetch() updates this value.
1519	Response interface{}
1520
1521	// InternalFetch is for use by the Google Cloud Libraries only.
1522	// It is not part of the stable interface of this package.
1523	//
1524	// InternalFetch returns results from a single call to the underlying RPC.
1525	// The number of results is no greater than pageSize.
1526	// If there are no more results, nextPageToken is empty and err is nil.
1527	InternalFetch func(pageSize int, pageToken string) (results []*kmspb.CryptoKeyVersion, nextPageToken string, err error)
1528}
1529
1530// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1531func (it *CryptoKeyVersionIterator) PageInfo() *iterator.PageInfo {
1532	return it.pageInfo
1533}
1534
1535// Next returns the next result. Its second return value is iterator.Done if there are no more
1536// results. Once Next returns Done, all subsequent calls will return Done.
1537func (it *CryptoKeyVersionIterator) Next() (*kmspb.CryptoKeyVersion, error) {
1538	var item *kmspb.CryptoKeyVersion
1539	if err := it.nextFunc(); err != nil {
1540		return item, err
1541	}
1542	item = it.items[0]
1543	it.items = it.items[1:]
1544	return item, nil
1545}
1546
1547func (it *CryptoKeyVersionIterator) bufLen() int {
1548	return len(it.items)
1549}
1550
1551func (it *CryptoKeyVersionIterator) takeBuf() interface{} {
1552	b := it.items
1553	it.items = nil
1554	return b
1555}
1556
1557// ImportJobIterator manages a stream of *kmspb.ImportJob.
1558type ImportJobIterator struct {
1559	items    []*kmspb.ImportJob
1560	pageInfo *iterator.PageInfo
1561	nextFunc func() error
1562
1563	// Response is the raw response for the current page.
1564	// It must be cast to the RPC response type.
1565	// Calling Next() or InternalFetch() updates this value.
1566	Response interface{}
1567
1568	// InternalFetch is for use by the Google Cloud Libraries only.
1569	// It is not part of the stable interface of this package.
1570	//
1571	// InternalFetch returns results from a single call to the underlying RPC.
1572	// The number of results is no greater than pageSize.
1573	// If there are no more results, nextPageToken is empty and err is nil.
1574	InternalFetch func(pageSize int, pageToken string) (results []*kmspb.ImportJob, nextPageToken string, err error)
1575}
1576
1577// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1578func (it *ImportJobIterator) PageInfo() *iterator.PageInfo {
1579	return it.pageInfo
1580}
1581
1582// Next returns the next result. Its second return value is iterator.Done if there are no more
1583// results. Once Next returns Done, all subsequent calls will return Done.
1584func (it *ImportJobIterator) Next() (*kmspb.ImportJob, error) {
1585	var item *kmspb.ImportJob
1586	if err := it.nextFunc(); err != nil {
1587		return item, err
1588	}
1589	item = it.items[0]
1590	it.items = it.items[1:]
1591	return item, nil
1592}
1593
1594func (it *ImportJobIterator) bufLen() int {
1595	return len(it.items)
1596}
1597
1598func (it *ImportJobIterator) takeBuf() interface{} {
1599	b := it.items
1600	it.items = nil
1601	return b
1602}
1603
1604// KeyRingIterator manages a stream of *kmspb.KeyRing.
1605type KeyRingIterator struct {
1606	items    []*kmspb.KeyRing
1607	pageInfo *iterator.PageInfo
1608	nextFunc func() error
1609
1610	// Response is the raw response for the current page.
1611	// It must be cast to the RPC response type.
1612	// Calling Next() or InternalFetch() updates this value.
1613	Response interface{}
1614
1615	// InternalFetch is for use by the Google Cloud Libraries only.
1616	// It is not part of the stable interface of this package.
1617	//
1618	// InternalFetch returns results from a single call to the underlying RPC.
1619	// The number of results is no greater than pageSize.
1620	// If there are no more results, nextPageToken is empty and err is nil.
1621	InternalFetch func(pageSize int, pageToken string) (results []*kmspb.KeyRing, nextPageToken string, err error)
1622}
1623
1624// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1625func (it *KeyRingIterator) PageInfo() *iterator.PageInfo {
1626	return it.pageInfo
1627}
1628
1629// Next returns the next result. Its second return value is iterator.Done if there are no more
1630// results. Once Next returns Done, all subsequent calls will return Done.
1631func (it *KeyRingIterator) Next() (*kmspb.KeyRing, error) {
1632	var item *kmspb.KeyRing
1633	if err := it.nextFunc(); err != nil {
1634		return item, err
1635	}
1636	item = it.items[0]
1637	it.items = it.items[1:]
1638	return item, nil
1639}
1640
1641func (it *KeyRingIterator) bufLen() int {
1642	return len(it.items)
1643}
1644
1645func (it *KeyRingIterator) takeBuf() interface{} {
1646	b := it.items
1647	it.items = nil
1648	return b
1649}
1650