本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/cloudfront.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleCloudFront_DeleteStreamingDistribution
func ExampleCloudFront_DeleteStreamingDistribution() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudfront.New(sess)
params := &cloudfront.DeleteStreamingDistributionInput{
Id: aws.String("string"), // Required
IfMatch: aws.String("string"),
}
resp, err := svc.DeleteStreamingDistribution(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例2: ExampleCloudFront_ListInvalidations
func ExampleCloudFront_ListInvalidations() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudfront.New(sess)
params := &cloudfront.ListInvalidationsInput{
DistributionId: aws.String("string"), // Required
Marker: aws.String("string"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListInvalidations(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例3: ExampleCloudFront_ListStreamingDistributions
func ExampleCloudFront_ListStreamingDistributions() {
svc := cloudfront.New(nil)
params := &cloudfront.ListStreamingDistributionsInput{
Marker: aws.String("string"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListStreamingDistributions(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例4: ExampleCloudFront_CreateCloudFrontOriginAccessIdentity
func ExampleCloudFront_CreateCloudFrontOriginAccessIdentity() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudfront.New(sess)
params := &cloudfront.CreateCloudFrontOriginAccessIdentityInput{
CloudFrontOriginAccessIdentityConfig: &cloudfront.OriginAccessIdentityConfig{ // Required
CallerReference: aws.String("string"), // Required
Comment: aws.String("string"), // Required
},
}
resp, err := svc.CreateCloudFrontOriginAccessIdentity(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例5: ExampleCloudFront_UntagResource
func ExampleCloudFront_UntagResource() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudfront.New(sess)
params := &cloudfront.UntagResourceInput{
Resource: aws.String("ResourceARN"), // Required
TagKeys: &cloudfront.TagKeys{ // Required
Items: []*string{
aws.String("TagKey"), // Required
// More values...
},
},
}
resp, err := svc.UntagResource(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例6: ExampleCloudFront_UpdateCloudFrontOriginAccessIdentity
func ExampleCloudFront_UpdateCloudFrontOriginAccessIdentity() {
svc := cloudfront.New(nil)
params := &cloudfront.UpdateCloudFrontOriginAccessIdentityInput{
CloudFrontOriginAccessIdentityConfig: &cloudfront.OriginAccessIdentityConfig{ // Required
CallerReference: aws.String("string"), // Required
Comment: aws.String("string"), // Required
},
Id: aws.String("string"), // Required
IfMatch: aws.String("string"),
}
resp, err := svc.UpdateCloudFrontOriginAccessIdentity(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例7: ExampleCloudFront_CreateInvalidation
func ExampleCloudFront_CreateInvalidation() {
svc := cloudfront.New(session.New())
params := &cloudfront.CreateInvalidationInput{
DistributionId: aws.String("string"), // Required
InvalidationBatch: &cloudfront.InvalidationBatch{ // Required
CallerReference: aws.String("string"), // Required
Paths: &cloudfront.Paths{ // Required
Quantity: aws.Int64(1), // Required
Items: []*string{
aws.String("string"), // Required
// More values...
},
},
},
}
resp, err := svc.CreateInvalidation(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例8: ExampleCloudFront_GetInvalidation
func ExampleCloudFront_GetInvalidation() {
svc := cloudfront.New(nil)
params := &cloudfront.GetInvalidationInput{
DistributionID: aws.String("string"), // Required
ID: aws.String("string"), // Required
}
resp, err := svc.GetInvalidation(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例9: ExampleCloudFront_UpdateStreamingDistribution
func ExampleCloudFront_UpdateStreamingDistribution() {
svc := cloudfront.New(nil)
params := &cloudfront.UpdateStreamingDistributionInput{
Id: aws.String("string"), // Required
StreamingDistributionConfig: &cloudfront.StreamingDistributionConfig{ // Required
CallerReference: aws.String("string"), // Required
Comment: aws.String("string"), // Required
Enabled: aws.Bool(true), // Required
S3Origin: &cloudfront.S3Origin{ // Required
DomainName: aws.String("string"), // Required
OriginAccessIdentity: aws.String("string"), // Required
},
TrustedSigners: &cloudfront.TrustedSigners{ // Required
Enabled: aws.Bool(true), // Required
Quantity: aws.Int64(1), // Required
Items: []*string{
aws.String("string"), // Required
// More values...
},
},
Aliases: &cloudfront.Aliases{
Quantity: aws.Int64(1), // Required
Items: []*string{
aws.String("string"), // Required
// More values...
},
},
Logging: &cloudfront.StreamingLoggingConfig{
Bucket: aws.String("string"), // Required
Enabled: aws.Bool(true), // Required
Prefix: aws.String("string"), // Required
},
PriceClass: aws.String("PriceClass"),
},
IfMatch: aws.String("string"),
}
resp, err := svc.UpdateStreamingDistribution(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例10: ExampleCloudFront_UpdateStreamingDistribution
func ExampleCloudFront_UpdateStreamingDistribution() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := cloudfront.New(sess)
params := &cloudfront.UpdateStreamingDistributionInput{
Id: aws.String("string"), // Required
StreamingDistributionConfig: &cloudfront.StreamingDistributionConfig{ // Required
CallerReference: aws.String("string"), // Required
Comment: aws.String("string"), // Required
Enabled: aws.Bool(true), // Required
S3Origin: &cloudfront.S3Origin{ // Required
DomainName: aws.String("string"), // Required
OriginAccessIdentity: aws.String("string"), // Required
},
TrustedSigners: &cloudfront.TrustedSigners{ // Required
Enabled: aws.Bool(true), // Required
Quantity: aws.Int64(1), // Required
Items: []*string{
aws.String("string"), // Required
// More values...
},
},
Aliases: &cloudfront.Aliases{
Quantity: aws.Int64(1), // Required
Items: []*string{
aws.String("string"), // Required
// More values...
},
},
Logging: &cloudfront.StreamingLoggingConfig{
Bucket: aws.String("string"), // Required
Enabled: aws.Bool(true), // Required
Prefix: aws.String("string"), // Required
},
PriceClass: aws.String("PriceClass"),
},
IfMatch: aws.String("string"),
}
resp, err := svc.UpdateStreamingDistribution(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例11: NewAWS
func NewAWS(p *Plugin) AWS {
sess := session.New(&aws.Config{
Credentials: credentials.NewStaticCredentials(p.Key, p.Secret, ""),
Region: aws.String(p.Region),
})
c := s3.New(sess)
cf := cloudfront.New(sess)
r := make([]string, 1, 1)
l := make([]string, 1, 1)
return AWS{c, cf, r, l, p}
}
示例12: ExampleCloudFront_GetCloudFrontOriginAccessIdentity
func ExampleCloudFront_GetCloudFrontOriginAccessIdentity() {
svc := cloudfront.New(nil)
params := &cloudfront.GetCloudFrontOriginAccessIdentityInput{
Id: aws.String("string"), // Required
}
resp, err := svc.GetCloudFrontOriginAccessIdentity(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例13: ExampleCloudFront_GetStreamingDistributionConfig
func ExampleCloudFront_GetStreamingDistributionConfig() {
svc := cloudfront.New(session.New())
params := &cloudfront.GetStreamingDistributionConfigInput{
Id: aws.String("string"), // Required
}
resp, err := svc.GetStreamingDistributionConfig(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例14: ExampleCloudFront_ListStreamingDistributions
func ExampleCloudFront_ListStreamingDistributions() {
svc := cloudfront.New(session.New())
params := &cloudfront.ListStreamingDistributionsInput{
Marker: aws.String("string"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListStreamingDistributions(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例15: ExampleCloudFront_ListDistributionsByWebACLId
func ExampleCloudFront_ListDistributionsByWebACLId() {
svc := cloudfront.New(nil)
params := &cloudfront.ListDistributionsByWebACLIdInput{
WebACLId: aws.String("string"), // Required
Marker: aws.String("string"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListDistributionsByWebACLId(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}