{-# 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-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)
--
-- 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.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:/ '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
(GetGrant -> GetGrant -> Bool)
-> (GetGrant -> GetGrant -> Bool) -> Eq GetGrant
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]
(Int -> ReadS GetGrant)
-> ReadS [GetGrant]
-> ReadPrec GetGrant
-> ReadPrec [GetGrant]
-> Read 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
(Int -> GetGrant -> ShowS)
-> (GetGrant -> String) -> ([GetGrant] -> ShowS) -> Show GetGrant
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. GetGrant -> Rep GetGrant x)
-> (forall x. Rep GetGrant x -> GetGrant) -> Generic GetGrant
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' :: Maybe Text -> Text -> GetGrant
GetGrant'
    { $sel:version:GetGrant' :: Maybe Text
version = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> GetGrant -> f GetGrant
getGrant_version = (GetGrant -> Maybe Text)
-> (GetGrant -> Maybe Text -> GetGrant)
-> Lens GetGrant GetGrant (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> GetGrant -> f GetGrant
getGrant_grantArn = (GetGrant -> Text)
-> (GetGrant -> Text -> GetGrant)
-> Lens GetGrant GetGrant Text Text
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 :: GetGrant -> Request GetGrant
request = Service -> GetGrant -> Request GetGrant
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGrant)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetGrant))
-> Logger
-> Service
-> Proxy GetGrant
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGrant)))
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 Grant -> Int -> GetGrantResponse
GetGrantResponse'
            (Maybe Grant -> Int -> GetGrantResponse)
-> Either String (Maybe Grant)
-> Either String (Int -> GetGrantResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Grant)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Grant")
            Either String (Int -> GetGrantResponse)
-> Either String Int -> Either String GetGrantResponse
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 GetGrant

instance Prelude.NFData GetGrant

instance Core.ToHeaders GetGrant where
  toHeaders :: GetGrant -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetGrant -> 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.GetGrant" :: 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
            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 GetGrant where
  toPath :: GetGrant -> ByteString
toPath = ByteString -> GetGrant -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetGrant where
  toQuery :: GetGrant -> QueryString
toQuery = QueryString -> GetGrant -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetGrantResponse -> GetGrantResponse -> Bool)
-> (GetGrantResponse -> GetGrantResponse -> Bool)
-> Eq GetGrantResponse
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]
(Int -> ReadS GetGrantResponse)
-> ReadS [GetGrantResponse]
-> ReadPrec GetGrantResponse
-> ReadPrec [GetGrantResponse]
-> Read 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
(Int -> GetGrantResponse -> ShowS)
-> (GetGrantResponse -> String)
-> ([GetGrantResponse] -> ShowS)
-> Show GetGrantResponse
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. GetGrantResponse -> Rep GetGrantResponse x)
-> (forall x. Rep GetGrantResponse x -> GetGrantResponse)
-> Generic GetGrantResponse
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' :: Maybe Grant -> Int -> GetGrantResponse
GetGrantResponse'
    { $sel:grant:GetGrantResponse' :: Maybe Grant
grant = Maybe 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 :: (Maybe Grant -> f (Maybe Grant))
-> GetGrantResponse -> f GetGrantResponse
getGrantResponse_grant = (GetGrantResponse -> Maybe Grant)
-> (GetGrantResponse -> Maybe Grant -> GetGrantResponse)
-> Lens
     GetGrantResponse GetGrantResponse (Maybe Grant) (Maybe 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 :: (Int -> f Int) -> GetGrantResponse -> f GetGrantResponse
getGrantResponse_httpStatus = (GetGrantResponse -> Int)
-> (GetGrantResponse -> Int -> GetGrantResponse)
-> Lens GetGrantResponse GetGrantResponse Int Int
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