{-# 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.MemoryDb.DeleteACL
-- 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)
--
-- Deletes an Access Control List. The ACL must first be disassociated from
-- the cluster before it can be deleted. For more information, see
-- <https://docs.aws.amazon.com/MemoryDB/latest/devguide/clusters.acls.html Authenticating users with Access Contol Lists (ACLs)>.
module Amazonka.MemoryDb.DeleteACL
  ( -- * Creating a Request
    DeleteACL (..),
    newDeleteACL,

    -- * Request Lenses
    deleteACL_aCLName,

    -- * Destructuring the Response
    DeleteACLResponse (..),
    newDeleteACLResponse,

    -- * Response Lenses
    deleteACLResponse_acl,
    deleteACLResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteACL' smart constructor.
data DeleteACL = DeleteACL'
  { -- | The name of the Access Control List to delete
    DeleteACL -> Text
aCLName :: Prelude.Text
  }
  deriving (DeleteACL -> DeleteACL -> Bool
(DeleteACL -> DeleteACL -> Bool)
-> (DeleteACL -> DeleteACL -> Bool) -> Eq DeleteACL
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteACL -> DeleteACL -> Bool
$c/= :: DeleteACL -> DeleteACL -> Bool
== :: DeleteACL -> DeleteACL -> Bool
$c== :: DeleteACL -> DeleteACL -> Bool
Prelude.Eq, ReadPrec [DeleteACL]
ReadPrec DeleteACL
Int -> ReadS DeleteACL
ReadS [DeleteACL]
(Int -> ReadS DeleteACL)
-> ReadS [DeleteACL]
-> ReadPrec DeleteACL
-> ReadPrec [DeleteACL]
-> Read DeleteACL
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteACL]
$creadListPrec :: ReadPrec [DeleteACL]
readPrec :: ReadPrec DeleteACL
$creadPrec :: ReadPrec DeleteACL
readList :: ReadS [DeleteACL]
$creadList :: ReadS [DeleteACL]
readsPrec :: Int -> ReadS DeleteACL
$creadsPrec :: Int -> ReadS DeleteACL
Prelude.Read, Int -> DeleteACL -> ShowS
[DeleteACL] -> ShowS
DeleteACL -> String
(Int -> DeleteACL -> ShowS)
-> (DeleteACL -> String)
-> ([DeleteACL] -> ShowS)
-> Show DeleteACL
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteACL] -> ShowS
$cshowList :: [DeleteACL] -> ShowS
show :: DeleteACL -> String
$cshow :: DeleteACL -> String
showsPrec :: Int -> DeleteACL -> ShowS
$cshowsPrec :: Int -> DeleteACL -> ShowS
Prelude.Show, (forall x. DeleteACL -> Rep DeleteACL x)
-> (forall x. Rep DeleteACL x -> DeleteACL) -> Generic DeleteACL
forall x. Rep DeleteACL x -> DeleteACL
forall x. DeleteACL -> Rep DeleteACL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteACL x -> DeleteACL
$cfrom :: forall x. DeleteACL -> Rep DeleteACL x
Prelude.Generic)

-- |
-- Create a value of 'DeleteACL' 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:
--
-- 'aCLName', 'deleteACL_aCLName' - The name of the Access Control List to delete
newDeleteACL ::
  -- | 'aCLName'
  Prelude.Text ->
  DeleteACL
newDeleteACL :: Text -> DeleteACL
newDeleteACL Text
pACLName_ =
  DeleteACL' :: Text -> DeleteACL
DeleteACL' {$sel:aCLName:DeleteACL' :: Text
aCLName = Text
pACLName_}

-- | The name of the Access Control List to delete
deleteACL_aCLName :: Lens.Lens' DeleteACL Prelude.Text
deleteACL_aCLName :: (Text -> f Text) -> DeleteACL -> f DeleteACL
deleteACL_aCLName = (DeleteACL -> Text)
-> (DeleteACL -> Text -> DeleteACL)
-> Lens DeleteACL DeleteACL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteACL' {Text
aCLName :: Text
$sel:aCLName:DeleteACL' :: DeleteACL -> Text
aCLName} -> Text
aCLName) (\s :: DeleteACL
s@DeleteACL' {} Text
a -> DeleteACL
s {$sel:aCLName:DeleteACL' :: Text
aCLName = Text
a} :: DeleteACL)

instance Core.AWSRequest DeleteACL where
  type AWSResponse DeleteACL = DeleteACLResponse
  request :: DeleteACL -> Request DeleteACL
request = Service -> DeleteACL -> Request DeleteACL
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteACL)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteACL))
-> Logger
-> Service
-> Proxy DeleteACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteACL)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ACL -> Int -> DeleteACLResponse
DeleteACLResponse'
            (Maybe ACL -> Int -> DeleteACLResponse)
-> Either String (Maybe ACL)
-> Either String (Int -> DeleteACLResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ACL)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ACL")
            Either String (Int -> DeleteACLResponse)
-> Either String Int -> Either String DeleteACLResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteACL

instance Prelude.NFData DeleteACL

instance Core.ToHeaders DeleteACL where
  toHeaders :: DeleteACL -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteACL -> 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
"AmazonMemoryDB.DeleteACL" :: 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 DeleteACL where
  toJSON :: DeleteACL -> Value
toJSON DeleteACL' {Text
aCLName :: Text
$sel:aCLName:DeleteACL' :: DeleteACL -> 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
"ACLName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
aCLName)]
      )

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

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

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

-- |
-- Create a value of 'DeleteACLResponse' 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:
--
-- 'acl', 'deleteACLResponse_acl' - The Access Control List object that has been deleted.
--
-- 'httpStatus', 'deleteACLResponse_httpStatus' - The response's http status code.
newDeleteACLResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteACLResponse
newDeleteACLResponse :: Int -> DeleteACLResponse
newDeleteACLResponse Int
pHttpStatus_ =
  DeleteACLResponse' :: Maybe ACL -> Int -> DeleteACLResponse
DeleteACLResponse'
    { $sel:acl:DeleteACLResponse' :: Maybe ACL
acl = Maybe ACL
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteACLResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Access Control List object that has been deleted.
deleteACLResponse_acl :: Lens.Lens' DeleteACLResponse (Prelude.Maybe ACL)
deleteACLResponse_acl :: (Maybe ACL -> f (Maybe ACL))
-> DeleteACLResponse -> f DeleteACLResponse
deleteACLResponse_acl = (DeleteACLResponse -> Maybe ACL)
-> (DeleteACLResponse -> Maybe ACL -> DeleteACLResponse)
-> Lens DeleteACLResponse DeleteACLResponse (Maybe ACL) (Maybe ACL)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteACLResponse' {Maybe ACL
acl :: Maybe ACL
$sel:acl:DeleteACLResponse' :: DeleteACLResponse -> Maybe ACL
acl} -> Maybe ACL
acl) (\s :: DeleteACLResponse
s@DeleteACLResponse' {} Maybe ACL
a -> DeleteACLResponse
s {$sel:acl:DeleteACLResponse' :: Maybe ACL
acl = Maybe ACL
a} :: DeleteACLResponse)

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

instance Prelude.NFData DeleteACLResponse