libqtaws  0.1.0
UnofficialAWSlibraryforQt
Public Types | Public Member Functions | Static Public Member Functions | List of all members
AwsEndpoint Class Reference

Provides AWS endpoint information. More...

Public Types

enum  Transport { HTTP = 0x01, HTTPS = 0x02, SMTP = 0x04, AnyTransport = HTTP|HTTPS|SMTP }
 Network transport supported by one or more AWS endpoints.
 

Public Member Functions

 AwsEndpoint (const QByteArray &hostName)
 Constructs a new AwsEndpoint object. More...
 
 AwsEndpoint (const QString &hostName)
 Constructs a new AwsEndpoint object. More...
 
 ~AwsEndpoint ()
 AwsEndpoint destructor.
 
bool isSupported (const Transport transport) const
 Is the given transport supported by this endpoint? More...
 
bool isValid () const
 Is this endpoint valid? More...
 
QString fullServiceName () const
 Get this endpoint's full service name. More...
 
QString hostName () const
 Get the name of host represented by this endpoint. More...
 
QString regionName () const
 Get this endpoint's primary region name. More...
 
QString serviceName () const
 Get this endpoint's service name. More...
 
QStringList supportedRegions (const Transports transport=AnyTransport) const
 Get the full list of regions this endpoint supports. More...
 

Static Public Member Functions

static QUrl getEndpoint (const QString &regionName, const QString &serviceName, const Transports transport=AnyTransport)
 Get a QUrl for an AWS endpoint. More...
 
static bool isSupported (const QString &regionName, const QString &serviceName, const Transports transport=AnyTransport)
 Is a region / service / transport combination supported by Amazon? More...
 
static QString fullServiceName (const QString &serviceName)
 Get the full name for given service. More...
 
static QStringList supportedRegions (const QString &serviceName, const Transports transport=AnyTransport)
 Get a list of regions that supported for a given service. More...
 
static QStringList supportedServices (const QString &regionName, const Transports transport=AnyTransport)
 Get a list of services that support a given region. More...
 

Detailed Description

Provides AWS endpoint information.

Note
This class provides fairly low-level access to AWS endpoint data. You should consider using the AwsRegion and/or various AwsService-derived classes in preference to using this class directly where possible.

This class parses the endpoint.xml data available at http://aws-sdk-configurations.amazonwebservices.com/endpoints.xml

The endpoint.xml file is embedded as a resource in the libqtaws library - not fetched remotely at runtime.

Example usage:

AwsEndpoint endpoint(QLatin1String("cloudformation.us-east-1.amazonaws.com"));
endpoint.hostName(); // "cloudformation.us-east-1.amazonaws.com"
endpoint.regionName(); // "us-east-1"
endpoint.serviceName(); // "cloudformation"
endpoint.supportedRegions(); // [ "us-east-1" ]
endpoint.isSupported(AwsEndpoint::HTTP); // false
endpoint.isSupported(AwsEndpoint::HTTPS); // true
QUrl ec2 = AwsEndpoint::getEndpoint("ap-southeast-2", "ec2");
QUrl iam = AwsEndpoint::getEndpoint("ap-southeast-2", "iam");
ec2.host(); // "ec2.ap-southeast-2.amazonaws.com"
iam.host(); // "iam.amazonaws.com"
See also
AwsRegion
AwsService

Constructor & Destructor Documentation

AwsEndpoint::AwsEndpoint ( const QByteArray &  hostName)

Constructs a new AwsEndpoint object.

Parameters
hostNameName of an AWS host, encoded as UTF-8.
AwsEndpoint::AwsEndpoint ( const QString &  hostName)

Constructs a new AwsEndpoint object.

Parameters
hostNameName of an AWS host.

Member Function Documentation

QString AwsEndpoint::fullServiceName ( ) const

Get this endpoint's full service name.

The full service name is a human-readbale form. For example, the full name for the cloudsearch service is Amazon CloudSearch. Likewise, the full name for the rds service is Amazon Relational Database Service.

Returns
This endpoint's full service name.
See also
serviceName
QString AwsEndpoint::fullServiceName ( const QString &  serviceName)
static

Get the full name for given service.

The full service name is a human-readbale form. For example, the full name for the cloudsearch service is Amazon CloudSearch. Likewise, the full name for the rds service is Amazon Relational Database Service.

Parameters
serviceNameCanonical AWS service name to get the full name of.
Returns
This endpoint's full service name.
See also
serviceName
QUrl AwsEndpoint::getEndpoint ( const QString &  regionName,
const QString &  serviceName,
const Transports  transport = AnyTransport 
)
static

Get a QUrl for an AWS endpoint.

