github.com/aavshr/aws-sdk-go@v1.41.3/service/elasticache/examples_test.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package elasticache_test 4 5 import ( 6 "fmt" 7 "strings" 8 "time" 9 10 "github.com/aavshr/aws-sdk-go/aws" 11 "github.com/aavshr/aws-sdk-go/aws/awserr" 12 "github.com/aavshr/aws-sdk-go/aws/session" 13 "github.com/aavshr/aws-sdk-go/service/elasticache" 14 ) 15 16 var _ time.Duration 17 var _ strings.Reader 18 var _ aws.Config 19 20 func parseTime(layout, value string) *time.Time { 21 t, err := time.Parse(layout, value) 22 if err != nil { 23 panic(err) 24 } 25 return &t 26 } 27 28 // AddTagsToResource 29 // 30 // Adds up to 10 tags, key/value pairs, to a cluster or snapshot resource. 31 func ExampleElastiCache_AddTagsToResource_shared00() { 32 svc := elasticache.New(session.New()) 33 input := &elasticache.AddTagsToResourceInput{ 34 ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"), 35 Tags: []*elasticache.Tag{ 36 { 37 Key: aws.String("APIVersion"), 38 Value: aws.String("20150202"), 39 }, 40 { 41 Key: aws.String("Service"), 42 Value: aws.String("ElastiCache"), 43 }, 44 }, 45 } 46 47 result, err := svc.AddTagsToResource(input) 48 if err != nil { 49 if aerr, ok := err.(awserr.Error); ok { 50 switch aerr.Code() { 51 case elasticache.ErrCodeCacheClusterNotFoundFault: 52 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 53 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 54 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 55 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 56 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 57 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 58 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 59 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 60 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 61 case elasticache.ErrCodeReplicationGroupNotFoundFault: 62 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 63 case elasticache.ErrCodeReservedCacheNodeNotFoundFault: 64 fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error()) 65 case elasticache.ErrCodeSnapshotNotFoundFault: 66 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 67 case elasticache.ErrCodeUserNotFoundFault: 68 fmt.Println(elasticache.ErrCodeUserNotFoundFault, aerr.Error()) 69 case elasticache.ErrCodeUserGroupNotFoundFault: 70 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 71 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 72 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 73 case elasticache.ErrCodeInvalidARNFault: 74 fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error()) 75 default: 76 fmt.Println(aerr.Error()) 77 } 78 } else { 79 // Print the error, cast err to awserr.Error to get the Code and 80 // Message from an error. 81 fmt.Println(err.Error()) 82 } 83 return 84 } 85 86 fmt.Println(result) 87 } 88 89 // AuthorizeCacheCacheSecurityGroupIngress 90 // 91 // Allows network ingress to a cache security group. Applications using ElastiCache 92 // must be running on Amazon EC2. Amazon EC2 security groups are used as the authorization 93 // mechanism. 94 func ExampleElastiCache_AuthorizeCacheSecurityGroupIngress_shared00() { 95 svc := elasticache.New(session.New()) 96 input := &elasticache.AuthorizeCacheSecurityGroupIngressInput{ 97 CacheSecurityGroupName: aws.String("my-sec-grp"), 98 EC2SecurityGroupName: aws.String("my-ec2-sec-grp"), 99 EC2SecurityGroupOwnerId: aws.String("1234567890"), 100 } 101 102 result, err := svc.AuthorizeCacheSecurityGroupIngress(input) 103 if err != nil { 104 if aerr, ok := err.(awserr.Error); ok { 105 switch aerr.Code() { 106 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 107 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 108 case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: 109 fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) 110 case elasticache.ErrCodeAuthorizationAlreadyExistsFault: 111 fmt.Println(elasticache.ErrCodeAuthorizationAlreadyExistsFault, aerr.Error()) 112 case elasticache.ErrCodeInvalidParameterValueException: 113 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 114 case elasticache.ErrCodeInvalidParameterCombinationException: 115 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 116 default: 117 fmt.Println(aerr.Error()) 118 } 119 } else { 120 // Print the error, cast err to awserr.Error to get the Code and 121 // Message from an error. 122 fmt.Println(err.Error()) 123 } 124 return 125 } 126 127 fmt.Println(result) 128 } 129 130 // CopySnapshot 131 // 132 // Copies a snapshot to a specified name. 133 func ExampleElastiCache_CopySnapshot_shared00() { 134 svc := elasticache.New(session.New()) 135 input := &elasticache.CopySnapshotInput{ 136 SourceSnapshotName: aws.String("my-snapshot"), 137 TargetBucket: aws.String(""), 138 TargetSnapshotName: aws.String("my-snapshot-copy"), 139 } 140 141 result, err := svc.CopySnapshot(input) 142 if err != nil { 143 if aerr, ok := err.(awserr.Error); ok { 144 switch aerr.Code() { 145 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 146 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 147 case elasticache.ErrCodeSnapshotNotFoundFault: 148 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 149 case elasticache.ErrCodeSnapshotQuotaExceededFault: 150 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 151 case elasticache.ErrCodeInvalidSnapshotStateFault: 152 fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error()) 153 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 154 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 155 case elasticache.ErrCodeInvalidParameterValueException: 156 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 157 case elasticache.ErrCodeInvalidParameterCombinationException: 158 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 159 default: 160 fmt.Println(aerr.Error()) 161 } 162 } else { 163 // Print the error, cast err to awserr.Error to get the Code and 164 // Message from an error. 165 fmt.Println(err.Error()) 166 } 167 return 168 } 169 170 fmt.Println(result) 171 } 172 173 // CreateCacheCluster 174 // 175 // Creates a Memcached cluster with 2 nodes. 176 func ExampleElastiCache_CreateCacheCluster_shared00() { 177 svc := elasticache.New(session.New()) 178 input := &elasticache.CreateCacheClusterInput{ 179 AZMode: aws.String("cross-az"), 180 CacheClusterId: aws.String("my-memcached-cluster"), 181 CacheNodeType: aws.String("cache.r3.large"), 182 CacheSubnetGroupName: aws.String("default"), 183 Engine: aws.String("memcached"), 184 EngineVersion: aws.String("1.4.24"), 185 NumCacheNodes: aws.Int64(2), 186 Port: aws.Int64(11211), 187 } 188 189 result, err := svc.CreateCacheCluster(input) 190 if err != nil { 191 if aerr, ok := err.(awserr.Error); ok { 192 switch aerr.Code() { 193 case elasticache.ErrCodeReplicationGroupNotFoundFault: 194 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 195 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 196 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 197 case elasticache.ErrCodeCacheClusterAlreadyExistsFault: 198 fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error()) 199 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 200 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 201 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 202 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 203 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 204 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 205 case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: 206 fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) 207 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 208 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 209 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 210 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 211 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 212 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 213 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 214 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 215 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 216 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 217 case elasticache.ErrCodeInvalidParameterValueException: 218 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 219 case elasticache.ErrCodeInvalidParameterCombinationException: 220 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 221 default: 222 fmt.Println(aerr.Error()) 223 } 224 } else { 225 // Print the error, cast err to awserr.Error to get the Code and 226 // Message from an error. 227 fmt.Println(err.Error()) 228 } 229 return 230 } 231 232 fmt.Println(result) 233 } 234 235 // CreateCacheCluster 236 // 237 // Creates a Redis cluster with 1 node. 238 func ExampleElastiCache_CreateCacheCluster_shared01() { 239 svc := elasticache.New(session.New()) 240 input := &elasticache.CreateCacheClusterInput{ 241 AutoMinorVersionUpgrade: aws.Bool(true), 242 CacheClusterId: aws.String("my-redis"), 243 CacheNodeType: aws.String("cache.r3.larage"), 244 CacheSubnetGroupName: aws.String("default"), 245 Engine: aws.String("redis"), 246 EngineVersion: aws.String("3.2.4"), 247 NumCacheNodes: aws.Int64(1), 248 Port: aws.Int64(6379), 249 PreferredAvailabilityZone: aws.String("us-east-1c"), 250 SnapshotRetentionLimit: aws.Int64(7), 251 } 252 253 result, err := svc.CreateCacheCluster(input) 254 if err != nil { 255 if aerr, ok := err.(awserr.Error); ok { 256 switch aerr.Code() { 257 case elasticache.ErrCodeReplicationGroupNotFoundFault: 258 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 259 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 260 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 261 case elasticache.ErrCodeCacheClusterAlreadyExistsFault: 262 fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error()) 263 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 264 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 265 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 266 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 267 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 268 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 269 case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: 270 fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) 271 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 272 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 273 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 274 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 275 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 276 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 277 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 278 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 279 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 280 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 281 case elasticache.ErrCodeInvalidParameterValueException: 282 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 283 case elasticache.ErrCodeInvalidParameterCombinationException: 284 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 285 default: 286 fmt.Println(aerr.Error()) 287 } 288 } else { 289 // Print the error, cast err to awserr.Error to get the Code and 290 // Message from an error. 291 fmt.Println(err.Error()) 292 } 293 return 294 } 295 296 fmt.Println(result) 297 } 298 299 // CreateCacheParameterGroup 300 // 301 // Creates the Amazon ElastiCache parameter group custom-redis2-8. 302 func ExampleElastiCache_CreateCacheParameterGroup_shared00() { 303 svc := elasticache.New(session.New()) 304 input := &elasticache.CreateCacheParameterGroupInput{ 305 CacheParameterGroupFamily: aws.String("redis2.8"), 306 CacheParameterGroupName: aws.String("custom-redis2-8"), 307 Description: aws.String("Custom Redis 2.8 parameter group."), 308 } 309 310 result, err := svc.CreateCacheParameterGroup(input) 311 if err != nil { 312 if aerr, ok := err.(awserr.Error); ok { 313 switch aerr.Code() { 314 case elasticache.ErrCodeCacheParameterGroupQuotaExceededFault: 315 fmt.Println(elasticache.ErrCodeCacheParameterGroupQuotaExceededFault, aerr.Error()) 316 case elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault: 317 fmt.Println(elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault, aerr.Error()) 318 case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: 319 fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) 320 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 321 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 322 case elasticache.ErrCodeInvalidParameterValueException: 323 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 324 case elasticache.ErrCodeInvalidParameterCombinationException: 325 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 326 default: 327 fmt.Println(aerr.Error()) 328 } 329 } else { 330 // Print the error, cast err to awserr.Error to get the Code and 331 // Message from an error. 332 fmt.Println(err.Error()) 333 } 334 return 335 } 336 337 fmt.Println(result) 338 } 339 340 // CreateCacheSecurityGroup 341 // 342 // Creates an ElastiCache security group. ElastiCache security groups are only for clusters 343 // not running in an AWS VPC. 344 func ExampleElastiCache_CreateCacheSecurityGroup_shared00() { 345 svc := elasticache.New(session.New()) 346 input := &elasticache.CreateCacheSecurityGroupInput{ 347 CacheSecurityGroupName: aws.String("my-cache-sec-grp"), 348 Description: aws.String("Example ElastiCache security group."), 349 } 350 351 result, err := svc.CreateCacheSecurityGroup(input) 352 if err != nil { 353 if aerr, ok := err.(awserr.Error); ok { 354 switch aerr.Code() { 355 case elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault: 356 fmt.Println(elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault, aerr.Error()) 357 case elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault: 358 fmt.Println(elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault, aerr.Error()) 359 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 360 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 361 case elasticache.ErrCodeInvalidParameterValueException: 362 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 363 case elasticache.ErrCodeInvalidParameterCombinationException: 364 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 365 default: 366 fmt.Println(aerr.Error()) 367 } 368 } else { 369 // Print the error, cast err to awserr.Error to get the Code and 370 // Message from an error. 371 fmt.Println(err.Error()) 372 } 373 return 374 } 375 376 fmt.Println(result) 377 } 378 379 // CreateCacheSubnet 380 // 381 // Creates a new cache subnet group. 382 func ExampleElastiCache_CreateCacheSubnetGroup_shared00() { 383 svc := elasticache.New(session.New()) 384 input := &elasticache.CreateCacheSubnetGroupInput{ 385 CacheSubnetGroupDescription: aws.String("Sample subnet group"), 386 CacheSubnetGroupName: aws.String("my-sn-grp2"), 387 SubnetIds: []*string{ 388 aws.String("subnet-6f28c982"), 389 aws.String("subnet-bcd382f3"), 390 aws.String("subnet-845b3e7c0"), 391 }, 392 } 393 394 result, err := svc.CreateCacheSubnetGroup(input) 395 if err != nil { 396 if aerr, ok := err.(awserr.Error); ok { 397 switch aerr.Code() { 398 case elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault: 399 fmt.Println(elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault, aerr.Error()) 400 case elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault: 401 fmt.Println(elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault, aerr.Error()) 402 case elasticache.ErrCodeCacheSubnetQuotaExceededFault: 403 fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error()) 404 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 405 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 406 case elasticache.ErrCodeInvalidSubnet: 407 fmt.Println(elasticache.ErrCodeInvalidSubnet, aerr.Error()) 408 case elasticache.ErrCodeSubnetNotAllowedFault: 409 fmt.Println(elasticache.ErrCodeSubnetNotAllowedFault, aerr.Error()) 410 default: 411 fmt.Println(aerr.Error()) 412 } 413 } else { 414 // Print the error, cast err to awserr.Error to get the Code and 415 // Message from an error. 416 fmt.Println(err.Error()) 417 } 418 return 419 } 420 421 fmt.Println(result) 422 } 423 424 // CreateCacheReplicationGroup 425 // 426 // Creates a Redis replication group with 3 nodes. 427 func ExampleElastiCache_CreateReplicationGroup_shared00() { 428 svc := elasticache.New(session.New()) 429 input := &elasticache.CreateReplicationGroupInput{ 430 AutomaticFailoverEnabled: aws.Bool(true), 431 CacheNodeType: aws.String("cache.m3.medium"), 432 Engine: aws.String("redis"), 433 EngineVersion: aws.String("2.8.24"), 434 NumCacheClusters: aws.Int64(3), 435 ReplicationGroupDescription: aws.String("A Redis replication group."), 436 ReplicationGroupId: aws.String("my-redis-rg"), 437 SnapshotRetentionLimit: aws.Int64(30), 438 } 439 440 result, err := svc.CreateReplicationGroup(input) 441 if err != nil { 442 if aerr, ok := err.(awserr.Error); ok { 443 switch aerr.Code() { 444 case elasticache.ErrCodeCacheClusterNotFoundFault: 445 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 446 case elasticache.ErrCodeInvalidCacheClusterStateFault: 447 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 448 case elasticache.ErrCodeReplicationGroupAlreadyExistsFault: 449 fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error()) 450 case elasticache.ErrCodeInvalidUserGroupStateFault: 451 fmt.Println(elasticache.ErrCodeInvalidUserGroupStateFault, aerr.Error()) 452 case elasticache.ErrCodeUserGroupNotFoundFault: 453 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 454 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 455 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 456 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 457 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 458 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 459 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 460 case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: 461 fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) 462 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 463 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 464 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 465 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 466 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 467 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 468 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 469 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 470 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 471 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 472 case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault: 473 fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error()) 474 case elasticache.ErrCodeGlobalReplicationGroupNotFoundFault: 475 fmt.Println(elasticache.ErrCodeGlobalReplicationGroupNotFoundFault, aerr.Error()) 476 case elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault: 477 fmt.Println(elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault, aerr.Error()) 478 case elasticache.ErrCodeInvalidParameterValueException: 479 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 480 case elasticache.ErrCodeInvalidParameterCombinationException: 481 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 482 default: 483 fmt.Println(aerr.Error()) 484 } 485 } else { 486 // Print the error, cast err to awserr.Error to get the Code and 487 // Message from an error. 488 fmt.Println(err.Error()) 489 } 490 return 491 } 492 493 fmt.Println(result) 494 } 495 496 // CreateReplicationGroup 497 // 498 // Creates a Redis (cluster mode enabled) replication group with two shards. One shard 499 // has one read replica node and the other shard has two read replicas. 500 func ExampleElastiCache_CreateReplicationGroup_shared01() { 501 svc := elasticache.New(session.New()) 502 input := &elasticache.CreateReplicationGroupInput{ 503 AutoMinorVersionUpgrade: aws.Bool(true), 504 CacheNodeType: aws.String("cache.m3.medium"), 505 CacheParameterGroupName: aws.String("default.redis3.2.cluster.on"), 506 Engine: aws.String("redis"), 507 EngineVersion: aws.String("3.2.4"), 508 NodeGroupConfiguration: []*elasticache.NodeGroupConfiguration{ 509 { 510 PrimaryAvailabilityZone: aws.String("us-east-1c"), 511 ReplicaAvailabilityZones: []*string{ 512 aws.String("us-east-1b"), 513 }, 514 ReplicaCount: aws.Int64(1), 515 Slots: aws.String("0-8999"), 516 }, 517 { 518 PrimaryAvailabilityZone: aws.String("us-east-1a"), 519 ReplicaAvailabilityZones: []*string{ 520 aws.String("us-east-1a"), 521 aws.String("us-east-1c"), 522 }, 523 ReplicaCount: aws.Int64(2), 524 Slots: aws.String("9000-16383"), 525 }, 526 }, 527 NumNodeGroups: aws.Int64(2), 528 ReplicationGroupDescription: aws.String("A multi-sharded replication group"), 529 ReplicationGroupId: aws.String("clustered-redis-rg"), 530 SnapshotRetentionLimit: aws.Int64(8), 531 } 532 533 result, err := svc.CreateReplicationGroup(input) 534 if err != nil { 535 if aerr, ok := err.(awserr.Error); ok { 536 switch aerr.Code() { 537 case elasticache.ErrCodeCacheClusterNotFoundFault: 538 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 539 case elasticache.ErrCodeInvalidCacheClusterStateFault: 540 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 541 case elasticache.ErrCodeReplicationGroupAlreadyExistsFault: 542 fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error()) 543 case elasticache.ErrCodeInvalidUserGroupStateFault: 544 fmt.Println(elasticache.ErrCodeInvalidUserGroupStateFault, aerr.Error()) 545 case elasticache.ErrCodeUserGroupNotFoundFault: 546 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 547 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 548 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 549 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 550 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 551 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 552 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 553 case elasticache.ErrCodeClusterQuotaForCustomerExceededFault: 554 fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error()) 555 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 556 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 557 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 558 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 559 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 560 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 561 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 562 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 563 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 564 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 565 case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault: 566 fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error()) 567 case elasticache.ErrCodeGlobalReplicationGroupNotFoundFault: 568 fmt.Println(elasticache.ErrCodeGlobalReplicationGroupNotFoundFault, aerr.Error()) 569 case elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault: 570 fmt.Println(elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault, aerr.Error()) 571 case elasticache.ErrCodeInvalidParameterValueException: 572 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 573 case elasticache.ErrCodeInvalidParameterCombinationException: 574 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 575 default: 576 fmt.Println(aerr.Error()) 577 } 578 } else { 579 // Print the error, cast err to awserr.Error to get the Code and 580 // Message from an error. 581 fmt.Println(err.Error()) 582 } 583 return 584 } 585 586 fmt.Println(result) 587 } 588 589 // CreateSnapshot - NonClustered Redis, no read-replicas 590 // 591 // Creates a snapshot of a non-clustered Redis cluster that has only one node. 592 func ExampleElastiCache_CreateSnapshot_shared00() { 593 svc := elasticache.New(session.New()) 594 input := &elasticache.CreateSnapshotInput{ 595 CacheClusterId: aws.String("onenoderedis"), 596 SnapshotName: aws.String("snapshot-1"), 597 } 598 599 result, err := svc.CreateSnapshot(input) 600 if err != nil { 601 if aerr, ok := err.(awserr.Error); ok { 602 switch aerr.Code() { 603 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 604 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 605 case elasticache.ErrCodeCacheClusterNotFoundFault: 606 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 607 case elasticache.ErrCodeReplicationGroupNotFoundFault: 608 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 609 case elasticache.ErrCodeInvalidCacheClusterStateFault: 610 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 611 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 612 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 613 case elasticache.ErrCodeSnapshotQuotaExceededFault: 614 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 615 case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: 616 fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) 617 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 618 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 619 case elasticache.ErrCodeInvalidParameterCombinationException: 620 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 621 case elasticache.ErrCodeInvalidParameterValueException: 622 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 623 default: 624 fmt.Println(aerr.Error()) 625 } 626 } else { 627 // Print the error, cast err to awserr.Error to get the Code and 628 // Message from an error. 629 fmt.Println(err.Error()) 630 } 631 return 632 } 633 634 fmt.Println(result) 635 } 636 637 // CreateSnapshot - NonClustered Redis, 2 read-replicas 638 // 639 // Creates a snapshot of a non-clustered Redis cluster that has only three nodes, primary 640 // and two read-replicas. CacheClusterId must be a specific node in the cluster. 641 func ExampleElastiCache_CreateSnapshot_shared01() { 642 svc := elasticache.New(session.New()) 643 input := &elasticache.CreateSnapshotInput{ 644 CacheClusterId: aws.String("threenoderedis-001"), 645 SnapshotName: aws.String("snapshot-2"), 646 } 647 648 result, err := svc.CreateSnapshot(input) 649 if err != nil { 650 if aerr, ok := err.(awserr.Error); ok { 651 switch aerr.Code() { 652 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 653 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 654 case elasticache.ErrCodeCacheClusterNotFoundFault: 655 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 656 case elasticache.ErrCodeReplicationGroupNotFoundFault: 657 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 658 case elasticache.ErrCodeInvalidCacheClusterStateFault: 659 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 660 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 661 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 662 case elasticache.ErrCodeSnapshotQuotaExceededFault: 663 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 664 case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: 665 fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) 666 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 667 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 668 case elasticache.ErrCodeInvalidParameterCombinationException: 669 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 670 case elasticache.ErrCodeInvalidParameterValueException: 671 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 672 default: 673 fmt.Println(aerr.Error()) 674 } 675 } else { 676 // Print the error, cast err to awserr.Error to get the Code and 677 // Message from an error. 678 fmt.Println(err.Error()) 679 } 680 return 681 } 682 683 fmt.Println(result) 684 } 685 686 // CreateSnapshot-clustered Redis 687 // 688 // Creates a snapshot of a clustered Redis cluster that has 2 shards, each with a primary 689 // and 4 read-replicas. 690 func ExampleElastiCache_CreateSnapshot_shared02() { 691 svc := elasticache.New(session.New()) 692 input := &elasticache.CreateSnapshotInput{ 693 ReplicationGroupId: aws.String("clusteredredis"), 694 SnapshotName: aws.String("snapshot-2x5"), 695 } 696 697 result, err := svc.CreateSnapshot(input) 698 if err != nil { 699 if aerr, ok := err.(awserr.Error); ok { 700 switch aerr.Code() { 701 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 702 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 703 case elasticache.ErrCodeCacheClusterNotFoundFault: 704 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 705 case elasticache.ErrCodeReplicationGroupNotFoundFault: 706 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 707 case elasticache.ErrCodeInvalidCacheClusterStateFault: 708 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 709 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 710 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 711 case elasticache.ErrCodeSnapshotQuotaExceededFault: 712 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 713 case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: 714 fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) 715 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 716 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 717 case elasticache.ErrCodeInvalidParameterCombinationException: 718 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 719 case elasticache.ErrCodeInvalidParameterValueException: 720 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 721 default: 722 fmt.Println(aerr.Error()) 723 } 724 } else { 725 // Print the error, cast err to awserr.Error to get the Code and 726 // Message from an error. 727 fmt.Println(err.Error()) 728 } 729 return 730 } 731 732 fmt.Println(result) 733 } 734 735 // DeleteCacheCluster 736 // 737 // Deletes an Amazon ElastiCache cluster. 738 func ExampleElastiCache_DeleteCacheCluster_shared00() { 739 svc := elasticache.New(session.New()) 740 input := &elasticache.DeleteCacheClusterInput{ 741 CacheClusterId: aws.String("my-memcached"), 742 } 743 744 result, err := svc.DeleteCacheCluster(input) 745 if err != nil { 746 if aerr, ok := err.(awserr.Error); ok { 747 switch aerr.Code() { 748 case elasticache.ErrCodeCacheClusterNotFoundFault: 749 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 750 case elasticache.ErrCodeInvalidCacheClusterStateFault: 751 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 752 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 753 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 754 case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: 755 fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) 756 case elasticache.ErrCodeSnapshotQuotaExceededFault: 757 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 758 case elasticache.ErrCodeInvalidParameterValueException: 759 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 760 case elasticache.ErrCodeInvalidParameterCombinationException: 761 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 762 default: 763 fmt.Println(aerr.Error()) 764 } 765 } else { 766 // Print the error, cast err to awserr.Error to get the Code and 767 // Message from an error. 768 fmt.Println(err.Error()) 769 } 770 return 771 } 772 773 fmt.Println(result) 774 } 775 776 // DeleteCacheParameterGroup 777 // 778 // Deletes the Amazon ElastiCache parameter group custom-mem1-4. 779 func ExampleElastiCache_DeleteCacheParameterGroup_shared00() { 780 svc := elasticache.New(session.New()) 781 input := &elasticache.DeleteCacheParameterGroupInput{ 782 CacheParameterGroupName: aws.String("custom-mem1-4"), 783 } 784 785 result, err := svc.DeleteCacheParameterGroup(input) 786 if err != nil { 787 if aerr, ok := err.(awserr.Error); ok { 788 switch aerr.Code() { 789 case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: 790 fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) 791 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 792 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 793 case elasticache.ErrCodeInvalidParameterValueException: 794 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 795 case elasticache.ErrCodeInvalidParameterCombinationException: 796 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 797 default: 798 fmt.Println(aerr.Error()) 799 } 800 } else { 801 // Print the error, cast err to awserr.Error to get the Code and 802 // Message from an error. 803 fmt.Println(err.Error()) 804 } 805 return 806 } 807 808 fmt.Println(result) 809 } 810 811 // DeleteCacheSecurityGroup 812 // 813 // Deletes a cache security group. 814 func ExampleElastiCache_DeleteCacheSecurityGroup_shared00() { 815 svc := elasticache.New(session.New()) 816 input := &elasticache.DeleteCacheSecurityGroupInput{ 817 CacheSecurityGroupName: aws.String("my-sec-group"), 818 } 819 820 result, err := svc.DeleteCacheSecurityGroup(input) 821 if err != nil { 822 if aerr, ok := err.(awserr.Error); ok { 823 switch aerr.Code() { 824 case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: 825 fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) 826 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 827 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 828 case elasticache.ErrCodeInvalidParameterValueException: 829 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 830 case elasticache.ErrCodeInvalidParameterCombinationException: 831 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 832 default: 833 fmt.Println(aerr.Error()) 834 } 835 } else { 836 // Print the error, cast err to awserr.Error to get the Code and 837 // Message from an error. 838 fmt.Println(err.Error()) 839 } 840 return 841 } 842 843 fmt.Println(result) 844 } 845 846 // DeleteCacheSubnetGroup 847 // 848 // Deletes the Amazon ElastiCache subnet group my-subnet-group. 849 func ExampleElastiCache_DeleteCacheSubnetGroup_shared00() { 850 svc := elasticache.New(session.New()) 851 input := &elasticache.DeleteCacheSubnetGroupInput{ 852 CacheSubnetGroupName: aws.String("my-subnet-group"), 853 } 854 855 result, err := svc.DeleteCacheSubnetGroup(input) 856 if err != nil { 857 if aerr, ok := err.(awserr.Error); ok { 858 switch aerr.Code() { 859 case elasticache.ErrCodeCacheSubnetGroupInUse: 860 fmt.Println(elasticache.ErrCodeCacheSubnetGroupInUse, aerr.Error()) 861 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 862 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 863 default: 864 fmt.Println(aerr.Error()) 865 } 866 } else { 867 // Print the error, cast err to awserr.Error to get the Code and 868 // Message from an error. 869 fmt.Println(err.Error()) 870 } 871 return 872 } 873 874 fmt.Println(result) 875 } 876 877 // DeleteReplicationGroup 878 // 879 // Deletes the Amazon ElastiCache replication group my-redis-rg. 880 func ExampleElastiCache_DeleteReplicationGroup_shared00() { 881 svc := elasticache.New(session.New()) 882 input := &elasticache.DeleteReplicationGroupInput{ 883 ReplicationGroupId: aws.String("my-redis-rg"), 884 RetainPrimaryCluster: aws.Bool(false), 885 } 886 887 result, err := svc.DeleteReplicationGroup(input) 888 if err != nil { 889 if aerr, ok := err.(awserr.Error); ok { 890 switch aerr.Code() { 891 case elasticache.ErrCodeReplicationGroupNotFoundFault: 892 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 893 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 894 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 895 case elasticache.ErrCodeSnapshotAlreadyExistsFault: 896 fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error()) 897 case elasticache.ErrCodeSnapshotFeatureNotSupportedFault: 898 fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error()) 899 case elasticache.ErrCodeSnapshotQuotaExceededFault: 900 fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error()) 901 case elasticache.ErrCodeInvalidParameterValueException: 902 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 903 case elasticache.ErrCodeInvalidParameterCombinationException: 904 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 905 default: 906 fmt.Println(aerr.Error()) 907 } 908 } else { 909 // Print the error, cast err to awserr.Error to get the Code and 910 // Message from an error. 911 fmt.Println(err.Error()) 912 } 913 return 914 } 915 916 fmt.Println(result) 917 } 918 919 // DeleteSnapshot 920 // 921 // Deletes the Redis snapshot snapshot-20160822. 922 func ExampleElastiCache_DeleteSnapshot_shared00() { 923 svc := elasticache.New(session.New()) 924 input := &elasticache.DeleteSnapshotInput{ 925 SnapshotName: aws.String("snapshot-20161212"), 926 } 927 928 result, err := svc.DeleteSnapshot(input) 929 if err != nil { 930 if aerr, ok := err.(awserr.Error); ok { 931 switch aerr.Code() { 932 case elasticache.ErrCodeSnapshotNotFoundFault: 933 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 934 case elasticache.ErrCodeInvalidSnapshotStateFault: 935 fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error()) 936 case elasticache.ErrCodeInvalidParameterValueException: 937 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 938 case elasticache.ErrCodeInvalidParameterCombinationException: 939 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 940 default: 941 fmt.Println(aerr.Error()) 942 } 943 } else { 944 // Print the error, cast err to awserr.Error to get the Code and 945 // Message from an error. 946 fmt.Println(err.Error()) 947 } 948 return 949 } 950 951 fmt.Println(result) 952 } 953 954 // DescribeCacheClusters 955 // 956 // Lists the details for up to 50 cache clusters. 957 func ExampleElastiCache_DescribeCacheClusters_shared00() { 958 svc := elasticache.New(session.New()) 959 input := &elasticache.DescribeCacheClustersInput{ 960 CacheClusterId: aws.String("my-mem-cluster"), 961 } 962 963 result, err := svc.DescribeCacheClusters(input) 964 if err != nil { 965 if aerr, ok := err.(awserr.Error); ok { 966 switch aerr.Code() { 967 case elasticache.ErrCodeCacheClusterNotFoundFault: 968 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 969 case elasticache.ErrCodeInvalidParameterValueException: 970 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 971 case elasticache.ErrCodeInvalidParameterCombinationException: 972 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 973 default: 974 fmt.Println(aerr.Error()) 975 } 976 } else { 977 // Print the error, cast err to awserr.Error to get the Code and 978 // Message from an error. 979 fmt.Println(err.Error()) 980 } 981 return 982 } 983 984 fmt.Println(result) 985 } 986 987 // DescribeCacheClusters 988 // 989 // Lists the details for the cache cluster my-mem-cluster. 990 func ExampleElastiCache_DescribeCacheClusters_shared01() { 991 svc := elasticache.New(session.New()) 992 input := &elasticache.DescribeCacheClustersInput{ 993 CacheClusterId: aws.String("my-mem-cluster"), 994 ShowCacheNodeInfo: aws.Bool(true), 995 } 996 997 result, err := svc.DescribeCacheClusters(input) 998 if err != nil { 999 if aerr, ok := err.(awserr.Error); ok { 1000 switch aerr.Code() { 1001 case elasticache.ErrCodeCacheClusterNotFoundFault: 1002 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1003 case elasticache.ErrCodeInvalidParameterValueException: 1004 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1005 case elasticache.ErrCodeInvalidParameterCombinationException: 1006 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1007 default: 1008 fmt.Println(aerr.Error()) 1009 } 1010 } else { 1011 // Print the error, cast err to awserr.Error to get the Code and 1012 // Message from an error. 1013 fmt.Println(err.Error()) 1014 } 1015 return 1016 } 1017 1018 fmt.Println(result) 1019 } 1020 1021 // DescribeCacheEngineVersions 1022 // 1023 // Lists the details for up to 25 Memcached and Redis cache engine versions. 1024 func ExampleElastiCache_DescribeCacheEngineVersions_shared00() { 1025 svc := elasticache.New(session.New()) 1026 input := &elasticache.DescribeCacheEngineVersionsInput{} 1027 1028 result, err := svc.DescribeCacheEngineVersions(input) 1029 if err != nil { 1030 if aerr, ok := err.(awserr.Error); ok { 1031 switch aerr.Code() { 1032 default: 1033 fmt.Println(aerr.Error()) 1034 } 1035 } else { 1036 // Print the error, cast err to awserr.Error to get the Code and 1037 // Message from an error. 1038 fmt.Println(err.Error()) 1039 } 1040 return 1041 } 1042 1043 fmt.Println(result) 1044 } 1045 1046 // DescribeCacheEngineVersions 1047 // 1048 // Lists the details for up to 50 Redis cache engine versions. 1049 func ExampleElastiCache_DescribeCacheEngineVersions_shared01() { 1050 svc := elasticache.New(session.New()) 1051 input := &elasticache.DescribeCacheEngineVersionsInput{ 1052 DefaultOnly: aws.Bool(false), 1053 Engine: aws.String("redis"), 1054 MaxRecords: aws.Int64(50), 1055 } 1056 1057 result, err := svc.DescribeCacheEngineVersions(input) 1058 if err != nil { 1059 if aerr, ok := err.(awserr.Error); ok { 1060 switch aerr.Code() { 1061 default: 1062 fmt.Println(aerr.Error()) 1063 } 1064 } else { 1065 // Print the error, cast err to awserr.Error to get the Code and 1066 // Message from an error. 1067 fmt.Println(err.Error()) 1068 } 1069 return 1070 } 1071 1072 fmt.Println(result) 1073 } 1074 1075 // DescribeCacheParameterGroups 1076 // 1077 // Returns a list of cache parameter group descriptions. If a cache parameter group 1078 // name is specified, the list contains only the descriptions for that group. 1079 func ExampleElastiCache_DescribeCacheParameterGroups_shared00() { 1080 svc := elasticache.New(session.New()) 1081 input := &elasticache.DescribeCacheParameterGroupsInput{ 1082 CacheParameterGroupName: aws.String("custom-mem1-4"), 1083 } 1084 1085 result, err := svc.DescribeCacheParameterGroups(input) 1086 if err != nil { 1087 if aerr, ok := err.(awserr.Error); ok { 1088 switch aerr.Code() { 1089 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1090 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1091 case elasticache.ErrCodeInvalidParameterValueException: 1092 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1093 case elasticache.ErrCodeInvalidParameterCombinationException: 1094 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1095 default: 1096 fmt.Println(aerr.Error()) 1097 } 1098 } else { 1099 // Print the error, cast err to awserr.Error to get the Code and 1100 // Message from an error. 1101 fmt.Println(err.Error()) 1102 } 1103 return 1104 } 1105 1106 fmt.Println(result) 1107 } 1108 1109 // DescribeCacheParameters 1110 // 1111 // Lists up to 100 user parameter values for the parameter group custom.redis2.8. 1112 func ExampleElastiCache_DescribeCacheParameters_shared00() { 1113 svc := elasticache.New(session.New()) 1114 input := &elasticache.DescribeCacheParametersInput{ 1115 CacheParameterGroupName: aws.String("custom-redis2-8"), 1116 MaxRecords: aws.Int64(100), 1117 Source: aws.String("user"), 1118 } 1119 1120 result, err := svc.DescribeCacheParameters(input) 1121 if err != nil { 1122 if aerr, ok := err.(awserr.Error); ok { 1123 switch aerr.Code() { 1124 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1125 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1126 case elasticache.ErrCodeInvalidParameterValueException: 1127 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1128 case elasticache.ErrCodeInvalidParameterCombinationException: 1129 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1130 default: 1131 fmt.Println(aerr.Error()) 1132 } 1133 } else { 1134 // Print the error, cast err to awserr.Error to get the Code and 1135 // Message from an error. 1136 fmt.Println(err.Error()) 1137 } 1138 return 1139 } 1140 1141 fmt.Println(result) 1142 } 1143 1144 // DescribeCacheSecurityGroups 1145 // 1146 // Returns a list of cache security group descriptions. If a cache security group name 1147 // is specified, the list contains only the description of that group. 1148 func ExampleElastiCache_DescribeCacheSecurityGroups_shared00() { 1149 svc := elasticache.New(session.New()) 1150 input := &elasticache.DescribeCacheSecurityGroupsInput{ 1151 CacheSecurityGroupName: aws.String("my-sec-group"), 1152 } 1153 1154 result, err := svc.DescribeCacheSecurityGroups(input) 1155 if err != nil { 1156 if aerr, ok := err.(awserr.Error); ok { 1157 switch aerr.Code() { 1158 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 1159 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 1160 case elasticache.ErrCodeInvalidParameterValueException: 1161 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1162 case elasticache.ErrCodeInvalidParameterCombinationException: 1163 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1164 default: 1165 fmt.Println(aerr.Error()) 1166 } 1167 } else { 1168 // Print the error, cast err to awserr.Error to get the Code and 1169 // Message from an error. 1170 fmt.Println(err.Error()) 1171 } 1172 return 1173 } 1174 1175 fmt.Println(result) 1176 } 1177 1178 // DescribeCacheSubnetGroups 1179 // 1180 // Describes up to 25 cache subnet groups. 1181 func ExampleElastiCache_DescribeCacheSubnetGroups_shared00() { 1182 svc := elasticache.New(session.New()) 1183 input := &elasticache.DescribeCacheSubnetGroupsInput{ 1184 MaxRecords: aws.Int64(25), 1185 } 1186 1187 result, err := svc.DescribeCacheSubnetGroups(input) 1188 if err != nil { 1189 if aerr, ok := err.(awserr.Error); ok { 1190 switch aerr.Code() { 1191 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 1192 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 1193 default: 1194 fmt.Println(aerr.Error()) 1195 } 1196 } else { 1197 // Print the error, cast err to awserr.Error to get the Code and 1198 // Message from an error. 1199 fmt.Println(err.Error()) 1200 } 1201 return 1202 } 1203 1204 fmt.Println(result) 1205 } 1206 1207 // DescribeEngineDefaultParameters 1208 // 1209 // Returns the default engine and system parameter information for the specified cache 1210 // engine. 1211 func ExampleElastiCache_DescribeEngineDefaultParameters_shared00() { 1212 svc := elasticache.New(session.New()) 1213 input := &elasticache.DescribeEngineDefaultParametersInput{ 1214 CacheParameterGroupFamily: aws.String("redis2.8"), 1215 MaxRecords: aws.Int64(25), 1216 } 1217 1218 result, err := svc.DescribeEngineDefaultParameters(input) 1219 if err != nil { 1220 if aerr, ok := err.(awserr.Error); ok { 1221 switch aerr.Code() { 1222 case elasticache.ErrCodeInvalidParameterValueException: 1223 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1224 case elasticache.ErrCodeInvalidParameterCombinationException: 1225 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1226 default: 1227 fmt.Println(aerr.Error()) 1228 } 1229 } else { 1230 // Print the error, cast err to awserr.Error to get the Code and 1231 // Message from an error. 1232 fmt.Println(err.Error()) 1233 } 1234 return 1235 } 1236 1237 fmt.Println(result) 1238 } 1239 1240 // DescribeEvents 1241 // 1242 // Describes all the cache-cluster events for the past 120 minutes. 1243 func ExampleElastiCache_DescribeEvents_shared00() { 1244 svc := elasticache.New(session.New()) 1245 input := &elasticache.DescribeEventsInput{ 1246 Duration: aws.Int64(360), 1247 SourceType: aws.String("cache-cluster"), 1248 } 1249 1250 result, err := svc.DescribeEvents(input) 1251 if err != nil { 1252 if aerr, ok := err.(awserr.Error); ok { 1253 switch aerr.Code() { 1254 case elasticache.ErrCodeInvalidParameterValueException: 1255 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1256 case elasticache.ErrCodeInvalidParameterCombinationException: 1257 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1258 default: 1259 fmt.Println(aerr.Error()) 1260 } 1261 } else { 1262 // Print the error, cast err to awserr.Error to get the Code and 1263 // Message from an error. 1264 fmt.Println(err.Error()) 1265 } 1266 return 1267 } 1268 1269 fmt.Println(result) 1270 } 1271 1272 // DescribeEvents 1273 // 1274 // Describes all the replication-group events from 3:00P to 5:00P on November 11, 2016. 1275 func ExampleElastiCache_DescribeEvents_shared01() { 1276 svc := elasticache.New(session.New()) 1277 input := &elasticache.DescribeEventsInput{ 1278 StartTime: parseTime("2006-01-02T15:04:05.999999999Z", "2016-12-22T15:00:00.000Z"), 1279 } 1280 1281 result, err := svc.DescribeEvents(input) 1282 if err != nil { 1283 if aerr, ok := err.(awserr.Error); ok { 1284 switch aerr.Code() { 1285 case elasticache.ErrCodeInvalidParameterValueException: 1286 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1287 case elasticache.ErrCodeInvalidParameterCombinationException: 1288 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1289 default: 1290 fmt.Println(aerr.Error()) 1291 } 1292 } else { 1293 // Print the error, cast err to awserr.Error to get the Code and 1294 // Message from an error. 1295 fmt.Println(err.Error()) 1296 } 1297 return 1298 } 1299 1300 fmt.Println(result) 1301 } 1302 1303 // DescribeReplicationGroups 1304 // 1305 // Returns information about the replication group myreplgroup. 1306 func ExampleElastiCache_DescribeReplicationGroups_shared00() { 1307 svc := elasticache.New(session.New()) 1308 input := &elasticache.DescribeReplicationGroupsInput{} 1309 1310 result, err := svc.DescribeReplicationGroups(input) 1311 if err != nil { 1312 if aerr, ok := err.(awserr.Error); ok { 1313 switch aerr.Code() { 1314 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1315 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1316 case elasticache.ErrCodeInvalidParameterValueException: 1317 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1318 case elasticache.ErrCodeInvalidParameterCombinationException: 1319 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1320 default: 1321 fmt.Println(aerr.Error()) 1322 } 1323 } else { 1324 // Print the error, cast err to awserr.Error to get the Code and 1325 // Message from an error. 1326 fmt.Println(err.Error()) 1327 } 1328 return 1329 } 1330 1331 fmt.Println(result) 1332 } 1333 1334 // DescribeReservedCacheNodes 1335 // 1336 // Returns information about reserved cache nodes for this account, or about a specified 1337 // reserved cache node. If the account has no reserved cache nodes, the operation returns 1338 // an empty list, as shown here. 1339 func ExampleElastiCache_DescribeReservedCacheNodes_shared00() { 1340 svc := elasticache.New(session.New()) 1341 input := &elasticache.DescribeReservedCacheNodesInput{ 1342 MaxRecords: aws.Int64(25), 1343 } 1344 1345 result, err := svc.DescribeReservedCacheNodes(input) 1346 if err != nil { 1347 if aerr, ok := err.(awserr.Error); ok { 1348 switch aerr.Code() { 1349 case elasticache.ErrCodeReservedCacheNodeNotFoundFault: 1350 fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error()) 1351 case elasticache.ErrCodeInvalidParameterValueException: 1352 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1353 case elasticache.ErrCodeInvalidParameterCombinationException: 1354 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1355 default: 1356 fmt.Println(aerr.Error()) 1357 } 1358 } else { 1359 // Print the error, cast err to awserr.Error to get the Code and 1360 // Message from an error. 1361 fmt.Println(err.Error()) 1362 } 1363 return 1364 } 1365 1366 fmt.Println(result) 1367 } 1368 1369 // DescribeReseredCacheNodeOfferings 1370 // 1371 // Lists available reserved cache node offerings. 1372 func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared00() { 1373 svc := elasticache.New(session.New()) 1374 input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ 1375 MaxRecords: aws.Int64(20), 1376 } 1377 1378 result, err := svc.DescribeReservedCacheNodesOfferings(input) 1379 if err != nil { 1380 if aerr, ok := err.(awserr.Error); ok { 1381 switch aerr.Code() { 1382 case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: 1383 fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) 1384 case elasticache.ErrCodeInvalidParameterValueException: 1385 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1386 case elasticache.ErrCodeInvalidParameterCombinationException: 1387 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1388 default: 1389 fmt.Println(aerr.Error()) 1390 } 1391 } else { 1392 // Print the error, cast err to awserr.Error to get the Code and 1393 // Message from an error. 1394 fmt.Println(err.Error()) 1395 } 1396 return 1397 } 1398 1399 fmt.Println(result) 1400 } 1401 1402 // DescribeReseredCacheNodeOfferings 1403 // 1404 // Lists available reserved cache node offerings for cache.r3.large nodes with a 3 year 1405 // commitment. 1406 func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared01() { 1407 svc := elasticache.New(session.New()) 1408 input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ 1409 CacheNodeType: aws.String("cache.r3.large"), 1410 Duration: aws.String("3"), 1411 MaxRecords: aws.Int64(25), 1412 OfferingType: aws.String("Light Utilization"), 1413 ReservedCacheNodesOfferingId: aws.String(""), 1414 } 1415 1416 result, err := svc.DescribeReservedCacheNodesOfferings(input) 1417 if err != nil { 1418 if aerr, ok := err.(awserr.Error); ok { 1419 switch aerr.Code() { 1420 case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: 1421 fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) 1422 case elasticache.ErrCodeInvalidParameterValueException: 1423 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1424 case elasticache.ErrCodeInvalidParameterCombinationException: 1425 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1426 default: 1427 fmt.Println(aerr.Error()) 1428 } 1429 } else { 1430 // Print the error, cast err to awserr.Error to get the Code and 1431 // Message from an error. 1432 fmt.Println(err.Error()) 1433 } 1434 return 1435 } 1436 1437 fmt.Println(result) 1438 } 1439 1440 // DescribeReseredCacheNodeOfferings 1441 // 1442 // Lists available reserved cache node offerings. 1443 func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared02() { 1444 svc := elasticache.New(session.New()) 1445 input := &elasticache.DescribeReservedCacheNodesOfferingsInput{ 1446 CacheNodeType: aws.String(""), 1447 Duration: aws.String(""), 1448 Marker: aws.String(""), 1449 MaxRecords: aws.Int64(25), 1450 OfferingType: aws.String(""), 1451 ProductDescription: aws.String(""), 1452 ReservedCacheNodesOfferingId: aws.String("438012d3-4052-4cc7-b2e3-8d3372e0e706"), 1453 } 1454 1455 result, err := svc.DescribeReservedCacheNodesOfferings(input) 1456 if err != nil { 1457 if aerr, ok := err.(awserr.Error); ok { 1458 switch aerr.Code() { 1459 case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: 1460 fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) 1461 case elasticache.ErrCodeInvalidParameterValueException: 1462 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1463 case elasticache.ErrCodeInvalidParameterCombinationException: 1464 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1465 default: 1466 fmt.Println(aerr.Error()) 1467 } 1468 } else { 1469 // Print the error, cast err to awserr.Error to get the Code and 1470 // Message from an error. 1471 fmt.Println(err.Error()) 1472 } 1473 return 1474 } 1475 1476 fmt.Println(result) 1477 } 1478 1479 // DescribeSnapshots 1480 // 1481 // Returns information about the snapshot mysnapshot. By default. 1482 func ExampleElastiCache_DescribeSnapshots_shared00() { 1483 svc := elasticache.New(session.New()) 1484 input := &elasticache.DescribeSnapshotsInput{ 1485 SnapshotName: aws.String("snapshot-20161212"), 1486 } 1487 1488 result, err := svc.DescribeSnapshots(input) 1489 if err != nil { 1490 if aerr, ok := err.(awserr.Error); ok { 1491 switch aerr.Code() { 1492 case elasticache.ErrCodeCacheClusterNotFoundFault: 1493 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1494 case elasticache.ErrCodeSnapshotNotFoundFault: 1495 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 1496 case elasticache.ErrCodeInvalidParameterValueException: 1497 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1498 case elasticache.ErrCodeInvalidParameterCombinationException: 1499 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1500 default: 1501 fmt.Println(aerr.Error()) 1502 } 1503 } else { 1504 // Print the error, cast err to awserr.Error to get the Code and 1505 // Message from an error. 1506 fmt.Println(err.Error()) 1507 } 1508 return 1509 } 1510 1511 fmt.Println(result) 1512 } 1513 1514 // ListAllowedNodeTypeModifications 1515 // 1516 // Lists all available node types that you can scale your Redis cluster's or replication 1517 // group's current node type up to. 1518 func ExampleElastiCache_ListAllowedNodeTypeModifications_shared00() { 1519 svc := elasticache.New(session.New()) 1520 input := &elasticache.ListAllowedNodeTypeModificationsInput{ 1521 ReplicationGroupId: aws.String("myreplgroup"), 1522 } 1523 1524 result, err := svc.ListAllowedNodeTypeModifications(input) 1525 if err != nil { 1526 if aerr, ok := err.(awserr.Error); ok { 1527 switch aerr.Code() { 1528 case elasticache.ErrCodeCacheClusterNotFoundFault: 1529 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1530 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1531 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1532 case elasticache.ErrCodeInvalidParameterCombinationException: 1533 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1534 case elasticache.ErrCodeInvalidParameterValueException: 1535 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1536 default: 1537 fmt.Println(aerr.Error()) 1538 } 1539 } else { 1540 // Print the error, cast err to awserr.Error to get the Code and 1541 // Message from an error. 1542 fmt.Println(err.Error()) 1543 } 1544 return 1545 } 1546 1547 fmt.Println(result) 1548 } 1549 1550 // ListAllowedNodeTypeModifications 1551 // 1552 // Lists all available node types that you can scale your Redis cluster's or replication 1553 // group's current node type up to. 1554 func ExampleElastiCache_ListAllowedNodeTypeModifications_shared01() { 1555 svc := elasticache.New(session.New()) 1556 input := &elasticache.ListAllowedNodeTypeModificationsInput{ 1557 CacheClusterId: aws.String("mycluster"), 1558 } 1559 1560 result, err := svc.ListAllowedNodeTypeModifications(input) 1561 if err != nil { 1562 if aerr, ok := err.(awserr.Error); ok { 1563 switch aerr.Code() { 1564 case elasticache.ErrCodeCacheClusterNotFoundFault: 1565 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1566 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1567 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1568 case elasticache.ErrCodeInvalidParameterCombinationException: 1569 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1570 case elasticache.ErrCodeInvalidParameterValueException: 1571 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1572 default: 1573 fmt.Println(aerr.Error()) 1574 } 1575 } else { 1576 // Print the error, cast err to awserr.Error to get the Code and 1577 // Message from an error. 1578 fmt.Println(err.Error()) 1579 } 1580 return 1581 } 1582 1583 fmt.Println(result) 1584 } 1585 1586 // ListTagsForResource 1587 // 1588 // Lists all cost allocation tags currently on the named resource. A cost allocation 1589 // tag is a key-value pair where the key is case-sensitive and the value is optional. 1590 // You can use cost allocation tags to categorize and track your AWS costs. 1591 func ExampleElastiCache_ListTagsForResource_shared00() { 1592 svc := elasticache.New(session.New()) 1593 input := &elasticache.ListTagsForResourceInput{ 1594 ResourceName: aws.String("arn:aws:elasticache:us-west-2:<my-account-id>:cluster:mycluster"), 1595 } 1596 1597 result, err := svc.ListTagsForResource(input) 1598 if err != nil { 1599 if aerr, ok := err.(awserr.Error); ok { 1600 switch aerr.Code() { 1601 case elasticache.ErrCodeCacheClusterNotFoundFault: 1602 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1603 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1604 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1605 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 1606 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 1607 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 1608 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 1609 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 1610 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 1611 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1612 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1613 case elasticache.ErrCodeReservedCacheNodeNotFoundFault: 1614 fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error()) 1615 case elasticache.ErrCodeSnapshotNotFoundFault: 1616 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 1617 case elasticache.ErrCodeUserNotFoundFault: 1618 fmt.Println(elasticache.ErrCodeUserNotFoundFault, aerr.Error()) 1619 case elasticache.ErrCodeUserGroupNotFoundFault: 1620 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 1621 case elasticache.ErrCodeInvalidARNFault: 1622 fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error()) 1623 default: 1624 fmt.Println(aerr.Error()) 1625 } 1626 } else { 1627 // Print the error, cast err to awserr.Error to get the Code and 1628 // Message from an error. 1629 fmt.Println(err.Error()) 1630 } 1631 return 1632 } 1633 1634 fmt.Println(result) 1635 } 1636 1637 // ModifyCacheCluster 1638 // 1639 // Copies a snapshot to a specified name. 1640 func ExampleElastiCache_ModifyCacheCluster_shared00() { 1641 svc := elasticache.New(session.New()) 1642 input := &elasticache.ModifyCacheClusterInput{ 1643 ApplyImmediately: aws.Bool(true), 1644 CacheClusterId: aws.String("redis-cluster"), 1645 SnapshotRetentionLimit: aws.Int64(14), 1646 } 1647 1648 result, err := svc.ModifyCacheCluster(input) 1649 if err != nil { 1650 if aerr, ok := err.(awserr.Error); ok { 1651 switch aerr.Code() { 1652 case elasticache.ErrCodeInvalidCacheClusterStateFault: 1653 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 1654 case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: 1655 fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) 1656 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 1657 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 1658 case elasticache.ErrCodeCacheClusterNotFoundFault: 1659 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1660 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 1661 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 1662 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 1663 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 1664 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 1665 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 1666 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1667 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1668 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 1669 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 1670 case elasticache.ErrCodeInvalidParameterValueException: 1671 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1672 case elasticache.ErrCodeInvalidParameterCombinationException: 1673 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1674 default: 1675 fmt.Println(aerr.Error()) 1676 } 1677 } else { 1678 // Print the error, cast err to awserr.Error to get the Code and 1679 // Message from an error. 1680 fmt.Println(err.Error()) 1681 } 1682 return 1683 } 1684 1685 fmt.Println(result) 1686 } 1687 1688 // ModifyCacheParameterGroup 1689 // 1690 // Modifies one or more parameter values in the specified parameter group. You cannot 1691 // modify any default parameter group. 1692 func ExampleElastiCache_ModifyCacheParameterGroup_shared00() { 1693 svc := elasticache.New(session.New()) 1694 input := &elasticache.ModifyCacheParameterGroupInput{ 1695 CacheParameterGroupName: aws.String("custom-mem1-4"), 1696 ParameterNameValues: []*elasticache.ParameterNameValue{ 1697 { 1698 ParameterName: aws.String("binding_protocol"), 1699 ParameterValue: aws.String("ascii"), 1700 }, 1701 { 1702 ParameterName: aws.String("chunk_size"), 1703 ParameterValue: aws.String("96"), 1704 }, 1705 }, 1706 } 1707 1708 result, err := svc.ModifyCacheParameterGroup(input) 1709 if err != nil { 1710 if aerr, ok := err.(awserr.Error); ok { 1711 switch aerr.Code() { 1712 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1713 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1714 case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: 1715 fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) 1716 case elasticache.ErrCodeInvalidParameterValueException: 1717 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1718 case elasticache.ErrCodeInvalidParameterCombinationException: 1719 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1720 case elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault: 1721 fmt.Println(elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault, aerr.Error()) 1722 default: 1723 fmt.Println(aerr.Error()) 1724 } 1725 } else { 1726 // Print the error, cast err to awserr.Error to get the Code and 1727 // Message from an error. 1728 fmt.Println(err.Error()) 1729 } 1730 return 1731 } 1732 1733 fmt.Println(result) 1734 } 1735 1736 // ModifyCacheSubnetGroup 1737 // 1738 // Modifies an existing ElastiCache subnet group. 1739 func ExampleElastiCache_ModifyCacheSubnetGroup_shared00() { 1740 svc := elasticache.New(session.New()) 1741 input := &elasticache.ModifyCacheSubnetGroupInput{ 1742 CacheSubnetGroupName: aws.String("my-sn-grp"), 1743 SubnetIds: []*string{ 1744 aws.String("subnet-bcde2345"), 1745 }, 1746 } 1747 1748 result, err := svc.ModifyCacheSubnetGroup(input) 1749 if err != nil { 1750 if aerr, ok := err.(awserr.Error); ok { 1751 switch aerr.Code() { 1752 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 1753 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 1754 case elasticache.ErrCodeCacheSubnetQuotaExceededFault: 1755 fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error()) 1756 case elasticache.ErrCodeSubnetInUse: 1757 fmt.Println(elasticache.ErrCodeSubnetInUse, aerr.Error()) 1758 case elasticache.ErrCodeInvalidSubnet: 1759 fmt.Println(elasticache.ErrCodeInvalidSubnet, aerr.Error()) 1760 case elasticache.ErrCodeSubnetNotAllowedFault: 1761 fmt.Println(elasticache.ErrCodeSubnetNotAllowedFault, aerr.Error()) 1762 default: 1763 fmt.Println(aerr.Error()) 1764 } 1765 } else { 1766 // Print the error, cast err to awserr.Error to get the Code and 1767 // Message from an error. 1768 fmt.Println(err.Error()) 1769 } 1770 return 1771 } 1772 1773 fmt.Println(result) 1774 } 1775 1776 // ModifyReplicationGroup 1777 // 1778 1779 func ExampleElastiCache_ModifyReplicationGroup_shared00() { 1780 svc := elasticache.New(session.New()) 1781 input := &elasticache.ModifyReplicationGroupInput{ 1782 ApplyImmediately: aws.Bool(true), 1783 ReplicationGroupDescription: aws.String("Modified replication group"), 1784 ReplicationGroupId: aws.String("my-redis-rg"), 1785 SnapshotRetentionLimit: aws.Int64(30), 1786 SnapshottingClusterId: aws.String("my-redis-rg-001"), 1787 } 1788 1789 result, err := svc.ModifyReplicationGroup(input) 1790 if err != nil { 1791 if aerr, ok := err.(awserr.Error); ok { 1792 switch aerr.Code() { 1793 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1794 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1795 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 1796 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 1797 case elasticache.ErrCodeInvalidUserGroupStateFault: 1798 fmt.Println(elasticache.ErrCodeInvalidUserGroupStateFault, aerr.Error()) 1799 case elasticache.ErrCodeUserGroupNotFoundFault: 1800 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 1801 case elasticache.ErrCodeInvalidCacheClusterStateFault: 1802 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 1803 case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: 1804 fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) 1805 case elasticache.ErrCodeInsufficientCacheClusterCapacityFault: 1806 fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error()) 1807 case elasticache.ErrCodeCacheClusterNotFoundFault: 1808 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1809 case elasticache.ErrCodeNodeQuotaForClusterExceededFault: 1810 fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error()) 1811 case elasticache.ErrCodeNodeQuotaForCustomerExceededFault: 1812 fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error()) 1813 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 1814 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 1815 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1816 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1817 case elasticache.ErrCodeInvalidVPCNetworkStateFault: 1818 fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error()) 1819 case elasticache.ErrCodeInvalidKMSKeyFault: 1820 fmt.Println(elasticache.ErrCodeInvalidKMSKeyFault, aerr.Error()) 1821 case elasticache.ErrCodeInvalidParameterValueException: 1822 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1823 case elasticache.ErrCodeInvalidParameterCombinationException: 1824 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1825 default: 1826 fmt.Println(aerr.Error()) 1827 } 1828 } else { 1829 // Print the error, cast err to awserr.Error to get the Code and 1830 // Message from an error. 1831 fmt.Println(err.Error()) 1832 } 1833 return 1834 } 1835 1836 fmt.Println(result) 1837 } 1838 1839 // PurchaseReservedCacheNodesOfferings 1840 // 1841 // Allows you to purchase a reserved cache node offering. 1842 func ExampleElastiCache_PurchaseReservedCacheNodesOffering_shared00() { 1843 svc := elasticache.New(session.New()) 1844 input := &elasticache.PurchaseReservedCacheNodesOfferingInput{ 1845 ReservedCacheNodesOfferingId: aws.String("1ef01f5b-94ff-433f-a530-61a56bfc8e7a"), 1846 } 1847 1848 result, err := svc.PurchaseReservedCacheNodesOffering(input) 1849 if err != nil { 1850 if aerr, ok := err.(awserr.Error); ok { 1851 switch aerr.Code() { 1852 case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault: 1853 fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error()) 1854 case elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault: 1855 fmt.Println(elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault, aerr.Error()) 1856 case elasticache.ErrCodeReservedCacheNodeQuotaExceededFault: 1857 fmt.Println(elasticache.ErrCodeReservedCacheNodeQuotaExceededFault, aerr.Error()) 1858 case elasticache.ErrCodeTagQuotaPerResourceExceeded: 1859 fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error()) 1860 case elasticache.ErrCodeInvalidParameterValueException: 1861 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1862 case elasticache.ErrCodeInvalidParameterCombinationException: 1863 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1864 default: 1865 fmt.Println(aerr.Error()) 1866 } 1867 } else { 1868 // Print the error, cast err to awserr.Error to get the Code and 1869 // Message from an error. 1870 fmt.Println(err.Error()) 1871 } 1872 return 1873 } 1874 1875 fmt.Println(result) 1876 } 1877 1878 // RebootCacheCluster 1879 // 1880 // Reboots the specified nodes in the names cluster. 1881 func ExampleElastiCache_RebootCacheCluster_shared00() { 1882 svc := elasticache.New(session.New()) 1883 input := &elasticache.RebootCacheClusterInput{ 1884 CacheClusterId: aws.String("custom-mem1-4 "), 1885 CacheNodeIdsToReboot: []*string{ 1886 aws.String("0001"), 1887 aws.String("0002"), 1888 }, 1889 } 1890 1891 result, err := svc.RebootCacheCluster(input) 1892 if err != nil { 1893 if aerr, ok := err.(awserr.Error); ok { 1894 switch aerr.Code() { 1895 case elasticache.ErrCodeInvalidCacheClusterStateFault: 1896 fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error()) 1897 case elasticache.ErrCodeCacheClusterNotFoundFault: 1898 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1899 default: 1900 fmt.Println(aerr.Error()) 1901 } 1902 } else { 1903 // Print the error, cast err to awserr.Error to get the Code and 1904 // Message from an error. 1905 fmt.Println(err.Error()) 1906 } 1907 return 1908 } 1909 1910 fmt.Println(result) 1911 } 1912 1913 // RemoveTagsFromResource 1914 // 1915 // Removes tags identified by a list of tag keys from the list of tags on the specified 1916 // resource. 1917 func ExampleElastiCache_RemoveTagsFromResource_shared00() { 1918 svc := elasticache.New(session.New()) 1919 input := &elasticache.RemoveTagsFromResourceInput{ 1920 ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"), 1921 TagKeys: []*string{ 1922 aws.String("A"), 1923 aws.String("C"), 1924 aws.String("E"), 1925 }, 1926 } 1927 1928 result, err := svc.RemoveTagsFromResource(input) 1929 if err != nil { 1930 if aerr, ok := err.(awserr.Error); ok { 1931 switch aerr.Code() { 1932 case elasticache.ErrCodeCacheClusterNotFoundFault: 1933 fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error()) 1934 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1935 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1936 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 1937 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 1938 case elasticache.ErrCodeCacheSubnetGroupNotFoundFault: 1939 fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error()) 1940 case elasticache.ErrCodeInvalidReplicationGroupStateFault: 1941 fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error()) 1942 case elasticache.ErrCodeReplicationGroupNotFoundFault: 1943 fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error()) 1944 case elasticache.ErrCodeReservedCacheNodeNotFoundFault: 1945 fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error()) 1946 case elasticache.ErrCodeSnapshotNotFoundFault: 1947 fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error()) 1948 case elasticache.ErrCodeUserNotFoundFault: 1949 fmt.Println(elasticache.ErrCodeUserNotFoundFault, aerr.Error()) 1950 case elasticache.ErrCodeUserGroupNotFoundFault: 1951 fmt.Println(elasticache.ErrCodeUserGroupNotFoundFault, aerr.Error()) 1952 case elasticache.ErrCodeInvalidARNFault: 1953 fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error()) 1954 case elasticache.ErrCodeTagNotFoundFault: 1955 fmt.Println(elasticache.ErrCodeTagNotFoundFault, aerr.Error()) 1956 default: 1957 fmt.Println(aerr.Error()) 1958 } 1959 } else { 1960 // Print the error, cast err to awserr.Error to get the Code and 1961 // Message from an error. 1962 fmt.Println(err.Error()) 1963 } 1964 return 1965 } 1966 1967 fmt.Println(result) 1968 } 1969 1970 // ResetCacheParameterGroup 1971 // 1972 // Modifies the parameters of a cache parameter group to the engine or system default 1973 // value. 1974 func ExampleElastiCache_ResetCacheParameterGroup_shared00() { 1975 svc := elasticache.New(session.New()) 1976 input := &elasticache.ResetCacheParameterGroupInput{ 1977 CacheParameterGroupName: aws.String("custom-mem1-4"), 1978 ResetAllParameters: aws.Bool(true), 1979 } 1980 1981 result, err := svc.ResetCacheParameterGroup(input) 1982 if err != nil { 1983 if aerr, ok := err.(awserr.Error); ok { 1984 switch aerr.Code() { 1985 case elasticache.ErrCodeInvalidCacheParameterGroupStateFault: 1986 fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error()) 1987 case elasticache.ErrCodeCacheParameterGroupNotFoundFault: 1988 fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error()) 1989 case elasticache.ErrCodeInvalidParameterValueException: 1990 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 1991 case elasticache.ErrCodeInvalidParameterCombinationException: 1992 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 1993 case elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault: 1994 fmt.Println(elasticache.ErrCodeInvalidGlobalReplicationGroupStateFault, aerr.Error()) 1995 default: 1996 fmt.Println(aerr.Error()) 1997 } 1998 } else { 1999 // Print the error, cast err to awserr.Error to get the Code and 2000 // Message from an error. 2001 fmt.Println(err.Error()) 2002 } 2003 return 2004 } 2005 2006 fmt.Println(result) 2007 } 2008 2009 // DescribeCacheSecurityGroups 2010 // 2011 // Returns a list of cache security group descriptions. If a cache security group name 2012 // is specified, the list contains only the description of that group. 2013 func ExampleElastiCache_RevokeCacheSecurityGroupIngress_shared00() { 2014 svc := elasticache.New(session.New()) 2015 input := &elasticache.RevokeCacheSecurityGroupIngressInput{ 2016 CacheSecurityGroupName: aws.String("my-sec-grp"), 2017 EC2SecurityGroupName: aws.String("my-ec2-sec-grp"), 2018 EC2SecurityGroupOwnerId: aws.String("1234567890"), 2019 } 2020 2021 result, err := svc.RevokeCacheSecurityGroupIngress(input) 2022 if err != nil { 2023 if aerr, ok := err.(awserr.Error); ok { 2024 switch aerr.Code() { 2025 case elasticache.ErrCodeCacheSecurityGroupNotFoundFault: 2026 fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error()) 2027 case elasticache.ErrCodeAuthorizationNotFoundFault: 2028 fmt.Println(elasticache.ErrCodeAuthorizationNotFoundFault, aerr.Error()) 2029 case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault: 2030 fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error()) 2031 case elasticache.ErrCodeInvalidParameterValueException: 2032 fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error()) 2033 case elasticache.ErrCodeInvalidParameterCombinationException: 2034 fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error()) 2035 default: 2036 fmt.Println(aerr.Error()) 2037 } 2038 } else { 2039 // Print the error, cast err to awserr.Error to get the Code and 2040 // Message from an error. 2041 fmt.Println(err.Error()) 2042 } 2043 return 2044 } 2045 2046 fmt.Println(result) 2047 }