Blame vendor/github.com/aws/aws-sdk-go/aws/endpoints/doc.go

Packit 63bb0d
// Package endpoints provides the types and functionality for defining regions
Packit 63bb0d
// and endpoints, as well as querying those definitions.
Packit 63bb0d
//
Packit 63bb0d
// The SDK's Regions and Endpoints metadata is code generated into the endpoints
Packit 63bb0d
// package, and is accessible via the DefaultResolver function. This function
Packit 63bb0d
// returns a endpoint Resolver will search the metadata and build an associated
Packit 63bb0d
// endpoint if one is found. The default resolver will search all partitions
Packit 63bb0d
// known by the SDK. e.g AWS Standard (aws), AWS China (aws-cn), and
Packit 63bb0d
// AWS GovCloud (US) (aws-us-gov).
Packit 63bb0d
// .
Packit 63bb0d
//
Packit 63bb0d
// Enumerating Regions and Endpoint Metadata
Packit 63bb0d
//
Packit 63bb0d
// Casting the Resolver returned by DefaultResolver to a EnumPartitions interface
Packit 63bb0d
// will allow you to get access to the list of underlying Partitions with the
Packit 63bb0d
// Partitions method. This is helpful if you want to limit the SDK's endpoint
Packit 63bb0d
// resolving to a single partition, or enumerate regions, services, and endpoints
Packit 63bb0d
// in the partition.
Packit 63bb0d
//
Packit 63bb0d
//     resolver := endpoints.DefaultResolver()
Packit 63bb0d
//     partitions := resolver.(endpoints.EnumPartitions).Partitions()
Packit 63bb0d
//
Packit 63bb0d
//     for _, p := range partitions {
Packit 63bb0d
//         fmt.Println("Regions for", p.ID())
Packit 63bb0d
//         for id, _ := range p.Regions() {
Packit 63bb0d
//             fmt.Println("*", id)
Packit 63bb0d
//         }
Packit 63bb0d
//
Packit 63bb0d
//         fmt.Println("Services for", p.ID())
Packit 63bb0d
//         for id, _ := range p.Services() {
Packit 63bb0d
//             fmt.Println("*", id)
Packit 63bb0d
//         }
Packit 63bb0d
//     }
Packit 63bb0d
//
Packit 63bb0d
// Using Custom Endpoints
Packit 63bb0d
//
Packit 63bb0d
// The endpoints package also gives you the ability to use your own logic how
Packit 63bb0d
// endpoints are resolved. This is a great way to define a custom endpoint
Packit 63bb0d
// for select services, without passing that logic down through your code.
Packit 63bb0d
//
Packit 63bb0d
// If a type implements the Resolver interface it can be used to resolve
Packit 63bb0d
// endpoints. To use this with the SDK's Session and Config set the value
Packit 63bb0d
// of the type to the EndpointsResolver field of aws.Config when initializing
Packit 63bb0d
// the session, or service client.
Packit 63bb0d
//
Packit 63bb0d
// In addition the ResolverFunc is a wrapper for a func matching the signature
Packit 63bb0d
// of Resolver.EndpointFor, converting it to a type that satisfies the
Packit 63bb0d
// Resolver interface.
Packit 63bb0d
//
Packit 63bb0d
//
Packit 63bb0d
//     myCustomResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
Packit 63bb0d
//         if service == endpoints.S3ServiceID {
Packit 63bb0d
//             return endpoints.ResolvedEndpoint{
Packit 63bb0d
//                 URL:           "s3.custom.endpoint.com",
Packit 63bb0d
//                 SigningRegion: "custom-signing-region",
Packit 63bb0d
//             }, nil
Packit 63bb0d
//         }
Packit 63bb0d
//
Packit 63bb0d
//         return endpoints.DefaultResolver().EndpointFor(service, region, optFns...)
Packit 63bb0d
//     }
Packit 63bb0d
//
Packit 63bb0d
//     sess := session.Must(session.NewSession(&aws.Config{
Packit 63bb0d
//         Region:           aws.String("us-west-2"),
Packit 63bb0d
//         EndpointResolver: endpoints.ResolverFunc(myCustomResolver),
Packit 63bb0d
//     }))
Packit 63bb0d
package endpoints