libqtaws  0.1.0
UnofficialAWSlibraryforQt-InternalDocumentation
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
AwsRegion Class Reference

Provides AWS region information. More...

Collaboration diagram for AwsRegion:
Collaboration graph
[legend]

Public Types

enum  CardinalDirection {
  North = 0x00, NorthNorthEast = 0x10, NorthEast = 0x20, EastNorthEast = 0x30,
  East = 0x40, EastSouthEast = 0x50, SouthEast = 0x60, SouthSouthEast = 0x70,
  South = 0x80, SouthSouthWest = 0x90, SouthWest = 0xA0, WestSouthWest = 0xB0,
  West = 0xC0, WestNorthWest = 0xD0, NorthWest = 0xE0, NortNorthWest = 0xF0
}
 
enum  MacroRegion {
  AsiaPacific = 0x100, Europe = 0x300, SouthAmerica = 0xA00, UnitedStates = 0xB00,
  UnitedStatesGov = 0xC00
}
 AWS macro-regions.
 
enum  Region {
  InvalidRegion = 0, AP_Northeast_1 = AsiaPacific + NorthEast + 0x1, AP_Southeast_1 = AsiaPacific + SouthEast + 0x1, AP_Southeast_2 = AsiaPacific + SouthEast + 0x2,
  EU_West_1 = Europe + West + 0x1, SA_East_1 = SouthAmerica + East + 0x1, US_East_1 = UnitedStates + East + 0x1, US_Gov_West_1 = UnitedStatesGov + West + 0x1,
  US_West_1 = UnitedStates + West + 0x1, US_West_2 = UnitedStates + West + 0x2
}
 AWS regions.
 

Public Member Functions

 AwsRegion (const Region region)
 Constructs a new AwsRegion object. More...
 
 AwsRegion (const QString &regionName)
 Constructs a new AwsRegion object. More...
 
 ~AwsRegion ()
 AwsRegion destructor.
 
bool isValid () const
 Is this AWS region object valid? More...
 
Region region () const
 Get the region this object represents. More...
 
QString name () const
 Get the canonical AWS name for this region. More...
 
QString fullName () const
 Get the full name for this region. More...
 
QString hostName (const QString &serviceName) const
 Get name of the host the supports a given service for this region. More...
 
bool isSupported (const QString &serviceName, const AwsEndpoint::Transports transports=AwsEndpoint::AnyTransport) const
 Is a given service supported for this region? More...
 
QStringList supportedServices (const AwsEndpoint::Transports transports=AwsEndpoint::AnyTransport) const
 Get a list of services supported by this region. More...
 

Static Public Member Functions

static QString name (const Region &region)
 Get the canonical AWS name for a region. More...
 
static QString fullName (const Region &region)
 Get the full name for an AWS region. More...
 
static Region fromName (const QString &regionName)
 Get an AwsRegion::Region enumeration value from a region name. More...
 

Private Attributes

AwsRegionPrivate *const d_ptr
 Internal d-pointer.
 

Friends

class TestAwsRegion
 

Detailed Description

Provides AWS region information.

Basic usage example:

const AwsRegion region(AwsRegion::AP_Northeast_1);
region.name(); // "ap-northeast-1"
region.fullName(); // "Asia Pacific (Tokyo) Region"
region.hostName("iam"); // "iam.amazonaws.com"
See also
http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html

Definition at line 33 of file awsregion.h.

Member Enumeration Documentation

Bit flags representing the possible cardinal directions of AWS regions within macro-regions.

Definition at line 38 of file awsregion.h.

38  {
39  North = 0x00,
40  NorthNorthEast = 0x10,
41  NorthEast = 0x20,
42  EastNorthEast = 0x30,
43  East = 0x40,
44  EastSouthEast = 0x50,
45  SouthEast = 0x60,
46  SouthSouthEast = 0x70,
47  South = 0x80,
48  SouthSouthWest = 0x90,
49  SouthWest = 0xA0,
50  WestSouthWest = 0xB0,
51  West = 0xC0,
52  WestNorthWest = 0xD0,
53  NorthWest = 0xE0,
54  NortNorthWest = 0xF0
55  };

Constructor & Destructor Documentation

AwsRegion::AwsRegion ( const Region  region)

Constructs a new AwsRegion object.

Parameters
regionAWS region for this object to represent.

Definition at line 48 of file awsregion.cpp.

References region().

48  : d_ptr(new AwsRegionPrivate(this))
49 {
50  Q_D(AwsRegion);
51  d->region = region;
52 }
Private implementation for AwsRegion.
Definition: awsregion_p.h:29
Region region() const
Get the region this object represents.
Definition: awsregion.cpp:90
Provides AWS region information.
Definition: awsregion.h:33
AwsRegionPrivate *const d_ptr
Internal d-pointer.
Definition: awsregion.h:105
AwsRegion::AwsRegion ( const QString &  regionName)

Constructs a new AwsRegion object.

If regionName is not recognised as a valid AWS region, AwsRegion::isValid will return false for the created object.

Parameters
regionNameName of the AWS region for this object to represent.

