{-# 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.AcceptGrant
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Accepts the specified grant.
module Amazonka.LicenseManager.AcceptGrant
  ( -- * Creating a Request
    AcceptGrant (..),
    newAcceptGrant,

    -- * Request Lenses
    acceptGrant_grantArn,

    -- * Destructuring the Response
    AcceptGrantResponse (..),
    newAcceptGrantResponse,

    -- * Response Lenses
    acceptGrantResponse_grantArn,
    acceptGrantResponse_status,
    acceptGrantResponse_version,
    acceptGrantResponse_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:/ 'newAcceptGrant' smart constructor.
data AcceptGrant = AcceptGrant'
  { -- | Amazon Resource Name (ARN) of the grant.
    AcceptGrant -> Text
grantArn :: Prelude.Text
  }
  deriving (AcceptGrant -> AcceptGrant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceptGrant -> AcceptGrant -> Bool
$c/= :: AcceptGrant -> AcceptGrant -> Bool
== :: AcceptGrant -> AcceptGrant -> Bool
$c== :: AcceptGrant -> AcceptGrant -> Bool
Prelude.Eq, ReadPrec [AcceptGrant]
ReadPrec AcceptGrant
Int -> ReadS AcceptGrant
ReadS [AcceptGrant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceptGrant]
$creadListPrec :: ReadPrec [AcceptGrant]
readPrec :: ReadPrec AcceptGrant
$creadPrec :: ReadPrec AcceptGrant
readList :: ReadS [AcceptGrant]
$creadList :: ReadS [AcceptGrant]
readsPrec :: Int -> ReadS AcceptGrant
$creadsPrec :: Int -> ReadS AcceptGrant
Prelude.Read, Int -> AcceptGrant -> ShowS
[AcceptGrant] -> ShowS
AcceptGrant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceptGrant] -> ShowS
$cshowList :: [AcceptGrant] -> ShowS
show :: AcceptGrant -> String
$cshow :: AcceptGrant -> String
showsPrec :: Int -> AcceptGrant -> ShowS
$cshowsPrec :: Int -> AcceptGrant -> ShowS
Prelude.Show, forall x. Rep AcceptGrant x -> AcceptGrant
forall x. AcceptGrant -> Rep AcceptGrant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceptGrant x -> AcceptGrant
$cfrom :: forall x. AcceptGrant -> Rep AcceptGrant x
Prelude.Generic)

-- |
-- Create a value of 'AcceptGrant' 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', 'acceptGrant_grantArn' - Amazon Resource Name (ARN) of the grant.
newAcceptGrant ::
  -- | 'grantArn'
  Prelude.Text ->
  AcceptGrant
newAcceptGrant :: Text -> AcceptGrant
newAcceptGrant Text
pGrantArn_ =
  AcceptGrant' {$sel:grantArn:AcceptGrant' :: Text
grantArn = Text
pGrantArn_}

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

instance Core.AWSRequest AcceptGrant where
  type AWSResponse AcceptGrant = AcceptGrantResponse
  request :: (Service -> Service) -> AcceptGrant -> Request AcceptGrant
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 AcceptGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptGrant)))
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 -> AcceptGrantResponse
AcceptGrantResponse'
            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 AcceptGrant where
  hashWithSalt :: Int -> AcceptGrant -> Int
hashWithSalt Int
_salt AcceptGrant' {Text
grantArn :: Text
$sel:grantArn:AcceptGrant' :: AcceptGrant -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
grantArn

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

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

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

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

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

-- |
-- Create a value of 'AcceptGrantResponse' 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', 'acceptGrantResponse_grantArn' - Grant ARN.
--
-- 'status', 'acceptGrantResponse_status' - Grant status.
--
-- 'version', 'acceptGrantResponse_version' - Grant version.
--
-- 'httpStatus', 'acceptGrantResponse_httpStatus' - The response's http status code.
newAcceptGrantResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AcceptGrantResponse
newAcceptGrantResponse :: Int -> AcceptGrantResponse
newAcceptGrantResponse Int
pHttpStatus_ =
  AcceptGrantResponse'
    { $sel:grantArn:AcceptGrantResponse' :: Maybe Text
grantArn = forall a. Maybe a
Prelude.Nothing,
      $sel:status:AcceptGrantResponse' :: Maybe GrantStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:version:AcceptGrantResponse' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AcceptGrantResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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

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

instance Prelude.NFData AcceptGrantResponse where
  rnf :: AcceptGrantResponse -> ()
rnf AcceptGrantResponse' {Int
Maybe Text
Maybe GrantStatus
httpStatus :: Int
version :: Maybe Text
status :: Maybe GrantStatus
grantArn :: Maybe Text
$sel:httpStatus:AcceptGrantResponse' :: AcceptGrantResponse -> Int
$sel:version:AcceptGrantResponse' :: AcceptGrantResponse -> Maybe Text
$sel:status:AcceptGrantResponse' :: AcceptGrantResponse -> Maybe GrantStatus
$sel:grantArn:AcceptGrantResponse' :: AcceptGrantResponse -> 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