1// Copyright 2018 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// AUTO-GENERATED CODE. DO NOT EDIT. 16 17package kms_test 18 19import ( 20 "cloud.google.com/go/kms/apiv1" 21 "golang.org/x/net/context" 22 "google.golang.org/api/iterator" 23 kmspb "google.golang.org/genproto/googleapis/cloud/kms/v1" 24) 25 26func ExampleNewKeyManagementClient() { 27 ctx := context.Background() 28 c, err := kms.NewKeyManagementClient(ctx) 29 if err != nil { 30 // TODO: Handle error. 31 } 32 // TODO: Use client. 33 _ = c 34} 35 36func ExampleKeyManagementClient_ListKeyRings() { 37 ctx := context.Background() 38 c, err := kms.NewKeyManagementClient(ctx) 39 if err != nil { 40 // TODO: Handle error. 41 } 42 43 req := &kmspb.ListKeyRingsRequest{ 44 // TODO: Fill request struct fields. 45 } 46 it := c.ListKeyRings(ctx, req) 47 for { 48 resp, err := it.Next() 49 if err == iterator.Done { 50 break 51 } 52 if err != nil { 53 // TODO: Handle error. 54 } 55 // TODO: Use resp. 56 _ = resp 57 } 58} 59 60func ExampleKeyManagementClient_ListCryptoKeys() { 61 ctx := context.Background() 62 c, err := kms.NewKeyManagementClient(ctx) 63 if err != nil { 64 // TODO: Handle error. 65 } 66 67 req := &kmspb.ListCryptoKeysRequest{ 68 // TODO: Fill request struct fields. 69 } 70 it := c.ListCryptoKeys(ctx, req) 71 for { 72 resp, err := it.Next() 73 if err == iterator.Done { 74 break 75 } 76 if err != nil { 77 // TODO: Handle error. 78 } 79 // TODO: Use resp. 80 _ = resp 81 } 82} 83 84func ExampleKeyManagementClient_ListCryptoKeyVersions() { 85 ctx := context.Background() 86 c, err := kms.NewKeyManagementClient(ctx) 87 if err != nil { 88 // TODO: Handle error. 89 } 90 91 req := &kmspb.ListCryptoKeyVersionsRequest{ 92 // TODO: Fill request struct fields. 93 } 94 it := c.ListCryptoKeyVersions(ctx, req) 95 for { 96 resp, err := it.Next() 97 if err == iterator.Done { 98 break 99 } 100 if err != nil { 101 // TODO: Handle error. 102 } 103 // TODO: Use resp. 104 _ = resp 105 } 106} 107 108func ExampleKeyManagementClient_GetKeyRing() { 109 ctx := context.Background() 110 c, err := kms.NewKeyManagementClient(ctx) 111 if err != nil { 112 // TODO: Handle error. 113 } 114 115 req := &kmspb.GetKeyRingRequest{ 116 // TODO: Fill request struct fields. 117 } 118 resp, err := c.GetKeyRing(ctx, req) 119 if err != nil { 120 // TODO: Handle error. 121 } 122 // TODO: Use resp. 123 _ = resp 124} 125 126func ExampleKeyManagementClient_GetCryptoKey() { 127 ctx := context.Background() 128 c, err := kms.NewKeyManagementClient(ctx) 129 if err != nil { 130 // TODO: Handle error. 131 } 132 133 req := &kmspb.GetCryptoKeyRequest{ 134 // TODO: Fill request struct fields. 135 } 136 resp, err := c.GetCryptoKey(ctx, req) 137 if err != nil { 138 // TODO: Handle error. 139 } 140 // TODO: Use resp. 141 _ = resp 142} 143 144func ExampleKeyManagementClient_GetCryptoKeyVersion() { 145 ctx := context.Background() 146 c, err := kms.NewKeyManagementClient(ctx) 147 if err != nil { 148 // TODO: Handle error. 149 } 150 151 req := &kmspb.GetCryptoKeyVersionRequest{ 152 // TODO: Fill request struct fields. 153 } 154 resp, err := c.GetCryptoKeyVersion(ctx, req) 155 if err != nil { 156 // TODO: Handle error. 157 } 158 // TODO: Use resp. 159 _ = resp 160} 161 162func ExampleKeyManagementClient_CreateKeyRing() { 163 ctx := context.Background() 164 c, err := kms.NewKeyManagementClient(ctx) 165 if err != nil { 166 // TODO: Handle error. 167 } 168 169 req := &kmspb.CreateKeyRingRequest{ 170 // TODO: Fill request struct fields. 171 } 172 resp, err := c.CreateKeyRing(ctx, req) 173 if err != nil { 174 // TODO: Handle error. 175 } 176 // TODO: Use resp. 177 _ = resp 178} 179 180func ExampleKeyManagementClient_CreateCryptoKey() { 181 ctx := context.Background() 182 c, err := kms.NewKeyManagementClient(ctx) 183 if err != nil { 184 // TODO: Handle error. 185 } 186 187 req := &kmspb.CreateCryptoKeyRequest{ 188 // TODO: Fill request struct fields. 189 } 190 resp, err := c.CreateCryptoKey(ctx, req) 191 if err != nil { 192 // TODO: Handle error. 193 } 194 // TODO: Use resp. 195 _ = resp 196} 197 198func ExampleKeyManagementClient_CreateCryptoKeyVersion() { 199 ctx := context.Background() 200 c, err := kms.NewKeyManagementClient(ctx) 201 if err != nil { 202 // TODO: Handle error. 203 } 204 205 req := &kmspb.CreateCryptoKeyVersionRequest{ 206 // TODO: Fill request struct fields. 207 } 208 resp, err := c.CreateCryptoKeyVersion(ctx, req) 209 if err != nil { 210 // TODO: Handle error. 211 } 212 // TODO: Use resp. 213 _ = resp 214} 215 216func ExampleKeyManagementClient_UpdateCryptoKey() { 217 ctx := context.Background() 218 c, err := kms.NewKeyManagementClient(ctx) 219 if err != nil { 220 // TODO: Handle error. 221 } 222 223 req := &kmspb.UpdateCryptoKeyRequest{ 224 // TODO: Fill request struct fields. 225 } 226 resp, err := c.UpdateCryptoKey(ctx, req) 227 if err != nil { 228 // TODO: Handle error. 229 } 230 // TODO: Use resp. 231 _ = resp 232} 233 234func ExampleKeyManagementClient_UpdateCryptoKeyVersion() { 235 ctx := context.Background() 236 c, err := kms.NewKeyManagementClient(ctx) 237 if err != nil { 238 // TODO: Handle error. 239 } 240 241 req := &kmspb.UpdateCryptoKeyVersionRequest{ 242 // TODO: Fill request struct fields. 243 } 244 resp, err := c.UpdateCryptoKeyVersion(ctx, req) 245 if err != nil { 246 // TODO: Handle error. 247 } 248 // TODO: Use resp. 249 _ = resp 250} 251 252func ExampleKeyManagementClient_Encrypt() { 253 ctx := context.Background() 254 c, err := kms.NewKeyManagementClient(ctx) 255 if err != nil { 256 // TODO: Handle error. 257 } 258 259 req := &kmspb.EncryptRequest{ 260 // TODO: Fill request struct fields. 261 } 262 resp, err := c.Encrypt(ctx, req) 263 if err != nil { 264 // TODO: Handle error. 265 } 266 // TODO: Use resp. 267 _ = resp 268} 269 270func ExampleKeyManagementClient_Decrypt() { 271 ctx := context.Background() 272 c, err := kms.NewKeyManagementClient(ctx) 273 if err != nil { 274 // TODO: Handle error. 275 } 276 277 req := &kmspb.DecryptRequest{ 278 // TODO: Fill request struct fields. 279 } 280 resp, err := c.Decrypt(ctx, req) 281 if err != nil { 282 // TODO: Handle error. 283 } 284 // TODO: Use resp. 285 _ = resp 286} 287 288func ExampleKeyManagementClient_UpdateCryptoKeyPrimaryVersion() { 289 ctx := context.Background() 290 c, err := kms.NewKeyManagementClient(ctx) 291 if err != nil { 292 // TODO: Handle error. 293 } 294 295 req := &kmspb.UpdateCryptoKeyPrimaryVersionRequest{ 296 // TODO: Fill request struct fields. 297 } 298 resp, err := c.UpdateCryptoKeyPrimaryVersion(ctx, req) 299 if err != nil { 300 // TODO: Handle error. 301 } 302 // TODO: Use resp. 303 _ = resp 304} 305 306func ExampleKeyManagementClient_DestroyCryptoKeyVersion() { 307 ctx := context.Background() 308 c, err := kms.NewKeyManagementClient(ctx) 309 if err != nil { 310 // TODO: Handle error. 311 } 312 313 req := &kmspb.DestroyCryptoKeyVersionRequest{ 314 // TODO: Fill request struct fields. 315 } 316 resp, err := c.DestroyCryptoKeyVersion(ctx, req) 317 if err != nil { 318 // TODO: Handle error. 319 } 320 // TODO: Use resp. 321 _ = resp 322} 323 324func ExampleKeyManagementClient_RestoreCryptoKeyVersion() { 325 ctx := context.Background() 326 c, err := kms.NewKeyManagementClient(ctx) 327 if err != nil { 328 // TODO: Handle error. 329 } 330 331 req := &kmspb.RestoreCryptoKeyVersionRequest{ 332 // TODO: Fill request struct fields. 333 } 334 resp, err := c.RestoreCryptoKeyVersion(ctx, req) 335 if err != nil { 336 // TODO: Handle error. 337 } 338 // TODO: Use resp. 339 _ = resp 340} 341