Definition at line 62 of file awsregion.cpp.

References fromName().

62  : d_ptr(new AwsRegionPrivate(this))
63 {
64  Q_D(AwsRegion);
65  d->region = fromName(regionName);
66 }
Private implementation for AwsRegion.
Definition: awsregion_p.h:29
Provides AWS region information.
Definition: awsregion.h:33
AwsRegionPrivate *const d_ptr
Internal d-pointer.
Definition: awsregion.h:105
static Region fromName(const QString &regionName)
Get an AwsRegion::Region enumeration value from a region name.
Definition: awsregion.cpp:260

Member Function Documentation

AwsRegion::Region AwsRegion::fromName ( const QString &  regionName)
static

Get an AwsRegion::Region enumeration value from a region name.

Note
The region name is evaluated in a case-insensitve manner.
Parameters
regionNameAWS region name to get an enumeration value for.
Returns
An AwsRegion::Region enumeration value corresponding to the specified AWS region name, or AwsRegion::InvalidRegion if the region name is not valid or not recognised.

Definition at line 260 of file awsregion.cpp.

Referenced by AwsRegion().

261 {
262  const QString lowerName(regionName.toLower());
263  if (lowerName == QLatin1String("ap-northeast-1")) return AP_Northeast_1;
264  if (lowerName == QLatin1String("ap-southeast-1")) return AP_Southeast_1;
265  if (lowerName == QLatin1String("ap-southeast-2")) return AP_Southeast_2;
266  if (lowerName == QLatin1String("eu-west-1")) return EU_West_1;
267  if (lowerName == QLatin1String("sa-east-1")) return SA_East_1;
268  if (lowerName == QLatin1String("us-east-1")) return US_East_1;
269  if (lowerName == QLatin1String("us-gov-west-1")) return US_Gov_West_1;
270  if (lowerName == QLatin1String("us-west-1")) return US_West_1;
271  if (lowerName == QLatin1String("us-west-2")) return US_West_2;
272  Q_ASSERT_X(false, Q_FUNC_INFO, qPrintable(QString::fromLatin1("invalid region name: %1").arg(regionName)));
273  return InvalidRegion;
274 }
QString AwsRegion::fullName ( ) const

Get the full name for this region.

This returns a humand-readable name for this object's region. For example, for the AwsRegion::US_East_1 region, this will return something like "US East (Northern Virginia) Region".

These full names were gleaned from http://aws.amazon.com/about-aws/globalinfrastructure/ and http://docs.aws.amazon.com/general/latest/gr/rande.html.

Returns
The full name for this region.
See also
http://aws.amazon.com/about-aws/globalinfrastructure/
http://docs.aws.amazon.com/general/latest/gr/rande.html

Definition at line 167 of file awsregion.cpp.

References region().

168 {
169  return fullName(region());
170 }
QString fullName() const
Get the full name for this region.
Definition: awsregion.cpp:167
Region region() const
Get the region this object represents.
Definition: awsregion.cpp:90
QString AwsRegion::fullName ( const Region region)
static

Get the full name for an AWS region.

This returns a humand-readable name for the specified AWS region. For example, for the AwsRegion::US_East_1 region, this will return something like "US East (Northern Virginia) Region".

These full names were gleaned from http://aws.amazon.com/about-aws/globalinfrastructure/ and http://docs.aws.amazon.com/general/latest/gr/rande.html.

Parameters
regionAWS region to get the full name of.
Returns
The full name for the specified AWS region.
See also
http://aws.amazon.com/about-aws/globalinfrastructure/
http://docs.aws.amazon.com/general/latest/gr/rande.html

Definition at line 190 of file awsregion.cpp.

191 {
192  switch (region) {
193  case AP_Northeast_1: return QLatin1String("Asia Pacific (Tokyo) Region");
194  case AP_Southeast_1: return QLatin1String("Asia Pacific (Singapore) Region");
195  case AP_Southeast_2: return QLatin1String("Asia Pacific (Sydney) Region");
196  case EU_West_1: return QLatin1String("EU (Ireland) Region");
197  case SA_East_1: return QLatin1String("São Paulo Region");
198  case US_East_1: return QLatin1String("US East (Northern Virginia) Region");
199  case US_Gov_West_1: return QLatin1String("AWS GovCloud (US) Region");
200  case US_West_1: return QLatin1String("US West (Northern California) Region");
201  case US_West_2: return QLatin1String("US West (Oregon) Region");
202  default:
203  Q_ASSERT_X(false, Q_FUNC_INFO, qPrintable(QString::fromLatin1("invalid region: %1").arg(region)));
204  }
205  return QString();
206 }
Region region() const
Get the region this object represents.
Definition: awsregion.cpp:90
QString AwsRegion::hostName ( const QString &  serviceName) const

Get name of the host the supports a given service for this region.

Parameters
serviceNameThe service to get the hostname for.
Returns
The name of the host that supports the given service for this region, or a null string if the this service is not supported for this region.

Definition at line 216 of file awsregion.cpp.

References AwsEndpoint::getEndpoint(), and name().

