{-# 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 #-}
module Amazonka.FMS.GetPolicy
(
GetPolicy (..),
newGetPolicy,
getPolicy_policyId,
GetPolicyResponse (..),
newGetPolicyResponse,
getPolicyResponse_policy,
getPolicyResponse_policyArn,
getPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetPolicy = GetPolicy'
{
GetPolicy -> Text
policyId :: Prelude.Text
}
deriving (GetPolicy -> GetPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPolicy -> GetPolicy -> Bool
$c/= :: GetPolicy -> GetPolicy -> Bool
== :: GetPolicy -> GetPolicy -> Bool
$c== :: GetPolicy -> GetPolicy -> Bool
Prelude.Eq, ReadPrec [GetPolicy]
ReadPrec GetPolicy
Int -> ReadS GetPolicy
ReadS [GetPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPolicy]
$creadListPrec :: ReadPrec [GetPolicy]
readPrec :: ReadPrec GetPolicy
$creadPrec :: ReadPrec GetPolicy
readList :: ReadS [GetPolicy]
$creadList :: ReadS [GetPolicy]
readsPrec :: Int -> ReadS GetPolicy
$creadsPrec :: Int -> ReadS GetPolicy
Prelude.Read, Int -> GetPolicy -> ShowS
[GetPolicy] -> ShowS
GetPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPolicy] -> ShowS
$cshowList :: [GetPolicy] -> ShowS
show :: GetPolicy -> String
$cshow :: GetPolicy -> String
showsPrec :: Int -> GetPolicy -> ShowS
$cshowsPrec :: Int -> GetPolicy -> ShowS
Prelude.Show, forall x. Rep GetPolicy x -> GetPolicy
forall x. GetPolicy -> Rep GetPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPolicy x -> GetPolicy
$cfrom :: forall x. GetPolicy -> Rep GetPolicy x
Prelude.Generic)
newGetPolicy ::
Prelude.Text ->
GetPolicy
newGetPolicy :: Text -> GetPolicy
newGetPolicy Text
pPolicyId_ =
GetPolicy' {$sel:policyId:GetPolicy' :: Text
policyId = Text
pPolicyId_}
getPolicy_policyId :: Lens.Lens' GetPolicy Prelude.Text
getPolicy_policyId :: Lens' GetPolicy Text
getPolicy_policyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPolicy' {Text
policyId :: Text
$sel:policyId:GetPolicy' :: GetPolicy -> Text
policyId} -> Text
policyId) (\s :: GetPolicy
s@GetPolicy' {} Text
a -> GetPolicy
s {$sel:policyId:GetPolicy' :: Text
policyId = Text
a} :: GetPolicy)
instance Core.AWSRequest GetPolicy where
type AWSResponse GetPolicy = GetPolicyResponse
request :: (Service -> Service) -> GetPolicy -> Request GetPolicy
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 GetPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPolicy)))
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 Policy -> Maybe Text -> Int -> GetPolicyResponse
GetPolicyResponse'
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
"Policy")
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
"PolicyArn")
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 GetPolicy where
hashWithSalt :: Int -> GetPolicy -> Int
hashWithSalt Int
_salt GetPolicy' {Text
policyId :: Text
$sel:policyId:GetPolicy' :: GetPolicy -> Text
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyId
instance Prelude.NFData GetPolicy where
rnf :: GetPolicy -> ()
rnf GetPolicy' {Text
policyId :: Text
$sel:policyId:GetPolicy' :: GetPolicy -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
policyId
instance Data.ToHeaders GetPolicy where
toHeaders :: GetPolicy -> 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
"AWSFMS_20180101.GetPolicy" :: 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 GetPolicy where
toJSON :: GetPolicy -> Value
toJSON GetPolicy' {Text
policyId :: Text
$sel:policyId:GetPolicy' :: GetPolicy -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"PolicyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyId)]
)
instance Data.ToPath GetPolicy where
toPath :: GetPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetPolicy where
toQuery :: GetPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data GetPolicyResponse = GetPolicyResponse'
{
GetPolicyResponse -> Maybe Policy
policy :: Prelude.Maybe Policy,
GetPolicyResponse -> Maybe Text
policyArn :: Prelude.Maybe Prelude.Text,
GetPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetPolicyResponse -> GetPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPolicyResponse -> GetPolicyResponse -> Bool
$c/= :: GetPolicyResponse -> GetPolicyResponse -> Bool
== :: GetPolicyResponse -> GetPolicyResponse -> Bool
$c== :: GetPolicyResponse -> GetPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetPolicyResponse]
ReadPrec GetPolicyResponse
Int -> ReadS GetPolicyResponse
ReadS [GetPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPolicyResponse]
$creadListPrec :: ReadPrec [GetPolicyResponse]
readPrec :: ReadPrec GetPolicyResponse
$creadPrec :: ReadPrec GetPolicyResponse
readList :: ReadS [GetPolicyResponse]
$creadList :: ReadS [GetPolicyResponse]
readsPrec :: Int -> ReadS GetPolicyResponse
$creadsPrec :: Int -> ReadS GetPolicyResponse
Prelude.Read, Int -> GetPolicyResponse -> ShowS
[GetPolicyResponse] -> ShowS
GetPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPolicyResponse] -> ShowS
$cshowList :: [GetPolicyResponse] -> ShowS
show :: GetPolicyResponse -> String
$cshow :: GetPolicyResponse -> String
showsPrec :: Int -> GetPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetPolicyResponse -> ShowS
Prelude.Show, forall x. Rep GetPolicyResponse x -> GetPolicyResponse
forall x. GetPolicyResponse -> Rep GetPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPolicyResponse x -> GetPolicyResponse
$cfrom :: forall x. GetPolicyResponse -> Rep GetPolicyResponse x
Prelude.Generic)
newGetPolicyResponse ::
Prelude.Int ->
GetPolicyResponse
newGetPolicyResponse :: Int -> GetPolicyResponse
newGetPolicyResponse Int
pHttpStatus_ =
GetPolicyResponse'
{ $sel:policy:GetPolicyResponse' :: Maybe Policy
policy = forall a. Maybe a
Prelude.Nothing,
$sel:policyArn:GetPolicyResponse' :: Maybe Text
policyArn = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getPolicyResponse_policy :: Lens.Lens' GetPolicyResponse (Prelude.Maybe Policy)
getPolicyResponse_policy :: Lens' GetPolicyResponse (Maybe Policy)
getPolicyResponse_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPolicyResponse' {Maybe Policy
policy :: Maybe Policy
$sel:policy:GetPolicyResponse' :: GetPolicyResponse -> Maybe Policy
policy} -> Maybe Policy
policy) (\s :: GetPolicyResponse
s@GetPolicyResponse' {} Maybe Policy
a -> GetPolicyResponse
s {$sel:policy:GetPolicyResponse' :: Maybe Policy
policy = Maybe Policy
a} :: GetPolicyResponse)
getPolicyResponse_policyArn :: Lens.Lens' GetPolicyResponse (Prelude.Maybe Prelude.Text)
getPolicyResponse_policyArn :: Lens' GetPolicyResponse (Maybe Text)
getPolicyResponse_policyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPolicyResponse' {Maybe Text
policyArn :: Maybe Text
$sel:policyArn:GetPolicyResponse' :: GetPolicyResponse -> Maybe Text
policyArn} -> Maybe Text
policyArn) (\s :: GetPolicyResponse
s@GetPolicyResponse' {} Maybe Text
a -> GetPolicyResponse
s {$sel:policyArn:GetPolicyResponse' :: Maybe Text
policyArn = Maybe Text
a} :: GetPolicyResponse)
getPolicyResponse_httpStatus :: Lens.Lens' GetPolicyResponse Prelude.Int
getPolicyResponse_httpStatus :: Lens' GetPolicyResponse Int
getPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetPolicyResponse' :: GetPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetPolicyResponse
s@GetPolicyResponse' {} Int
a -> GetPolicyResponse
s {$sel:httpStatus:GetPolicyResponse' :: Int
httpStatus = Int
a} :: GetPolicyResponse)
instance Prelude.NFData GetPolicyResponse where
rnf :: GetPolicyResponse -> ()
rnf GetPolicyResponse' {Int
Maybe Text
Maybe Policy
httpStatus :: Int
policyArn :: Maybe Text
policy :: Maybe Policy
$sel:httpStatus:GetPolicyResponse' :: GetPolicyResponse -> Int
$sel:policyArn:GetPolicyResponse' :: GetPolicyResponse -> Maybe Text
$sel:policy:GetPolicyResponse' :: GetPolicyResponse -> Maybe Policy
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Policy
policy
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus