1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2024-12-25 04:51:18 +00:00
share/vendor/github.com/aws/aws-sdk-go/service/pricing/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

154 lines
4.5 KiB
Go

// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package pricing_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/pricing"
)
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 retrieve a list of services and service codes
//
func ExamplePricing_DescribeServices_shared00() {
svc := pricing.New(session.New())
input := &pricing.DescribeServicesInput{
FormatVersion: aws.String("aws_v1"),
MaxResults: aws.Int64(1),
ServiceCode: aws.String("AmazonEC2"),
}
result, err := svc.DescribeServices(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case pricing.ErrCodeInternalErrorException:
fmt.Println(pricing.ErrCodeInternalErrorException, aerr.Error())
case pricing.ErrCodeInvalidParameterException:
fmt.Println(pricing.ErrCodeInvalidParameterException, aerr.Error())
case pricing.ErrCodeNotFoundException:
fmt.Println(pricing.ErrCodeNotFoundException, aerr.Error())
case pricing.ErrCodeInvalidNextTokenException:
fmt.Println(pricing.ErrCodeInvalidNextTokenException, aerr.Error())
case pricing.ErrCodeExpiredNextTokenException:
fmt.Println(pricing.ErrCodeExpiredNextTokenException, 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 retrieve a list of attribute values
//
// This operation returns a list of values available for the given attribute.
func ExamplePricing_GetAttributeValues_shared00() {
svc := pricing.New(session.New())
input := &pricing.GetAttributeValuesInput{
AttributeName: aws.String("volumeType"),
MaxResults: aws.Int64(2),
ServiceCode: aws.String("AmazonEC2"),
}
result, err := svc.GetAttributeValues(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case pricing.ErrCodeInternalErrorException:
fmt.Println(pricing.ErrCodeInternalErrorException, aerr.Error())
case pricing.ErrCodeInvalidParameterException:
fmt.Println(pricing.ErrCodeInvalidParameterException, aerr.Error())
case pricing.ErrCodeNotFoundException:
fmt.Println(pricing.ErrCodeNotFoundException, aerr.Error())
case pricing.ErrCodeInvalidNextTokenException:
fmt.Println(pricing.ErrCodeInvalidNextTokenException, aerr.Error())
case pricing.ErrCodeExpiredNextTokenException:
fmt.Println(pricing.ErrCodeExpiredNextTokenException, 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 retrieve a list of products
//
// This operation returns a list of products that match the given criteria.
func ExamplePricing_GetProducts_shared00() {
svc := pricing.New(session.New())
input := &pricing.GetProductsInput{
Filters: []*pricing.Filter{
{
Field: aws.String("ServiceCode"),
Type: aws.String("TERM_MATCH"),
Value: aws.String("AmazonEC2"),
},
{
Field: aws.String("volumeType"),
Type: aws.String("TERM_MATCH"),
Value: aws.String("Provisioned IOPS"),
},
},
FormatVersion: aws.String("aws_v1"),
MaxResults: aws.Int64(1),
}
result, err := svc.GetProducts(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case pricing.ErrCodeInternalErrorException:
fmt.Println(pricing.ErrCodeInternalErrorException, aerr.Error())
case pricing.ErrCodeInvalidParameterException:
fmt.Println(pricing.ErrCodeInvalidParameterException, aerr.Error())
case pricing.ErrCodeNotFoundException:
fmt.Println(pricing.ErrCodeNotFoundException, aerr.Error())
case pricing.ErrCodeInvalidNextTokenException:
fmt.Println(pricing.ErrCodeInvalidNextTokenException, aerr.Error())
case pricing.ErrCodeExpiredNextTokenException:
fmt.Println(pricing.ErrCodeExpiredNextTokenException, 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)
}