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

-- | 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
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]
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
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. 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'
    { $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 :: Lens' AttributeKey Text
attributeKey_schemaArn = 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 :: Lens' AttributeKey Text
attributeKey_facetName = 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 :: Lens' AttributeKey Text
attributeKey_name = 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 Data.FromJSON AttributeKey where
  parseJSON :: Value -> Parser AttributeKey
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttributeKey"
      ( \Object
x ->
          Text -> Text -> Text -> AttributeKey
AttributeKey'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SchemaArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FacetName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

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

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"SchemaArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
schemaArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"FacetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
facetName),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )