{-# 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.DataLocationResource
-- 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.DataLocationResource where

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

-- | A structure for a data location object where permissions are granted or
-- revoked.
--
-- /See:/ 'newDataLocationResource' smart constructor.
data DataLocationResource = DataLocationResource'
  { -- | The identifier for the Data Catalog where the location is registered
    -- with AWS Lake Formation. By default, it is the account ID of the caller.
    DataLocationResource -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) that uniquely identifies the data
    -- location resource.
    DataLocationResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (DataLocationResource -> DataLocationResource -> Bool
(DataLocationResource -> DataLocationResource -> Bool)
-> (DataLocationResource -> DataLocationResource -> Bool)
-> Eq DataLocationResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataLocationResource -> DataLocationResource -> Bool
$c/= :: DataLocationResource -> DataLocationResource -> Bool
== :: DataLocationResource -> DataLocationResource -> Bool
$c== :: DataLocationResource -> DataLocationResource -> Bool
Prelude.Eq, ReadPrec [DataLocationResource]
ReadPrec DataLocationResource
Int -> ReadS DataLocationResource
ReadS [DataLocationResource]
(Int -> ReadS DataLocationResource)
-> ReadS [DataLocationResource]
-> ReadPrec DataLocationResource
-> ReadPrec [DataLocationResource]
-> Read DataLocationResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataLocationResource]
$creadListPrec :: ReadPrec [DataLocationResource]
readPrec :: ReadPrec DataLocationResource
$creadPrec :: ReadPrec DataLocationResource
readList :: ReadS [DataLocationResource]
$creadList :: ReadS [DataLocationResource]
readsPrec :: Int -> ReadS DataLocationResource
$creadsPrec :: Int -> ReadS DataLocationResource
Prelude.Read, Int -> DataLocationResource -> ShowS
[DataLocationResource] -> ShowS
DataLocationResource -> String
(Int -> DataLocationResource -> ShowS)
-> (DataLocationResource -> String)
-> ([DataLocationResource] -> ShowS)
-> Show DataLocationResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataLocationResource] -> ShowS
$cshowList :: [DataLocationResource] -> ShowS
show :: DataLocationResource -> String
$cshow :: DataLocationResource -> String
showsPrec :: Int -> DataLocationResource -> ShowS
$cshowsPrec :: Int -> DataLocationResource -> ShowS
Prelude.Show, (forall x. DataLocationResource -> Rep DataLocationResource x)
-> (forall x. Rep DataLocationResource x -> DataLocationResource)
-> Generic DataLocationResource
forall x. Rep DataLocationResource x -> DataLocationResource
forall x. DataLocationResource -> Rep DataLocationResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataLocationResource x -> DataLocationResource
$cfrom :: forall x. DataLocationResource -> Rep DataLocationResource x
Prelude.Generic)

-- |
-- Create a value of 'DataLocationResource' 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', 'dataLocationResource_catalogId' - The identifier for the Data Catalog where the location is registered
-- with AWS Lake Formation. By default, it is the account ID of the caller.
--
-- 'resourceArn', 'dataLocationResource_resourceArn' - The Amazon Resource Name (ARN) that uniquely identifies the data
-- location resource.
newDataLocationResource ::
  -- | 'resourceArn'
  Prelude.Text ->
  DataLocationResource
newDataLocationResource :: Text -> DataLocationResource
newDataLocationResource Text
pResourceArn_ =
  DataLocationResource' :: Maybe Text -> Text -> DataLocationResource
DataLocationResource'
    { $sel:catalogId:DataLocationResource' :: Maybe Text
catalogId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:DataLocationResource' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The identifier for the Data Catalog where the location is registered
-- with AWS Lake Formation. By default, it is the account ID of the caller.
dataLocationResource_catalogId :: Lens.Lens' DataLocationResource (Prelude.Maybe Prelude.Text)
dataLocationResource_catalogId :: (Maybe Text -> f (Maybe Text))
-> DataLocationResource -> f DataLocationResource
dataLocationResource_catalogId = (DataLocationResource -> Maybe Text)
-> (DataLocationResource -> Maybe Text -> DataLocationResource)
-> Lens
     DataLocationResource DataLocationResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataLocationResource' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:DataLocationResource' :: DataLocationResource -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: DataLocationResource
s@DataLocationResource' {} Maybe Text
a -> DataLocationResource
s {$sel:catalogId:DataLocationResource' :: Maybe Text
catalogId = Maybe Text
a} :: DataLocationResource)

-- | The Amazon Resource Name (ARN) that uniquely identifies the data
-- location resource.
dataLocationResource_resourceArn :: Lens.Lens' DataLocationResource Prelude.Text
dataLocationResource_resourceArn :: (Text -> f Text) -> DataLocationResource -> f DataLocationResource
dataLocationResource_resourceArn = (DataLocationResource -> Text)
-> (DataLocationResource -> Text -> DataLocationResource)
-> Lens DataLocationResource DataLocationResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataLocationResource' {Text
resourceArn :: Text
$sel:resourceArn:DataLocationResource' :: DataLocationResource -> Text
resourceArn} -> Text
resourceArn) (\s :: DataLocationResource
s@DataLocationResource' {} Text
a -> DataLocationResource
s {$sel:resourceArn:DataLocationResource' :: Text
resourceArn = Text
a} :: DataLocationResource)

instance Core.FromJSON DataLocationResource where
  parseJSON :: Value -> Parser DataLocationResource
parseJSON =
    String
-> (Object -> Parser DataLocationResource)
-> Value
-> Parser DataLocationResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataLocationResource"
      ( \Object
x ->
          Maybe Text -> Text -> DataLocationResource
DataLocationResource'
            (Maybe Text -> Text -> DataLocationResource)
-> Parser (Maybe Text) -> Parser (Text -> DataLocationResource)
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 -> DataLocationResource)
-> Parser Text -> Parser DataLocationResource
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
"ResourceArn")
      )

instance Prelude.Hashable DataLocationResource

instance Prelude.NFData DataLocationResource

instance Core.ToJSON DataLocationResource where
  toJSON :: DataLocationResource -> Value
toJSON DataLocationResource' {Maybe Text
Text
resourceArn :: Text
catalogId :: Maybe Text
$sel:resourceArn:DataLocationResource' :: DataLocationResource -> Text
$sel:catalogId:DataLocationResource' :: DataLocationResource -> 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
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn)
          ]
      )