AwsAbstractResponse Class

(QtAws::Core::AwsAbstractResponse)

The AwsAbstractResponse class provides an interface for AWS responses. More...

Header: #include <AwsAbstractResponse>
Inherited By:

QtAws::ACM::AcmResponse, QtAws::ACMPCA::AcmpcaResponse, QtAws::AlexaForBusiness::AlexaForBusinessResponse, QtAws::APIGateway::APIGatewayResponse, QtAws::ApplicationAutoScaling::ApplicationAutoScalingResponse, QtAws::ApplicationDiscoveryService::ApplicationDiscoveryServiceResponse, QtAws::AppStream::AppStreamResponse, QtAws::AppSync::AppSyncResponse, QtAws::Athena::AthenaResponse, QtAws::AutoScaling::AutoScalingResponse, QtAws::AutoScalingPlans::AutoScalingPlansResponse, QtAws::Batch::BatchResponse, QtAws::Budgets::BudgetsResponse, QtAws::Cloud9::Cloud9Response, QtAws::CloudDirectory::CloudDirectoryResponse, QtAws::CloudFormation::CloudFormationResponse, QtAws::CloudFront::CloudFrontResponse, QtAws::CloudHSM::CloudHSMResponse, QtAws::CloudHSMV2::CloudHSMV2Response, QtAws::CloudSearch::CloudSearchResponse, QtAws::CloudSearchDomain::CloudSearchDomainResponse, QtAws::CloudTrail::CloudTrailResponse, QtAws::CloudWatch::CloudWatchResponse, QtAws::CloudWatchEvents::CloudWatchEventsResponse, QtAws::CloudWatchLogs::CloudWatchLogsResponse, QtAws::CodeBuild::CodeBuildResponse, QtAws::CodeCommit::CodeCommitResponse, QtAws::CodeDeploy::CodeDeployResponse, QtAws::CodePipeline::CodePipelineResponse, QtAws::CodeStar::CodeStarResponse, QtAws::CognitoIdentity::CognitoIdentityResponse, QtAws::CognitoIdentityProvider::CognitoIdentityProviderResponse, QtAws::CognitoSync::CognitoSyncResponse, QtAws::Comprehend::ComprehendResponse, QtAws::ConfigService::ConfigServiceResponse, QtAws::Connect::ConnectResponse, QtAws::CostandUsageReportService::CostandUsageReportServiceResponse, QtAws::CostExplorer::CostExplorerResponse, QtAws::DatabaseMigrationService::DatabaseMigrationServiceResponse, QtAws::DataPipeline::DataPipelineResponse, QtAws::DAX::DaxResponse, QtAws::DeviceFarm::DeviceFarmResponse, QtAws::DirectConnect::DirectConnectResponse, QtAws::DirectoryService::DirectoryServiceResponse, QtAws::DynamoDB::DynamoDBResponse, QtAws::DynamoDBStreams::DynamoDBStreamsResponse, QtAws::EC2::Ec2Response, QtAws::ECR::EcrResponse, QtAws::ECS::EcsResponse, QtAws::EFS::EfsResponse, QtAws::ElastiCache::ElastiCacheResponse, QtAws::ElasticBeanstalk::ElasticBeanstalkResponse, QtAws::ElasticLoadBalancing::ElasticLoadBalancingResponse, QtAws::ElasticLoadBalancingv2::ElasticLoadBalancingv2Response, QtAws::ElasticsearchService::ElasticsearchServiceResponse, QtAws::ElasticTranscoder::ElasticTranscoderResponse, QtAws::EMR::EmrResponse, QtAws::Firehose::FirehoseResponse, QtAws::FMS::FmsResponse, QtAws::GameLift::GameLiftResponse, QtAws::Glacier::GlacierResponse, QtAws::Glue::GlueResponse, QtAws::Greengrass::GreengrassResponse, QtAws::GuardDuty::GuardDutyResponse, QtAws::Health::HealthResponse, QtAws::IAM::IamResponse, QtAws::ImportExport::ImportExportResponse, QtAws::Inspector::InspectorResponse, QtAws::IoT1ClickDevicesService::IoT1ClickDevicesServiceResponse, QtAws::IoT1ClickProjects::IoT1ClickProjectsResponse, QtAws::IoT::IoTResponse, QtAws::IoTAnalytics::IoTAnalyticsResponse, QtAws::IoTDataPlane::IoTDataPlaneResponse, QtAws::IoTJobsDataPlane::IoTJobsDataPlaneResponse, QtAws::Kinesis::KinesisResponse, QtAws::KinesisAnalytics::KinesisAnalyticsResponse, QtAws::KinesisVideo::KinesisVideoResponse, QtAws::KinesisVideoArchivedMedia::KinesisVideoArchivedMediaResponse, QtAws::KinesisVideoMedia::KinesisVideoMediaResponse, QtAws::KMS::KmsResponse, QtAws::Lambda::LambdaResponse, QtAws::LexModelBuildingService::LexModelBuildingServiceResponse, QtAws::LexRuntimeService::LexRuntimeServiceResponse, QtAws::Lightsail::LightsailResponse, QtAws::MachineLearning::MachineLearningResponse, QtAws::MarketplaceCommerceAnalytics::MarketplaceCommerceAnalyticsResponse, QtAws::MarketplaceEntitlementService::MarketplaceEntitlementServiceResponse, QtAws::MarketplaceMetering::MarketplaceMeteringResponse, QtAws::MediaConvert::MediaConvertResponse, QtAws::MediaLive::MediaLiveResponse, QtAws::MediaPackage::MediaPackageResponse, QtAws::MediaStore::MediaStoreResponse, QtAws::MediaStoreData::MediaStoreDataResponse, QtAws::MigrationHub::MigrationHubResponse, QtAws::Mobile::MobileResponse, QtAws::MobileAnalytics::MobileAnalyticsResponse, QtAws::MQ::MqResponse, QtAws::MTurk::MTurkResponse, QtAws::OpsWorks::OpsWorksResponse, QtAws::OpsWorksCM::OpsWorksCMResponse, QtAws::Organizations::OrganizationsResponse, QtAws::Pinpoint::PinpointResponse, QtAws::Polly::PollyResponse, QtAws::Pricing::PricingResponse, QtAws::RDS::RdsResponse, QtAws::Redshift::RedshiftResponse, QtAws::Rekognition::RekognitionResponse, QtAws::ResourceGroups::ResourceGroupsResponse, QtAws::ResourceGroupsTaggingAPI::ResourceGroupsTaggingAPIResponse, QtAws::Route53::Route53Response, QtAws::Route53Domains::Route53DomainsResponse, QtAws::S3::S3Response, QtAws::SageMaker::SageMakerResponse, QtAws::SageMakerRuntime::SageMakerRuntimeResponse, QtAws::SecretsManager::SecretsManagerResponse, QtAws::ServerlessApplicationRepository::ServerlessApplicationRepositoryResponse, QtAws::ServiceCatalog::ServiceCatalogResponse, QtAws::ServiceDiscovery::ServiceDiscoveryResponse, QtAws::SES::SesResponse, QtAws::SFN::SfnResponse, QtAws::Shield::ShieldResponse, QtAws::SimpleDB::SimpleDBResponse, QtAws::SMS::SmsResponse, QtAws::Snowball::SnowballResponse, QtAws::SNS::SnsResponse, QtAws::SQS::SqsResponse, QtAws::SSM::SsmResponse, QtAws::StorageGateway::StorageGatewayResponse, QtAws::STS::StsResponse, QtAws::Support::SupportResponse, QtAws::SWF::SwfResponse, QtAws::TranscribeService::TranscribeServiceResponse, QtAws::Translate::TranslateResponse, QtAws::WAF::WafResponse, QtAws::WAFRegional::WAFRegionalResponse, QtAws::WorkDocs::WorkDocsResponse, QtAws::WorkMail::WorkMailResponse, QtAws::WorkSpaces::WorkSpacesResponse, and QtAws::XRay::XRayResponse

