func TestListDistributions(t *testing.T) {
	client := cloudfront.New(nil)
	resp, err := client.ListDistributions(nil)

	assert.Nil(t, err)
	assert.True(t, *resp.DistributionList.Quantity >= 0)
}
func TestCreateDistribution(t *testing.T) {
	client := cloudfront.New(nil)
	_, serr := client.CreateDistribution(&cloudfront.CreateDistributionInput{
		DistributionConfig: &cloudfront.DistributionConfig{
			CallerReference: aws.String("ID1"),
			Enabled:         aws.Boolean(true),
			Comment:         aws.String("A comment"),
			Origins:         &cloudfront.Origins{Quantity: aws.Long(0)},
			DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{
				ForwardedValues: &cloudfront.ForwardedValues{
					Cookies:     &cloudfront.CookiePreference{Forward: aws.String("cookie")},
					QueryString: aws.Boolean(true),
				},
				TargetOriginID: aws.String("origin"),
				TrustedSigners: &cloudfront.TrustedSigners{
					Enabled:  aws.Boolean(true),
					Quantity: aws.Long(0),
				},
				ViewerProtocolPolicy: aws.String("policy"),
				MinTTL:               aws.Long(0),
			},
		},
	})

	err := aws.Error(serr)
	assert.NotNil(t, err)
	assert.Equal(t, "MalformedXML", err.Code)
	assertMatches(t, "validation errors detected", err.Message)
}
Example #3
0
func ExampleCloudFront_CreateInvalidation() {
	svc := cloudfront.New(nil)

	params := &cloudfront.CreateInvalidationInput{
		DistributionID: aws.String("string"), // Required
		InvalidationBatch: &cloudfront.InvalidationBatch{ // Required
			CallerReference: aws.String("string"), // Required
			Paths: &cloudfront.Paths{ // Required
				Quantity: aws.Long(1), // Required
				Items: []*string{
					aws.String("string"), // Required
					// More values...
				},
			},
		},
	}
	resp, err := svc.CreateInvalidation(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #4
0
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.Boolean(true),    // Required
			S3Origin: &cloudfront.S3Origin{ // Required
				DomainName:           aws.String("string"), // Required
				OriginAccessIdentity: aws.String("string"), // Required
			},
			TrustedSigners: &cloudfront.TrustedSigners{ // Required
				Enabled:  aws.Boolean(true), // Required
				Quantity: aws.Long(1),       // Required
				Items: []*string{
					aws.String("string"), // Required
					// More values...
				},
			},
			Aliases: &cloudfront.Aliases{
				Quantity: aws.Long(1), // Required
				Items: []*string{
					aws.String("string"), // Required
					// More values...
				},
			},
			Logging: &cloudfront.StreamingLoggingConfig{
				Bucket:  aws.String("string"), // Required
				Enabled: aws.Boolean(true),    // Required
				Prefix:  aws.String("string"), // Required
			},
			PriceClass: aws.String("PriceClass"),
		},
		IfMatch: aws.String("string"),
	}
	resp, err := svc.UpdateStreamingDistribution(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #5
0
func ExampleCloudFront_GetStreamingDistributionConfig() {
	svc := cloudfront.New(nil)

	params := &cloudfront.GetStreamingDistributionConfigInput{
		ID: aws.String("string"), // Required
	}
	resp, err := svc.GetStreamingDistributionConfig(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #6
0
func ExampleCloudFront_ListStreamingDistributions() {
	svc := cloudfront.New(nil)

	params := &cloudfront.ListStreamingDistributionsInput{
		Marker:   aws.String("string"),
		MaxItems: aws.String("string"),
	}
	resp, err := svc.ListStreamingDistributions(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #7
0
func ExampleCloudFront_DeleteCloudFrontOriginAccessIdentity() {
	svc := cloudfront.New(nil)

	params := &cloudfront.DeleteCloudFrontOriginAccessIdentityInput{
		ID:      aws.String("string"), // Required
		IfMatch: aws.String("string"),
	}
	resp, err := svc.DeleteCloudFrontOriginAccessIdentity(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #8
0
func ExampleCloudFront_CreateCloudFrontOriginAccessIdentity() {
	svc := cloudfront.New(nil)

	params := &cloudfront.CreateCloudFrontOriginAccessIdentityInput{
		CloudFrontOriginAccessIdentityConfig: &cloudfront.CloudFrontOriginAccessIdentityConfig{ // Required
			CallerReference: aws.String("string"), // Required
			Comment:         aws.String("string"), // Required
		},
	}
	resp, err := svc.CreateCloudFrontOriginAccessIdentity(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
Example #9
0
func ExampleCloudFront_UpdateDistribution() {
	svc := cloudfront.New(nil)

	params := &cloudfront.UpdateDistributionInput{
		DistributionConfig: &cloudfront.DistributionConfig{ // Required
			CallerReference: aws.String("string"), // Required
			Comment:         aws.String("string"), // Required
			DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required
				ForwardedValues: &cloudfront.ForwardedValues{ // Required
					Cookies: &cloudfront.CookiePreference{ // Required
						Forward: aws.String("ItemSelection"), // Required
						WhitelistedNames: &cloudfront.CookieNames{
							Quantity: aws.Long(1), // Required
							Items: []*string{
								aws.String("string"), // Required
								// More values...
							},
						},
					},
					QueryString: aws.Boolean(true), // Required
					Headers: &cloudfront.Headers{
						Quantity: aws.Long(1), // Required
						Items: []*string{
							aws.String("string"), // Required
							// More values...
						},
					},
				},
				MinTTL:         aws.Long(1),          // Required
				TargetOriginID: aws.String("string"), // Required
				TrustedSigners: &cloudfront.TrustedSigners{ // Required
					Enabled:  aws.Boolean(true), // Required
					Quantity: aws.Long(1),       // Required
					Items: []*string{
						aws.String("string"), // Required
						// More values...
					},
				},
				ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required
				AllowedMethods: &cloudfront.AllowedMethods{
					Items: []*string{ // Required
						aws.String("Method"), // Required
						// More values...
					},
					Quantity: aws.Long(1), // Required
					CachedMethods: &cloudfront.CachedMethods{
						Items: []*string{ // Required
							aws.String("Method"), // Required
							// More values...
						},
						Quantity: aws.Long(1), // Required
					},
				},
				SmoothStreaming: aws.Boolean(true),
			},
			Enabled: aws.Boolean(true), // Required
			Origins: &cloudfront.Origins{ // Required
				Quantity: aws.Long(1), // Required
				Items: []*cloudfront.Origin{
					&cloudfront.Origin{ // Required
						DomainName: aws.String("string"), // Required
						ID:         aws.String("string"), // Required
						CustomOriginConfig: &cloudfront.CustomOriginConfig{
							HTTPPort:             aws.Long(1),                        // Required
							HTTPSPort:            aws.Long(1),                        // Required
							OriginProtocolPolicy: aws.String("OriginProtocolPolicy"), // Required
						},
						OriginPath: aws.String("string"),
						S3OriginConfig: &cloudfront.S3OriginConfig{
							OriginAccessIdentity: aws.String("string"), // Required
						},
					},
					// More values...
				},
			},
			Aliases: &cloudfront.Aliases{
				Quantity: aws.Long(1), // Required
				Items: []*string{
					aws.String("string"), // Required
					// More values...
				},
			},
			CacheBehaviors: &cloudfront.CacheBehaviors{
				Quantity: aws.Long(1), // Required
				Items: []*cloudfront.CacheBehavior{
					&cloudfront.CacheBehavior{ // Required
						ForwardedValues: &cloudfront.ForwardedValues{ // Required
							Cookies: &cloudfront.CookiePreference{ // Required
								Forward: aws.String("ItemSelection"), // Required
								WhitelistedNames: &cloudfront.CookieNames{
									Quantity: aws.Long(1), // Required
									Items: []*string{
										aws.String("string"), // Required
										// More values...
									},
								},
							},
							QueryString: aws.Boolean(true), // Required
							Headers: &cloudfront.Headers{
								Quantity: aws.Long(1), // Required
								Items: []*string{
									aws.String("string"), // Required
									// More values...
								},
							},
						},
						MinTTL:         aws.Long(1),          // Required
						PathPattern:    aws.String("string"), // Required
						TargetOriginID: aws.String("string"), // Required
						TrustedSigners: &cloudfront.TrustedSigners{ // Required
							Enabled:  aws.Boolean(true), // Required
							Quantity: aws.Long(1),       // Required
							Items: []*string{
								aws.String("string"), // Required
								// More values...
							},
						},
						ViewerProtocolPolicy: aws.String("ViewerProtocolPolicy"), // Required
						AllowedMethods: &cloudfront.AllowedMethods{
							Items: []*string{ // Required
								aws.String("Method"), // Required
								// More values...
							},
							Quantity: aws.Long(1), // Required
							CachedMethods: &cloudfront.CachedMethods{
								Items: []*string{ // Required
									aws.String("Method"), // Required
									// More values...
								},
								Quantity: aws.Long(1), // Required
							},
						},
						SmoothStreaming: aws.Boolean(true),
					},
					// More values...
				},
			},
			CustomErrorResponses: &cloudfront.CustomErrorResponses{
				Quantity: aws.Long(1), // Required
				Items: []*cloudfront.CustomErrorResponse{
					&cloudfront.CustomErrorResponse{ // Required
						ErrorCode:          aws.Long(1), // Required
						ErrorCachingMinTTL: aws.Long(1),
						ResponseCode:       aws.String("string"),
						ResponsePagePath:   aws.String("string"),
					},
					// More values...
				},
			},
			DefaultRootObject: aws.String("string"),
			Logging: &cloudfront.LoggingConfig{
				Bucket:         aws.String("string"), // Required
				Enabled:        aws.Boolean(true),    // Required
				IncludeCookies: aws.Boolean(true),    // Required
				Prefix:         aws.String("string"), // Required
			},
			PriceClass: aws.String("PriceClass"),
			Restrictions: &cloudfront.Restrictions{
				GeoRestriction: &cloudfront.GeoRestriction{ // Required
					Quantity:        aws.Long(1),                      // Required
					RestrictionType: aws.String("GeoRestrictionType"), // Required
					Items: []*string{
						aws.String("string"), // Required
						// More values...
					},
				},
			},
			ViewerCertificate: &cloudfront.ViewerCertificate{
				CloudFrontDefaultCertificate: aws.Boolean(true),
				IAMCertificateID:             aws.String("string"),
				MinimumProtocolVersion:       aws.String("MinimumProtocolVersion"),
				SSLSupportMethod:             aws.String("SSLSupportMethod"),
			},
		},
		ID:      aws.String("string"), // Required
		IfMatch: aws.String("string"),
	}
	resp, err := svc.UpdateDistribution(params)

	if awserr := aws.Error(err); awserr != nil {
		// A service error occurred.
		fmt.Println("Error:", awserr.Code, awserr.Message)
	} else if err != nil {
		// A non-service error occurred.
		panic(err)
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}