{-# 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.OpsWorks.GrantAccess
(
GrantAccess (..),
newGrantAccess,
grantAccess_validForInMinutes,
grantAccess_instanceId,
GrantAccessResponse (..),
newGrantAccessResponse,
grantAccessResponse_temporaryCredential,
grantAccessResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GrantAccess = GrantAccess'
{
GrantAccess -> Maybe Natural
validForInMinutes :: Prelude.Maybe Prelude.Natural,
GrantAccess -> Text
instanceId :: Prelude.Text
}
deriving (GrantAccess -> GrantAccess -> Bool
(GrantAccess -> GrantAccess -> Bool)
-> (GrantAccess -> GrantAccess -> Bool) -> Eq GrantAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrantAccess -> GrantAccess -> Bool
$c/= :: GrantAccess -> GrantAccess -> Bool
== :: GrantAccess -> GrantAccess -> Bool
$c== :: GrantAccess -> GrantAccess -> Bool
Prelude.Eq, ReadPrec [GrantAccess]
ReadPrec GrantAccess
Int -> ReadS GrantAccess
ReadS [GrantAccess]
(Int -> ReadS GrantAccess)
-> ReadS [GrantAccess]
-> ReadPrec GrantAccess
-> ReadPrec [GrantAccess]
-> Read GrantAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrantAccess]
$creadListPrec :: ReadPrec [GrantAccess]
readPrec :: ReadPrec GrantAccess
$creadPrec :: ReadPrec GrantAccess
readList :: ReadS [GrantAccess]
$creadList :: ReadS [GrantAccess]
readsPrec :: Int -> ReadS GrantAccess
$creadsPrec :: Int -> ReadS GrantAccess
Prelude.Read, Int -> GrantAccess -> ShowS
[GrantAccess] -> ShowS
GrantAccess -> String
(Int -> GrantAccess -> ShowS)
-> (GrantAccess -> String)
-> ([GrantAccess] -> ShowS)
-> Show GrantAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrantAccess] -> ShowS
$cshowList :: [GrantAccess] -> ShowS
show :: GrantAccess -> String
$cshow :: GrantAccess -> String
showsPrec :: Int -> GrantAccess -> ShowS
$cshowsPrec :: Int -> GrantAccess -> ShowS
Prelude.Show, (forall x. GrantAccess -> Rep GrantAccess x)
-> (forall x. Rep GrantAccess x -> GrantAccess)
-> Generic GrantAccess
forall x. Rep GrantAccess x -> GrantAccess
forall x. GrantAccess -> Rep GrantAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrantAccess x -> GrantAccess
$cfrom :: forall x. GrantAccess -> Rep GrantAccess x
Prelude.Generic)
newGrantAccess ::
Prelude.Text ->
GrantAccess
newGrantAccess :: Text -> GrantAccess
newGrantAccess Text
pInstanceId_ =
GrantAccess' :: Maybe Natural -> Text -> GrantAccess
GrantAccess'
{ $sel:validForInMinutes:GrantAccess' :: Maybe Natural
validForInMinutes = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:instanceId:GrantAccess' :: Text
instanceId = Text
pInstanceId_
}
grantAccess_validForInMinutes :: Lens.Lens' GrantAccess (Prelude.Maybe Prelude.Natural)
grantAccess_validForInMinutes :: (Maybe Natural -> f (Maybe Natural))
-> GrantAccess -> f GrantAccess
grantAccess_validForInMinutes = (GrantAccess -> Maybe Natural)
-> (GrantAccess -> Maybe Natural -> GrantAccess)
-> Lens GrantAccess GrantAccess (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrantAccess' {Maybe Natural
validForInMinutes :: Maybe Natural
$sel:validForInMinutes:GrantAccess' :: GrantAccess -> Maybe Natural
validForInMinutes} -> Maybe Natural
validForInMinutes) (\s :: GrantAccess
s@GrantAccess' {} Maybe Natural
a -> GrantAccess
s {$sel:validForInMinutes:GrantAccess' :: Maybe Natural
validForInMinutes = Maybe Natural
a} :: GrantAccess)
grantAccess_instanceId :: Lens.Lens' GrantAccess Prelude.Text
grantAccess_instanceId :: (Text -> f Text) -> GrantAccess -> f GrantAccess
grantAccess_instanceId = (GrantAccess -> Text)
-> (GrantAccess -> Text -> GrantAccess)
-> Lens GrantAccess GrantAccess Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrantAccess' {Text
instanceId :: Text
$sel:instanceId:GrantAccess' :: GrantAccess -> Text
instanceId} -> Text
instanceId) (\s :: GrantAccess
s@GrantAccess' {} Text
a -> GrantAccess
s {$sel:instanceId:GrantAccess' :: Text
instanceId = Text
a} :: GrantAccess)
instance Core.AWSRequest GrantAccess where
type AWSResponse GrantAccess = GrantAccessResponse
request :: GrantAccess -> Request GrantAccess
request = Service -> GrantAccess -> Request GrantAccess
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GrantAccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GrantAccess)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GrantAccess))
-> Logger
-> Service
-> Proxy GrantAccess
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GrantAccess)))
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 TemporaryCredential -> Int -> GrantAccessResponse
GrantAccessResponse'
(Maybe TemporaryCredential -> Int -> GrantAccessResponse)
-> Either String (Maybe TemporaryCredential)
-> Either String (Int -> GrantAccessResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe TemporaryCredential)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TemporaryCredential")
Either String (Int -> GrantAccessResponse)
-> Either String Int -> Either String GrantAccessResponse
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 GrantAccess
instance Prelude.NFData GrantAccess
instance Core.ToHeaders GrantAccess where
toHeaders :: GrantAccess -> ResponseHeaders
toHeaders =
ResponseHeaders -> GrantAccess -> 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
"OpsWorks_20130218.GrantAccess" ::
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 GrantAccess where
toJSON :: GrantAccess -> Value
toJSON GrantAccess' {Maybe Natural
Text
instanceId :: Text
validForInMinutes :: Maybe Natural
$sel:instanceId:GrantAccess' :: GrantAccess -> Text
$sel:validForInMinutes:GrantAccess' :: GrantAccess -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ValidForInMinutes" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
validForInMinutes,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)
]
)
instance Core.ToPath GrantAccess where
toPath :: GrantAccess -> ByteString
toPath = ByteString -> GrantAccess -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GrantAccess where
toQuery :: GrantAccess -> QueryString
toQuery = QueryString -> GrantAccess -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GrantAccessResponse = GrantAccessResponse'
{
GrantAccessResponse -> Maybe TemporaryCredential
temporaryCredential :: Prelude.Maybe TemporaryCredential,
GrantAccessResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GrantAccessResponse -> GrantAccessResponse -> Bool
(GrantAccessResponse -> GrantAccessResponse -> Bool)
-> (GrantAccessResponse -> GrantAccessResponse -> Bool)
-> Eq GrantAccessResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrantAccessResponse -> GrantAccessResponse -> Bool
$c/= :: GrantAccessResponse -> GrantAccessResponse -> Bool
== :: GrantAccessResponse -> GrantAccessResponse -> Bool
$c== :: GrantAccessResponse -> GrantAccessResponse -> Bool
Prelude.Eq, ReadPrec [GrantAccessResponse]
ReadPrec GrantAccessResponse
Int -> ReadS GrantAccessResponse
ReadS [GrantAccessResponse]
(Int -> ReadS GrantAccessResponse)
-> ReadS [GrantAccessResponse]
-> ReadPrec GrantAccessResponse
-> ReadPrec [GrantAccessResponse]
-> Read GrantAccessResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrantAccessResponse]
$creadListPrec :: ReadPrec [GrantAccessResponse]
readPrec :: ReadPrec GrantAccessResponse
$creadPrec :: ReadPrec GrantAccessResponse
readList :: ReadS [GrantAccessResponse]
$creadList :: ReadS [GrantAccessResponse]
readsPrec :: Int -> ReadS GrantAccessResponse
$creadsPrec :: Int -> ReadS GrantAccessResponse
Prelude.Read, Int -> GrantAccessResponse -> ShowS
[GrantAccessResponse] -> ShowS
GrantAccessResponse -> String
(Int -> GrantAccessResponse -> ShowS)
-> (GrantAccessResponse -> String)
-> ([GrantAccessResponse] -> ShowS)
-> Show GrantAccessResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrantAccessResponse] -> ShowS
$cshowList :: [GrantAccessResponse] -> ShowS
show :: GrantAccessResponse -> String
$cshow :: GrantAccessResponse -> String
showsPrec :: Int -> GrantAccessResponse -> ShowS
$cshowsPrec :: Int -> GrantAccessResponse -> ShowS
Prelude.Show, (forall x. GrantAccessResponse -> Rep GrantAccessResponse x)
-> (forall x. Rep GrantAccessResponse x -> GrantAccessResponse)
-> Generic GrantAccessResponse
forall x. Rep GrantAccessResponse x -> GrantAccessResponse
forall x. GrantAccessResponse -> Rep GrantAccessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrantAccessResponse x -> GrantAccessResponse
$cfrom :: forall x. GrantAccessResponse -> Rep GrantAccessResponse x
Prelude.Generic)
newGrantAccessResponse ::
Prelude.Int ->
GrantAccessResponse
newGrantAccessResponse :: Int -> GrantAccessResponse
newGrantAccessResponse Int
pHttpStatus_ =
GrantAccessResponse' :: Maybe TemporaryCredential -> Int -> GrantAccessResponse
GrantAccessResponse'
{ $sel:temporaryCredential:GrantAccessResponse' :: Maybe TemporaryCredential
temporaryCredential =
Maybe TemporaryCredential
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GrantAccessResponse' :: Int
httpStatus = Int
pHttpStatus_
}
grantAccessResponse_temporaryCredential :: Lens.Lens' GrantAccessResponse (Prelude.Maybe TemporaryCredential)
grantAccessResponse_temporaryCredential :: (Maybe TemporaryCredential -> f (Maybe TemporaryCredential))
-> GrantAccessResponse -> f GrantAccessResponse
grantAccessResponse_temporaryCredential = (GrantAccessResponse -> Maybe TemporaryCredential)
-> (GrantAccessResponse
-> Maybe TemporaryCredential -> GrantAccessResponse)
-> Lens
GrantAccessResponse
GrantAccessResponse
(Maybe TemporaryCredential)
(Maybe TemporaryCredential)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrantAccessResponse' {Maybe TemporaryCredential
temporaryCredential :: Maybe TemporaryCredential
$sel:temporaryCredential:GrantAccessResponse' :: GrantAccessResponse -> Maybe TemporaryCredential
temporaryCredential} -> Maybe TemporaryCredential
temporaryCredential) (\s :: GrantAccessResponse
s@GrantAccessResponse' {} Maybe TemporaryCredential
a -> GrantAccessResponse
s {$sel:temporaryCredential:GrantAccessResponse' :: Maybe TemporaryCredential
temporaryCredential = Maybe TemporaryCredential
a} :: GrantAccessResponse)
grantAccessResponse_httpStatus :: Lens.Lens' GrantAccessResponse Prelude.Int
grantAccessResponse_httpStatus :: (Int -> f Int) -> GrantAccessResponse -> f GrantAccessResponse
grantAccessResponse_httpStatus = (GrantAccessResponse -> Int)
-> (GrantAccessResponse -> Int -> GrantAccessResponse)
-> Lens GrantAccessResponse GrantAccessResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrantAccessResponse' {Int
httpStatus :: Int
$sel:httpStatus:GrantAccessResponse' :: GrantAccessResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GrantAccessResponse
s@GrantAccessResponse' {} Int
a -> GrantAccessResponse
s {$sel:httpStatus:GrantAccessResponse' :: Int
httpStatus = Int
a} :: GrantAccessResponse)
instance Prelude.NFData GrantAccessResponse