Public Functions

AwsAbstractResponse(QObject * const parent = 0)
virtual ~AwsAbstractResponse()
virtual QString errorString() const
virtual bool hasError() const
virtual bool isValid() const
virtual QNetworkReply::NetworkError networkError() const
virtual const AwsAbstractRequest *request() const = 0
virtual QXmlStreamReader::Error xmlParseError() const
virtual QString xmlParseErrorString() const

Signals

void finished()

Static Public Members

QVariantMap toVariant(QXmlStreamReader &xml, const QString &prefix = QLatin1String( "." ), const int maxDepth = 1024)

Protected Functions

virtual bool isSuccess(QNetworkReply * const reply) const
virtual void parse(QNetworkReply * const reply)
virtual void parseFailure(QIODevice &response) = 0
virtual void parseSuccess(QIODevice &response) = 0
void setReply(QNetworkReply * const reply)
void setRequest(const AwsAbstractRequest * const request)
void setXmlError(const QXmlStreamReader &xml)

Protected Slots

virtual void replyFinished()

Detailed Description

The AwsAbstractResponse class provides an interface for AWS responses.

Typically instances of AwsAbstractResponse-derviced classes are returned by their respective AwsAbstractRequest-derived classes, often via an intermediate AwsAbstractClient-derived class.

For example, sending an SqsCreateQueueRequest results in a pointer to an SqsCreateQueueResponse object, optionally via an SqsClient instance.

Member Function Documentation

AwsAbstractResponse::AwsAbstractResponse(QObject * const parent = 0)

Constructs an AwsAbstractResponse object with parent parent.

[virtual] AwsAbstractResponse::~AwsAbstractResponse()

Destroys the AWS response.

[virtual] QString AwsAbstractResponse::errorString() const

Returns the network reply error string, or a null string if none have occurred.

This base implementation returns either the internal network reply object's error string (if the reply object has an error), or the internal XML parse error (if one was set, eg via set setXmlError), otherwise a null QString.

