{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AutoScaling.Types.MetricDimension
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AutoScaling.Types.MetricDimension where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the dimension of a metric.
--
-- /See:/ 'newMetricDimension' smart constructor.
data MetricDimension = MetricDimension'
  { -- | The name of the dimension.
    MetricDimension -> Text
name :: Prelude.Text,
    -- | The value of the dimension.
    MetricDimension -> Text
value :: Prelude.Text
  }
  deriving (MetricDimension -> MetricDimension -> Bool
(MetricDimension -> MetricDimension -> Bool)
-> (MetricDimension -> MetricDimension -> Bool)
-> Eq MetricDimension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricDimension -> MetricDimension -> Bool
$c/= :: MetricDimension -> MetricDimension -> Bool
== :: MetricDimension -> MetricDimension -> Bool
$c== :: MetricDimension -> MetricDimension -> Bool
Prelude.Eq, ReadPrec [MetricDimension]
ReadPrec MetricDimension
Int -> ReadS MetricDimension
ReadS [MetricDimension]
(Int -> ReadS MetricDimension)
-> ReadS [MetricDimension]
-> ReadPrec MetricDimension
-> ReadPrec [MetricDimension]
-> Read MetricDimension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricDimension]
$creadListPrec :: ReadPrec [MetricDimension]
readPrec :: ReadPrec MetricDimension
$creadPrec :: ReadPrec MetricDimension
readList :: ReadS [MetricDimension]
$creadList :: ReadS [MetricDimension]
readsPrec :: Int -> ReadS MetricDimension
$creadsPrec :: Int -> ReadS MetricDimension
Prelude.Read, Int -> MetricDimension -> ShowS
[MetricDimension] -> ShowS
MetricDimension -> String
(Int -> MetricDimension -> ShowS)
-> (MetricDimension -> String)
-> ([MetricDimension] -> ShowS)
-> Show MetricDimension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricDimension] -> ShowS
$cshowList :: [MetricDimension] -> ShowS
show :: MetricDimension -> String
$cshow :: MetricDimension -> String
showsPrec :: Int -> MetricDimension -> ShowS
$cshowsPrec :: Int -> MetricDimension -> ShowS
Prelude.Show, (forall x. MetricDimension -> Rep MetricDimension x)
-> (forall x. Rep MetricDimension x -> MetricDimension)
-> Generic MetricDimension
forall x. Rep MetricDimension x -> MetricDimension
forall x. MetricDimension -> Rep MetricDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricDimension x -> MetricDimension
$cfrom :: forall x. MetricDimension -> Rep MetricDimension x
Prelude.Generic)

-- |
-- Create a value of 'MetricDimension' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'name', 'metricDimension_name' - The name of the dimension.
--
-- 'value', 'metricDimension_value' - The value of the dimension.
newMetricDimension ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  MetricDimension
newMetricDimension :: Text -> Text -> MetricDimension
newMetricDimension Text
pName_ Text
pValue_ =
  MetricDimension' :: Text -> Text -> MetricDimension
MetricDimension' {$sel:name:MetricDimension' :: Text
name = Text
pName_, $sel:value:MetricDimension' :: Text
value = Text
pValue_}

-- | The name of the dimension.
metricDimension_name :: Lens.Lens' MetricDimension Prelude.Text
metricDimension_name :: (Text -> f Text) -> MetricDimension -> f MetricDimension
metricDimension_name = (MetricDimension -> Text)
-> (MetricDimension -> Text -> MetricDimension)
-> Lens MetricDimension MetricDimension Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDimension' {Text
name :: Text
$sel:name:MetricDimension' :: MetricDimension -> Text
name} -> Text
name) (\s :: MetricDimension
s@MetricDimension' {} Text
a -> MetricDimension
s {$sel:name:MetricDimension' :: Text
name = Text
a} :: MetricDimension)

-- | The value of the dimension.
metricDimension_value :: Lens.Lens' MetricDimension Prelude.Text
metricDimension_value :: (Text -> f Text) -> MetricDimension -> f MetricDimension
metricDimension_value = (MetricDimension -> Text)
-> (MetricDimension -> Text -> MetricDimension)
-> Lens MetricDimension MetricDimension Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricDimension' {Text
value :: Text
$sel:value:MetricDimension' :: MetricDimension -> Text
value} -> Text
value) (\s :: MetricDimension
s@MetricDimension' {} Text
a -> MetricDimension
s {$sel:value:MetricDimension' :: Text
value = Text
a} :: MetricDimension)

instance Core.FromXML MetricDimension where
  parseXML :: [Node] -> Either String MetricDimension
parseXML [Node]
x =
    Text -> Text -> MetricDimension
MetricDimension'
      (Text -> Text -> MetricDimension)
-> Either String Text -> Either String (Text -> MetricDimension)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Name") Either String (Text -> MetricDimension)
-> Either String Text -> Either String MetricDimension
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Value")

instance Prelude.Hashable MetricDimension

instance Prelude.NFData MetricDimension

instance Core.ToQuery MetricDimension where
  toQuery :: MetricDimension -> QueryString
toQuery MetricDimension' {Text
value :: Text
name :: Text
$sel:value:MetricDimension' :: MetricDimension -> Text
$sel:name:MetricDimension' :: MetricDimension -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Name" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
name, ByteString
"Value" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
value]