{-# 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.CloudDirectory.Types.AttributeKey
-- 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.CloudDirectory.Types.AttributeKey where

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

-- | A unique identifier for an attribute.
--
-- /See:/ 'newAttributeKey' smart constructor.
data AttributeKey = AttributeKey'
  { -- | The Amazon Resource Name (ARN) of the schema that contains the facet and
    -- attribute.
    AttributeKey -> Text
schemaArn :: Prelude.Text,
    -- | The name of the facet that the attribute exists within.
    AttributeKey -> Text
facetName :: Prelude.Text,
    -- | The name of the attribute.
    AttributeKey -> Text
name :: Prelude.Text
  }
  deriving (AttributeKey -> AttributeKey -> Bool
(AttributeKey -> AttributeKey -> Bool)
-> (AttributeKey -> AttributeKey -> Bool) -> Eq AttributeKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeKey -> AttributeKey -> Bool
$c/= :: AttributeKey -> AttributeKey -> Bool
== :: AttributeKey -> AttributeKey -> Bool
$c== :: AttributeKey -> AttributeKey -> Bool
Prelude.Eq, ReadPrec [AttributeKey]
ReadPrec AttributeKey
Int -> ReadS AttributeKey
ReadS [AttributeKey]
(Int -> ReadS AttributeKey)
-> ReadS [AttributeKey]
-> ReadPrec AttributeKey
-> ReadPrec [AttributeKey]
-> Read AttributeKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributeKey]
$creadListPrec :: ReadPrec [AttributeKey]
readPrec :: ReadPrec AttributeKey
$creadPrec :: ReadPrec AttributeKey
readList :: ReadS [AttributeKey]
$creadList :: ReadS [AttributeKey]
readsPrec :: Int -> ReadS AttributeKey
$creadsPrec :: Int -> ReadS AttributeKey
Prelude.Read, Int -> AttributeKey -> ShowS
[AttributeKey] -> ShowS
AttributeKey -> String
(Int -> AttributeKey -> ShowS)
-> (AttributeKey -> String)
-> ([AttributeKey] -> ShowS)
-> Show AttributeKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeKey] -> ShowS
$cshowList :: [AttributeKey] -> ShowS
show :: AttributeKey -> String
$cshow :: AttributeKey -> String
showsPrec :: Int -> AttributeKey -> ShowS
$cshowsPrec :: Int -> AttributeKey -> ShowS
Prelude.Show, (forall x. AttributeKey -> Rep AttributeKey x)
-> (forall x. Rep AttributeKey x -> AttributeKey)
-> Generic AttributeKey
forall x. Rep AttributeKey x -> AttributeKey
forall x. AttributeKey -> Rep AttributeKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeKey x -> AttributeKey
$cfrom :: forall x. AttributeKey -> Rep AttributeKey x
Prelude.Generic)

-- |
-- Create a value of 'AttributeKey' 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:
--
-- 'schemaArn', 'attributeKey_schemaArn' - The Amazon Resource Name (ARN) of the schema that contains the facet and
-- attribute.
--
-- 'facetName', 'attributeKey_facetName' - The name of the facet that the attribute exists within.
--
-- 'name', 'attributeKey_name' - The name of the attribute.
newAttributeKey ::
  -- | 'schemaArn'
  Prelude.Text ->
  -- | 'facetName'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  AttributeKey
newAttributeKey :: Text -> Text -> Text -> AttributeKey
newAttributeKey Text
pSchemaArn_ Text
pFacetName_ Text
pName_ =
  AttributeKey' :: Text -> Text -> Text -> AttributeKey
AttributeKey'
    { $sel:schemaArn:AttributeKey' :: Text
schemaArn = Text
pSchemaArn_,
      $sel:facetName:AttributeKey' :: Text
facetName = Text
pFacetName_,
      $sel:name:AttributeKey' :: Text
name = Text
pName_
    }

-- | The Amazon Resource Name (ARN) of the schema that contains the facet and
-- attribute.
attributeKey_schemaArn :: Lens.Lens' AttributeKey Prelude.Text
attributeKey_schemaArn :: (Text -> f Text) -> AttributeKey -> f AttributeKey
attributeKey_schemaArn = (AttributeKey -> Text)
-> (AttributeKey -> Text -> AttributeKey)
-> Lens AttributeKey AttributeKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeKey' {Text
schemaArn :: Text
$sel:schemaArn:AttributeKey' :: AttributeKey -> Text
schemaArn} -> Text
schemaArn) (\s :: AttributeKey
s@AttributeKey' {} Text
a -> AttributeKey
s {$sel:schemaArn:AttributeKey' :: Text
schemaArn = Text
a} :: AttributeKey)

-- | The name of the facet that the attribute exists within.
attributeKey_facetName :: Lens.Lens' AttributeKey Prelude.Text
attributeKey_facetName :: (Text -> f Text) -> AttributeKey -> f AttributeKey
attributeKey_facetName = (AttributeKey -> Text)
-> (AttributeKey -> Text -> AttributeKey)
-> Lens AttributeKey AttributeKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeKey' {Text
facetName :: Text
$sel:facetName:AttributeKey' :: AttributeKey -> Text
facetName} -> Text
facetName) (\s :: AttributeKey
s@AttributeKey' {} Text
a -> AttributeKey
s {$sel:facetName:AttributeKey' :: Text
facetName = Text
a} :: AttributeKey)

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

instance Core.FromJSON AttributeKey where
  parseJSON :: Value -> Parser AttributeKey
parseJSON =
    String
-> (Object -> Parser AttributeKey) -> Value -> Parser AttributeKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttributeKey"
      ( \Object
x ->
          Text -> Text -> Text -> AttributeKey
AttributeKey'
            (Text -> Text -> Text -> AttributeKey)
-> Parser Text -> Parser (Text -> Text -> AttributeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SchemaArn")
            Parser (Text -> Text -> AttributeKey)
-> Parser Text -> Parser (Text -> AttributeKey)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FacetName")
            Parser (Text -> AttributeKey) -> Parser Text -> Parser AttributeKey
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
      )

instance Prelude.Hashable AttributeKey

instance Prelude.NFData AttributeKey

instance Core.ToJSON AttributeKey where
  toJSON :: AttributeKey -> Value
toJSON AttributeKey' {Text
name :: Text
facetName :: Text
schemaArn :: Text
$sel:name:AttributeKey' :: AttributeKey -> Text
$sel:facetName:AttributeKey' :: AttributeKey -> Text
$sel:schemaArn:AttributeKey' :: AttributeKey -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SchemaArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
schemaArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FacetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
facetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )