{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateLFTag
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates an LF-tag with the specified name and values.
module Amazonka.LakeFormation.CreateLFTag
  ( -- * Creating a Request
    CreateLFTag (..),
    newCreateLFTag,

    -- * Request Lenses
    createLFTag_catalogId,
    createLFTag_tagKey,
    createLFTag_tagValues,

    -- * Destructuring the Response
    CreateLFTagResponse (..),
    newCreateLFTagResponse,

    -- * Response Lenses
    createLFTagResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LakeFormation.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateLFTag' smart constructor.
data CreateLFTag = CreateLFTag'
  { -- | 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 Lake Formation environment.
    CreateLFTag -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The key-name for the LF-tag.
    CreateLFTag -> Text
tagKey :: Prelude.Text,
    -- | A list of possible values an attribute can take.
    CreateLFTag -> NonEmpty Text
tagValues :: Prelude.NonEmpty Prelude.Text
  }
  deriving (CreateLFTag -> CreateLFTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLFTag -> CreateLFTag -> Bool
$c/= :: CreateLFTag -> CreateLFTag -> Bool
== :: CreateLFTag -> CreateLFTag -> Bool
$c== :: CreateLFTag -> CreateLFTag -> Bool
Prelude.Eq, ReadPrec [CreateLFTag]
ReadPrec CreateLFTag
Int -> ReadS CreateLFTag
ReadS [CreateLFTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLFTag]
$creadListPrec :: ReadPrec [CreateLFTag]
readPrec :: ReadPrec CreateLFTag
$creadPrec :: ReadPrec CreateLFTag
readList :: ReadS [CreateLFTag]
$creadList :: ReadS [CreateLFTag]
readsPrec :: Int -> ReadS CreateLFTag
$creadsPrec :: Int -> ReadS CreateLFTag
Prelude.Read, Int -> CreateLFTag -> ShowS
[CreateLFTag] -> ShowS
CreateLFTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLFTag] -> ShowS
$cshowList :: [CreateLFTag] -> ShowS
show :: CreateLFTag -> String
$cshow :: CreateLFTag -> String
showsPrec :: Int -> CreateLFTag -> ShowS
$cshowsPrec :: Int -> CreateLFTag -> ShowS
Prelude.Show, forall x. Rep CreateLFTag x -> CreateLFTag
forall x. CreateLFTag -> Rep CreateLFTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLFTag x -> CreateLFTag
$cfrom :: forall x. CreateLFTag -> Rep CreateLFTag x
Prelude.Generic)

-- |
-- Create a value of 'CreateLFTag' 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', 'createLFTag_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 Lake Formation environment.
--
-- 'tagKey', 'createLFTag_tagKey' - The key-name for the LF-tag.
--
-- 'tagValues', 'createLFTag_tagValues' - A list of possible values an attribute can take.
newCreateLFTag ::
  -- | 'tagKey'
  Prelude.Text ->
  -- | 'tagValues'
  Prelude.NonEmpty Prelude.Text ->
  CreateLFTag
newCreateLFTag :: Text -> NonEmpty Text -> CreateLFTag
newCreateLFTag Text
pTagKey_ NonEmpty Text
pTagValues_ =
  CreateLFTag'
    { $sel:catalogId:CreateLFTag' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:CreateLFTag' :: Text
tagKey = Text
pTagKey_,
      $sel:tagValues:CreateLFTag' :: NonEmpty Text
tagValues = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 Lake Formation environment.
createLFTag_catalogId :: Lens.Lens' CreateLFTag (Prelude.Maybe Prelude.Text)
createLFTag_catalogId :: Lens' CreateLFTag (Maybe Text)
createLFTag_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLFTag' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:CreateLFTag' :: CreateLFTag -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: CreateLFTag
s@CreateLFTag' {} Maybe Text
a -> CreateLFTag
s {$sel:catalogId:CreateLFTag' :: Maybe Text
catalogId = Maybe Text
a} :: CreateLFTag)

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

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

instance Core.AWSRequest CreateLFTag where
  type AWSResponse CreateLFTag = CreateLFTagResponse
  request :: (Service -> Service) -> CreateLFTag -> Request CreateLFTag
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateLFTag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateLFTag)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateLFTagResponse
CreateLFTagResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateLFTag where
  hashWithSalt :: Int -> CreateLFTag -> Int
