1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package costandusagereportservice_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/costandusagereportservice"
)
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 delete the AWS Cost and Usage report named ExampleReport.
// The following example deletes the AWS Cost and Usage report named ExampleReport.
func ExampleCostandUsageReportService_DeleteReportDefinition_shared00() {
svc := costandusagereportservice.New(session.New())
input := &costandusagereportservice.DeleteReportDefinitionInput{
ReportName: aws.String("ExampleReport"),
}
result, err := svc.DeleteReportDefinition(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case costandusagereportservice.ErrCodeInternalErrorException:
fmt.Println(costandusagereportservice.ErrCodeInternalErrorException, aerr.Error())
case costandusagereportservice.ErrCodeValidationException:
fmt.Println(costandusagereportservice.ErrCodeValidationException, 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 list the AWS Cost and Usage reports for the account.
// The following example lists the AWS Cost and Usage reports for the account.
func ExampleCostandUsageReportService_DescribeReportDefinitions_shared00() {
svc := costandusagereportservice.New(session.New())
input := &costandusagereportservice.DescribeReportDefinitionsInput{
MaxResults: aws.Int64(5),
}
result, err := svc.DescribeReportDefinitions(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case costandusagereportservice.ErrCodeInternalErrorException:
fmt.Println(costandusagereportservice.ErrCodeInternalErrorException, 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 report named ExampleReport.
// The following example creates a AWS Cost and Usage report named ExampleReport.
func ExampleCostandUsageReportService_PutReportDefinition_shared00() {
svc := costandusagereportservice.New(session.New())
input := &costandusagereportservice.PutReportDefinitionInput{
ReportDefinition: &costandusagereportservice.ReportDefinition{
AdditionalArtifacts: []*string{
aws.String("REDSHIFT"),
aws.String("QUICKSIGHT"),
},
AdditionalSchemaElements: []*string{
aws.String("RESOURCES"),
},
Compression: aws.String("ZIP"),
Format: aws.String("textORcsv"),
ReportName: aws.String("ExampleReport"),
S3Bucket: aws.String("example-s3-bucket"),
S3Prefix: aws.String("exampleprefix"),
S3Region: aws.String("us-east-1"),
TimeUnit: aws.String("DAILY"),
},
}
result, err := svc.PutReportDefinition(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case costandusagereportservice.ErrCodeDuplicateReportNameException:
fmt.Println(costandusagereportservice.ErrCodeDuplicateReportNameException, aerr.Error())
case costandusagereportservice.ErrCodeReportLimitReachedException:
fmt.Println(costandusagereportservice.ErrCodeReportLimitReachedException, aerr.Error())
case costandusagereportservice.ErrCodeInternalErrorException:
fmt.Println(costandusagereportservice.ErrCodeInternalErrorException, aerr.Error())
case costandusagereportservice.ErrCodeValidationException:
fmt.Println(costandusagereportservice.ErrCodeValidationException, aerr.Error())
case costandusagereportservice.ErrCodeResourceNotFoundException:
fmt.Println(costandusagereportservice.ErrCodeResourceNotFoundException, 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)
}
|