{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LakeFormation.Types.DataLocationResource 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 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 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
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]
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
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. 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 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'
    { $sel:catalogId:DataLocationResource' :: Maybe Text
catalogId = 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 Lake Formation. By default, it is the account ID of the caller.
dataLocationResource_catalogId :: Lens.Lens' DataLocationResource (Prelude.Maybe Prelude.Text)
dataLocationResource_catalogId :: Lens' DataLocationResource (Maybe Text)
dataLocationResource_catalogId = 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 :: Lens' DataLocationResource Text
dataLocationResource_resourceArn = 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 Data.FromJSON DataLocationResource where
  parseJSON :: Value -> Parser DataLocationResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataLocationResource"
      ( \Object
x ->
          Maybe Text -> Text -> DataLocationResource
DataLocationResource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (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 -> Parser a
Data..: Key
"ResourceArn")
      )

instance Prelude.Hashable DataLocationResource where
  hashWithSalt :: Int -> DataLocationResource -> Int
hashWithSalt Int
_salt DataLocationResource' {Maybe Text
Text
resourceArn :: Text
catalogId :: Maybe Text
$sel:resourceArn:DataLocationResource' :: DataLocationResource -> Text
$sel:catalogId:DataLocationResource' :: DataLocationResource -> 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
resourceArn

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

instance Data.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
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
"ResourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceArn)
          ]
      )