hashWithSalt Int
_salt CreateLFTag' {Maybe Text
NonEmpty Text
Text
tagValues :: NonEmpty Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagValues:CreateLFTag' :: CreateLFTag -> NonEmpty Text
$sel:tagKey:CreateLFTag' :: CreateLFTag -> Text
$sel:catalogId:CreateLFTag' :: CreateLFTag -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tagKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
tagValues

instance Prelude.NFData CreateLFTag where
  rnf :: CreateLFTag -> ()
rnf CreateLFTag' {Maybe Text
NonEmpty Text
Text
tagValues :: NonEmpty Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagValues:CreateLFTag' :: CreateLFTag -> NonEmpty Text
$sel:tagKey:CreateLFTag' :: CreateLFTag -> Text
$sel:catalogId:CreateLFTag' :: CreateLFTag -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tagKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
tagValues

instance Data.ToHeaders CreateLFTag where
  toHeaders :: CreateLFTag -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToPath CreateLFTag where
  toPath :: CreateLFTag -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/CreateLFTag"

instance Data.ToQuery CreateLFTag where
  toQuery :: CreateLFTag -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateLFTagResponse' smart constructor.
data CreateLFTagResponse = CreateLFTagResponse'
  { -- | The response's http status code.
    CreateLFTagResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateLFTagResponse -> CreateLFTagResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateLFTagResponse -> CreateLFTagResponse -> Bool
$c/= :: CreateLFTagResponse -> CreateLFTagResponse -> Bool
== :: CreateLFTagResponse -> CreateLFTagResponse -> Bool
$c== :: CreateLFTagResponse -> CreateLFTagResponse -> Bool
Prelude.Eq, ReadPrec [CreateLFTagResponse]
ReadPrec CreateLFTagResponse
Int -> ReadS CreateLFTagResponse
ReadS [CreateLFTagResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateLFTagResponse]
$creadListPrec :: ReadPrec [CreateLFTagResponse]
readPrec :: ReadPrec CreateLFTagResponse
$creadPrec :: ReadPrec CreateLFTagResponse
readList :: ReadS [CreateLFTagResponse]
$creadList :: ReadS [CreateLFTagResponse]
readsPrec :: Int -> ReadS CreateLFTagResponse
$creadsPrec :: Int -> ReadS CreateLFTagResponse
Prelude.Read, Int -> CreateLFTagResponse -> ShowS
[CreateLFTagResponse] -> ShowS
CreateLFTagResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateLFTagResponse] -> ShowS
$cshowList :: [CreateLFTagResponse] -> ShowS
show :: CreateLFTagResponse -> String
$cshow :: CreateLFTagResponse -> String
showsPrec :: Int -> CreateLFTagResponse -> ShowS
$cshowsPrec :: Int -> CreateLFTagResponse -> ShowS
Prelude.Show, forall x. Rep CreateLFTagResponse x -> CreateLFTagResponse
forall x. CreateLFTagResponse -> Rep CreateLFTagResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateLFTagResponse x -> CreateLFTagResponse
$cfrom :: forall x. CreateLFTagResponse -> Rep CreateLFTagResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateLFTagResponse' 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:
--
-- 'httpStatus', 'createLFTagResponse_httpStatus' - The response's http status code.
newCreateLFTagResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateLFTagResponse
newCreateLFTagResponse :: Int -> CreateLFTagResponse
newCreateLFTagResponse Int
pHttpStatus_ =
  CreateLFTagResponse' {$sel:httpStatus:CreateLFTagResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
createLFTagResponse_httpStatus :: Lens.Lens' CreateLFTagResponse Prelude.Int
createLFTagResponse_httpStatus :: Lens' CreateLFTagResponse Int
createLFTagResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateLFTagResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateLFTagResponse' :: CreateLFTagResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateLFTagResponse
s@CreateLFTagResponse' {} Int
a -> CreateLFTagResponse
s {$sel:httpStatus:CreateLFTagResponse' :: Int
httpStatus = Int
a} :: CreateLFTagResponse)

instance Prelude.NFData CreateLFTagResponse where
  rnf :: CreateLFTagResponse -> ()
rnf CreateLFTagResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateLFTagResponse' :: CreateLFTagResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus