1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2024-12-21 02:51:17 +00:00
share/vendor/github.com/aws/aws-sdk-go/service/elasticache/examples_test.go
Knut Ahlers 8f80d158ca
Move CLI util
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-12-02 19:12:46 +01:00

1953 lines
71 KiB
Go

// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package elasticache_test
import (
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elasticache"
)
var _ time.Duration
var _ strings.Reader
var _ aws.Config
func parseTime(layout, value string) *time.Time {
t, err := time.Parse(layout, value)
if err != nil {
panic(err)
}
return &t
}
// AddTagsToResource
//
// Adds up to 10 tags, key/value pairs, to a cluster or snapshot resource.
func ExampleElastiCache_AddTagsToResource_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.AddTagsToResourceInput{
ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"),
Tags: []*elasticache.Tag{
{
Key: aws.String("APIVersion"),
Value: aws.String("20150202"),
},
{
Key: aws.String("Service"),
Value: aws.String("ElastiCache"),
},
},
}
result, err := svc.AddTagsToResource(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeTagQuotaPerResourceExceeded:
fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error())
case elasticache.ErrCodeInvalidARNFault:
fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// AuthorizeCacheCacheSecurityGroupIngress
//
// Allows network ingress to a cache security group. Applications using ElastiCache
// must be running on Amazon EC2. Amazon EC2 security groups are used as the authorization
// mechanism.
func ExampleElastiCache_AuthorizeCacheSecurityGroupIngress_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.AuthorizeCacheSecurityGroupIngressInput{
CacheSecurityGroupName: aws.String("my-sec-grp"),
EC2SecurityGroupName: aws.String("my-ec2-sec-grp"),
EC2SecurityGroupOwnerId: aws.String("1234567890"),
}
result, err := svc.AuthorizeCacheSecurityGroupIngress(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error())
case elasticache.ErrCodeAuthorizationAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeAuthorizationAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CopySnapshot
//
// Copies a snapshot to a specified name.
func ExampleElastiCache_CopySnapshot_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CopySnapshotInput{
SourceSnapshotName: aws.String("my-snapshot"),
TargetBucket: aws.String(""),
TargetSnapshotName: aws.String("my-snapshot-copy"),
}
result, err := svc.CopySnapshot(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidSnapshotStateFault:
fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheCluster
//
// Creates a Memcached cluster with 2 nodes.
func ExampleElastiCache_CreateCacheCluster_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateCacheClusterInput{
AZMode: aws.String("cross-az"),
CacheClusterId: aws.String("my-memcached-cluster"),
CacheNodeType: aws.String("cache.r3.large"),
CacheSubnetGroupName: aws.String("default"),
Engine: aws.String("memcached"),
EngineVersion: aws.String("1.4.24"),
NumCacheNodes: aws.Int64(2),
Port: aws.Int64(11211),
}
result, err := svc.CreateCacheCluster(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeCacheClusterAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeClusterQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeTagQuotaPerResourceExceeded:
fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheCluster
//
// Creates a Redis cluster with 1 node.
func ExampleElastiCache_CreateCacheCluster_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.CreateCacheClusterInput{
AutoMinorVersionUpgrade: aws.Bool(true),
CacheClusterId: aws.String("my-redis"),
CacheNodeType: aws.String("cache.r3.larage"),
CacheSubnetGroupName: aws.String("default"),
Engine: aws.String("redis"),
EngineVersion: aws.String("3.2.4"),
NumCacheNodes: aws.Int64(1),
Port: aws.Int64(6379),
PreferredAvailabilityZone: aws.String("us-east-1c"),
SnapshotRetentionLimit: aws.Int64(7),
}
result, err := svc.CreateCacheCluster(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeCacheClusterAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeCacheClusterAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeClusterQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeTagQuotaPerResourceExceeded:
fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheParameterGroup
//
// Creates the Amazon ElastiCache parameter group custom-redis2-8.
func ExampleElastiCache_CreateCacheParameterGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateCacheParameterGroupInput{
CacheParameterGroupFamily: aws.String("redis2.8"),
CacheParameterGroupName: aws.String("custom-redis2-8"),
Description: aws.String("Custom Redis 2.8 parameter group."),
}
result, err := svc.CreateCacheParameterGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheParameterGroupQuotaExceededFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheParameterGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheSecurityGroup
//
// Creates an ElastiCache security group. ElastiCache security groups are only for clusters
// not running in an AWS VPC.
func ExampleElastiCache_CreateCacheSecurityGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateCacheSecurityGroupInput{
CacheSecurityGroupName: aws.String("my-cache-sec-grp"),
Description: aws.String("Example ElastiCache security group."),
}
result, err := svc.CreateCacheSecurityGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheSubnet
//
// Creates a new cache subnet group.
func ExampleElastiCache_CreateCacheSubnetGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateCacheSubnetGroupInput{
CacheSubnetGroupDescription: aws.String("Sample subnet group"),
CacheSubnetGroupName: aws.String("my-sn-grp2"),
SubnetIds: []*string{
aws.String("subnet-6f28c982"),
aws.String("subnet-bcd382f3"),
aws.String("subnet-845b3e7c0"),
},
}
result, err := svc.CreateCacheSubnetGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetQuotaExceededFault:
fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidSubnet:
fmt.Println(elasticache.ErrCodeInvalidSubnet, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateCacheReplicationGroup
//
// Creates a Redis replication group with 3 nodes.
func ExampleElastiCache_CreateReplicationGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateReplicationGroupInput{
AutomaticFailoverEnabled: aws.Bool(true),
CacheNodeType: aws.String("cache.m3.medium"),
Engine: aws.String("redis"),
EngineVersion: aws.String("2.8.24"),
NumCacheClusters: aws.Int64(3),
ReplicationGroupDescription: aws.String("A Redis replication group."),
ReplicationGroupId: aws.String("my-redis-rg"),
SnapshotRetentionLimit: aws.Int64(30),
}
result, err := svc.CreateReplicationGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeClusterQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeTagQuotaPerResourceExceeded:
fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error())
case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault:
fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateReplicationGroup
//
// Creates a Redis (cluster mode enabled) replication group with two shards. One shard
// has one read replica node and the other shard has two read replicas.
func ExampleElastiCache_CreateReplicationGroup_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.CreateReplicationGroupInput{
AutoMinorVersionUpgrade: aws.Bool(true),
CacheNodeType: aws.String("cache.m3.medium"),
CacheParameterGroupName: aws.String("default.redis3.2.cluster.on"),
Engine: aws.String("redis"),
EngineVersion: aws.String("3.2.4"),
NodeGroupConfiguration: []*elasticache.NodeGroupConfiguration{
{
PrimaryAvailabilityZone: aws.String("us-east-1c"),
ReplicaAvailabilityZones: []*string{
aws.String("us-east-1b"),
},
ReplicaCount: aws.Int64(1),
Slots: aws.String("0-8999"),
},
{
PrimaryAvailabilityZone: aws.String("us-east-1a"),
ReplicaAvailabilityZones: []*string{
aws.String("us-east-1a"),
aws.String("us-east-1c"),
},
ReplicaCount: aws.Int64(2),
Slots: aws.String("9000-16383"),
},
},
NumNodeGroups: aws.Int64(2),
ReplicationGroupDescription: aws.String("A multi-sharded replication group"),
ReplicationGroupId: aws.String("clustered-redis-rg"),
SnapshotRetentionLimit: aws.Int64(8),
}
result, err := svc.CreateReplicationGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeReplicationGroupAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeClusterQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeClusterQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeTagQuotaPerResourceExceeded:
fmt.Println(elasticache.ErrCodeTagQuotaPerResourceExceeded, aerr.Error())
case elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault:
fmt.Println(elasticache.ErrCodeNodeGroupsPerReplicationGroupQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateSnapshot - NonClustered Redis, no read-replicas
//
// Creates a snapshot of a non-clustered Redis cluster that has only one node.
func ExampleElastiCache_CreateSnapshot_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.CreateSnapshotInput{
CacheClusterId: aws.String("onenoderedis"),
SnapshotName: aws.String("snapshot-1"),
}
result, err := svc.CreateSnapshot(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeSnapshotFeatureNotSupportedFault:
fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateSnapshot - NonClustered Redis, 2 read-replicas
//
// Creates a snapshot of a non-clustered Redis cluster that has only three nodes, primary
// and two read-replicas. CacheClusterId must be a specific node in the cluster.
func ExampleElastiCache_CreateSnapshot_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.CreateSnapshotInput{
CacheClusterId: aws.String("threenoderedis-001"),
SnapshotName: aws.String("snapshot-2"),
}
result, err := svc.CreateSnapshot(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeSnapshotFeatureNotSupportedFault:
fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// CreateSnapshot-clustered Redis
//
// Creates a snapshot of a clustered Redis cluster that has 2 shards, each with a primary
// and 4 read-replicas.
func ExampleElastiCache_CreateSnapshot_shared02() {
svc := elasticache.New(session.New())
input := &elasticache.CreateSnapshotInput{
ReplicationGroupId: aws.String("clusteredredis"),
SnapshotName: aws.String("snapshot-2x5"),
}
result, err := svc.CreateSnapshot(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeSnapshotFeatureNotSupportedFault:
fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteCacheCluster
//
// Deletes an Amazon ElastiCache cluster.
func ExampleElastiCache_DeleteCacheCluster_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteCacheClusterInput{
CacheClusterId: aws.String("my-memcached"),
}
result, err := svc.DeleteCacheCluster(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeSnapshotFeatureNotSupportedFault:
fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteCacheParameterGroup
//
// Deletes the Amazon ElastiCache parameter group custom-mem1-4.
func ExampleElastiCache_DeleteCacheParameterGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteCacheParameterGroupInput{
CacheParameterGroupName: aws.String("custom-mem1-4"),
}
result, err := svc.DeleteCacheParameterGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidCacheParameterGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteCacheSecurityGroup
//
// Deletes a cache security group.
func ExampleElastiCache_DeleteCacheSecurityGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteCacheSecurityGroupInput{
CacheSecurityGroupName: aws.String("my-sec-group"),
}
result, err := svc.DeleteCacheSecurityGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteCacheSubnetGroup
//
// Deletes the Amazon ElastiCache subnet group my-subnet-group.
func ExampleElastiCache_DeleteCacheSubnetGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteCacheSubnetGroupInput{
CacheSubnetGroupName: aws.String("my-subnet-group"),
}
result, err := svc.DeleteCacheSubnetGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSubnetGroupInUse:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupInUse, aerr.Error())
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteReplicationGroup
//
// Deletes the Amazon ElastiCache replication group my-redis-rg.
func ExampleElastiCache_DeleteReplicationGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteReplicationGroupInput{
ReplicationGroupId: aws.String("my-redis-rg"),
RetainPrimaryCluster: aws.Bool(false),
}
result, err := svc.DeleteReplicationGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeSnapshotAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeSnapshotAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeSnapshotFeatureNotSupportedFault:
fmt.Println(elasticache.ErrCodeSnapshotFeatureNotSupportedFault, aerr.Error())
case elasticache.ErrCodeSnapshotQuotaExceededFault:
fmt.Println(elasticache.ErrCodeSnapshotQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DeleteSnapshot
//
// Deletes the Redis snapshot snapshot-20160822.
func ExampleElastiCache_DeleteSnapshot_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DeleteSnapshotInput{
SnapshotName: aws.String("snapshot-20161212"),
}
result, err := svc.DeleteSnapshot(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidSnapshotStateFault:
fmt.Println(elasticache.ErrCodeInvalidSnapshotStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheClusters
//
// Lists the details for up to 50 cache clusters.
func ExampleElastiCache_DescribeCacheClusters_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheClustersInput{
CacheClusterId: aws.String("my-mem-cluster"),
}
result, err := svc.DescribeCacheClusters(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheClusters
//
// Lists the details for the cache cluster my-mem-cluster.
func ExampleElastiCache_DescribeCacheClusters_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheClustersInput{
CacheClusterId: aws.String("my-mem-cluster"),
ShowCacheNodeInfo: aws.Bool(true),
}
result, err := svc.DescribeCacheClusters(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheEngineVersions
//
// Lists the details for up to 25 Memcached and Redis cache engine versions.
func ExampleElastiCache_DescribeCacheEngineVersions_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheEngineVersionsInput{}
result, err := svc.DescribeCacheEngineVersions(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheEngineVersions
//
// Lists the details for up to 50 Redis cache engine versions.
func ExampleElastiCache_DescribeCacheEngineVersions_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheEngineVersionsInput{
DefaultOnly: aws.Bool(false),
Engine: aws.String("redis"),
MaxRecords: aws.Int64(50),
}
result, err := svc.DescribeCacheEngineVersions(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheParameterGroups
//
// Returns a list of cache parameter group descriptions. If a cache parameter group
// name is specified, the list contains only the descriptions for that group.
func ExampleElastiCache_DescribeCacheParameterGroups_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheParameterGroupsInput{
CacheParameterGroupName: aws.String("custom-mem1-4"),
}
result, err := svc.DescribeCacheParameterGroups(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheParameters
//
// Lists up to 100 user parameter values for the parameter group custom.redis2.8.
func ExampleElastiCache_DescribeCacheParameters_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheParametersInput{
CacheParameterGroupName: aws.String("custom-redis2-8"),
MaxRecords: aws.Int64(100),
Source: aws.String("user"),
}
result, err := svc.DescribeCacheParameters(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheSecurityGroups
//
// Returns a list of cache security group descriptions. If a cache security group name
// is specified, the list contains only the description of that group.
func ExampleElastiCache_DescribeCacheSecurityGroups_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheSecurityGroupsInput{
CacheSecurityGroupName: aws.String("my-sec-group"),
}
result, err := svc.DescribeCacheSecurityGroups(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheSubnetGroups
//
// Describes up to 25 cache subnet groups.
func ExampleElastiCache_DescribeCacheSubnetGroups_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeCacheSubnetGroupsInput{
MaxRecords: aws.Int64(25),
}
result, err := svc.DescribeCacheSubnetGroups(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeEngineDefaultParameters
//
// Returns the default engine and system parameter information for the specified cache
// engine.
func ExampleElastiCache_DescribeEngineDefaultParameters_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeEngineDefaultParametersInput{
CacheParameterGroupFamily: aws.String("redis2.8"),
MaxRecords: aws.Int64(25),
}
result, err := svc.DescribeEngineDefaultParameters(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeEvents
//
// Describes all the cache-cluster events for the past 120 minutes.
func ExampleElastiCache_DescribeEvents_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeEventsInput{
Duration: aws.Int64(360),
SourceType: aws.String("cache-cluster"),
}
result, err := svc.DescribeEvents(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeEvents
//
// Describes all the replication-group events from 3:00P to 5:00P on November 11, 2016.
func ExampleElastiCache_DescribeEvents_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeEventsInput{
StartTime: parseTime("2006-01-02T15:04:05Z", "2016-12-22T15:00:00.000Z"),
}
result, err := svc.DescribeEvents(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeReplicationGroups
//
// Returns information about the replication group myreplgroup.
func ExampleElastiCache_DescribeReplicationGroups_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeReplicationGroupsInput{}
result, err := svc.DescribeReplicationGroups(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeReservedCacheNodes
//
// Returns information about reserved cache nodes for this account, or about a specified
// reserved cache node. If the account has no reserved cache nodes, the operation returns
// an empty list, as shown here.
func ExampleElastiCache_DescribeReservedCacheNodes_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeReservedCacheNodesInput{
MaxRecords: aws.Int64(25),
}
result, err := svc.DescribeReservedCacheNodes(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReservedCacheNodeNotFoundFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodeNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeReseredCacheNodeOfferings
//
// Lists available reserved cache node offerings.
func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeReservedCacheNodesOfferingsInput{
MaxRecords: aws.Int64(20),
}
result, err := svc.DescribeReservedCacheNodesOfferings(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeReseredCacheNodeOfferings
//
// Lists available reserved cache node offerings for cache.r3.large nodes with a 3 year
// commitment.
func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeReservedCacheNodesOfferingsInput{
CacheNodeType: aws.String("cache.r3.large"),
Duration: aws.String("3"),
MaxRecords: aws.Int64(25),
OfferingType: aws.String("Light Utilization"),
ReservedCacheNodesOfferingId: aws.String(""),
}
result, err := svc.DescribeReservedCacheNodesOfferings(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeReseredCacheNodeOfferings
//
// Lists available reserved cache node offerings.
func ExampleElastiCache_DescribeReservedCacheNodesOfferings_shared02() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeReservedCacheNodesOfferingsInput{
CacheNodeType: aws.String(""),
Duration: aws.String(""),
Marker: aws.String(""),
MaxRecords: aws.Int64(25),
OfferingType: aws.String(""),
ProductDescription: aws.String(""),
ReservedCacheNodesOfferingId: aws.String("438012d3-4052-4cc7-b2e3-8d3372e0e706"),
}
result, err := svc.DescribeReservedCacheNodesOfferings(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeSnapshots
//
// Returns information about the snapshot mysnapshot. By default.
func ExampleElastiCache_DescribeSnapshots_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.DescribeSnapshotsInput{
SnapshotName: aws.String("snapshot-20161212"),
}
result, err := svc.DescribeSnapshots(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ListAllowedNodeTypeModifications
//
// Lists all available node types that you can scale your Redis cluster's or replication
// group's current node type up to.
func ExampleElastiCache_ListAllowedNodeTypeModifications_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ListAllowedNodeTypeModificationsInput{
ReplicationGroupId: aws.String("myreplgroup"),
}
result, err := svc.ListAllowedNodeTypeModifications(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ListAllowedNodeTypeModifications
//
// Lists all available node types that you can scale your Redis cluster's or replication
// group's current node type up to.
func ExampleElastiCache_ListAllowedNodeTypeModifications_shared01() {
svc := elasticache.New(session.New())
input := &elasticache.ListAllowedNodeTypeModificationsInput{
CacheClusterId: aws.String("mycluster"),
}
result, err := svc.ListAllowedNodeTypeModifications(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ListTagsForResource
//
// Lists all cost allocation tags currently on the named resource. A cost allocation
// tag is a key-value pair where the key is case-sensitive and the value is optional.
// You can use cost allocation tags to categorize and track your AWS costs.
func ExampleElastiCache_ListTagsForResource_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ListTagsForResourceInput{
ResourceName: aws.String("arn:aws:elasticache:us-west-2:<my-account-id>:cluster:mycluster"),
}
result, err := svc.ListTagsForResource(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidARNFault:
fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ModifyCacheCluster
//
// Copies a snapshot to a specified name.
func ExampleElastiCache_ModifyCacheCluster_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ModifyCacheClusterInput{
ApplyImmediately: aws.Bool(true),
CacheClusterId: aws.String("redis-cluster"),
SnapshotRetentionLimit: aws.Int64(14),
}
result, err := svc.ModifyCacheCluster(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ModifyCacheParameterGroup
//
// Modifies one or more parameter values in the specified parameter group. You cannot
// modify any default parameter group.
func ExampleElastiCache_ModifyCacheParameterGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ModifyCacheParameterGroupInput{
CacheParameterGroupName: aws.String("custom-mem1-4"),
ParameterNameValues: []*elasticache.ParameterNameValue{
{
ParameterName: aws.String("binding_protocol"),
ParameterValue: aws.String("ascii"),
},
{
ParameterName: aws.String("chunk_size"),
ParameterValue: aws.String("96"),
},
},
}
result, err := svc.ModifyCacheParameterGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheParameterGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ModifyCacheSubnetGroup
//
// Modifies an existing ElastiCache subnet group.
func ExampleElastiCache_ModifyCacheSubnetGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ModifyCacheSubnetGroupInput{
CacheSubnetGroupName: aws.String("my-sn-grp"),
SubnetIds: []*string{
aws.String("subnet-bcde2345"),
},
}
result, err := svc.ModifyCacheSubnetGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSubnetGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSubnetGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheSubnetQuotaExceededFault:
fmt.Println(elasticache.ErrCodeCacheSubnetQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeSubnetInUse:
fmt.Println(elasticache.ErrCodeSubnetInUse, aerr.Error())
case elasticache.ErrCodeInvalidSubnet:
fmt.Println(elasticache.ErrCodeInvalidSubnet, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ModifyReplicationGroup
//
func ExampleElastiCache_ModifyReplicationGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ModifyReplicationGroupInput{
ApplyImmediately: aws.Bool(true),
ReplicationGroupDescription: aws.String("Modified replication group"),
ReplicationGroupId: aws.String("my-redis-rg"),
SnapshotRetentionLimit: aws.Int64(30),
SnapshottingClusterId: aws.String("my-redis-rg-001"),
}
result, err := svc.ModifyReplicationGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReplicationGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeReplicationGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidReplicationGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidReplicationGroupStateFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error())
case elasticache.ErrCodeInsufficientCacheClusterCapacityFault:
fmt.Println(elasticache.ErrCodeInsufficientCacheClusterCapacityFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForClusterExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForClusterExceededFault, aerr.Error())
case elasticache.ErrCodeNodeQuotaForCustomerExceededFault:
fmt.Println(elasticache.ErrCodeNodeQuotaForCustomerExceededFault, aerr.Error())
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidVPCNetworkStateFault:
fmt.Println(elasticache.ErrCodeInvalidVPCNetworkStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// PurchaseReservedCacheNodesOfferings
//
// Allows you to purchase a reserved cache node offering.
func ExampleElastiCache_PurchaseReservedCacheNodesOffering_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.PurchaseReservedCacheNodesOfferingInput{
ReservedCacheNodesOfferingId: aws.String("1ef01f5b-94ff-433f-a530-61a56bfc8e7a"),
}
result, err := svc.PurchaseReservedCacheNodesOffering(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodesOfferingNotFoundFault, aerr.Error())
case elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodeAlreadyExistsFault, aerr.Error())
case elasticache.ErrCodeReservedCacheNodeQuotaExceededFault:
fmt.Println(elasticache.ErrCodeReservedCacheNodeQuotaExceededFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// RebootCacheCluster
//
// Reboots the specified nodes in the names cluster.
func ExampleElastiCache_RebootCacheCluster_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.RebootCacheClusterInput{
CacheClusterId: aws.String("custom-mem1-4 "),
CacheNodeIdsToReboot: []*string{
aws.String("0001"),
aws.String("0002"),
},
}
result, err := svc.RebootCacheCluster(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidCacheClusterStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheClusterStateFault, aerr.Error())
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// RemoveTagsFromResource
//
// Removes tags identified by a list of tag keys from the list of tags on the specified
// resource.
func ExampleElastiCache_RemoveTagsFromResource_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.RemoveTagsFromResourceInput{
ResourceName: aws.String("arn:aws:elasticache:us-east-1:1234567890:cluster:my-mem-cluster"),
TagKeys: []*string{
aws.String("A"),
aws.String("C"),
aws.String("E"),
},
}
result, err := svc.RemoveTagsFromResource(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheClusterNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheClusterNotFoundFault, aerr.Error())
case elasticache.ErrCodeSnapshotNotFoundFault:
fmt.Println(elasticache.ErrCodeSnapshotNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidARNFault:
fmt.Println(elasticache.ErrCodeInvalidARNFault, aerr.Error())
case elasticache.ErrCodeTagNotFoundFault:
fmt.Println(elasticache.ErrCodeTagNotFoundFault, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// ResetCacheParameterGroup
//
// Modifies the parameters of a cache parameter group to the engine or system default
// value.
func ExampleElastiCache_ResetCacheParameterGroup_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.ResetCacheParameterGroupInput{
CacheParameterGroupName: aws.String("custom-mem1-4"),
ResetAllParameters: aws.Bool(true),
}
result, err := svc.ResetCacheParameterGroup(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeInvalidCacheParameterGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheParameterGroupStateFault, aerr.Error())
case elasticache.ErrCodeCacheParameterGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheParameterGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
// DescribeCacheSecurityGroups
//
// Returns a list of cache security group descriptions. If a cache security group name
// is specified, the list contains only the description of that group.
func ExampleElastiCache_RevokeCacheSecurityGroupIngress_shared00() {
svc := elasticache.New(session.New())
input := &elasticache.RevokeCacheSecurityGroupIngressInput{
CacheSecurityGroupName: aws.String("my-sec-grp"),
EC2SecurityGroupName: aws.String("my-ec2-sec-grp"),
EC2SecurityGroupOwnerId: aws.String("1234567890"),
}
result, err := svc.RevokeCacheSecurityGroupIngress(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case elasticache.ErrCodeCacheSecurityGroupNotFoundFault:
fmt.Println(elasticache.ErrCodeCacheSecurityGroupNotFoundFault, aerr.Error())
case elasticache.ErrCodeAuthorizationNotFoundFault:
fmt.Println(elasticache.ErrCodeAuthorizationNotFoundFault, aerr.Error())
case elasticache.ErrCodeInvalidCacheSecurityGroupStateFault:
fmt.Println(elasticache.ErrCodeInvalidCacheSecurityGroupStateFault, aerr.Error())
case elasticache.ErrCodeInvalidParameterValueException:
fmt.Println(elasticache.ErrCodeInvalidParameterValueException, aerr.Error())
case elasticache.ErrCodeInvalidParameterCombinationException:
fmt.Println(elasticache.ErrCodeInvalidParameterCombinationException, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}