use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
use rusoto_core::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Alias {
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AnnotationValue {
#[serde(rename = "BooleanValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub boolean_value: Option<bool>,
#[serde(rename = "NumberValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_value: Option<f64>,
#[serde(rename = "StringValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub string_value: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AvailabilityZoneDetail {
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BackendConnectionErrors {
#[serde(rename = "ConnectionRefusedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub connection_refused_count: Option<i64>,
#[serde(rename = "HTTPCode4XXCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_code_4xx_count: Option<i64>,
#[serde(rename = "HTTPCode5XXCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_code_5xx_count: Option<i64>,
#[serde(rename = "OtherCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub other_count: Option<i64>,
#[serde(rename = "TimeoutCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout_count: Option<i64>,
#[serde(rename = "UnknownHostCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_host_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct BatchGetTracesRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "TraceIds")]
pub trace_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BatchGetTracesResult {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Traces")]
#[serde(skip_serializing_if = "Option::is_none")]
pub traces: Option<Vec<Trace>>,
#[serde(rename = "UnprocessedTraceIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_trace_ids: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateGroupRequest {
#[serde(rename = "FilterExpression")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_expression: Option<String>,
#[serde(rename = "GroupName")]
pub group_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateGroupResult {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateSamplingRuleRequest {
#[serde(rename = "SamplingRule")]
pub sampling_rule: SamplingRule,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateSamplingRuleResult {
#[serde(rename = "SamplingRuleRecord")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_rule_record: Option<SamplingRuleRecord>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteGroupRequest {
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteGroupResult {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteSamplingRuleRequest {
#[serde(rename = "RuleARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_arn: Option<String>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteSamplingRuleResult {
#[serde(rename = "SamplingRuleRecord")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_rule_record: Option<SamplingRuleRecord>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Edge {
#[serde(rename = "Aliases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub aliases: Option<Vec<Alias>>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "ReferenceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reference_id: Option<i64>,
#[serde(rename = "ResponseTimeHistogram")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_time_histogram: Option<Vec<HistogramEntry>>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
#[serde(rename = "SummaryStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub summary_statistics: Option<EdgeStatistics>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EdgeStatistics {
#[serde(rename = "ErrorStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_statistics: Option<ErrorStatistics>,
#[serde(rename = "FaultStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fault_statistics: Option<FaultStatistics>,
#[serde(rename = "OkCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ok_count: Option<i64>,
#[serde(rename = "TotalCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_count: Option<i64>,
#[serde(rename = "TotalResponseTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_response_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EncryptionConfig {
#[serde(rename = "KeyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_id: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ErrorRootCause {
#[serde(rename = "Services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<ErrorRootCauseService>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ErrorRootCauseEntity {
#[serde(rename = "Exceptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exceptions: Option<Vec<RootCauseException>>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Remote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ErrorRootCauseService {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "EntityPath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_path: Option<Vec<ErrorRootCauseEntity>>,
#[serde(rename = "Inferred")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inferred: Option<bool>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ErrorStatistics {
#[serde(rename = "OtherCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub other_count: Option<i64>,
#[serde(rename = "ThrottleCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub throttle_count: Option<i64>,
#[serde(rename = "TotalCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FaultRootCause {
#[serde(rename = "Services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<FaultRootCauseService>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FaultRootCauseEntity {
#[serde(rename = "Exceptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exceptions: Option<Vec<RootCauseException>>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Remote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FaultRootCauseService {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "EntityPath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_path: Option<Vec<FaultRootCauseEntity>>,
#[serde(rename = "Inferred")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inferred: Option<bool>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FaultStatistics {
#[serde(rename = "OtherCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub other_count: Option<i64>,
#[serde(rename = "TotalCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetEncryptionConfigRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetEncryptionConfigResult {
#[serde(rename = "EncryptionConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption_config: Option<EncryptionConfig>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetGroupRequest {
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetGroupResult {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetGroupsRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetGroupsResult {
#[serde(rename = "Groups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub groups: Option<Vec<GroupSummary>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetSamplingRulesRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetSamplingRulesResult {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "SamplingRuleRecords")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_rule_records: Option<Vec<SamplingRuleRecord>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetSamplingStatisticSummariesRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetSamplingStatisticSummariesResult {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "SamplingStatisticSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_statistic_summaries: Option<Vec<SamplingStatisticSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetSamplingTargetsRequest {
#[serde(rename = "SamplingStatisticsDocuments")]
pub sampling_statistics_documents: Vec<SamplingStatisticsDocument>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetSamplingTargetsResult {
#[serde(rename = "LastRuleModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_rule_modification: Option<f64>,
#[serde(rename = "SamplingTargetDocuments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_target_documents: Option<Vec<SamplingTargetDocument>>,
#[serde(rename = "UnprocessedStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_statistics: Option<Vec<UnprocessedStatistics>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetServiceGraphRequest {
#[serde(rename = "EndTime")]
pub end_time: f64,
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "StartTime")]
pub start_time: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetServiceGraphResult {
#[serde(rename = "ContainsOldGroupVersions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contains_old_group_versions: Option<bool>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<Service>>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetTraceGraphRequest {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "TraceIds")]
pub trace_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetTraceGraphResult {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<Service>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetTraceSummariesRequest {
#[serde(rename = "EndTime")]
pub end_time: f64,
#[serde(rename = "FilterExpression")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_expression: Option<String>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Sampling")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling: Option<bool>,
#[serde(rename = "StartTime")]
pub start_time: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetTraceSummariesResult {
#[serde(rename = "ApproximateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub approximate_time: Option<f64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "TraceSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub trace_summaries: Option<Vec<TraceSummary>>,
#[serde(rename = "TracesProcessedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub traces_processed_count: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Group {
#[serde(rename = "FilterExpression")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_expression: Option<String>,
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GroupSummary {
#[serde(rename = "FilterExpression")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_expression: Option<String>,
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HistogramEntry {
#[serde(rename = "Count")]
#[serde(skip_serializing_if = "Option::is_none")]
pub count: Option<i64>,
#[serde(rename = "Value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Http {
#[serde(rename = "ClientIp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_ip: Option<String>,
#[serde(rename = "HttpMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_method: Option<String>,
#[serde(rename = "HttpStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_status: Option<i64>,
#[serde(rename = "HttpURL")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_url: Option<String>,
#[serde(rename = "UserAgent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct InstanceIdDetail {
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutEncryptionConfigRequest {
#[serde(rename = "KeyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_id: Option<String>,
#[serde(rename = "Type")]
pub type_: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutEncryptionConfigResult {
#[serde(rename = "EncryptionConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encryption_config: Option<EncryptionConfig>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutTelemetryRecordsRequest {
#[serde(rename = "EC2InstanceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ec2_instance_id: Option<String>,
#[serde(rename = "Hostname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hostname: Option<String>,
#[serde(rename = "ResourceARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
#[serde(rename = "TelemetryRecords")]
pub telemetry_records: Vec<TelemetryRecord>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutTelemetryRecordsResult {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutTraceSegmentsRequest {
#[serde(rename = "TraceSegmentDocuments")]
pub trace_segment_documents: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutTraceSegmentsResult {
#[serde(rename = "UnprocessedTraceSegments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unprocessed_trace_segments: Option<Vec<UnprocessedTraceSegment>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResourceARNDetail {
#[serde(rename = "ARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResponseTimeRootCause {
#[serde(rename = "Services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<ResponseTimeRootCauseService>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResponseTimeRootCauseEntity {
#[serde(rename = "Coverage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub coverage: Option<f64>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Remote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResponseTimeRootCauseService {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "EntityPath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_path: Option<Vec<ResponseTimeRootCauseEntity>>,
#[serde(rename = "Inferred")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inferred: Option<bool>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RootCauseException {
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SamplingRule {
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "FixedRate")]
pub fixed_rate: f64,
#[serde(rename = "HTTPMethod")]
pub http_method: String,
#[serde(rename = "Host")]
pub host: String,
#[serde(rename = "Priority")]
pub priority: i64,
#[serde(rename = "ReservoirSize")]
pub reservoir_size: i64,
#[serde(rename = "ResourceARN")]
pub resource_arn: String,
#[serde(rename = "RuleARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_arn: Option<String>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
#[serde(rename = "ServiceName")]
pub service_name: String,
#[serde(rename = "ServiceType")]
pub service_type: String,
#[serde(rename = "URLPath")]
pub url_path: String,
#[serde(rename = "Version")]
pub version: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SamplingRuleRecord {
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "ModifiedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub modified_at: Option<f64>,
#[serde(rename = "SamplingRule")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_rule: Option<SamplingRule>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct SamplingRuleUpdate {
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "FixedRate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fixed_rate: Option<f64>,
#[serde(rename = "HTTPMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http_method: Option<String>,
#[serde(rename = "Host")]
#[serde(skip_serializing_if = "Option::is_none")]
pub host: Option<String>,
#[serde(rename = "Priority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i64>,
#[serde(rename = "ReservoirSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reservoir_size: Option<i64>,
#[serde(rename = "ResourceARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
#[serde(rename = "RuleARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_arn: Option<String>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
#[serde(rename = "ServiceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_name: Option<String>,
#[serde(rename = "ServiceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_type: Option<String>,
#[serde(rename = "URLPath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url_path: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SamplingStatisticSummary {
#[serde(rename = "BorrowCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub borrow_count: Option<i64>,
#[serde(rename = "RequestCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub request_count: Option<i64>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
#[serde(rename = "SampledCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampled_count: Option<i64>,
#[serde(rename = "Timestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct SamplingStatisticsDocument {
#[serde(rename = "BorrowCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub borrow_count: Option<i64>,
#[serde(rename = "ClientID")]
pub client_id: String,
#[serde(rename = "RequestCount")]
pub request_count: i64,
#[serde(rename = "RuleName")]
pub rule_name: String,
#[serde(rename = "SampledCount")]
pub sampled_count: i64,
#[serde(rename = "Timestamp")]
pub timestamp: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SamplingTargetDocument {
#[serde(rename = "FixedRate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fixed_rate: Option<f64>,
#[serde(rename = "Interval")]
#[serde(skip_serializing_if = "Option::is_none")]
pub interval: Option<i64>,
#[serde(rename = "ReservoirQuota")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reservoir_quota: Option<i64>,
#[serde(rename = "ReservoirQuotaTTL")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reservoir_quota_ttl: Option<f64>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Segment {
#[serde(rename = "Document")]
#[serde(skip_serializing_if = "Option::is_none")]
pub document: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Service {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "DurationHistogram")]
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_histogram: Option<Vec<HistogramEntry>>,
#[serde(rename = "Edges")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edges: Option<Vec<Edge>>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "ReferenceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reference_id: Option<i64>,
#[serde(rename = "ResponseTimeHistogram")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_time_histogram: Option<Vec<HistogramEntry>>,
#[serde(rename = "Root")]
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<bool>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "SummaryStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub summary_statistics: Option<ServiceStatistics>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ServiceId {
#[serde(rename = "AccountId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<String>>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ServiceStatistics {
#[serde(rename = "ErrorStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_statistics: Option<ErrorStatistics>,
#[serde(rename = "FaultStatistics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fault_statistics: Option<FaultStatistics>,
#[serde(rename = "OkCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ok_count: Option<i64>,
#[serde(rename = "TotalCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_count: Option<i64>,
#[serde(rename = "TotalResponseTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_response_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TelemetryRecord {
#[serde(rename = "BackendConnectionErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backend_connection_errors: Option<BackendConnectionErrors>,
#[serde(rename = "SegmentsReceivedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segments_received_count: Option<i64>,
#[serde(rename = "SegmentsRejectedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segments_rejected_count: Option<i64>,
#[serde(rename = "SegmentsSentCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segments_sent_count: Option<i64>,
#[serde(rename = "SegmentsSpilloverCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segments_spillover_count: Option<i64>,
#[serde(rename = "Timestamp")]
pub timestamp: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Trace {
#[serde(rename = "Duration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<f64>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Segments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub segments: Option<Vec<Segment>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TraceSummary {
#[serde(rename = "Annotations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub annotations: Option<::std::collections::HashMap<String, Vec<ValueWithServiceIds>>>,
#[serde(rename = "AvailabilityZones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub availability_zones: Option<Vec<AvailabilityZoneDetail>>,
#[serde(rename = "Duration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<f64>,
#[serde(rename = "EntryPoint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub entry_point: Option<ServiceId>,
#[serde(rename = "ErrorRootCauses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_root_causes: Option<Vec<ErrorRootCause>>,
#[serde(rename = "FaultRootCauses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fault_root_causes: Option<Vec<FaultRootCause>>,
#[serde(rename = "HasError")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_error: Option<bool>,
#[serde(rename = "HasFault")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_fault: Option<bool>,
#[serde(rename = "HasThrottle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_throttle: Option<bool>,
#[serde(rename = "Http")]
#[serde(skip_serializing_if = "Option::is_none")]
pub http: Option<Http>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "InstanceIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_ids: Option<Vec<InstanceIdDetail>>,
#[serde(rename = "IsPartial")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_partial: Option<bool>,
#[serde(rename = "ResourceARNs")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_ar_ns: Option<Vec<ResourceARNDetail>>,
#[serde(rename = "ResponseTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_time: Option<f64>,
#[serde(rename = "ResponseTimeRootCauses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_time_root_causes: Option<Vec<ResponseTimeRootCause>>,
#[serde(rename = "Revision")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<i64>,
#[serde(rename = "ServiceIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_ids: Option<Vec<ServiceId>>,
#[serde(rename = "Users")]
#[serde(skip_serializing_if = "Option::is_none")]
pub users: Option<Vec<TraceUser>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TraceUser {
#[serde(rename = "ServiceIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_ids: Option<Vec<ServiceId>>,
#[serde(rename = "UserName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UnprocessedStatistics {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "RuleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UnprocessedTraceSegment {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateGroupRequest {
#[serde(rename = "FilterExpression")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_expression: Option<String>,
#[serde(rename = "GroupARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_arn: Option<String>,
#[serde(rename = "GroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateGroupResult {
#[serde(rename = "Group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateSamplingRuleRequest {
#[serde(rename = "SamplingRuleUpdate")]
pub sampling_rule_update: SamplingRuleUpdate,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateSamplingRuleResult {
#[serde(rename = "SamplingRuleRecord")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sampling_rule_record: Option<SamplingRuleRecord>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ValueWithServiceIds {
#[serde(rename = "AnnotationValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub annotation_value: Option<AnnotationValue>,
#[serde(rename = "ServiceIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_ids: Option<Vec<ServiceId>>,
}
#[derive(Debug, PartialEq)]
pub enum BatchGetTracesError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchGetTracesError {
pub fn from_response(res: BufferedHttpResponse) -> BatchGetTracesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return BatchGetTracesError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return BatchGetTracesError::Throttled(String::from(error_message));
}
"ValidationException" => {
return BatchGetTracesError::Validation(error_message.to_string());
}
_ => {}
}
}
return BatchGetTracesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for BatchGetTracesError {
fn from(err: serde_json::error::Error) -> BatchGetTracesError {
BatchGetTracesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for BatchGetTracesError {
fn from(err: CredentialsError) -> BatchGetTracesError {
BatchGetTracesError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchGetTracesError {
fn from(err: HttpDispatchError) -> BatchGetTracesError {
BatchGetTracesError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchGetTracesError {
fn from(err: io::Error) -> BatchGetTracesError {
BatchGetTracesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for BatchGetTracesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchGetTracesError {
fn description(&self) -> &str {
match *self {
BatchGetTracesError::InvalidRequest(ref cause) => cause,
BatchGetTracesError::Throttled(ref cause) => cause,
BatchGetTracesError::Validation(ref cause) => cause,
BatchGetTracesError::Credentials(ref err) => err.description(),
BatchGetTracesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
BatchGetTracesError::ParseError(ref cause) => cause,
BatchGetTracesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateGroupError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateGroupError {
pub fn from_response(res: BufferedHttpResponse) -> CreateGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return CreateGroupError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return CreateGroupError::Throttled(String::from(error_message));
}
"ValidationException" => {
return CreateGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateGroupError {
fn from(err: serde_json::error::Error) -> CreateGroupError {
CreateGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateGroupError {
fn from(err: CredentialsError) -> CreateGroupError {
CreateGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateGroupError {
fn from(err: HttpDispatchError) -> CreateGroupError {
CreateGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateGroupError {
fn from(err: io::Error) -> CreateGroupError {
CreateGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateGroupError {
fn description(&self) -> &str {
match *self {
CreateGroupError::InvalidRequest(ref cause) => cause,
CreateGroupError::Throttled(ref cause) => cause,
CreateGroupError::Validation(ref cause) => cause,
CreateGroupError::Credentials(ref err) => err.description(),
CreateGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateGroupError::ParseError(ref cause) => cause,
CreateGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateSamplingRuleError {
InvalidRequest(String),
RuleLimitExceeded(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateSamplingRuleError {
pub fn from_response(res: BufferedHttpResponse) -> CreateSamplingRuleError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return CreateSamplingRuleError::InvalidRequest(String::from(error_message));
}
"RuleLimitExceededException" => {
return CreateSamplingRuleError::RuleLimitExceeded(String::from(error_message));
}
"ThrottledException" => {
return CreateSamplingRuleError::Throttled(String::from(error_message));
}
"ValidationException" => {
return CreateSamplingRuleError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateSamplingRuleError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateSamplingRuleError {
fn from(err: serde_json::error::Error) -> CreateSamplingRuleError {
CreateSamplingRuleError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateSamplingRuleError {
fn from(err: CredentialsError) -> CreateSamplingRuleError {
CreateSamplingRuleError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateSamplingRuleError {
fn from(err: HttpDispatchError) -> CreateSamplingRuleError {
CreateSamplingRuleError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateSamplingRuleError {
fn from(err: io::Error) -> CreateSamplingRuleError {
CreateSamplingRuleError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateSamplingRuleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateSamplingRuleError {
fn description(&self) -> &str {
match *self {
CreateSamplingRuleError::InvalidRequest(ref cause) => cause,
CreateSamplingRuleError::RuleLimitExceeded(ref cause) => cause,
CreateSamplingRuleError::Throttled(ref cause) => cause,
CreateSamplingRuleError::Validation(ref cause) => cause,
CreateSamplingRuleError::Credentials(ref err) => err.description(),
CreateSamplingRuleError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateSamplingRuleError::ParseError(ref cause) => cause,
CreateSamplingRuleError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteGroupError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteGroupError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return DeleteGroupError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return DeleteGroupError::Throttled(String::from(error_message));
}
"ValidationException" => {
return DeleteGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteGroupError {
fn from(err: serde_json::error::Error) -> DeleteGroupError {
DeleteGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteGroupError {
fn from(err: CredentialsError) -> DeleteGroupError {
DeleteGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteGroupError {
fn from(err: HttpDispatchError) -> DeleteGroupError {
DeleteGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteGroupError {
fn from(err: io::Error) -> DeleteGroupError {
DeleteGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteGroupError {
fn description(&self) -> &str {
match *self {
DeleteGroupError::InvalidRequest(ref cause) => cause,
DeleteGroupError::Throttled(ref cause) => cause,
DeleteGroupError::Validation(ref cause) => cause,
DeleteGroupError::Credentials(ref err) => err.description(),
DeleteGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteGroupError::ParseError(ref cause) => cause,
DeleteGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteSamplingRuleError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteSamplingRuleError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteSamplingRuleError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return DeleteSamplingRuleError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return DeleteSamplingRuleError::Throttled(String::from(error_message));
}
"ValidationException" => {
return DeleteSamplingRuleError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteSamplingRuleError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteSamplingRuleError {
fn from(err: serde_json::error::Error) -> DeleteSamplingRuleError {
DeleteSamplingRuleError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteSamplingRuleError {
fn from(err: CredentialsError) -> DeleteSamplingRuleError {
DeleteSamplingRuleError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteSamplingRuleError {
fn from(err: HttpDispatchError) -> DeleteSamplingRuleError {
DeleteSamplingRuleError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteSamplingRuleError {
fn from(err: io::Error) -> DeleteSamplingRuleError {
DeleteSamplingRuleError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteSamplingRuleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteSamplingRuleError {
fn description(&self) -> &str {
match *self {
DeleteSamplingRuleError::InvalidRequest(ref cause) => cause,
DeleteSamplingRuleError::Throttled(ref cause) => cause,
DeleteSamplingRuleError::Validation(ref cause) => cause,
DeleteSamplingRuleError::Credentials(ref err) => err.description(),
DeleteSamplingRuleError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteSamplingRuleError::ParseError(ref cause) => cause,
DeleteSamplingRuleError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetEncryptionConfigError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetEncryptionConfigError {
pub fn from_response(res: BufferedHttpResponse) -> GetEncryptionConfigError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetEncryptionConfigError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetEncryptionConfigError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetEncryptionConfigError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetEncryptionConfigError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetEncryptionConfigError {
fn from(err: serde_json::error::Error) -> GetEncryptionConfigError {
GetEncryptionConfigError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetEncryptionConfigError {
fn from(err: CredentialsError) -> GetEncryptionConfigError {
GetEncryptionConfigError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetEncryptionConfigError {
fn from(err: HttpDispatchError) -> GetEncryptionConfigError {
GetEncryptionConfigError::HttpDispatch(err)
}
}
impl From<io::Error> for GetEncryptionConfigError {
fn from(err: io::Error) -> GetEncryptionConfigError {
GetEncryptionConfigError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetEncryptionConfigError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetEncryptionConfigError {
fn description(&self) -> &str {
match *self {
GetEncryptionConfigError::InvalidRequest(ref cause) => cause,
GetEncryptionConfigError::Throttled(ref cause) => cause,
GetEncryptionConfigError::Validation(ref cause) => cause,
GetEncryptionConfigError::Credentials(ref err) => err.description(),
GetEncryptionConfigError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetEncryptionConfigError::ParseError(ref cause) => cause,
GetEncryptionConfigError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetGroupError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetGroupError {
pub fn from_response(res: BufferedHttpResponse) -> GetGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetGroupError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetGroupError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetGroupError {
fn from(err: serde_json::error::Error) -> GetGroupError {
GetGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetGroupError {
fn from(err: CredentialsError) -> GetGroupError {
GetGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetGroupError {
fn from(err: HttpDispatchError) -> GetGroupError {
GetGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for GetGroupError {
fn from(err: io::Error) -> GetGroupError {
GetGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetGroupError {
fn description(&self) -> &str {
match *self {
GetGroupError::InvalidRequest(ref cause) => cause,
GetGroupError::Throttled(ref cause) => cause,
GetGroupError::Validation(ref cause) => cause,
GetGroupError::Credentials(ref err) => err.description(),
GetGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetGroupError::ParseError(ref cause) => cause,
GetGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetGroupsError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetGroupsError {
pub fn from_response(res: BufferedHttpResponse) -> GetGroupsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetGroupsError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetGroupsError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetGroupsError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetGroupsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetGroupsError {
fn from(err: serde_json::error::Error) -> GetGroupsError {
GetGroupsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetGroupsError {
fn from(err: CredentialsError) -> GetGroupsError {
GetGroupsError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetGroupsError {
fn from(err: HttpDispatchError) -> GetGroupsError {
GetGroupsError::HttpDispatch(err)
}
}
impl From<io::Error> for GetGroupsError {
fn from(err: io::Error) -> GetGroupsError {
GetGroupsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetGroupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetGroupsError {
fn description(&self) -> &str {
match *self {
GetGroupsError::InvalidRequest(ref cause) => cause,
GetGroupsError::Throttled(ref cause) => cause,
GetGroupsError::Validation(ref cause) => cause,
GetGroupsError::Credentials(ref err) => err.description(),
GetGroupsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetGroupsError::ParseError(ref cause) => cause,
GetGroupsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetSamplingRulesError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetSamplingRulesError {
pub fn from_response(res: BufferedHttpResponse) -> GetSamplingRulesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetSamplingRulesError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetSamplingRulesError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetSamplingRulesError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetSamplingRulesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetSamplingRulesError {
fn from(err: serde_json::error::Error) -> GetSamplingRulesError {
GetSamplingRulesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetSamplingRulesError {
fn from(err: CredentialsError) -> GetSamplingRulesError {
GetSamplingRulesError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetSamplingRulesError {
fn from(err: HttpDispatchError) -> GetSamplingRulesError {
GetSamplingRulesError::HttpDispatch(err)
}
}
impl From<io::Error> for GetSamplingRulesError {
fn from(err: io::Error) -> GetSamplingRulesError {
GetSamplingRulesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetSamplingRulesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetSamplingRulesError {
fn description(&self) -> &str {
match *self {
GetSamplingRulesError::InvalidRequest(ref cause) => cause,
GetSamplingRulesError::Throttled(ref cause) => cause,
GetSamplingRulesError::Validation(ref cause) => cause,
GetSamplingRulesError::Credentials(ref err) => err.description(),
GetSamplingRulesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetSamplingRulesError::ParseError(ref cause) => cause,
GetSamplingRulesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetSamplingStatisticSummariesError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetSamplingStatisticSummariesError {
pub fn from_response(res: BufferedHttpResponse) -> GetSamplingStatisticSummariesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetSamplingStatisticSummariesError::InvalidRequest(String::from(
error_message,
));
}
"ThrottledException" => {
return GetSamplingStatisticSummariesError::Throttled(String::from(
error_message,
));
}
"ValidationException" => {
return GetSamplingStatisticSummariesError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetSamplingStatisticSummariesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetSamplingStatisticSummariesError {
fn from(err: serde_json::error::Error) -> GetSamplingStatisticSummariesError {
GetSamplingStatisticSummariesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetSamplingStatisticSummariesError {
fn from(err: CredentialsError) -> GetSamplingStatisticSummariesError {
GetSamplingStatisticSummariesError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetSamplingStatisticSummariesError {
fn from(err: HttpDispatchError) -> GetSamplingStatisticSummariesError {
GetSamplingStatisticSummariesError::HttpDispatch(err)
}
}
impl From<io::Error> for GetSamplingStatisticSummariesError {
fn from(err: io::Error) -> GetSamplingStatisticSummariesError {
GetSamplingStatisticSummariesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetSamplingStatisticSummariesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetSamplingStatisticSummariesError {
fn description(&self) -> &str {
match *self {
GetSamplingStatisticSummariesError::InvalidRequest(ref cause) => cause,
GetSamplingStatisticSummariesError::Throttled(ref cause) => cause,
GetSamplingStatisticSummariesError::Validation(ref cause) => cause,
GetSamplingStatisticSummariesError::Credentials(ref err) => err.description(),
GetSamplingStatisticSummariesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetSamplingStatisticSummariesError::ParseError(ref cause) => cause,
GetSamplingStatisticSummariesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetSamplingTargetsError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetSamplingTargetsError {
pub fn from_response(res: BufferedHttpResponse) -> GetSamplingTargetsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetSamplingTargetsError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetSamplingTargetsError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetSamplingTargetsError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetSamplingTargetsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetSamplingTargetsError {
fn from(err: serde_json::error::Error) -> GetSamplingTargetsError {
GetSamplingTargetsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetSamplingTargetsError {
fn from(err: CredentialsError) -> GetSamplingTargetsError {
GetSamplingTargetsError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetSamplingTargetsError {
fn from(err: HttpDispatchError) -> GetSamplingTargetsError {
GetSamplingTargetsError::HttpDispatch(err)
}
}
impl From<io::Error> for GetSamplingTargetsError {
fn from(err: io::Error) -> GetSamplingTargetsError {
GetSamplingTargetsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetSamplingTargetsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetSamplingTargetsError {
fn description(&self) -> &str {
match *self {
GetSamplingTargetsError::InvalidRequest(ref cause) => cause,
GetSamplingTargetsError::Throttled(ref cause) => cause,
GetSamplingTargetsError::Validation(ref cause) => cause,
GetSamplingTargetsError::Credentials(ref err) => err.description(),
GetSamplingTargetsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetSamplingTargetsError::ParseError(ref cause) => cause,
GetSamplingTargetsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetServiceGraphError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetServiceGraphError {
pub fn from_response(res: BufferedHttpResponse) -> GetServiceGraphError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetServiceGraphError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetServiceGraphError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetServiceGraphError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetServiceGraphError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetServiceGraphError {
fn from(err: serde_json::error::Error) -> GetServiceGraphError {
GetServiceGraphError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetServiceGraphError {
fn from(err: CredentialsError) -> GetServiceGraphError {
GetServiceGraphError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetServiceGraphError {
fn from(err: HttpDispatchError) -> GetServiceGraphError {
GetServiceGraphError::HttpDispatch(err)
}
}
impl From<io::Error> for GetServiceGraphError {
fn from(err: io::Error) -> GetServiceGraphError {
GetServiceGraphError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetServiceGraphError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetServiceGraphError {
fn description(&self) -> &str {
match *self {
GetServiceGraphError::InvalidRequest(ref cause) => cause,
GetServiceGraphError::Throttled(ref cause) => cause,
GetServiceGraphError::Validation(ref cause) => cause,
GetServiceGraphError::Credentials(ref err) => err.description(),
GetServiceGraphError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetServiceGraphError::ParseError(ref cause) => cause,
GetServiceGraphError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetTraceGraphError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetTraceGraphError {
pub fn from_response(res: BufferedHttpResponse) -> GetTraceGraphError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetTraceGraphError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetTraceGraphError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetTraceGraphError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetTraceGraphError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetTraceGraphError {
fn from(err: serde_json::error::Error) -> GetTraceGraphError {
GetTraceGraphError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetTraceGraphError {
fn from(err: CredentialsError) -> GetTraceGraphError {
GetTraceGraphError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetTraceGraphError {
fn from(err: HttpDispatchError) -> GetTraceGraphError {
GetTraceGraphError::HttpDispatch(err)
}
}
impl From<io::Error> for GetTraceGraphError {
fn from(err: io::Error) -> GetTraceGraphError {
GetTraceGraphError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetTraceGraphError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetTraceGraphError {
fn description(&self) -> &str {
match *self {
GetTraceGraphError::InvalidRequest(ref cause) => cause,
GetTraceGraphError::Throttled(ref cause) => cause,
GetTraceGraphError::Validation(ref cause) => cause,
GetTraceGraphError::Credentials(ref err) => err.description(),
GetTraceGraphError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetTraceGraphError::ParseError(ref cause) => cause,
GetTraceGraphError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetTraceSummariesError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetTraceSummariesError {
pub fn from_response(res: BufferedHttpResponse) -> GetTraceSummariesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return GetTraceSummariesError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return GetTraceSummariesError::Throttled(String::from(error_message));
}
"ValidationException" => {
return GetTraceSummariesError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetTraceSummariesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetTraceSummariesError {
fn from(err: serde_json::error::Error) -> GetTraceSummariesError {
GetTraceSummariesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetTraceSummariesError {
fn from(err: CredentialsError) -> GetTraceSummariesError {
GetTraceSummariesError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetTraceSummariesError {
fn from(err: HttpDispatchError) -> GetTraceSummariesError {
GetTraceSummariesError::HttpDispatch(err)
}
}
impl From<io::Error> for GetTraceSummariesError {
fn from(err: io::Error) -> GetTraceSummariesError {
GetTraceSummariesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetTraceSummariesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetTraceSummariesError {
fn description(&self) -> &str {
match *self {
GetTraceSummariesError::InvalidRequest(ref cause) => cause,
GetTraceSummariesError::Throttled(ref cause) => cause,
GetTraceSummariesError::Validation(ref cause) => cause,
GetTraceSummariesError::Credentials(ref err) => err.description(),
GetTraceSummariesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetTraceSummariesError::ParseError(ref cause) => cause,
GetTraceSummariesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutEncryptionConfigError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PutEncryptionConfigError {
pub fn from_response(res: BufferedHttpResponse) -> PutEncryptionConfigError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return PutEncryptionConfigError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return PutEncryptionConfigError::Throttled(String::from(error_message));
}
"ValidationException" => {
return PutEncryptionConfigError::Validation(error_message.to_string());
}
_ => {}
}
}
return PutEncryptionConfigError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PutEncryptionConfigError {
fn from(err: serde_json::error::Error) -> PutEncryptionConfigError {
PutEncryptionConfigError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PutEncryptionConfigError {
fn from(err: CredentialsError) -> PutEncryptionConfigError {
PutEncryptionConfigError::Credentials(err)
}
}
impl From<HttpDispatchError> for PutEncryptionConfigError {
fn from(err: HttpDispatchError) -> PutEncryptionConfigError {
PutEncryptionConfigError::HttpDispatch(err)
}
}
impl From<io::Error> for PutEncryptionConfigError {
fn from(err: io::Error) -> PutEncryptionConfigError {
PutEncryptionConfigError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PutEncryptionConfigError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutEncryptionConfigError {
fn description(&self) -> &str {
match *self {
PutEncryptionConfigError::InvalidRequest(ref cause) => cause,
PutEncryptionConfigError::Throttled(ref cause) => cause,
PutEncryptionConfigError::Validation(ref cause) => cause,
PutEncryptionConfigError::Credentials(ref err) => err.description(),
PutEncryptionConfigError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
PutEncryptionConfigError::ParseError(ref cause) => cause,
PutEncryptionConfigError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutTelemetryRecordsError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PutTelemetryRecordsError {
pub fn from_response(res: BufferedHttpResponse) -> PutTelemetryRecordsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return PutTelemetryRecordsError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return PutTelemetryRecordsError::Throttled(String::from(error_message));
}
"ValidationException" => {
return PutTelemetryRecordsError::Validation(error_message.to_string());
}
_ => {}
}
}
return PutTelemetryRecordsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PutTelemetryRecordsError {
fn from(err: serde_json::error::Error) -> PutTelemetryRecordsError {
PutTelemetryRecordsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PutTelemetryRecordsError {
fn from(err: CredentialsError) -> PutTelemetryRecordsError {
PutTelemetryRecordsError::Credentials(err)
}
}
impl From<HttpDispatchError> for PutTelemetryRecordsError {
fn from(err: HttpDispatchError) -> PutTelemetryRecordsError {
PutTelemetryRecordsError::HttpDispatch(err)
}
}
impl From<io::Error> for PutTelemetryRecordsError {
fn from(err: io::Error) -> PutTelemetryRecordsError {
PutTelemetryRecordsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PutTelemetryRecordsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutTelemetryRecordsError {
fn description(&self) -> &str {
match *self {
PutTelemetryRecordsError::InvalidRequest(ref cause) => cause,
PutTelemetryRecordsError::Throttled(ref cause) => cause,
PutTelemetryRecordsError::Validation(ref cause) => cause,
PutTelemetryRecordsError::Credentials(ref err) => err.description(),
PutTelemetryRecordsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
PutTelemetryRecordsError::ParseError(ref cause) => cause,
PutTelemetryRecordsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutTraceSegmentsError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PutTraceSegmentsError {
pub fn from_response(res: BufferedHttpResponse) -> PutTraceSegmentsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return PutTraceSegmentsError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return PutTraceSegmentsError::Throttled(String::from(error_message));
}
"ValidationException" => {
return PutTraceSegmentsError::Validation(error_message.to_string());
}
_ => {}
}
}
return PutTraceSegmentsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PutTraceSegmentsError {
fn from(err: serde_json::error::Error) -> PutTraceSegmentsError {
PutTraceSegmentsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PutTraceSegmentsError {
fn from(err: CredentialsError) -> PutTraceSegmentsError {
PutTraceSegmentsError::Credentials(err)
}
}
impl From<HttpDispatchError> for PutTraceSegmentsError {
fn from(err: HttpDispatchError) -> PutTraceSegmentsError {
PutTraceSegmentsError::HttpDispatch(err)
}
}
impl From<io::Error> for PutTraceSegmentsError {
fn from(err: io::Error) -> PutTraceSegmentsError {
PutTraceSegmentsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PutTraceSegmentsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutTraceSegmentsError {
fn description(&self) -> &str {
match *self {
PutTraceSegmentsError::InvalidRequest(ref cause) => cause,
PutTraceSegmentsError::Throttled(ref cause) => cause,
PutTraceSegmentsError::Validation(ref cause) => cause,
PutTraceSegmentsError::Credentials(ref err) => err.description(),
PutTraceSegmentsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
PutTraceSegmentsError::ParseError(ref cause) => cause,
PutTraceSegmentsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateGroupError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateGroupError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return UpdateGroupError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return UpdateGroupError::Throttled(String::from(error_message));
}
"ValidationException" => {
return UpdateGroupError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateGroupError {
fn from(err: serde_json::error::Error) -> UpdateGroupError {
UpdateGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateGroupError {
fn from(err: CredentialsError) -> UpdateGroupError {
UpdateGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateGroupError {
fn from(err: HttpDispatchError) -> UpdateGroupError {
UpdateGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateGroupError {
fn from(err: io::Error) -> UpdateGroupError {
UpdateGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateGroupError {
fn description(&self) -> &str {
match *self {
UpdateGroupError::InvalidRequest(ref cause) => cause,
UpdateGroupError::Throttled(ref cause) => cause,
UpdateGroupError::Validation(ref cause) => cause,
UpdateGroupError::Credentials(ref err) => err.description(),
UpdateGroupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateGroupError::ParseError(ref cause) => cause,
UpdateGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateSamplingRuleError {
InvalidRequest(String),
Throttled(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateSamplingRuleError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateSamplingRuleError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestException" => {
return UpdateSamplingRuleError::InvalidRequest(String::from(error_message));
}
"ThrottledException" => {
return UpdateSamplingRuleError::Throttled(String::from(error_message));
}
"ValidationException" => {
return UpdateSamplingRuleError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateSamplingRuleError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateSamplingRuleError {
fn from(err: serde_json::error::Error) -> UpdateSamplingRuleError {
UpdateSamplingRuleError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateSamplingRuleError {
fn from(err: CredentialsError) -> UpdateSamplingRuleError {
UpdateSamplingRuleError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateSamplingRuleError {
fn from(err: HttpDispatchError) -> UpdateSamplingRuleError {
UpdateSamplingRuleError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateSamplingRuleError {
fn from(err: io::Error) -> UpdateSamplingRuleError {
UpdateSamplingRuleError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateSamplingRuleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateSamplingRuleError {
fn description(&self) -> &str {
match *self {
UpdateSamplingRuleError::InvalidRequest(ref cause) => cause,
UpdateSamplingRuleError::Throttled(ref cause) => cause,
UpdateSamplingRuleError::Validation(ref cause) => cause,
UpdateSamplingRuleError::Credentials(ref err) => err.description(),
UpdateSamplingRuleError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateSamplingRuleError::ParseError(ref cause) => cause,
UpdateSamplingRuleError::Unknown(_) => "unknown error",
}
}
}
pub trait XRay {
fn batch_get_traces(
&self,
input: BatchGetTracesRequest,
) -> RusotoFuture<BatchGetTracesResult, BatchGetTracesError>;
fn create_group(
&self,
input: CreateGroupRequest,
) -> RusotoFuture<CreateGroupResult, CreateGroupError>;
fn create_sampling_rule(
&self,
input: CreateSamplingRuleRequest,
) -> RusotoFuture<CreateSamplingRuleResult, CreateSamplingRuleError>;
fn delete_group(
&self,
input: DeleteGroupRequest,
) -> RusotoFuture<DeleteGroupResult, DeleteGroupError>;
fn delete_sampling_rule(
&self,
input: DeleteSamplingRuleRequest,
) -> RusotoFuture<DeleteSamplingRuleResult, DeleteSamplingRuleError>;
fn get_encryption_config(
&self,
) -> RusotoFuture<GetEncryptionConfigResult, GetEncryptionConfigError>;
fn get_group(&self, input: GetGroupRequest) -> RusotoFuture<GetGroupResult, GetGroupError>;
fn get_groups(&self, input: GetGroupsRequest) -> RusotoFuture<GetGroupsResult, GetGroupsError>;
fn get_sampling_rules(
&self,
input: GetSamplingRulesRequest,
) -> RusotoFuture<GetSamplingRulesResult, GetSamplingRulesError>;
fn get_sampling_statistic_summaries(
&self,
input: GetSamplingStatisticSummariesRequest,
) -> RusotoFuture<GetSamplingStatisticSummariesResult, GetSamplingStatisticSummariesError>;
fn get_sampling_targets(
&self,
input: GetSamplingTargetsRequest,
) -> RusotoFuture<GetSamplingTargetsResult, GetSamplingTargetsError>;
fn get_service_graph(
&self,
input: GetServiceGraphRequest,
) -> RusotoFuture<GetServiceGraphResult, GetServiceGraphError>;
fn get_trace_graph(
&self,
input: GetTraceGraphRequest,
) -> RusotoFuture<GetTraceGraphResult, GetTraceGraphError>;
fn get_trace_summaries(
&self,
input: GetTraceSummariesRequest,
) -> RusotoFuture<GetTraceSummariesResult, GetTraceSummariesError>;
fn put_encryption_config(
&self,
input: PutEncryptionConfigRequest,
) -> RusotoFuture<PutEncryptionConfigResult, PutEncryptionConfigError>;
fn put_telemetry_records(
&self,
input: PutTelemetryRecordsRequest,
) -> RusotoFuture<PutTelemetryRecordsResult, PutTelemetryRecordsError>;
fn put_trace_segments(
&self,
input: PutTraceSegmentsRequest,
) -> RusotoFuture<PutTraceSegmentsResult, PutTraceSegmentsError>;
fn update_group(
&self,
input: UpdateGroupRequest,
) -> RusotoFuture<UpdateGroupResult, UpdateGroupError>;
fn update_sampling_rule(
&self,
input: UpdateSamplingRuleRequest,
) -> RusotoFuture<UpdateSamplingRuleResult, UpdateSamplingRuleError>;
}
#[derive(Clone)]
pub struct XRayClient {
client: Client,
region: region::Region,
}
impl XRayClient {
pub fn new(region: region::Region) -> XRayClient {
XRayClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> XRayClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
XRayClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl XRay for XRayClient {
fn batch_get_traces(
&self,
input: BatchGetTracesRequest,
) -> RusotoFuture<BatchGetTracesResult, BatchGetTracesError> {
let request_uri = "/Traces";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<BatchGetTracesResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(BatchGetTracesError::from_response(response))),
)
}
})
}
fn create_group(
&self,
input: CreateGroupRequest,
) -> RusotoFuture<CreateGroupResult, CreateGroupError> {
let request_uri = "/CreateGroup";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<CreateGroupResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateGroupError::from_response(response))),
)
}
})
}
fn create_sampling_rule(
&self,
input: CreateSamplingRuleRequest,
) -> RusotoFuture<CreateSamplingRuleResult, CreateSamplingRuleError> {
let request_uri = "/CreateSamplingRule";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<CreateSamplingRuleResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateSamplingRuleError::from_response(response))),
)
}
})
}
fn delete_group(
&self,
input: DeleteGroupRequest,
) -> RusotoFuture<DeleteGroupResult, DeleteGroupError> {
let request_uri = "/DeleteGroup";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DeleteGroupResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteGroupError::from_response(response))),
)
}
})
}
fn delete_sampling_rule(
&self,
input: DeleteSamplingRuleRequest,
) -> RusotoFuture<DeleteSamplingRuleResult, DeleteSamplingRuleError> {
let request_uri = "/DeleteSamplingRule";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DeleteSamplingRuleResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteSamplingRuleError::from_response(response))),
)
}
})
}
fn get_encryption_config(
&self,
) -> RusotoFuture<GetEncryptionConfigResult, GetEncryptionConfigError> {
let request_uri = "/EncryptionConfig";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetEncryptionConfigResult>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetEncryptionConfigError::from_response(response))
}),
)
}
})
}
fn get_group(&self, input: GetGroupRequest) -> RusotoFuture<GetGroupResult, GetGroupError> {
let request_uri = "/GetGroup";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetGroupResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetGroupError::from_response(response))),
)
}
})
}
fn get_groups(&self, input: GetGroupsRequest) -> RusotoFuture<GetGroupsResult, GetGroupsError> {
let request_uri = "/Groups";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetGroupsResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetGroupsError::from_response(response))),
)
}
})
}
fn get_sampling_rules(
&self,
input: GetSamplingRulesRequest,
) -> RusotoFuture<GetSamplingRulesResult, GetSamplingRulesError> {
let request_uri = "/GetSamplingRules";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetSamplingRulesResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetSamplingRulesError::from_response(response))),
)
}
})
}
fn get_sampling_statistic_summaries(
&self,
input: GetSamplingStatisticSummariesRequest,
) -> RusotoFuture<GetSamplingStatisticSummariesResult, GetSamplingStatisticSummariesError> {
let request_uri = "/SamplingStatisticSummaries";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetSamplingStatisticSummariesResult>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(GetSamplingStatisticSummariesError::from_response(response))
}))
}
})
}
fn get_sampling_targets(
&self,
input: GetSamplingTargetsRequest,
) -> RusotoFuture<GetSamplingTargetsResult, GetSamplingTargetsError> {
let request_uri = "/SamplingTargets";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetSamplingTargetsResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetSamplingTargetsError::from_response(response))),
)
}
})
}
fn get_service_graph(
&self,
input: GetServiceGraphRequest,
) -> RusotoFuture<GetServiceGraphResult, GetServiceGraphError> {
let request_uri = "/ServiceGraph";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetServiceGraphResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetServiceGraphError::from_response(response))),
)
}
})
}
fn get_trace_graph(
&self,
input: GetTraceGraphRequest,
) -> RusotoFuture<GetTraceGraphResult, GetTraceGraphError> {
let request_uri = "/TraceGraph";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetTraceGraphResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetTraceGraphError::from_response(response))),
)
}
})
}
fn get_trace_summaries(
&self,
input: GetTraceSummariesRequest,
) -> RusotoFuture<GetTraceSummariesResult, GetTraceSummariesError> {
let request_uri = "/TraceSummaries";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetTraceSummariesResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetTraceSummariesError::from_response(response))),
)
}
})
}
fn put_encryption_config(
&self,
input: PutEncryptionConfigRequest,
) -> RusotoFuture<PutEncryptionConfigResult, PutEncryptionConfigError> {
let request_uri = "/PutEncryptionConfig";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<PutEncryptionConfigResult>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(PutEncryptionConfigError::from_response(response))
}),
)
}
})
}
fn put_telemetry_records(
&self,
input: PutTelemetryRecordsRequest,
) -> RusotoFuture<PutTelemetryRecordsResult, PutTelemetryRecordsError> {
let request_uri = "/TelemetryRecords";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<PutTelemetryRecordsResult>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(PutTelemetryRecordsError::from_response(response))
}),
)
}
})
}
fn put_trace_segments(
&self,
input: PutTraceSegmentsRequest,
) -> RusotoFuture<PutTraceSegmentsResult, PutTraceSegmentsError> {
let request_uri = "/TraceSegments";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<PutTraceSegmentsResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutTraceSegmentsError::from_response(response))),
)
}
})
}
fn update_group(
&self,
input: UpdateGroupRequest,
) -> RusotoFuture<UpdateGroupResult, UpdateGroupError> {
let request_uri = "/UpdateGroup";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<UpdateGroupResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateGroupError::from_response(response))),
)
}
})
}
fn update_sampling_rule(
&self,
input: UpdateSamplingRuleRequest,
) -> RusotoFuture<UpdateSamplingRuleResult, UpdateSamplingRuleError> {
let request_uri = "/UpdateSamplingRule";
let mut request = SignedRequest::new("POST", "xray", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<UpdateSamplingRuleResult>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateSamplingRuleError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}