{-# 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.LookoutMetrics.Types.AttributeValue
-- 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.LookoutMetrics.Types.AttributeValue 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

-- | An attribute value.
--
-- /See:/ 'newAttributeValue' smart constructor.
data AttributeValue = AttributeValue'
  { -- | A binary value.
    AttributeValue -> Maybe Text
b :: Prelude.Maybe Prelude.Text,
    -- | A list of binary values.
    AttributeValue -> Maybe [Text]
bs :: Prelude.Maybe [Prelude.Text],
    -- | A number.
    AttributeValue -> Maybe Text
n :: Prelude.Maybe Prelude.Text,
    -- | A list of numbers.
    AttributeValue -> Maybe [Text]
ns :: Prelude.Maybe [Prelude.Text],
    -- | A string.
    AttributeValue -> Maybe Text
s :: Prelude.Maybe Prelude.Text,
    -- | A list of strings.
    AttributeValue -> Maybe [Text]
ss :: Prelude.Maybe [Prelude.Text]
  }
  deriving (AttributeValue -> AttributeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeValue -> AttributeValue -> Bool
$c/= :: AttributeValue -> AttributeValue -> Bool
== :: AttributeValue -> AttributeValue -> Bool
$c== :: AttributeValue -> AttributeValue -> Bool
Prelude.Eq, ReadPrec [AttributeValue]
ReadPrec AttributeValue
Int -> ReadS AttributeValue
ReadS [AttributeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributeValue]
$creadListPrec :: ReadPrec [AttributeValue]
readPrec :: ReadPrec AttributeValue
$creadPrec :: ReadPrec AttributeValue
readList :: ReadS [AttributeValue]
$creadList :: ReadS [AttributeValue]
readsPrec :: Int -> ReadS AttributeValue
$creadsPrec :: Int -> ReadS AttributeValue
Prelude.Read, Int -> AttributeValue -> ShowS
[AttributeValue] -> ShowS
AttributeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeValue] -> ShowS
$cshowList :: [AttributeValue] -> ShowS
show :: AttributeValue -> String
$cshow :: AttributeValue -> String
showsPrec :: Int -> AttributeValue -> ShowS
$cshowsPrec :: Int -> AttributeValue -> ShowS
Prelude.Show, forall x. Rep AttributeValue x -> AttributeValue
forall x. AttributeValue -> Rep AttributeValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeValue x -> AttributeValue
$cfrom :: forall x. AttributeValue -> Rep AttributeValue x
Prelude.Generic)

-- |
-- Create a value of 'AttributeValue' 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:
--
-- 'b', 'attributeValue_b' - A binary value.
--
-- 'bs', 'attributeValue_bs' - A list of binary values.
--
-- 'n', 'attributeValue_n' - A number.
--
-- 'ns', 'attributeValue_ns' - A list of numbers.
--
-- 's', 'attributeValue_s' - A string.
--
-- 'ss', 'attributeValue_ss' - A list of strings.
newAttributeValue ::
  AttributeValue
newAttributeValue :: AttributeValue
newAttributeValue =
  AttributeValue'
    { $sel:b:AttributeValue' :: Maybe Text
b = forall a. Maybe a
Prelude.Nothing,
      $sel:bs:AttributeValue' :: Maybe [Text]
bs = forall a. Maybe a
Prelude.Nothing,
      $sel:n:AttributeValue' :: Maybe Text
n = forall a. Maybe a
Prelude.Nothing,
      $sel:ns:AttributeValue' :: Maybe [Text]
ns = forall a. Maybe a
Prelude.Nothing,
      $sel:s:AttributeValue' :: Maybe Text
s = forall a. Maybe a
Prelude.Nothing,
      $sel:ss:AttributeValue' :: Maybe [Text]
ss = forall a. Maybe a
Prelude.Nothing
    }

-- | A binary value.
attributeValue_b :: Lens.Lens' AttributeValue (Prelude.Maybe Prelude.Text)
attributeValue_b :: Lens' AttributeValue (Maybe Text)
attributeValue_b = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe Text
b :: Maybe Text
$sel:b:AttributeValue' :: AttributeValue -> Maybe Text
b} -> Maybe Text
b) (\s :: AttributeValue
s@AttributeValue' {} Maybe Text
a -> AttributeValue
s {$sel:b:AttributeValue' :: Maybe Text
b = Maybe Text
a} :: AttributeValue)

-- | A list of binary values.
attributeValue_bs :: Lens.Lens' AttributeValue (Prelude.Maybe [Prelude.Text])
attributeValue_bs :: Lens' AttributeValue (Maybe [Text])
attributeValue_bs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe [Text]
bs :: Maybe [Text]
$sel:bs:AttributeValue' :: AttributeValue -> Maybe [Text]
bs} -> Maybe [Text]
bs) (\s :: AttributeValue
s@AttributeValue' {} Maybe [Text]
a -> AttributeValue
s {$sel:bs:AttributeValue' :: Maybe [Text]
bs = Maybe [Text]
a} :: AttributeValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A number.
attributeValue_n :: Lens.Lens' AttributeValue (Prelude.Maybe Prelude.Text)
attributeValue_n :: Lens' AttributeValue (Maybe Text)
attributeValue_n = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe Text
n :: Maybe Text
$sel:n:AttributeValue' :: AttributeValue -> Maybe Text
n} -> Maybe Text
n) (\s :: AttributeValue
s@AttributeValue' {} Maybe Text
a -> AttributeValue
s {$sel:n:AttributeValue' :: Maybe Text
n = Maybe Text
a} :: AttributeValue)

-- | A list of numbers.
attributeValue_ns :: Lens.Lens' AttributeValue (Prelude.Maybe [Prelude.Text])
attributeValue_ns :: Lens' AttributeValue (Maybe [Text])
attributeValue_ns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe [Text]
ns :: Maybe [Text]
$sel:ns:AttributeValue' :: AttributeValue -> Maybe [Text]
ns} -> Maybe [Text]
ns) (\s :: AttributeValue
s@AttributeValue' {} Maybe [Text]
a -> AttributeValue
s {$sel:ns:AttributeValue' :: Maybe [Text]
ns = Maybe [Text]
a} :: AttributeValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A string.
attributeValue_s :: Lens.Lens' AttributeValue (Prelude.Maybe Prelude.Text)
attributeValue_s :: Lens' AttributeValue (Maybe Text)
attributeValue_s = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe Text
s :: Maybe Text
$sel:s:AttributeValue' :: AttributeValue -> Maybe Text
s} -> Maybe Text
s) (\s :: AttributeValue
s@AttributeValue' {} Maybe Text
a -> AttributeValue
s {$sel:s:AttributeValue' :: Maybe Text
s = Maybe Text
a} :: AttributeValue)

-- | A list of strings.
attributeValue_ss :: Lens.Lens' AttributeValue (Prelude.Maybe [Prelude.Text])
attributeValue_ss :: Lens' AttributeValue (Maybe [Text])
attributeValue_ss = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeValue' {Maybe [Text]
ss :: Maybe [Text]
$sel:ss:AttributeValue' :: AttributeValue -> Maybe [Text]
ss} -> Maybe [Text]
ss) (\s :: AttributeValue
s@AttributeValue' {} Maybe [Text]
a -> AttributeValue
s {$sel:ss:AttributeValue' :: Maybe [Text]
ss = Maybe [Text]
a} :: AttributeValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AttributeValue where
  parseJSON :: Value -> Parser AttributeValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttributeValue"
      ( \Object
x ->
          Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe [Text]
-> AttributeValue
AttributeValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"B")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BS" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"N")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NS" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"S")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SS" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AttributeValue where
  hashWithSalt :: Int -> AttributeValue -> Int
hashWithSalt Int
_salt AttributeValue' {Maybe [Text]
Maybe Text
ss :: Maybe [Text]
s :: Maybe Text
ns :: Maybe [Text]
n :: Maybe Text
bs :: Maybe [Text]
b :: Maybe Text
$sel:ss:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:s:AttributeValue' :: AttributeValue -> Maybe Text
$sel:ns:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:n:AttributeValue' :: AttributeValue -> Maybe Text
$sel:bs:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:b:AttributeValue' :: AttributeValue -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
b
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
bs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
n
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ss

instance Prelude.NFData AttributeValue where
  rnf :: AttributeValue -> ()
rnf AttributeValue' {Maybe [Text]
Maybe Text
ss :: Maybe [Text]
s :: Maybe Text
ns :: Maybe [Text]
n :: Maybe Text
bs :: Maybe [Text]
b :: Maybe Text
$sel:ss:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:s:AttributeValue' :: AttributeValue -> Maybe Text
$sel:ns:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:n:AttributeValue' :: AttributeValue -> Maybe Text
$sel:bs:AttributeValue' :: AttributeValue -> Maybe [Text]
$sel:b:AttributeValue' :: AttributeValue -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
b
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
bs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
n
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ss