{-# 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-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)
--
-- 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_status,
    acceptGrantResponse_version,
    acceptGrantResponse_grantArn,
    acceptGrantResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AcceptGrant -> AcceptGrant -> Bool)
-> (AcceptGrant -> AcceptGrant -> Bool) -> Eq AcceptGrant
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]
(Int -> ReadS AcceptGrant)
-> ReadS [AcceptGrant]
-> ReadPrec AcceptGrant
-> ReadPrec [AcceptGrant]
-> Read 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
(Int -> AcceptGrant -> ShowS)
-> (AcceptGrant -> String)
-> ([AcceptGrant] -> ShowS)
-> Show AcceptGrant
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. AcceptGrant -> Rep AcceptGrant x)
-> (forall x. Rep AcceptGrant x -> AcceptGrant)
-> Generic AcceptGrant
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' :: Text -> AcceptGrant
AcceptGrant' {$sel:grantArn:AcceptGrant' :: Text
grantArn = Text
pGrantArn_}

-- | Amazon Resource Name (ARN) of the grant.
acceptGrant_grantArn :: Lens.Lens' AcceptGrant Prelude.Text
acceptGrant_grantArn :: (Text -> f Text) -> AcceptGrant -> f AcceptGrant
acceptGrant_grantArn = (AcceptGrant -> Text)
-> (AcceptGrant -> Text -> AcceptGrant)
-> Lens AcceptGrant AcceptGrant Text Text
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 :: AcceptGrant -> Request AcceptGrant
request = Service -> AcceptGrant -> Request AcceptGrant
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AcceptGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptGrant)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AcceptGrant))
-> Logger
-> Service
-> Proxy AcceptGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AcceptGrant)))
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 GrantStatus
-> Maybe Text -> Maybe Text -> Int -> AcceptGrantResponse
AcceptGrantResponse'
            (Maybe GrantStatus
 -> Maybe Text -> Maybe Text -> Int -> AcceptGrantResponse)
-> Either String (Maybe GrantStatus)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> AcceptGrantResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GrantStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Status")
            Either
  String (Maybe Text -> Maybe Text -> Int -> AcceptGrantResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> AcceptGrantResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Version")
            Either String (Maybe Text -> Int -> AcceptGrantResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AcceptGrantResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GrantArn")
            Either String (Int -> AcceptGrantResponse)
-> Either String Int -> Either String AcceptGrantResponse
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 AcceptGrant

instance Prelude.NFData AcceptGrant

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

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

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

-- | /See:/ 'newAcceptGrantResponse' smart constructor.
data AcceptGrantResponse = AcceptGrantResponse'
  { -- | Grant status.
    AcceptGrantResponse -> Maybe GrantStatus
status :: Prelude.Maybe GrantStatus,
    -- | Grant version.
    AcceptGrantResponse -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | Grant ARN.
    AcceptGrantResponse -> Maybe Text
grantArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AcceptGrantResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AcceptGrantResponse -> AcceptGrantResponse -> Bool
(AcceptGrantResponse -> AcceptGrantResponse -> Bool)
-> (AcceptGrantResponse -> AcceptGrantResponse -> Bool)
-> Eq AcceptGrantResponse
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]
(Int -> ReadS AcceptGrantResponse)
-> ReadS [AcceptGrantResponse]
-> ReadPrec AcceptGrantResponse
-> ReadPrec [AcceptGrantResponse]
-> Read 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
(Int -> AcceptGrantResponse -> ShowS)
-> (AcceptGrantResponse -> String)
-> ([AcceptGrantResponse] -> ShowS)
-> Show AcceptGrantResponse
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. AcceptGrantResponse -> Rep AcceptGrantResponse x)
-> (forall x. Rep AcceptGrantResponse x -> AcceptGrantResponse)
-> Generic AcceptGrantResponse
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:
--
-- 'status', 'acceptGrantResponse_status' - Grant status.
--
-- 'version', 'acceptGrantResponse_version' - Grant version.
--
-- 'grantArn', 'acceptGrantResponse_grantArn' - Grant ARN.
--
-- 'httpStatus', 'acceptGrantResponse_httpStatus' - The response's http status code.
newAcceptGrantResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AcceptGrantResponse
newAcceptGrantResponse :: Int -> AcceptGrantResponse
newAcceptGrantResponse Int
pHttpStatus_ =
  AcceptGrantResponse' :: Maybe GrantStatus
-> Maybe Text -> Maybe Text -> Int -> AcceptGrantResponse
AcceptGrantResponse'
    { $sel:status:AcceptGrantResponse' :: Maybe GrantStatus
status = Maybe GrantStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:version:AcceptGrantResponse' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:grantArn:AcceptGrantResponse' :: Maybe Text
grantArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AcceptGrantResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Grant status.
acceptGrantResponse_status :: Lens.Lens' AcceptGrantResponse (Prelude.Maybe GrantStatus)
acceptGrantResponse_status :: (Maybe GrantStatus -> f (Maybe GrantStatus))
-> AcceptGrantResponse -> f AcceptGrantResponse
acceptGrantResponse_status = (AcceptGrantResponse -> Maybe GrantStatus)
-> (AcceptGrantResponse
    -> Maybe GrantStatus -> AcceptGrantResponse)
-> Lens
     AcceptGrantResponse
     AcceptGrantResponse
     (Maybe GrantStatus)
     (Maybe GrantStatus)
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 :: (Maybe Text -> f (Maybe Text))
-> AcceptGrantResponse -> f AcceptGrantResponse
acceptGrantResponse_version = (AcceptGrantResponse -> Maybe Text)
-> (AcceptGrantResponse -> Maybe Text -> AcceptGrantResponse)
-> Lens
     AcceptGrantResponse AcceptGrantResponse (Maybe Text) (Maybe Text)
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)

-- | Grant ARN.
acceptGrantResponse_grantArn :: Lens.Lens' AcceptGrantResponse (Prelude.Maybe Prelude.Text)
acceptGrantResponse_grantArn :: (Maybe Text -> f (Maybe Text))
-> AcceptGrantResponse -> f AcceptGrantResponse
acceptGrantResponse_grantArn = (AcceptGrantResponse -> Maybe Text)
-> (AcceptGrantResponse -> Maybe Text -> AcceptGrantResponse)
-> Lens
     AcceptGrantResponse AcceptGrantResponse (Maybe Text) (Maybe Text)
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)

-- | The response's http status code.
acceptGrantResponse_httpStatus :: Lens.Lens' AcceptGrantResponse Prelude.Int
acceptGrantResponse_httpStatus :: (Int -> f Int) -> AcceptGrantResponse -> f AcceptGrantResponse
acceptGrantResponse_httpStatus = (AcceptGrantResponse -> Int)
-> (AcceptGrantResponse -> Int -> AcceptGrantResponse)
-> Lens AcceptGrantResponse AcceptGrantResponse Int Int
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