{-# 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.DeregisterResource
-- 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)
--
-- Deregisters the resource as managed by the Data Catalog.
--
-- When you deregister a path, Lake Formation removes the path from the
-- inline policy attached to your service-linked role.
module Amazonka.LakeFormation.DeregisterResource
  ( -- * Creating a Request
    DeregisterResource (..),
    newDeregisterResource,

    -- * Request Lenses
    deregisterResource_resourceArn,

    -- * Destructuring the Response
    DeregisterResourceResponse (..),
    newDeregisterResourceResponse,

    -- * Response Lenses
    deregisterResourceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeregisterResource' smart constructor.
data DeregisterResource = DeregisterResource'
  { -- | The Amazon Resource Name (ARN) of the resource that you want to
    -- deregister.
    DeregisterResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (DeregisterResource -> DeregisterResource -> Bool
(DeregisterResource -> DeregisterResource -> Bool)
-> (DeregisterResource -> DeregisterResource -> Bool)
-> Eq DeregisterResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterResource -> DeregisterResource -> Bool
$c/= :: DeregisterResource -> DeregisterResource -> Bool
== :: DeregisterResource -> DeregisterResource -> Bool
$c== :: DeregisterResource -> DeregisterResource -> Bool
Prelude.Eq, ReadPrec [DeregisterResource]
ReadPrec DeregisterResource
Int -> ReadS DeregisterResource
ReadS [DeregisterResource]
(Int -> ReadS DeregisterResource)
-> ReadS [DeregisterResource]
-> ReadPrec DeregisterResource
-> ReadPrec [DeregisterResource]
-> Read DeregisterResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterResource]
$creadListPrec :: ReadPrec [DeregisterResource]
readPrec :: ReadPrec DeregisterResource
$creadPrec :: ReadPrec DeregisterResource
readList :: ReadS [DeregisterResource]
$creadList :: ReadS [DeregisterResource]
readsPrec :: Int -> ReadS DeregisterResource
$creadsPrec :: Int -> ReadS DeregisterResource
Prelude.Read, Int -> DeregisterResource -> ShowS
[DeregisterResource] -> ShowS
DeregisterResource -> String
(Int -> DeregisterResource -> ShowS)
-> (DeregisterResource -> String)
-> ([DeregisterResource] -> ShowS)
-> Show DeregisterResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterResource] -> ShowS
$cshowList :: [DeregisterResource] -> ShowS
show :: DeregisterResource -> String
$cshow :: DeregisterResource -> String
showsPrec :: Int -> DeregisterResource -> ShowS
$cshowsPrec :: Int -> DeregisterResource -> ShowS
Prelude.Show, (forall x. DeregisterResource -> Rep DeregisterResource x)
-> (forall x. Rep DeregisterResource x -> DeregisterResource)
-> Generic DeregisterResource
forall x. Rep DeregisterResource x -> DeregisterResource
forall x. DeregisterResource -> Rep DeregisterResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterResource x -> DeregisterResource
$cfrom :: forall x. DeregisterResource -> Rep DeregisterResource x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterResource' 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:
--
-- 'resourceArn', 'deregisterResource_resourceArn' - The Amazon Resource Name (ARN) of the resource that you want to
-- deregister.
newDeregisterResource ::
  -- | 'resourceArn'
  Prelude.Text ->
  DeregisterResource
newDeregisterResource :: Text -> DeregisterResource
newDeregisterResource Text
pResourceArn_ =
  DeregisterResource' :: Text -> DeregisterResource
DeregisterResource' {$sel:resourceArn:DeregisterResource' :: Text
resourceArn = Text
pResourceArn_}

-- | The Amazon Resource Name (ARN) of the resource that you want to
-- deregister.
deregisterResource_resourceArn :: Lens.Lens' DeregisterResource Prelude.Text
deregisterResource_resourceArn :: (Text -> f Text) -> DeregisterResource -> f DeregisterResource
deregisterResource_resourceArn = (DeregisterResource -> Text)
-> (DeregisterResource -> Text -> DeregisterResource)
-> Lens DeregisterResource DeregisterResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterResource' {Text
resourceArn :: Text
$sel:resourceArn:DeregisterResource' :: DeregisterResource -> Text
resourceArn} -> Text
resourceArn) (\s :: DeregisterResource
s@DeregisterResource' {} Text
a -> DeregisterResource
s {$sel:resourceArn:DeregisterResource' :: Text
resourceArn = Text
a} :: DeregisterResource)

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

instance Prelude.Hashable DeregisterResource

instance Prelude.NFData DeregisterResource

instance Core.ToHeaders DeregisterResource where
  toHeaders :: DeregisterResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeregisterResource -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSLakeFormation.DeregisterResource" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeregisterResource where
  toJSON :: DeregisterResource -> Value
toJSON DeregisterResource' {Text
resourceArn :: Text
$sel:resourceArn:DeregisterResource' :: DeregisterResource -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [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)]
      )

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

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

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

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

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

instance Prelude.NFData DeregisterResourceResponse