217 {
218  return AwsEndpoint::getEndpoint(name(), serviceName).host();
219 }
QString name() const
Get the canonical AWS name for this region.
Definition: awsregion.cpp:120
static QUrl getEndpoint(const QString &regionName, const QString &serviceName, const Transports transport=AnyTransport)
Get a QUrl for an AWS endpoint.
bool AwsRegion::isSupported ( const QString &  serviceName,
const AwsEndpoint::Transports  transports = AwsEndpoint::AnyTransport 
) const

Is a given service supported for this region?

Parameters
serviceNameThe service to check support for.
transportsAn optional set of transports to test for support.
Returns
The name of the host that supports the given service for this region for at least one of the specified transports, or a null string if the this service is not supported for this region with any such transports.

Definition at line 231 of file awsregion.cpp.

References AwsEndpoint::isSupported(), and name().

232 {
233  return AwsEndpoint::isSupported(name(), serviceName, transports);
234 }
QString name() const
Get the canonical AWS name for this region.
Definition: awsregion.cpp:120
static bool isSupported(const QString &regionName, const QString &serviceName, const Transports transport=AnyTransport)
Is a region / service / transport combination supported by Amazon?
bool AwsRegion::isValid ( ) const

Is this AWS region object valid?

Any AwsRegion object created using one of the valid AwsRegion::Region enumeration values (ie any but AwsRegion::InvalidRegion) will be considered valid.

However, if an unknown region name is supplied to the overloaded AwsRegion(const QString &regionName) constructor, then the constructed object will be considered invalid.

Returns
true if this object is valid, false otherwise.

Definition at line 108 of file awsregion.cpp.

References region().

109 {
110  return (region() != AwsRegion::InvalidRegion);
111 }
Region region() const
Get the region this object represents.
Definition: awsregion.cpp:90
QString AwsRegion::name ( ) const

Get the canonical AWS name for this region.

Returns
The canonical AWS name for this region, or null string if this object is invalid.
See also
isValid

Definition at line 120 of file awsregion.cpp.

Referenced by hostName(), isSupported(), and supportedServices().

121 {
122  Q_D(const AwsRegion);
123  return name(static_cast<AwsRegion::Region>(d->region));
124 }
QString name() const
Get the canonical AWS name for this region.
Definition: awsregion.cpp:120
Provides AWS region information.
Definition: awsregion.h:33
QString AwsRegion::name ( const Region region)
static

Get the canonical AWS name for a region.

Parameters
regionAWS region to get the canonical name of.
Returns
The canonical AWS name for region, or null string if region is invalid.

Definition at line 133 of file awsregion.cpp.

134 {
135  switch (region) {
136  case AP_Northeast_1: return QLatin1String("ap-northeast-1");
137  case AP_Southeast_1: return QLatin1String("ap-southeast-1");
138  case AP_Southeast_2: return QLatin1String("ap-southeast-2");
139  case EU_West_1: return QLatin1String("eu-west-1");
140  case SA_East_1: return QLatin1String("sa-east-1");
141  case US_East_1: return QLatin1String("us-east-1");
142  case US_Gov_West_1: return QLatin1String("us-gov-west-1");
143  case US_West_1: return QLatin1String("us-west-1");
144  case US_West_2: return QLatin1String("us-west-2");
145  default:
146  Q_ASSERT_X(false, Q_FUNC_INFO, qPrintable(QString::fromLatin1("invalid region: %1").arg(region)));
147  }
148  return QString();
149 }
Region region() const
Get the region this object represents.
Definition: awsregion.cpp:90
AwsRegion::Region AwsRegion::region ( ) const

Get the region this object represents.

If this object was given an AwsRegion::Region value during construction, this function will simply return that enumeration value.

If this object was constructed from an AWS region name, then this function will return the AwsRegion::Region enumeration value corresponding to that AWS region name, or AwsRegion::InvalidRegion if the given region name did not name a known, valid AWS region.

Returns
The region this object represents, or AwsRegion::InvalidRegion if this object does not represent a valid region.

Definition at line 90 of file awsregion.cpp.

Referenced by AwsRegion(), fullName(), and isValid().

91 {
92  Q_D(const AwsRegion);
93  return static_cast<AwsRegion::Region>(d->region);
94 }
Region
AWS regions.
Definition: awsregion.h:67
Provides AWS region information.
Definition: awsregion.h:33
QStringList AwsRegion::supportedServices ( const AwsEndpoint::Transports  transports = AwsEndpoint::AnyTransport) const

Get a list of services supported by this region.

Parameters
transportsOptional set of transports to test for support.
Returns
A list of the names of all AWS services support by this region for at least one of the specified transports. The list may be empty.

Definition at line 244 of file awsregion.cpp.

References name(), and AwsEndpoint::supportedServices().

245 {
246  return AwsEndpoint::supportedServices(name(), transports);
247 }
static QStringList supportedServices(const QString &regionName, const Transports transport=AnyTransport)
Get a list of services that support a given region.
QString name() const
Get the canonical AWS name for this region.
Definition: awsregion.cpp:120

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