| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
- package efs_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/efs"
- )
- 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
- }
- // To create a new file system
- //
- // This operation creates a new file system with the default generalpurpose performance
- // mode.
- func ExampleEFS_CreateFileSystem_shared00() {
- svc := efs.New(session.New())
- input := &efs.CreateFileSystemInput{
- CreationToken: aws.String("tokenstring"),
- PerformanceMode: aws.String("generalPurpose"),
- }
- result, err := svc.CreateFileSystem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemAlreadyExists:
- fmt.Println(efs.ErrCodeFileSystemAlreadyExists, aerr.Error())
- case efs.ErrCodeFileSystemLimitExceeded:
- fmt.Println(efs.ErrCodeFileSystemLimitExceeded, aerr.Error())
- case efs.ErrCodeInsufficientThroughputCapacity:
- fmt.Println(efs.ErrCodeInsufficientThroughputCapacity, aerr.Error())
- case efs.ErrCodeThroughputLimitExceeded:
- fmt.Println(efs.ErrCodeThroughputLimitExceeded, 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)
- }
- // To create a new mount target
- //
- // This operation creates a new mount target for an EFS file system.
- func ExampleEFS_CreateMountTarget_shared00() {
- svc := efs.New(session.New())
- input := &efs.CreateMountTargetInput{
- FileSystemId: aws.String("fs-01234567"),
- SubnetId: aws.String("subnet-1234abcd"),
- }
- result, err := svc.CreateMountTarget(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, aerr.Error())
- case efs.ErrCodeIncorrectFileSystemLifeCycleState:
- fmt.Println(efs.ErrCodeIncorrectFileSystemLifeCycleState, aerr.Error())
- case efs.ErrCodeMountTargetConflict:
- fmt.Println(efs.ErrCodeMountTargetConflict, aerr.Error())
- case efs.ErrCodeSubnetNotFound:
- fmt.Println(efs.ErrCodeSubnetNotFound, aerr.Error())
- case efs.ErrCodeNoFreeAddressesInSubnet:
- fmt.Println(efs.ErrCodeNoFreeAddressesInSubnet, aerr.Error())
- case efs.ErrCodeIpAddressInUse:
- fmt.Println(efs.ErrCodeIpAddressInUse, aerr.Error())
- case efs.ErrCodeNetworkInterfaceLimitExceeded:
- fmt.Println(efs.ErrCodeNetworkInterfaceLimitExceeded, aerr.Error())
- case efs.ErrCodeSecurityGroupLimitExceeded:
- fmt.Println(efs.ErrCodeSecurityGroupLimitExceeded, aerr.Error())
- case efs.ErrCodeSecurityGroupNotFound:
- fmt.Println(efs.ErrCodeSecurityGroupNotFound, aerr.Error())
- case efs.ErrCodeUnsupportedAvailabilityZone:
- fmt.Println(efs.ErrCodeUnsupportedAvailabilityZone, 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)
- }
- // To create a new tag
- //
- // This operation creates a new tag for an EFS file system.
- func ExampleEFS_CreateTags_shared00() {
- svc := efs.New(session.New())
- input := &efs.CreateTagsInput{
- FileSystemId: aws.String("fs-01234567"),
- Tags: []*efs.Tag{
- {
- Key: aws.String("Name"),
- Value: aws.String("MyFileSystem"),
- },
- },
- }
- result, err := svc.CreateTags(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, 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)
- }
- // To delete a file system
- //
- // This operation deletes an EFS file system.
- func ExampleEFS_DeleteFileSystem_shared00() {
- svc := efs.New(session.New())
- input := &efs.DeleteFileSystemInput{
- FileSystemId: aws.String("fs-01234567"),
- }
- result, err := svc.DeleteFileSystem(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, aerr.Error())
- case efs.ErrCodeFileSystemInUse:
- fmt.Println(efs.ErrCodeFileSystemInUse, 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)
- }
- // To delete a mount target
- //
- // This operation deletes a mount target.
- func ExampleEFS_DeleteMountTarget_shared00() {
- svc := efs.New(session.New())
- input := &efs.DeleteMountTargetInput{
- MountTargetId: aws.String("fsmt-12340abc"),
- }
- result, err := svc.DeleteMountTarget(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeDependencyTimeout:
- fmt.Println(efs.ErrCodeDependencyTimeout, aerr.Error())
- case efs.ErrCodeMountTargetNotFound:
- fmt.Println(efs.ErrCodeMountTargetNotFound, 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)
- }
- // To delete tags for an EFS file system
- //
- // This operation deletes tags for an EFS file system.
- func ExampleEFS_DeleteTags_shared00() {
- svc := efs.New(session.New())
- input := &efs.DeleteTagsInput{
- FileSystemId: aws.String("fs-01234567"),
- TagKeys: []*string{
- aws.String("Name"),
- },
- }
- result, err := svc.DeleteTags(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, 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)
- }
- // To describe an EFS file system
- //
- // This operation describes all of the EFS file systems in an account.
- func ExampleEFS_DescribeFileSystems_shared00() {
- svc := efs.New(session.New())
- input := &efs.DescribeFileSystemsInput{}
- result, err := svc.DescribeFileSystems(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, 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)
- }
- // To describe the security groups for a mount target
- //
- // This operation describes all of the security groups for a file system's mount target.
- func ExampleEFS_DescribeMountTargetSecurityGroups_shared00() {
- svc := efs.New(session.New())
- input := &efs.DescribeMountTargetSecurityGroupsInput{
- MountTargetId: aws.String("fsmt-12340abc"),
- }
- result, err := svc.DescribeMountTargetSecurityGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeMountTargetNotFound:
- fmt.Println(efs.ErrCodeMountTargetNotFound, aerr.Error())
- case efs.ErrCodeIncorrectMountTargetState:
- fmt.Println(efs.ErrCodeIncorrectMountTargetState, 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)
- }
- // To describe the mount targets for a file system
- //
- // This operation describes all of a file system's mount targets.
- func ExampleEFS_DescribeMountTargets_shared00() {
- svc := efs.New(session.New())
- input := &efs.DescribeMountTargetsInput{
- FileSystemId: aws.String("fs-01234567"),
- }
- result, err := svc.DescribeMountTargets(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, aerr.Error())
- case efs.ErrCodeMountTargetNotFound:
- fmt.Println(efs.ErrCodeMountTargetNotFound, 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)
- }
- // To describe the tags for a file system
- //
- // This operation describes all of a file system's tags.
- func ExampleEFS_DescribeTags_shared00() {
- svc := efs.New(session.New())
- input := &efs.DescribeTagsInput{
- FileSystemId: aws.String("fs-01234567"),
- }
- result, err := svc.DescribeTags(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeFileSystemNotFound:
- fmt.Println(efs.ErrCodeFileSystemNotFound, 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)
- }
- // To modify the security groups associated with a mount target for a file system
- //
- // This operation modifies the security groups associated with a mount target for a
- // file system.
- func ExampleEFS_ModifyMountTargetSecurityGroups_shared00() {
- svc := efs.New(session.New())
- input := &efs.ModifyMountTargetSecurityGroupsInput{
- MountTargetId: aws.String("fsmt-12340abc"),
- SecurityGroups: []*string{
- aws.String("sg-abcd1234"),
- },
- }
- result, err := svc.ModifyMountTargetSecurityGroups(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case efs.ErrCodeBadRequest:
- fmt.Println(efs.ErrCodeBadRequest, aerr.Error())
- case efs.ErrCodeInternalServerError:
- fmt.Println(efs.ErrCodeInternalServerError, aerr.Error())
- case efs.ErrCodeMountTargetNotFound:
- fmt.Println(efs.ErrCodeMountTargetNotFound, aerr.Error())
- case efs.ErrCodeIncorrectMountTargetState:
- fmt.Println(efs.ErrCodeIncorrectMountTargetState, aerr.Error())
- case efs.ErrCodeSecurityGroupLimitExceeded:
- fmt.Println(efs.ErrCodeSecurityGroupLimitExceeded, aerr.Error())
- case efs.ErrCodeSecurityGroupNotFound:
- fmt.Println(efs.ErrCodeSecurityGroupNotFound, 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)
- }
|