This function will return a QUrl object for accessing an AWS service. The region and service names must match those used by Amazon.

If the specified region and/or service are not known to be valid for AWS, or the service is not supported in the specified region, then an invalid QUrl will be returned.

Note
An invalid QUrl is one for which QUrl::isValid returns false.

The transport parameter may be used to specify one or more transports to consider. If the specified AWS endpoint exists, but does not support //any// of the given transports, then an invalid QUrl is returned.

Where it makes sense to do so, the resulting QUrl's scheme will be set according to the requested transport. For example, if the selected transport is AwsEndpoint::HTTPS, then the resulting QUrl's schems will be set to "https".

If transport includes both AwsEndpoint::HTTP //and// AwsEndpoint::HTTPS, and both are supported by the AWS endpoint, then "https" will be chosed in preference to "http".

Note
It is possible for the returned QUrl to specify a host that is not located in, nor dedicated to the specified region. For examepl, if requesting an endpoint for the iam service in ap-southeast-2, the return endpoint is for a host (iam.amazonaws.com) which provides the ami services for all regions, not just ap-southeast-2. Services known to behave like this include: cloudfront, iam, importexport, route53, and sts.

Example usage:

QUrl ec2 = AwsEndpoint::getEndpoint("ap-southeast-2", "ec2");
QUrl iam = AwsEndpoint::getEndpoint("ap-southeast-2", "iam");
ec2.host(); // "ec2.ap-southeast-2.amazonaws.com"
iam.host(); // "iam.amazonaws.com"
Parameters
regionNameEndpoint's region name.
serviceNameEndpoint's service name.
transportOptional network transport(s) for the endpoint.
Returns
A QUrl representing the AWS endpoint, or an invalid QUrl if there is no such known AWS endpoint.
Todo:
Handle SMTP here?
QString AwsEndpoint::hostName ( ) const

Get the name of host represented by this endpoint.

Returns
Name of host represented by this endpoint.
bool AwsEndpoint::isSupported ( const QString &  regionName,
const QString &  serviceName,
const Transports  transport = AnyTransport 
)
static

Is a region / service / transport combination supported by Amazon?

Parameters
regionNameAWS region name to check support for.
serviceNameAWS service name to check support for.
transportOptional transport to check support for.
Returns
true if the service is supported in the regionName region for at least one of the specified transports, false otherwise.
bool AwsEndpoint::isSupported ( const Transport  transport) const

Is the given transport supported by this endpoint?

Parameters
transportTransport to check for support for.
Returns
true if the transport is supported by this endpoint, false otherwise.
bool AwsEndpoint::isValid ( ) const

Is this endpoint valid?

An endpoint is considered valid if the host specified during construction is a known AWS host, and thus we know what region and service(s) it supports.

For example:

AwsEndpoint good(QLatin1String("cloudformation.us-east-1.amazonaws.com"));
AwsEndpoint bad(QLatin1String("example.com"));
Q_ASSERT(good.isValid()); // good is valid.
Q_ASSERT(!bad.isValid()); // bad is not.
Returns
true if this endpoint is valid, false otherwise.
QString AwsEndpoint::regionName ( ) const

Get this endpoint's primary region name.

It is possible for a single endpiont to support multuple regions, such as iam.amazonaws.com, which provides the ami servive for all (non-government) regions.

In these cases, this function returns the primary region in which the service is located. The AwsEndpoint::supportedRegions function may be used to fetch the full list of regions this endpoint supports.

Returns
This endpoint's region name.
See also
supportedRegions
QString AwsEndpoint::serviceName ( ) const

Get this endpoint's service name.

Returns
This endpoint's service name.
See also
fullServiceName
QStringList AwsEndpoint::supportedRegions ( const Transports  transport = AnyTransport) const

Get the full list of regions this endpoint supports.

Alternatvely, AwsEndpoint::regionName may be used to get this endpoint's primary region.

Parameters
transportOptional transport to check for support.
Returns
A list of all regions this endpoint supports for //at least one// of the specified transports.
See also
regionName
QStringList AwsEndpoint::supportedRegions ( const QString &  serviceName,
const Transports  transport = AnyTransport 
)
static

Get a list of regions that supported for a given service.

Parameters
serviceNameAWS service to get the supported regions for.
transportOptional transport(s) to check for support.
Returns
A list of AWS regions supported for the given service, for at least one of the specified transports.
QStringList AwsEndpoint::supportedServices ( const QString &  regionName,
const Transports  transport = AnyTransport 
)
static

Get a list of services that support a given region.

Parameters
regionNameAWS region to get the supported services for.
transportOptional transport(s) to check for support.
Returns
A list of AWS services supported for the given region, for at least one of the specified transports.

The documentation for this class was generated from the following files: