{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AutoScaling.Types.MetricDimension where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' MetricDimension Text
metricDimension_name = 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 :: Lens' MetricDimension Text
metricDimension_value = 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 Data.FromXML MetricDimension where
  parseXML :: [Node] -> Either String MetricDimension
parseXML [Node]
x =
    Text -> Text -> MetricDimension
MetricDimension'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Name")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Value")

instance Prelude.Hashable MetricDimension where
  hashWithSalt :: Int -> MetricDimension -> Int
hashWithSalt Int
_salt MetricDimension' {Text
value :: Text
name :: Text
$sel:value:MetricDimension' :: MetricDimension -> Text
$sel:name:MetricDimension' :: MetricDimension -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData MetricDimension where
  rnf :: MetricDimension -> ()
rnf MetricDimension' {Text
value :: Text
name :: Text
$sel:value:MetricDimension' :: MetricDimension -> Text
$sel:name:MetricDimension' :: MetricDimension -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

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