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

    -- * Request Lenses
    getGrant_version,
    getGrant_grantArn,

    -- * Destructuring the Response
    GetGrantResponse (..),
    newGetGrantResponse,

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

-- |
-- Create a value of 'GetGrant' 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:
--
-- 'version', 'getGrant_version' - Grant version.
--
-- 'grantArn', 'getGrant_grantArn' - Amazon Resource Name (ARN) of the grant.
newGetGrant ::
  -- | 'grantArn'
  Prelude.Text ->
  GetGrant
newGetGrant :: Text -> GetGrant
newGetGrant Text
pGrantArn_ =
  GetGrant'
    { $sel:version:GetGrant' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:grantArn:GetGrant' :: Text
grantArn = Text
pGrantArn_
    }

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

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

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

instance Prelude.NFData GetGrant where
  rnf :: GetGrant -> ()
rnf GetGrant' {Maybe Text
Text
grantArn :: Text
version :: Maybe Text
$sel:grantArn:GetGrant' :: GetGrant -> Text
$sel:version:GetGrant' :: GetGrant -> Maybe Text
..} =
    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 Text
grantArn

instance Data.ToHeaders GetGrant where
  toHeaders :: GetGrant -> 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.GetGrant" :: 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 GetGrant where
  toJSON :: GetGrant -> Value
toJSON GetGrant' {Maybe Text
Text
grantArn :: Text
version :: Maybe Text
$sel:grantArn:GetGrant' :: GetGrant -> Text
$sel:version:GetGrant' :: GetGrant -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Version" 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
version,
            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 GetGrant where
  toPath :: GetGrant -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetGrantResponse' 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:
--
-- 'grant', 'getGrantResponse_grant' - Grant details.
--
-- 'httpStatus', 'getGrantResponse_httpStatus' - The response's http status code.
newGetGrantResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetGrantResponse
newGetGrantResponse :: Int -> GetGrantResponse
newGetGrantResponse Int
pHttpStatus_ =
  GetGrantResponse'
    { $sel:grant:GetGrantResponse' :: Maybe Grant
grant = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetGrantResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Grant details.
getGrantResponse_grant :: Lens.Lens' GetGrantResponse (Prelude.Maybe Grant)
getGrantResponse_grant :: Lens' GetGrantResponse (Maybe Grant)
getGrantResponse_grant = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGrantResponse' {Maybe Grant
grant :: Maybe Grant
$sel:grant:GetGrantResponse' :: GetGrantResponse -> Maybe Grant
grant} -> Maybe Grant
grant) (\s :: GetGrantResponse
s@GetGrantResponse' {} Maybe Grant
a -> GetGrantResponse
s {$sel:grant:GetGrantResponse' :: Maybe Grant
grant = Maybe Grant
a} :: GetGrantResponse)

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

instance Prelude.NFData GetGrantResponse where
  rnf :: GetGrantResponse -> ()
rnf GetGrantResponse' {Int
Maybe Grant
httpStatus :: Int
grant :: Maybe Grant
$sel:httpStatus:GetGrantResponse' :: GetGrantResponse -> Int
$sel:grant:GetGrantResponse' :: GetGrantResponse -> Maybe Grant
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Grant
grant
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus