{-# 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.LicenseManager.DeleteGrant
-- 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 the specified grant.
module Amazonka.LicenseManager.DeleteGrant
  ( -- * Creating a Request
    DeleteGrant (..),
    newDeleteGrant,

    -- * Request Lenses
    deleteGrant_statusReason,
    deleteGrant_grantArn,
    deleteGrant_version,

    -- * Destructuring the Response
    DeleteGrantResponse (..),
    newDeleteGrantResponse,

    -- * Response Lenses
    deleteGrantResponse_grantArn,
    deleteGrantResponse_status,
    deleteGrantResponse_version,
    deleteGrantResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LicenseManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteGrant' smart constructor.
data DeleteGrant = DeleteGrant'
  { -- | The Status reason for the delete request.
    DeleteGrant -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the grant.
    DeleteGrant -> Text
grantArn :: Prelude.Text,
    -- | Current version of the grant.
    DeleteGrant -> Text
version :: Prelude.Text
  }
  deriving (DeleteGrant -> DeleteGrant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGrant -> DeleteGrant -> Bool
$c/= :: DeleteGrant -> DeleteGrant -> Bool
== :: DeleteGrant -> DeleteGrant -> Bool
$c== :: DeleteGrant -> DeleteGrant -> Bool
Prelude.Eq, ReadPrec [DeleteGrant]
ReadPrec DeleteGrant
Int -> ReadS DeleteGrant
ReadS [DeleteGrant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGrant]
$creadListPrec :: ReadPrec [DeleteGrant]
readPrec :: ReadPrec DeleteGrant
$creadPrec :: ReadPrec DeleteGrant
readList :: ReadS [DeleteGrant]
$creadList :: ReadS [DeleteGrant]
readsPrec :: Int -> ReadS DeleteGrant
$creadsPrec :: Int -> ReadS DeleteGrant
Prelude.Read, Int -> DeleteGrant -> ShowS
[DeleteGrant] -> ShowS
DeleteGrant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGrant] -> ShowS
$cshowList :: [DeleteGrant] -> ShowS
show :: DeleteGrant -> String
$cshow :: DeleteGrant -> String
showsPrec :: Int -> DeleteGrant -> ShowS
$cshowsPrec :: Int -> DeleteGrant -> ShowS
Prelude.Show, forall x. Rep DeleteGrant x -> DeleteGrant
forall x. DeleteGrant -> Rep DeleteGrant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteGrant x -> DeleteGrant
$cfrom :: forall x. DeleteGrant -> Rep DeleteGrant x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGrant' 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:
--
-- 'statusReason', 'deleteGrant_statusReason' - The Status reason for the delete request.
--
-- 'grantArn', 'deleteGrant_grantArn' - Amazon Resource Name (ARN) of the grant.
--
-- 'version', 'deleteGrant_version' - Current version of the grant.
newDeleteGrant ::
  -- | 'grantArn'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  DeleteGrant
newDeleteGrant :: Text -> Text -> DeleteGrant
newDeleteGrant Text
pGrantArn_ Text
pVersion_ =
  DeleteGrant'
    { $sel:statusReason:DeleteGrant' :: Maybe Text
statusReason = forall a. Maybe a
Prelude.Nothing,
      $sel:grantArn:DeleteGrant' :: Text
grantArn = Text
pGrantArn_,
      $sel:version:DeleteGrant' :: Text
version = Text
pVersion_
    }

-- | The Status reason for the delete request.
deleteGrant_statusReason :: Lens.Lens' DeleteGrant (Prelude.Maybe Prelude.Text)
deleteGrant_statusReason :: Lens' DeleteGrant (Maybe Text)
deleteGrant_statusReason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrant' {Maybe Text
statusReason :: Maybe Text
$sel:statusReason:DeleteGrant' :: DeleteGrant -> Maybe Text
statusReason} -> Maybe Text
statusReason) (\s :: DeleteGrant
s@DeleteGrant' {} Maybe Text
a -> DeleteGrant
s {$sel:statusReason:DeleteGrant' :: Maybe Text
statusReason = Maybe Text
a} :: DeleteGrant)

-- | Amazon Resource Name (ARN) of the grant.
deleteGrant_grantArn :: Lens.Lens' DeleteGrant Prelude.Text
deleteGrant_grantArn :: Lens' DeleteGrant Text
deleteGrant_grantArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrant' {Text
grantArn :: Text
$sel:grantArn:DeleteGrant' :: DeleteGrant -> Text
grantArn} -> Text
grantArn) (\s :: DeleteGrant
s@DeleteGrant' {} Text
a -> DeleteGrant
s {$sel:grantArn:DeleteGrant' :: Text
grantArn = Text
a} :: DeleteGrant)

-- | Current version of the grant.
deleteGrant_version :: Lens.Lens' DeleteGrant Prelude.Text
deleteGrant_version :: Lens' DeleteGrant Text
deleteGrant_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrant' {Text
version :: Text
$sel:version:DeleteGrant' :: DeleteGrant -> Text
version} -> Text
version) (\s :: DeleteGrant
s@DeleteGrant' {} Text
a -> DeleteGrant
s {$sel:version:DeleteGrant' :: Text
version = Text
a} :: DeleteGrant)

instance Core.AWSRequest DeleteGrant where
  type AWSResponse DeleteGrant = DeleteGrantResponse
  request :: (Service -> Service) -> DeleteGrant -> Request DeleteGrant
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 DeleteGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteGrant)))
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 Text
-> Maybe GrantStatus -> Maybe Text -> Int -> DeleteGrantResponse
DeleteGrantResponse'
            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
"GrantArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Version")
            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 DeleteGrant where
  hashWithSalt :: Int -> DeleteGrant -> Int
hashWithSalt Int
_salt DeleteGrant' {Maybe Text
Text
version :: Text
grantArn :: Text
statusReason :: Maybe Text
$sel:version:DeleteGrant' :: DeleteGrant -> Text
$sel:grantArn:DeleteGrant' :: DeleteGrant -> Text
$sel:statusReason:DeleteGrant' :: DeleteGrant -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
grantArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
version

instance Prelude.NFData DeleteGrant where
  rnf :: DeleteGrant -> ()
rnf DeleteGrant' {Maybe Text
Text
version :: Text
grantArn :: Text
statusReason :: Maybe Text
$sel:version:DeleteGrant' :: DeleteGrant -> Text
$sel:grantArn:DeleteGrant' :: DeleteGrant -> Text
$sel:statusReason:DeleteGrant' :: DeleteGrant -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
grantArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
version

instance Data.ToHeaders DeleteGrant where
  toHeaders :: DeleteGrant -> 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
"AWSLicenseManager.DeleteGrant" ::
                          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 DeleteGrant where
  toJSON :: DeleteGrant -> Value
toJSON DeleteGrant' {Maybe Text
Text
version :: Text
grantArn :: Text
statusReason :: Maybe Text
$sel:version:DeleteGrant' :: DeleteGrant -> Text
$sel:grantArn:DeleteGrant' :: DeleteGrant -> Text
$sel:statusReason:DeleteGrant' :: DeleteGrant -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StatusReason" 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
statusReason,
            forall a. a -> Maybe a
Prelude.Just (Key
"GrantArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
grantArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"Version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
version)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteGrantResponse' 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:
--
-- 'grantArn', 'deleteGrantResponse_grantArn' - Grant ARN.
--
-- 'status', 'deleteGrantResponse_status' - Grant status.
--
-- 'version', 'deleteGrantResponse_version' - Grant version.
--
-- 'httpStatus', 'deleteGrantResponse_httpStatus' - The response's http status code.
newDeleteGrantResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteGrantResponse
newDeleteGrantResponse :: Int -> DeleteGrantResponse
newDeleteGrantResponse Int
pHttpStatus_ =
  DeleteGrantResponse'
    { $sel:grantArn:DeleteGrantResponse' :: Maybe Text
grantArn = forall a. Maybe a
Prelude.Nothing,
      $sel:status:DeleteGrantResponse' :: Maybe GrantStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:version:DeleteGrantResponse' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteGrantResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Grant ARN.
deleteGrantResponse_grantArn :: Lens.Lens' DeleteGrantResponse (Prelude.Maybe Prelude.Text)
deleteGrantResponse_grantArn :: Lens' DeleteGrantResponse (Maybe Text)
deleteGrantResponse_grantArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrantResponse' {Maybe Text
grantArn :: Maybe Text
$sel:grantArn:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe Text
grantArn} -> Maybe Text
grantArn) (\s :: DeleteGrantResponse
s@DeleteGrantResponse' {} Maybe Text
a -> DeleteGrantResponse
s {$sel:grantArn:DeleteGrantResponse' :: Maybe Text
grantArn = Maybe Text
a} :: DeleteGrantResponse)

-- | Grant status.
deleteGrantResponse_status :: Lens.Lens' DeleteGrantResponse (Prelude.Maybe GrantStatus)
deleteGrantResponse_status :: Lens' DeleteGrantResponse (Maybe GrantStatus)
deleteGrantResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrantResponse' {Maybe GrantStatus
status :: Maybe GrantStatus
$sel:status:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe GrantStatus
status} -> Maybe GrantStatus
status) (\s :: DeleteGrantResponse
s@DeleteGrantResponse' {} Maybe GrantStatus
a -> DeleteGrantResponse
s {$sel:status:DeleteGrantResponse' :: Maybe GrantStatus
status = Maybe GrantStatus
a} :: DeleteGrantResponse)

-- | Grant version.
deleteGrantResponse_version :: Lens.Lens' DeleteGrantResponse (Prelude.Maybe Prelude.Text)
deleteGrantResponse_version :: Lens' DeleteGrantResponse (Maybe Text)
deleteGrantResponse_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGrantResponse' {Maybe Text
version :: Maybe Text
$sel:version:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe Text
version} -> Maybe Text
version) (\s :: DeleteGrantResponse
s@DeleteGrantResponse' {} Maybe Text
a -> DeleteGrantResponse
s {$sel:version:DeleteGrantResponse' :: Maybe Text
version = Maybe Text
a} :: DeleteGrantResponse)

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

instance Prelude.NFData DeleteGrantResponse where
  rnf :: DeleteGrantResponse -> ()
rnf DeleteGrantResponse' {Int
Maybe Text
Maybe GrantStatus
httpStatus :: Int
version :: Maybe Text
status :: Maybe GrantStatus
grantArn :: Maybe Text
$sel:httpStatus:DeleteGrantResponse' :: DeleteGrantResponse -> Int
$sel:version:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe Text
$sel:status:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe GrantStatus
$sel:grantArn:DeleteGrantResponse' :: DeleteGrantResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
grantArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GrantStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus