Packages
ex_aws
1.1.5
2.7.0
2.6.1
2.6.0
2.5.11
2.5.10
2.5.9
2.5.8
2.5.7
2.5.6
2.5.5
2.5.4
2.5.3
2.5.2
2.5.1
2.5.0
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.10
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.9
2.1.8
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.1
1.0.0-beta3
1.0.0-beta2
1.0.0-beta1
1.0.0-beta0
0.5.0
0.4.19
0.4.18
0.4.17
0.4.15
0.4.14
0.4.13
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
AWS client for Elixir. Currently supports Dynamo, DynamoStreams, EC2, Firehose, Kinesis, KMS, Lambda, RRDS, Route53, S3, SES, SNS, SQS, STS and others.
Current section
Files
Jump to
Current section
Files
lib/ex_aws/cloudwatch/parsers.ex
if Code.ensure_loaded?(SweetXml) do
defmodule ExAws.Cloudwatch.Parsers do
use ExAws.Operation.Query.Parser
def parse({:ok, %{body: xml}=resp}, :describe_alarms) do
parsed_body = xml
|> SweetXml.xpath(~x"//DescribeAlarmsResponse",
alarms: alarm_xml_description(),
next_token: ~x"./DescribeAlarmsResult/NextToken/text()"s,
request_id: ~x"./ResponseMetadata/RequestId/text()"s)
{:ok, Map.put(resp, :body, parsed_body)}
end
def parse(val, _), do: val
defp alarm_xml_description do
[
~x"./DescribeAlarmsResult/MetricAlarms/member"l,
alarm_name: ~x"./AlarmName/text()"s,
metric_name: ~x"./MetricName/text()"s,
alarm_description: ~x"./AlarmDescription/text()"s,
evaluation_periods: ~x"./EvaluationPeriods/text()"i,
actions_enabled: ~x"./ActionsEnabled/text()"s |> to_boolean(),
namespace: ~x"./Namespace/text()"s,
alarm_arn: ~x"./AlarmArn/text()"s,
state_value: ~x"./StateValue/text()"s,
threshold: ~x"./Threshold/text()"f,
period: ~x"./Period/text()"i,
statistic: ~x"./Statistic/text()"s,
comparison_operator: ~x"./ComparisonOperator/text()"s,
state_reason: ~x"./StateReason/text()"s,
state_reason_data: ~x"./StateReasonData/text()"s,
insufficient_data_actions: ~x"./InsufficientDataActions/member/text()"ls,
ok_actions: ~x"./OKActions/member/text()"ls,
alarm_actions: ~x"./AlarmActions/member/text()"ls,
state_updated_timestamp: ~x"./StateUpdatedTimestamp/text()"s,
alarm_configuration_updated_timestamp: ~x"./AlarmConfigurationUpdatedTimestamp/text()"s,
dimensions: [
~x"./Dimensions/member"l,
name: ~x"./Name/text()"s,
value: ~x"./Value/text()"s]
]
end
defp to_boolean(xpath) do
xpath |> SweetXml.transform_by(&(&1 == "true"))
end
end
else
defmodule ExAws.Cloudwatch.Parsers do
def parse(val, _), do: val
end
end