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_test
18
19import (
20	"context"
21
22	kms "cloud.google.com/go/kms/apiv1"
23	"google.golang.org/api/iterator"
24	kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
25)
26
27func ExampleNewKeyManagementClient() {
28	ctx := context.Background()
29	c, err := kms.NewKeyManagementClient(ctx)
30	if err != nil {
31		// TODO: Handle error.
32	}
33	// TODO: Use client.
34	_ = c
35}
36
37func ExampleKeyManagementClient_ListKeyRings() {
38	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
39	// import "google.golang.org/api/iterator"
40
41	ctx := context.Background()
42	c, err := kms.NewKeyManagementClient(ctx)
43	if err != nil {
44		// TODO: Handle error.
45	}
46
47	req := &kmspb.ListKeyRingsRequest{
48		// TODO: Fill request struct fields.
49	}
50	it := c.ListKeyRings(ctx, req)
51	for {
52		resp, err := it.Next()
53		if err == iterator.Done {
54			break
55		}
56		if err != nil {
57			// TODO: Handle error.
58		}
59		// TODO: Use resp.
60		_ = resp
61	}
62}
63
64func ExampleKeyManagementClient_ListCryptoKeys() {
65	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
66	// import "google.golang.org/api/iterator"
67
68	ctx := context.Background()
69	c, err := kms.NewKeyManagementClient(ctx)
70	if err != nil {
71		// TODO: Handle error.
72	}
73
74	req := &kmspb.ListCryptoKeysRequest{
75		// TODO: Fill request struct fields.
76	}
77	it := c.ListCryptoKeys(ctx, req)
78	for {
79		resp, err := it.Next()
80		if err == iterator.Done {
81			break
82		}
83		if err != nil {
84			// TODO: Handle error.
85		}
86		// TODO: Use resp.
87		_ = resp
88	}
89}
90
91func ExampleKeyManagementClient_ListCryptoKeyVersions() {
92	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
93	// import "google.golang.org/api/iterator"
94
95	ctx := context.Background()
96	c, err := kms.NewKeyManagementClient(ctx)
97	if err != nil {
98		// TODO: Handle error.
99	}
100
101	req := &kmspb.ListCryptoKeyVersionsRequest{
102		// TODO: Fill request struct fields.
103	}
104	it := c.ListCryptoKeyVersions(ctx, req)
105	for {
106		resp, err := it.Next()
107		if err == iterator.Done {
108			break
109		}
110		if err != nil {
111			// TODO: Handle error.
112		}
113		// TODO: Use resp.
114		_ = resp
115	}
116}
117
118func ExampleKeyManagementClient_ListImportJobs() {
119	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
120	// import "google.golang.org/api/iterator"
121
122	ctx := context.Background()
123	c, err := kms.NewKeyManagementClient(ctx)
124	if err != nil {
125		// TODO: Handle error.
126	}
127
128	req := &kmspb.ListImportJobsRequest{
129		// TODO: Fill request struct fields.
130	}
131	it := c.ListImportJobs(ctx, req)
132	for {
133		resp, err := it.Next()
134		if err == iterator.Done {
135			break
136		}
137		if err != nil {
138			// TODO: Handle error.
139		}
140		// TODO: Use resp.
141		_ = resp
142	}
143}
144
145func ExampleKeyManagementClient_GetKeyRing() {
146	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
147
148	ctx := context.Background()
149	c, err := kms.NewKeyManagementClient(ctx)
150	if err != nil {
151		// TODO: Handle error.
152	}
153
154	req := &kmspb.GetKeyRingRequest{
155		// TODO: Fill request struct fields.
156	}
157	resp, err := c.GetKeyRing(ctx, req)
158	if err != nil {
159		// TODO: Handle error.
160	}
161	// TODO: Use resp.
162	_ = resp
163}
164
165func ExampleKeyManagementClient_GetCryptoKey() {
166	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
167
168	ctx := context.Background()
169	c, err := kms.NewKeyManagementClient(ctx)
170	if err != nil {
171		// TODO: Handle error.
172	}
173
174	req := &kmspb.GetCryptoKeyRequest{
175		// TODO: Fill request struct fields.
176	}
177	resp, err := c.GetCryptoKey(ctx, req)
178	if err != nil {
179		// TODO: Handle error.
180	}
181	// TODO: Use resp.
182	_ = resp
183}
184
185func ExampleKeyManagementClient_GetCryptoKeyVersion() {
186	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
187
188	ctx := context.Background()
189	c, err := kms.NewKeyManagementClient(ctx)
190	if err != nil {
191		// TODO: Handle error.
192	}
193
194	req := &kmspb.GetCryptoKeyVersionRequest{
195		// TODO: Fill request struct fields.
196	}
197	resp, err := c.GetCryptoKeyVersion(ctx, req)
198	if err != nil {
199		// TODO: Handle error.
200	}
201	// TODO: Use resp.
202	_ = resp
203}
204
205func ExampleKeyManagementClient_GetPublicKey() {
206	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
207
208	ctx := context.Background()
209	c, err := kms.NewKeyManagementClient(ctx)
210	if err != nil {
211		// TODO: Handle error.
212	}
213
214	req := &kmspb.GetPublicKeyRequest{
215		// TODO: Fill request struct fields.
216	}
217	resp, err := c.GetPublicKey(ctx, req)
218	if err != nil {
219		// TODO: Handle error.
220	}
221	// TODO: Use resp.
222	_ = resp
223}
224
225func ExampleKeyManagementClient_GetImportJob() {
226	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
227
228	ctx := context.Background()
229	c, err := kms.NewKeyManagementClient(ctx)
230	if err != nil {
231		// TODO: Handle error.
232	}
233
234	req := &kmspb.GetImportJobRequest{
235		// TODO: Fill request struct fields.
236	}
237	resp, err := c.GetImportJob(ctx, req)
238	if err != nil {
239		// TODO: Handle error.
240	}
241	// TODO: Use resp.
242	_ = resp
243}
244
245func ExampleKeyManagementClient_CreateKeyRing() {
246	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
247
248	ctx := context.Background()
249	c, err := kms.NewKeyManagementClient(ctx)
250	if err != nil {
251		// TODO: Handle error.
252	}
253
254	req := &kmspb.CreateKeyRingRequest{
255		// TODO: Fill request struct fields.
256	}
257	resp, err := c.CreateKeyRing(ctx, req)
258	if err != nil {
259		// TODO: Handle error.
260	}
261	// TODO: Use resp.
262	_ = resp
263}
264
265func ExampleKeyManagementClient_CreateCryptoKey() {
266	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
267
268	ctx := context.Background()
269	c, err := kms.NewKeyManagementClient(ctx)
270	if err != nil {
271		// TODO: Handle error.
272	}
273
274	req := &kmspb.CreateCryptoKeyRequest{
275		// TODO: Fill request struct fields.
276	}
277	resp, err := c.CreateCryptoKey(ctx, req)
278	if err != nil {
279		// TODO: Handle error.
280	}
281	// TODO: Use resp.
282	_ = resp
283}
284
285func ExampleKeyManagementClient_CreateCryptoKeyVersion() {
286	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
287
288	ctx := context.Background()
289	c, err := kms.NewKeyManagementClient(ctx)
290	if err != nil {
291		// TODO: Handle error.
292	}
293
294	req := &kmspb.CreateCryptoKeyVersionRequest{
295		// TODO: Fill request struct fields.
296	}
297	resp, err := c.CreateCryptoKeyVersion(ctx, req)
298	if err != nil {
299		// TODO: Handle error.
300	}
301	// TODO: Use resp.
302	_ = resp
303}
304
305func ExampleKeyManagementClient_ImportCryptoKeyVersion() {
306	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
307
308	ctx := context.Background()
309	c, err := kms.NewKeyManagementClient(ctx)
310	if err != nil {
311		// TODO: Handle error.
312	}
313
314	req := &kmspb.ImportCryptoKeyVersionRequest{
315		// TODO: Fill request struct fields.
316	}
317	resp, err := c.ImportCryptoKeyVersion(ctx, req)
318	if err != nil {
319		// TODO: Handle error.
320	}
321	// TODO: Use resp.
322	_ = resp
323}
324
325func ExampleKeyManagementClient_CreateImportJob() {
326	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
327
328	ctx := context.Background()
329	c, err := kms.NewKeyManagementClient(ctx)
330	if err != nil {
331		// TODO: Handle error.
332	}
333
334	req := &kmspb.CreateImportJobRequest{
335		// TODO: Fill request struct fields.
336	}
337	resp, err := c.CreateImportJob(ctx, req)
338	if err != nil {
339		// TODO: Handle error.
340	}
341	// TODO: Use resp.
342	_ = resp
343}
344
345func ExampleKeyManagementClient_UpdateCryptoKey() {
346	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
347
348	ctx := context.Background()
349	c, err := kms.NewKeyManagementClient(ctx)
350	if err != nil {
351		// TODO: Handle error.
352	}
353
354	req := &kmspb.UpdateCryptoKeyRequest{
355		// TODO: Fill request struct fields.
356	}
357	resp, err := c.UpdateCryptoKey(ctx, req)
358	if err != nil {
359		// TODO: Handle error.
360	}
361	// TODO: Use resp.
362	_ = resp
363}
364
365func ExampleKeyManagementClient_UpdateCryptoKeyVersion() {
366	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
367
368	ctx := context.Background()
369	c, err := kms.NewKeyManagementClient(ctx)
370	if err != nil {
371		// TODO: Handle error.
372	}
373
374	req := &kmspb.UpdateCryptoKeyVersionRequest{
375		// TODO: Fill request struct fields.
376	}
377	resp, err := c.UpdateCryptoKeyVersion(ctx, req)
378	if err != nil {
379		// TODO: Handle error.
380	}
381	// TODO: Use resp.
382	_ = resp
383}
384
385func ExampleKeyManagementClient_Encrypt() {
386	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
387
388	ctx := context.Background()
389	c, err := kms.NewKeyManagementClient(ctx)
390	if err != nil {
391		// TODO: Handle error.
392	}
393
394	req := &kmspb.EncryptRequest{
395		// TODO: Fill request struct fields.
396	}
397	resp, err := c.Encrypt(ctx, req)
398	if err != nil {
399		// TODO: Handle error.
400	}
401	// TODO: Use resp.
402	_ = resp
403}
404
405func ExampleKeyManagementClient_Decrypt() {
406	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
407
408	ctx := context.Background()
409	c, err := kms.NewKeyManagementClient(ctx)
410	if err != nil {
411		// TODO: Handle error.
412	}
413
414	req := &kmspb.DecryptRequest{
415		// TODO: Fill request struct fields.
416	}
417	resp, err := c.Decrypt(ctx, req)
418	if err != nil {
419		// TODO: Handle error.
420	}
421	// TODO: Use resp.
422	_ = resp
423}
424
425func ExampleKeyManagementClient_AsymmetricSign() {
426	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
427
428	ctx := context.Background()
429	c, err := kms.NewKeyManagementClient(ctx)
430	if err != nil {
431		// TODO: Handle error.
432	}
433
434	req := &kmspb.AsymmetricSignRequest{
435		// TODO: Fill request struct fields.
436	}
437	resp, err := c.AsymmetricSign(ctx, req)
438	if err != nil {
439		// TODO: Handle error.
440	}
441	// TODO: Use resp.
442	_ = resp
443}
444
445func ExampleKeyManagementClient_AsymmetricDecrypt() {
446	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
447
448	ctx := context.Background()
449	c, err := kms.NewKeyManagementClient(ctx)
450	if err != nil {
451		// TODO: Handle error.
452	}
453
454	req := &kmspb.AsymmetricDecryptRequest{
455		// TODO: Fill request struct fields.
456	}
457	resp, err := c.AsymmetricDecrypt(ctx, req)
458	if err != nil {
459		// TODO: Handle error.
460	}
461	// TODO: Use resp.
462	_ = resp
463}
464
465func ExampleKeyManagementClient_UpdateCryptoKeyPrimaryVersion() {
466	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
467
468	ctx := context.Background()
469	c, err := kms.NewKeyManagementClient(ctx)
470	if err != nil {
471		// TODO: Handle error.
472	}
473
474	req := &kmspb.UpdateCryptoKeyPrimaryVersionRequest{
475		// TODO: Fill request struct fields.
476	}
477	resp, err := c.UpdateCryptoKeyPrimaryVersion(ctx, req)
478	if err != nil {
479		// TODO: Handle error.
480	}
481	// TODO: Use resp.
482	_ = resp
483}
484
485func ExampleKeyManagementClient_DestroyCryptoKeyVersion() {
486	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
487
488	ctx := context.Background()
489	c, err := kms.NewKeyManagementClient(ctx)
490	if err != nil {
491		// TODO: Handle error.
492	}
493
494	req := &kmspb.DestroyCryptoKeyVersionRequest{
495		// TODO: Fill request struct fields.
496	}
497	resp, err := c.DestroyCryptoKeyVersion(ctx, req)
498	if err != nil {
499		// TODO: Handle error.
500	}
501	// TODO: Use resp.
502	_ = resp
503}
504
505func ExampleKeyManagementClient_RestoreCryptoKeyVersion() {
506	// import kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1"
507
508	ctx := context.Background()
509	c, err := kms.NewKeyManagementClient(ctx)
510	if err != nil {
511		// TODO: Handle error.
512	}
513
514	req := &kmspb.RestoreCryptoKeyVersionRequest{
515		// TODO: Fill request struct fields.
516	}
517	resp, err := c.RestoreCryptoKeyVersion(ctx, req)
518	if err != nil {
519		// TODO: Handle error.
520	}
521	// TODO: Use resp.
522	_ = resp
523}
524