Derived classes may override this function to support additional error types. Typically such derived implementations would check this base implementation's result first, or fallback to this base implementation. For example:

if (weHaveOurOwnCustomError()) {
    return customErrorString();
} else {
    return AwsAbstractResponse::errorString();
}

See also hasError(), networkError(), and xmlParseError().

[signal] void AwsAbstractResponse::finished()

Emitted when this object has finished parsing the response.

Upon receiving this signal, slots should check isValid or hasError to check if the response was successful or not.

[virtual] bool AwsAbstractResponse::hasError() const

Returns true if an error occurred processing this reponse; false otherwise.

Errors could be anything from network requests errors, to errors validating AWS response content.

This base implementation supports network, and XML parsing errors. Derived classes may override this function to support additional error types.

Note: This function may be equivalent to !isValid, however, it is not safe for this function's implementation to be just that, since derived classes may assume the inverse, resulting in an infinite cycle between the two functions.

See also errorString() and isValid().

[virtual protected] bool AwsAbstractResponse::isSuccess(QNetworkReply * const reply) const

Returns true if reply represents a successful reponse; false otherwise.

This base implementation simply checks that reply has no errors, and that it represents an HTTP response with a 2xx HTTP status code.

Derived classes may override this function to perform other checks, and/or to support non-HTTP responses.

This function is used by the base implementation of the parse function, to delegate responsibility to either the parseSuccess or parseFailure functions.

[virtual] bool AwsAbstractResponse::isValid() const

Returns true of this response is valid; false otherwise.

This base implementation simply checks for the absense of network and XML parsing errors. Derived classes may override this function to check other error types, and/or apply additional validation rules.

Note: This function may be equivalent to !hasError, however, it is not safe for this function's implementation to be just that, since derived classes may assume the inverse, resulting in an infinite cycle between the two functions.

See also hasError().

[virtual] QNetworkReply::NetworkError AwsAbstractResponse::networkError() const

Returns the network error, or QNetowkrReply::NoError is there is none.

See also hasError() and errorString().

[virtual protected] void AwsAbstractResponse::parse(QNetworkReply * const reply)

Parses an AWS response from a network reply.

This base implementation reports networks, if any occurred, otherwise uses the result of the virtual isSuccess function to delegate parsing to either the pure virtual parseSuccess or pure virtual parseFailure methods.

Typically derived classes will only implement parseSuccess and parseFailure, without needing to override this function.

[pure virtual protected] void AwsAbstractResponse::parseFailure(QIODevice &response)

Parses a failure response.

Derived classes must implement this function to process failure responses (as defined by the virtual isSuccess function).

[pure virtual protected] void AwsAbstractResponse::parseSuccess(QIODevice &response)

Parses a successful response.

Derived classes must implement this function to process successful responses (as defined by the virtual isSuccess function).

[virtual protected slot] void AwsAbstractResponse::replyFinished()

Executed when the internal network reply is finished.

This slot should only be connectedd to QNetworkReply signals (specifcally, this function asserts that the signal sender is an qobject-castable to QNetworkReply).

This is convenience slot, that really exists just to abstract the sender casting logic from the parse function (ie so derived classes can override parse without having to implement explicit casts).

[pure virtual] const AwsAbstractRequest *AwsAbstractResponse::request() const

Return the response's originating AWS request.

See also setRequest().

[protected] void AwsAbstractResponse::setReply(QNetworkReply * const reply)

Sets the network reply to listen for an AWS response.

[protected] void AwsAbstractResponse::setRequest(const AwsAbstractRequest * const request)

Sets the AWS request that originated this response.

Note: This object will take ownership of the request pointer, and will delete request on destruction.

Callers should normally create a new request instance (making use of the request classes' copy-constructors). For example:

setRequest(new SpecializedAwsRequest(specializedRequest));

See also request().

[protected] void AwsAbstractResponse::setXmlError(const QXmlStreamReader &xml)

Sets the XML error from xml.

If xml has no error, this effectively clears any existing XML parsing error.

See also xmlParseError and xmlParseErrorString.

[static] QVariantMap AwsAbstractResponse::toVariant(QXmlStreamReader &xml, const QString &prefix = QLatin1String( "." ), const int maxDepth = 1024)

Returns a QVariantMap representation of xml, stopping at maxDepth.

If supplied, prefix will be applied to special (non-element) child entry names.

This function is used internally to embed opaque XML structures, such as the SQS service's ErrorResponse::Error::Detail, which the SQS schema defines as an arbitrary complex type.

Note: This static function exists within the AwsAbstractResponse for historic reasons. It should probably be moved out of this class, and into a more generic utility space at some point.

@todo Move this toVariant function to somewhere more generic.

[virtual] QXmlStreamReader::Error AwsAbstractResponse::xmlParseError() const

Returns the XML parse error if there is one; QXmlStreamReader::NoError otherwise.

See also hasError and errorString.

[virtual] QString AwsAbstractResponse::xmlParseErrorString() const

Returns the XML parse error string, or a null string is there is none.

See also hasError and errorString.

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