{-# 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.GetLFTag
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an LF-tag definition.
module Amazonka.LakeFormation.GetLFTag
  ( -- * Creating a Request
    GetLFTag (..),
    newGetLFTag,

    -- * Request Lenses
    getLFTag_catalogId,
    getLFTag_tagKey,

    -- * Destructuring the Response
    GetLFTagResponse (..),
    newGetLFTagResponse,

    -- * Response Lenses
    getLFTagResponse_catalogId,
    getLFTagResponse_tagKey,
    getLFTagResponse_tagValues,
    getLFTagResponse_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:/ 'newGetLFTag' smart constructor.
data GetLFTag = GetLFTag'
  { -- | 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.
    GetLFTag -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The key-name for the LF-tag.
    GetLFTag -> Text
tagKey :: Prelude.Text
  }
  deriving (GetLFTag -> GetLFTag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLFTag -> GetLFTag -> Bool
$c/= :: GetLFTag -> GetLFTag -> Bool
== :: GetLFTag -> GetLFTag -> Bool
$c== :: GetLFTag -> GetLFTag -> Bool
Prelude.Eq, ReadPrec [GetLFTag]
ReadPrec GetLFTag
Int -> ReadS GetLFTag
ReadS [GetLFTag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLFTag]
$creadListPrec :: ReadPrec [GetLFTag]
readPrec :: ReadPrec GetLFTag
$creadPrec :: ReadPrec GetLFTag
readList :: ReadS [GetLFTag]
$creadList :: ReadS [GetLFTag]
readsPrec :: Int -> ReadS GetLFTag
$creadsPrec :: Int -> ReadS GetLFTag
Prelude.Read, Int -> GetLFTag -> ShowS
[GetLFTag] -> ShowS
GetLFTag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLFTag] -> ShowS
$cshowList :: [GetLFTag] -> ShowS
show :: GetLFTag -> String
$cshow :: GetLFTag -> String
showsPrec :: Int -> GetLFTag -> ShowS
$cshowsPrec :: Int -> GetLFTag -> ShowS
Prelude.Show, forall x. Rep GetLFTag x -> GetLFTag
forall x. GetLFTag -> Rep GetLFTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLFTag x -> GetLFTag
$cfrom :: forall x. GetLFTag -> Rep GetLFTag x
Prelude.Generic)

-- |
-- Create a value of 'GetLFTag' 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', 'getLFTag_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', 'getLFTag_tagKey' - The key-name for the LF-tag.
newGetLFTag ::
  -- | 'tagKey'
  Prelude.Text ->
  GetLFTag
newGetLFTag :: Text -> GetLFTag
newGetLFTag Text
pTagKey_ =
  GetLFTag'
    { $sel:catalogId:GetLFTag' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:GetLFTag' :: Text
tagKey = Text
pTagKey_
    }

-- | 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.
getLFTag_catalogId :: Lens.Lens' GetLFTag (Prelude.Maybe Prelude.Text)
getLFTag_catalogId :: Lens' GetLFTag (Maybe Text)
getLFTag_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLFTag' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GetLFTag' :: GetLFTag -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: GetLFTag
s@GetLFTag' {} Maybe Text
a -> GetLFTag
s {$sel:catalogId:GetLFTag' :: Maybe Text
catalogId = Maybe Text
a} :: GetLFTag)

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

instance Core.AWSRequest GetLFTag where
  type AWSResponse GetLFTag = GetLFTagResponse
  request :: (Service -> Service) -> GetLFTag -> Request GetLFTag
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 GetLFTag
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLFTag)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text -> Maybe (NonEmpty Text) -> Int -> GetLFTagResponse
GetLFTagResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"CatalogId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TagKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TagValues")
            forall (f :: * -> *) a b. Applicative f => 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 GetLFTag where
  hashWithSalt :: Int -> GetLFTag -> Int
hashWithSalt Int
_salt GetLFTag' {Maybe Text
Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagKey:GetLFTag' :: GetLFTag -> Text
$sel:catalogId:GetLFTag' :: GetLFTag -> 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

instance Prelude.NFData GetLFTag where
  rnf :: GetLFTag -> ()
rnf GetLFTag' {Maybe Text
Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagKey:GetLFTag' :: GetLFTag -> Text
$sel:catalogId:GetLFTag' :: GetLFTag -> 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

instance Data.ToHeaders GetLFTag where
  toHeaders :: GetLFTag -> 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 GetLFTag where
  toJSON :: GetLFTag -> Value
toJSON GetLFTag' {Maybe Text
Text
tagKey :: Text
catalogId :: Maybe Text
$sel:tagKey:GetLFTag' :: GetLFTag -> Text
$sel:catalogId:GetLFTag' :: GetLFTag -> 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)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetLFTagResponse' 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', 'getLFTagResponse_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', 'getLFTagResponse_tagKey' - The key-name for the LF-tag.
--
-- 'tagValues', 'getLFTagResponse_tagValues' - A list of possible values an attribute can take.
--
-- 'httpStatus', 'getLFTagResponse_httpStatus' - The response's http status code.
newGetLFTagResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetLFTagResponse
newGetLFTagResponse :: Int -> GetLFTagResponse
newGetLFTagResponse Int
pHttpStatus_ =
  GetLFTagResponse'
    { $sel:catalogId:GetLFTagResponse' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:tagKey:GetLFTagResponse' :: Maybe Text
tagKey = forall a. Maybe a
Prelude.Nothing,
      $sel:tagValues:GetLFTagResponse' :: Maybe (NonEmpty Text)
tagValues = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetLFTagResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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.
getLFTagResponse_catalogId :: Lens.Lens' GetLFTagResponse (Prelude.Maybe Prelude.Text)
getLFTagResponse_catalogId :: Lens' GetLFTagResponse (Maybe Text)
getLFTagResponse_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLFTagResponse' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GetLFTagResponse' :: GetLFTagResponse -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: GetLFTagResponse
s@GetLFTagResponse' {} Maybe Text
a -> GetLFTagResponse
s {$sel:catalogId:GetLFTagResponse' :: Maybe Text
catalogId = Maybe Text
a} :: GetLFTagResponse)

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

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

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

instance Prelude.NFData GetLFTagResponse where
  rnf :: GetLFTagResponse -> ()
rnf GetLFTagResponse' {Int
Maybe (NonEmpty Text)
Maybe Text
httpStatus :: Int
tagValues :: Maybe (NonEmpty Text)
tagKey :: Maybe Text
catalogId :: Maybe Text
$sel:httpStatus:GetLFTagResponse' :: GetLFTagResponse -> Int
$sel:tagValues:GetLFTagResponse' :: GetLFTagResponse -> Maybe (NonEmpty Text)
$sel:tagKey:GetLFTagResponse' :: GetLFTagResponse -> Maybe Text
$sel:catalogId:GetLFTagResponse' :: GetLFTagResponse -> 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 Maybe Text
tagKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
tagValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus