{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$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 :: Lens' DeleteACL Text
deleteACL_aCLName = 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 :: (Service -> Service) -> DeleteACL -> Request DeleteACL
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 DeleteACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteACL)))
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 ACL -> Int -> DeleteACLResponse
DeleteACLResponse'
            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
"ACL")
            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 DeleteACL where
  hashWithSalt :: Int -> DeleteACL -> Int
hashWithSalt Int
_salt DeleteACL' {Text
aCLName :: Text
$sel:aCLName:DeleteACL' :: DeleteACL -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
aCLName

instance Prelude.NFData DeleteACL where
  rnf :: DeleteACL -> ()
rnf DeleteACL' {Text
aCLName :: Text
$sel:aCLName:DeleteACL' :: DeleteACL -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
aCLName

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

instance Data.ToJSON DeleteACL where
  toJSON :: DeleteACL -> Value
toJSON DeleteACL' {Text
aCLName :: Text
$sel:aCLName:DeleteACL' :: DeleteACL -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ACLName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
aCLName)]
      )

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

instance Data.ToQuery DeleteACL where
  toQuery :: DeleteACL -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:acl:DeleteACLResponse' :: Maybe ACL
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 :: Lens' DeleteACLResponse (Maybe ACL)
deleteACLResponse_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 :: Lens' DeleteACLResponse Int
deleteACLResponse_httpStatus = 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 where
  rnf :: DeleteACLResponse -> ()
rnf DeleteACLResponse' {Int
Maybe ACL
httpStatus :: Int
acl :: Maybe ACL
$sel:httpStatus:DeleteACLResponse' :: DeleteACLResponse -> Int
$sel:acl:DeleteACLResponse' :: DeleteACLResponse -> Maybe ACL
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ACL
acl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus