AwsEndpoint Class

(QtAws::Core::AwsEndpoint)

The AwsEndpoint class provides information about AWS endpoints. More...

Header: #include <AwsEndpoint>

Public Types

enum Transport { HTTP, HTTPS, SMTP, AnyTransport }
flags Transports

Public Functions

AwsEndpoint(const QByteArray &hostName)
AwsEndpoint(const QString &hostName)
~AwsEndpoint()
QString fullServiceName() const
QString hostName() const
bool isSupported(const Transport transport) const
bool isValid() const
QString regionName() const
QString serviceName() const
QStringList supportedRegions(const Transports transport = AnyTransport) const

Static Public Members

QString fullServiceName(const QString &serviceName)
QUrl getEndpoint(const QString &regionName, const QString &serviceName, const Transports transport = AnyTransport)
bool isSupported(const QString &regionName, const QString &serviceName, const Transports transport = AnyTransport)
QStringList supportedRegions(const QString &serviceName, const Transports transport = AnyTransport)
QStringList supportedServices(const QString &regionName, const Transports transport = AnyTransport)

Detailed Description

The AwsEndpoint class provides information about AWS endpoints.

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 QtAws 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 QtAws::Core::AwsRegion.

Member Type Documentation

enum AwsEndpoint::Transport
flags AwsEndpoint::Transports

This enum describes types of network transports supported by AWS endpoints.

ConstantValueDescription
QtAws::Core::AwsEndpoint::HTTP0x01Hypertext Transfer Protocol.
QtAws::Core::AwsEndpoint::HTTPS0x02Hypertext Transfer Protocol with transport layer security.
QtAws::Core::AwsEndpoint::SMTP0x04Simple Mail Transfer Protocol.
QtAws::Core::AwsEndpoint::AnyTransportHTTP | HTTPS | SMTPAny available transport.

Not all transports are supported by all endpoints. See isSupported for example.

The Transports type is a typedef for QFlags<Transport>. It stores an OR combination of Transport values.

Member Function Documentation

AwsEndpoint::AwsEndpoint(const QByteArray &hostName)

Constructs an AwsEndpoint object for a UTF-8 encoded AWS hostName.

AwsEndpoint::AwsEndpoint(const QString &hostName)

Constructs an AwsEndpoint object for AWS hostName.

AwsEndpoint::~AwsEndpoint()

Destroys the AWS endpoint.

QString AwsEndpoint::fullServiceName() const

Returns the 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`.

See also serviceName.

[static] QString AwsEndpoint::fullServiceName(const QString &serviceName)

Returns the full service name for the given serviceName.

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`.

See also serviceName.

[static] QUrl AwsEndpoint::getEndpoint(const QString &regionName, const QString &serviceName, const Transports transport = AnyTransport)

Returns the endpoint QUrl for AWS service serviceName in region regionName, or an invalid QUrl if there is no such 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 used 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 returned 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"

QString AwsEndpoint::hostName() const

Returns the name of the host represented by this endpoint.

[static] bool AwsEndpoint::isSupported(const QString &regionName, const QString &serviceName, const Transports transport = AnyTransport)

Returns true if the given regionName, serviceName, and transport combination supported by AWS; false otherwise.

bool AwsEndpoint::isSupported(const Transport transport) const

Returns true if the given transport is supported by this endpoint; false otherwise.

bool AwsEndpoint::isValid() const

Returns true is this endpoint is valid; false otherwise.

The 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.

QString AwsEndpoint::regionName() const

Returns the 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.

See also supportedRegions.

QString AwsEndpoint::serviceName() const

Returns the endpoint's service name.

See also fullServiceName.

QStringList AwsEndpoint::supportedRegions(const Transports transport = AnyTransport) const

Returns a list of regions the endpoint supports for at least one of the the given transports.

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

[static] QStringList AwsEndpoint::supportedRegions(const QString &serviceName, const Transports transport = AnyTransport)

Returns a list serviceName regions that support at least one of the the given transports.

[static] QStringList AwsEndpoint::supportedServices(const QString &regionName, const Transports transport = AnyTransport)

Returns a list regionName services that support at least one of the the given transports.

© 2018 Paul Colby Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.