{-# 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.LakeFormation.Types.LFTagKeyResource
-- 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.LakeFormation.Types.LFTagKeyResource where

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

-- | A structure containing a tag key and values for a resource.
--
-- /See:/ 'newLFTagKeyResource' smart constructor.
data LFTagKeyResource = LFTagKeyResource'
  { -- | The identifier for the Data Catalog. By default, the account ID. The
    -- Data Catalog is the persistent metadata store. It contains database
    -- definitions, table definitions, and other control information to manage
    -- your AWS Lake Formation environment.
    LFTagKeyResource -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The key-name for the tag.
    LFTagKeyResource -> Text
tagKey :: Prelude.Text,
    -- | A list of possible values an attribute can take.
    LFTagKeyResource -> NonEmpty Text
tagValues :: Prelude.NonEmpty Prelude.Text
  }
  deriving (LFTagKeyResource -> LFTagKeyResource -> Bool
(LFTagKeyResource -> LFTagKeyResource -> Bool)
-> (LFTagKeyResource -> LFTagKeyResource -> Bool)
-> Eq LFTagKeyResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LFTagKeyResource -> LFTagKeyResource -> Bool
$c/= :: LFTagKeyResource -> LFTagKeyResource -> Bool
== :: LFTagKeyResource -> LFTagKeyResource -> Bool
$c== :: LFTagKeyResource -> LFTagKeyResource -> Bool
Prelude.Eq, ReadPrec [LFTagKeyResource]
ReadPrec LFTagKeyResource
Int -> ReadS LFTagKeyResource
ReadS [LFTagKeyResource]
(Int -> ReadS LFTagKeyResource)
-> ReadS [LFTagKeyResource]
-> ReadPrec LFTagKeyResource
-> ReadPrec [LFTagKeyResource]
-> Read LFTagKeyResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LFTagKeyResource]
$creadListPrec :: ReadPrec [LFTagKeyResource]
readPrec :: ReadPrec LFTagKeyResource
$creadPrec :: ReadPrec LFTagKeyResource
readList :: ReadS [LFTagKeyResource]
$creadList :: ReadS [LFTagKeyResource]
readsPrec :: Int -> ReadS LFTagKeyResource
$creadsPrec :: Int -> ReadS LFTagKeyResource
Prelude.Read, Int -> LFTagKeyResource -> ShowS
[LFTagKeyResource] -> ShowS
LFTagKeyResource -> String
(Int -> LFTagKeyResource -> ShowS)
-> (LFTagKeyResource -> String)
-> ([LFTagKeyResource] -> ShowS)
-> Show LFTagKeyResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LFTagKeyResource] -> ShowS
$cshowList :: [LFTagKeyResource] -> ShowS
show :: LFTagKeyResource -> String
$cshow :: LFTagKeyResource -> String
showsPrec :: Int -> LFTagKeyResource -> ShowS
$cshowsPrec :: Int -> LFTagKeyResource -> ShowS
Prelude.Show, (forall x. LFTagKeyResource -> Rep LFTagKeyResource x)
-> (forall x. Rep LFTagKeyResource x -> LFTagKeyResource)
-> Generic LFTagKeyResource
forall x. Rep LFTagKeyResource x -> LFTagKeyResource
forall x. LFTagKeyResource -> Rep LFTagKeyResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LFTagKeyResource x -> LFTagKeyResource
$cfrom :: forall x. LFTagKeyResource -> Rep LFTagKeyResource x
Prelude.Generic)

-- |
-- Create a value of 'LFTagKeyResource' 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:
--
-- 'catalogId', 'lFTagKeyResource_catalogId' - The identifier for the Data Catalog. By default, the account ID. The
-- Data Catalog is the persistent metadata store. It contains database
-- definitions, table definitions, and other control information to manage
-- your AWS Lake Formation environment.
--
-- 'tagKey', 'lFTagKeyResource_tagKey' - The key-name for the tag.
--
-- 'tagValues', 'lFTagKeyResource_tagValues' - A list of possible values an attribute can take.
newLFTagKeyResource ::
  -- | 'tagKey'
  Prelude.Text ->
  -- | 'tagValues'
  Prelude.NonEmpty Prelude.Text ->
  LFTagKeyResource
newLFTagKeyResource :: Text -> NonEmpty Text -> LFTagKeyResource
newLFTagKeyResource Text
pTagKey_ NonEmpty Text
pTagValues_ =
  LFTagKeyResource' :: Maybe Text -> Text -> NonEmpty Text -> LFTagKeyResource
LFTagKeyResource'
    { $sel:catalogId:LFTagKeyResource' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:LFTagKeyResource' :: Text
tagKey = Text
pTagKey_,
      $sel:tagValues:LFTagKeyResource' :: NonEmpty Text
tagValues = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTagValues_
    }

-- | The identifier for the Data Catalog. By default, the account ID. The
-- Data Catalog is the persistent metadata store. It contains database
-- definitions, table definitions, and other control information to manage
-- your AWS Lake Formation environment.
lFTagKeyResource_catalogId :: Lens.Lens' LFTagKeyResource (Prelude.Maybe Prelude.Text)
lFTagKeyResource_catalogId :: (Maybe Text -> f (Maybe Text))
-> LFTagKeyResource -> f LFTagKeyResource
lFTagKeyResource_catalogId = (LFTagKeyResource -> Maybe Text)
-> (LFTagKeyResource -> Maybe Text -> LFTagKeyResource)
-> Lens LFTagKeyResource LFTagKeyResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LFTagKeyResource' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:LFTagKeyResource' :: LFTagKeyResource -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: LFTagKeyResource
s@LFTagKeyResource' {} Maybe Text
a -> LFTagKeyResource
s {$sel:catalogId:LFTagKeyResource' :: Maybe Text
catalogId = Maybe Text
a} :: LFTagKeyResource)

-- | The key-name for the tag.
lFTagKeyResource_tagKey :: Lens.Lens' LFTagKeyResource Prelude.Text
lFTagKeyResource_tagKey :: (Text -> f Text) -> LFTagKeyResource -> f LFTagKeyResource
lFTagKeyResource_tagKey = (LFTagKeyResource -> Text)
-> (LFTagKeyResource -> Text -> LFTagKeyResource)
-> Lens LFTagKeyResource LFTagKeyResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LFTagKeyResource' {Text
tagKey :: Text
$sel:tagKey:LFTagKeyResource' :: LFTagKeyResource -> Text
tagKey} -> Text
tagKey) (\s :: LFTagKeyResource
s@LFTagKeyResource' {} Text
a -> LFTagKeyResource
s {$sel:tagKey:LFTagKeyResource' :: Text
tagKey = Text
a} :: LFTagKeyResource)

-- | A list of possible values an attribute can take.
lFTagKeyResource_tagValues :: Lens.Lens' LFTagKeyResource (Prelude.NonEmpty Prelude.Text)
lFTagKeyResource_tagValues :: (NonEmpty Text -> f (NonEmpty Text))
-> LFTagKeyResource -> f LFTagKeyResource
lFTagKeyResource_tagValues = (LFTagKeyResource -> NonEmpty Text)
-> (LFTagKeyResource -> NonEmpty Text -> LFTagKeyResource)
-> Lens
     LFTagKeyResource LFTagKeyResource (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LFTagKeyResource' {NonEmpty Text
tagValues :: NonEmpty Text
$sel:tagValues:LFTagKeyResource' :: LFTagKeyResource -> NonEmpty Text
tagValues} -> NonEmpty Text
tagValues) (\s :: LFTagKeyResource
s@LFTagKeyResource' {} NonEmpty Text
a -> LFTagKeyResource
s {$sel:tagValues:LFTagKeyResource' :: NonEmpty Text
tagValues = NonEmpty Text
a} :: LFTagKeyResource) ((NonEmpty Text -> f (NonEmpty Text))
 -> LFTagKeyResource -> f LFTagKeyResource)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> LFTagKeyResource
-> f LFTagKeyResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LFTagKeyResource where
  parseJSON :: Value -> Parser LFTagKeyResource
parseJSON =
    String
-> (Object -> Parser LFTagKeyResource)
-> Value
-> Parser LFTagKeyResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LFTagKeyResource"
      ( \Object
x ->
          Maybe Text -> Text -> NonEmpty Text -> LFTagKeyResource
LFTagKeyResource'
            (Maybe Text -> Text -> NonEmpty Text -> LFTagKeyResource)
-> Parser (Maybe Text)
-> Parser (Text -> NonEmpty Text -> LFTagKeyResource)
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
"CatalogId")
            Parser (Text -> NonEmpty Text -> LFTagKeyResource)
-> Parser Text -> Parser (NonEmpty Text -> LFTagKeyResource)
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
"TagKey")
            Parser (NonEmpty Text -> LFTagKeyResource)
-> Parser (NonEmpty Text) -> Parser LFTagKeyResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TagValues")
      )

instance Prelude.Hashable LFTagKeyResource

instance Prelude.NFData LFTagKeyResource

instance Core.ToJSON LFTagKeyResource where
  toJSON :: LFTagKeyResource -> Value
toJSON LFTagKeyResource' {Maybe Text
NonEmpty Text
Text
tagValues :: NonEmpty Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagValues:LFTagKeyResource' :: LFTagKeyResource -> NonEmpty Text
$sel:tagKey:LFTagKeyResource' :: LFTagKeyResource -> Text
$sel:catalogId:LFTagKeyResource' :: LFTagKeyResource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CatalogId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
catalogId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tagKey),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TagValues" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
tagValues)
          ]
      )