{-# 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.Connect.Types.Attribute
-- 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.Connect.Types.Attribute where

import Amazonka.Connect.Types.InstanceAttributeType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A toggle for an individual feature at the instance level.
--
-- /See:/ 'newAttribute' smart constructor.
data Attribute = Attribute'
  { -- | The value of the attribute.
    Attribute -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The type of attribute.
    Attribute -> Maybe InstanceAttributeType
attributeType :: Prelude.Maybe InstanceAttributeType
  }
  deriving (Attribute -> Attribute -> Bool
(Attribute -> Attribute -> Bool)
-> (Attribute -> Attribute -> Bool) -> Eq Attribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Attribute -> Attribute -> Bool
$c/= :: Attribute -> Attribute -> Bool
== :: Attribute -> Attribute -> Bool
$c== :: Attribute -> Attribute -> Bool
Prelude.Eq, ReadPrec [Attribute]
ReadPrec Attribute
Int -> ReadS Attribute
ReadS [Attribute]
(Int -> ReadS Attribute)
-> ReadS [Attribute]
-> ReadPrec Attribute
-> ReadPrec [Attribute]
-> Read Attribute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Attribute]
$creadListPrec :: ReadPrec [Attribute]
readPrec :: ReadPrec Attribute
$creadPrec :: ReadPrec Attribute
readList :: ReadS [Attribute]
$creadList :: ReadS [Attribute]
readsPrec :: Int -> ReadS Attribute
$creadsPrec :: Int -> ReadS Attribute
Prelude.Read, Int -> Attribute -> ShowS
[Attribute] -> ShowS
Attribute -> String
(Int -> Attribute -> ShowS)
-> (Attribute -> String)
-> ([Attribute] -> ShowS)
-> Show Attribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Attribute] -> ShowS
$cshowList :: [Attribute] -> ShowS
show :: Attribute -> String
$cshow :: Attribute -> String
showsPrec :: Int -> Attribute -> ShowS
$cshowsPrec :: Int -> Attribute -> ShowS
Prelude.Show, (forall x. Attribute -> Rep Attribute x)
-> (forall x. Rep Attribute x -> Attribute) -> Generic Attribute
forall x. Rep Attribute x -> Attribute
forall x. Attribute -> Rep Attribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Attribute x -> Attribute
$cfrom :: forall x. Attribute -> Rep Attribute x
Prelude.Generic)

-- |
-- Create a value of 'Attribute' 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:
--
-- 'value', 'attribute_value' - The value of the attribute.
--
-- 'attributeType', 'attribute_attributeType' - The type of attribute.
newAttribute ::
  Attribute
newAttribute :: Attribute
newAttribute =
  Attribute' :: Maybe Text -> Maybe InstanceAttributeType -> Attribute
Attribute'
    { $sel:value:Attribute' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeType:Attribute' :: Maybe InstanceAttributeType
attributeType = Maybe InstanceAttributeType
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The type of attribute.
attribute_attributeType :: Lens.Lens' Attribute (Prelude.Maybe InstanceAttributeType)
attribute_attributeType :: (Maybe InstanceAttributeType -> f (Maybe InstanceAttributeType))
-> Attribute -> f Attribute
attribute_attributeType = (Attribute -> Maybe InstanceAttributeType)
-> (Attribute -> Maybe InstanceAttributeType -> Attribute)
-> Lens
     Attribute
     Attribute
     (Maybe InstanceAttributeType)
     (Maybe InstanceAttributeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Attribute' {Maybe InstanceAttributeType
attributeType :: Maybe InstanceAttributeType
$sel:attributeType:Attribute' :: Attribute -> Maybe InstanceAttributeType
attributeType} -> Maybe InstanceAttributeType
attributeType) (\s :: Attribute
s@Attribute' {} Maybe InstanceAttributeType
a -> Attribute
s {$sel:attributeType:Attribute' :: Maybe InstanceAttributeType
attributeType = Maybe InstanceAttributeType
a} :: Attribute)

instance Core.FromJSON Attribute where
  parseJSON :: Value -> Parser Attribute
parseJSON =
    String -> (Object -> Parser Attribute) -> Value -> Parser Attribute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Attribute"
      ( \Object
x ->
          Maybe Text -> Maybe InstanceAttributeType -> Attribute
Attribute'
            (Maybe Text -> Maybe InstanceAttributeType -> Attribute)
-> Parser (Maybe Text)
-> Parser (Maybe InstanceAttributeType -> Attribute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value")
            Parser (Maybe InstanceAttributeType -> Attribute)
-> Parser (Maybe InstanceAttributeType) -> Parser Attribute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe InstanceAttributeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttributeType")
      )

instance Prelude.Hashable Attribute

instance Prelude.NFData Attribute