{-# 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.RedshiftServerLess.GetCredentials
(
GetCredentials (..),
newGetCredentials,
getCredentials_dbName,
getCredentials_durationSeconds,
getCredentials_workgroupName,
GetCredentialsResponse (..),
newGetCredentialsResponse,
getCredentialsResponse_dbPassword,
getCredentialsResponse_dbUser,
getCredentialsResponse_expiration,
getCredentialsResponse_nextRefreshTime,
getCredentialsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.RedshiftServerLess.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetCredentials = GetCredentials'
{
GetCredentials -> Maybe Text
dbName :: Prelude.Maybe Prelude.Text,
GetCredentials -> Maybe Int
durationSeconds :: Prelude.Maybe Prelude.Int,
GetCredentials -> Text
workgroupName :: Prelude.Text
}
deriving (GetCredentials -> GetCredentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCredentials -> GetCredentials -> Bool
$c/= :: GetCredentials -> GetCredentials -> Bool
== :: GetCredentials -> GetCredentials -> Bool
$c== :: GetCredentials -> GetCredentials -> Bool
Prelude.Eq, ReadPrec [GetCredentials]
ReadPrec GetCredentials
Int -> ReadS GetCredentials
ReadS [GetCredentials]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCredentials]
$creadListPrec :: ReadPrec [GetCredentials]
readPrec :: ReadPrec GetCredentials
$creadPrec :: ReadPrec GetCredentials
readList :: ReadS [GetCredentials]
$creadList :: ReadS [GetCredentials]
readsPrec :: Int -> ReadS GetCredentials
$creadsPrec :: Int -> ReadS GetCredentials
Prelude.Read, Int -> GetCredentials -> ShowS
[GetCredentials] -> ShowS
GetCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCredentials] -> ShowS
$cshowList :: [GetCredentials] -> ShowS
show :: GetCredentials -> String
$cshow :: GetCredentials -> String
showsPrec :: Int -> GetCredentials -> ShowS
$cshowsPrec :: Int -> GetCredentials -> ShowS
Prelude.Show, forall x. Rep GetCredentials x -> GetCredentials
forall x. GetCredentials -> Rep GetCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCredentials x -> GetCredentials
$cfrom :: forall x. GetCredentials -> Rep GetCredentials x
Prelude.Generic)
newGetCredentials ::
Prelude.Text ->
GetCredentials
newGetCredentials :: Text -> GetCredentials
newGetCredentials Text
pWorkgroupName_ =
GetCredentials'
{ $sel:dbName:GetCredentials' :: Maybe Text
dbName = forall a. Maybe a
Prelude.Nothing,
$sel:durationSeconds:GetCredentials' :: Maybe Int
durationSeconds = forall a. Maybe a
Prelude.Nothing,
$sel:workgroupName:GetCredentials' :: Text
workgroupName = Text
pWorkgroupName_
}
getCredentials_dbName :: Lens.Lens' GetCredentials (Prelude.Maybe Prelude.Text)
getCredentials_dbName :: Lens' GetCredentials (Maybe Text)
getCredentials_dbName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentials' {Maybe Text
dbName :: Maybe Text
$sel:dbName:GetCredentials' :: GetCredentials -> Maybe Text
dbName} -> Maybe Text
dbName) (\s :: GetCredentials
s@GetCredentials' {} Maybe Text
a -> GetCredentials
s {$sel:dbName:GetCredentials' :: Maybe Text
dbName = Maybe Text
a} :: GetCredentials)
getCredentials_durationSeconds :: Lens.Lens' GetCredentials (Prelude.Maybe Prelude.Int)
getCredentials_durationSeconds :: Lens' GetCredentials (Maybe Int)
getCredentials_durationSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentials' {Maybe Int
durationSeconds :: Maybe Int
$sel:durationSeconds:GetCredentials' :: GetCredentials -> Maybe Int
durationSeconds} -> Maybe Int
durationSeconds) (\s :: GetCredentials
s@GetCredentials' {} Maybe Int
a -> GetCredentials
s {$sel:durationSeconds:GetCredentials' :: Maybe Int
durationSeconds = Maybe Int
a} :: GetCredentials)
getCredentials_workgroupName :: Lens.Lens' GetCredentials Prelude.Text
getCredentials_workgroupName :: Lens' GetCredentials Text
getCredentials_workgroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentials' {Text
workgroupName :: Text
$sel:workgroupName:GetCredentials' :: GetCredentials -> Text
workgroupName} -> Text
workgroupName) (\s :: GetCredentials
s@GetCredentials' {} Text
a -> GetCredentials
s {$sel:workgroupName:GetCredentials' :: Text
workgroupName = Text
a} :: GetCredentials)
instance Core.AWSRequest GetCredentials where
type
AWSResponse GetCredentials =
GetCredentialsResponse
request :: (Service -> Service) -> GetCredentials -> Request GetCredentials
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 GetCredentials
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCredentials)))
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 (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe POSIX
-> Maybe POSIX
-> Int
-> GetCredentialsResponse
GetCredentialsResponse'
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
"dbPassword")
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
"dbUser")
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
"expiration")
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
"nextRefreshTime")
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 GetCredentials where
hashWithSalt :: Int -> GetCredentials -> Int
hashWithSalt Int
_salt GetCredentials' {Maybe Int
Maybe Text
Text
workgroupName :: Text
durationSeconds :: Maybe Int
dbName :: Maybe Text
$sel:workgroupName:GetCredentials' :: GetCredentials -> Text
$sel:durationSeconds:GetCredentials' :: GetCredentials -> Maybe Int
$sel:dbName:GetCredentials' :: GetCredentials -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dbName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
durationSeconds
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workgroupName
instance Prelude.NFData GetCredentials where
rnf :: GetCredentials -> ()
rnf GetCredentials' {Maybe Int
Maybe Text
Text
workgroupName :: Text
durationSeconds :: Maybe Int
dbName :: Maybe Text
$sel:workgroupName:GetCredentials' :: GetCredentials -> Text
$sel:durationSeconds:GetCredentials' :: GetCredentials -> Maybe Int
$sel:dbName:GetCredentials' :: GetCredentials -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dbName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
durationSeconds
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
workgroupName
instance Data.ToHeaders GetCredentials where
toHeaders :: GetCredentials -> 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
"RedshiftServerless.GetCredentials" ::
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 GetCredentials where
toJSON :: GetCredentials -> Value
toJSON GetCredentials' {Maybe Int
Maybe Text
Text
workgroupName :: Text
durationSeconds :: Maybe Int
dbName :: Maybe Text
$sel:workgroupName:GetCredentials' :: GetCredentials -> Text
$sel:durationSeconds:GetCredentials' :: GetCredentials -> Maybe Int
$sel:dbName:GetCredentials' :: GetCredentials -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"dbName" 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
dbName,
(Key
"durationSeconds" 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 Int
durationSeconds,
forall a. a -> Maybe a
Prelude.Just
(Key
"workgroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workgroupName)
]
)
instance Data.ToPath GetCredentials where
toPath :: GetCredentials -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetCredentials where
toQuery :: GetCredentials -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data GetCredentialsResponse = GetCredentialsResponse'
{
GetCredentialsResponse -> Maybe (Sensitive Text)
dbPassword :: Prelude.Maybe (Data.Sensitive Prelude.Text),
GetCredentialsResponse -> Maybe (Sensitive Text)
dbUser :: Prelude.Maybe (Data.Sensitive Prelude.Text),
GetCredentialsResponse -> Maybe POSIX
expiration :: Prelude.Maybe Data.POSIX,
GetCredentialsResponse -> Maybe POSIX
nextRefreshTime :: Prelude.Maybe Data.POSIX,
GetCredentialsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetCredentialsResponse -> GetCredentialsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCredentialsResponse -> GetCredentialsResponse -> Bool
$c/= :: GetCredentialsResponse -> GetCredentialsResponse -> Bool
== :: GetCredentialsResponse -> GetCredentialsResponse -> Bool
$c== :: GetCredentialsResponse -> GetCredentialsResponse -> Bool
Prelude.Eq, Int -> GetCredentialsResponse -> ShowS
[GetCredentialsResponse] -> ShowS
GetCredentialsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCredentialsResponse] -> ShowS
$cshowList :: [GetCredentialsResponse] -> ShowS
show :: GetCredentialsResponse -> String
$cshow :: GetCredentialsResponse -> String
showsPrec :: Int -> GetCredentialsResponse -> ShowS
$cshowsPrec :: Int -> GetCredentialsResponse -> ShowS
Prelude.Show, forall x. Rep GetCredentialsResponse x -> GetCredentialsResponse
forall x. GetCredentialsResponse -> Rep GetCredentialsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCredentialsResponse x -> GetCredentialsResponse
$cfrom :: forall x. GetCredentialsResponse -> Rep GetCredentialsResponse x
Prelude.Generic)
newGetCredentialsResponse ::
Prelude.Int ->
GetCredentialsResponse
newGetCredentialsResponse :: Int -> GetCredentialsResponse
newGetCredentialsResponse Int
pHttpStatus_ =
GetCredentialsResponse'
{ $sel:dbPassword:GetCredentialsResponse' :: Maybe (Sensitive Text)
dbPassword =
forall a. Maybe a
Prelude.Nothing,
$sel:dbUser:GetCredentialsResponse' :: Maybe (Sensitive Text)
dbUser = forall a. Maybe a
Prelude.Nothing,
$sel:expiration:GetCredentialsResponse' :: Maybe POSIX
expiration = forall a. Maybe a
Prelude.Nothing,
$sel:nextRefreshTime:GetCredentialsResponse' :: Maybe POSIX
nextRefreshTime = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetCredentialsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getCredentialsResponse_dbPassword :: Lens.Lens' GetCredentialsResponse (Prelude.Maybe Prelude.Text)
getCredentialsResponse_dbPassword :: Lens' GetCredentialsResponse (Maybe Text)
getCredentialsResponse_dbPassword = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentialsResponse' {Maybe (Sensitive Text)
dbPassword :: Maybe (Sensitive Text)
$sel:dbPassword:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe (Sensitive Text)
dbPassword} -> Maybe (Sensitive Text)
dbPassword) (\s :: GetCredentialsResponse
s@GetCredentialsResponse' {} Maybe (Sensitive Text)
a -> GetCredentialsResponse
s {$sel:dbPassword:GetCredentialsResponse' :: Maybe (Sensitive Text)
dbPassword = Maybe (Sensitive Text)
a} :: GetCredentialsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive
getCredentialsResponse_dbUser :: Lens.Lens' GetCredentialsResponse (Prelude.Maybe Prelude.Text)
getCredentialsResponse_dbUser :: Lens' GetCredentialsResponse (Maybe Text)
getCredentialsResponse_dbUser = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentialsResponse' {Maybe (Sensitive Text)
dbUser :: Maybe (Sensitive Text)
$sel:dbUser:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe (Sensitive Text)
dbUser} -> Maybe (Sensitive Text)
dbUser) (\s :: GetCredentialsResponse
s@GetCredentialsResponse' {} Maybe (Sensitive Text)
a -> GetCredentialsResponse
s {$sel:dbUser:GetCredentialsResponse' :: Maybe (Sensitive Text)
dbUser = Maybe (Sensitive Text)
a} :: GetCredentialsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive
getCredentialsResponse_expiration :: Lens.Lens' GetCredentialsResponse (Prelude.Maybe Prelude.UTCTime)
getCredentialsResponse_expiration :: Lens' GetCredentialsResponse (Maybe UTCTime)
getCredentialsResponse_expiration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentialsResponse' {Maybe POSIX
expiration :: Maybe POSIX
$sel:expiration:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe POSIX
expiration} -> Maybe POSIX
expiration) (\s :: GetCredentialsResponse
s@GetCredentialsResponse' {} Maybe POSIX
a -> GetCredentialsResponse
s {$sel:expiration:GetCredentialsResponse' :: Maybe POSIX
expiration = Maybe POSIX
a} :: GetCredentialsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time
getCredentialsResponse_nextRefreshTime :: Lens.Lens' GetCredentialsResponse (Prelude.Maybe Prelude.UTCTime)
getCredentialsResponse_nextRefreshTime :: Lens' GetCredentialsResponse (Maybe UTCTime)
getCredentialsResponse_nextRefreshTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentialsResponse' {Maybe POSIX
nextRefreshTime :: Maybe POSIX
$sel:nextRefreshTime:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe POSIX
nextRefreshTime} -> Maybe POSIX
nextRefreshTime) (\s :: GetCredentialsResponse
s@GetCredentialsResponse' {} Maybe POSIX
a -> GetCredentialsResponse
s {$sel:nextRefreshTime:GetCredentialsResponse' :: Maybe POSIX
nextRefreshTime = Maybe POSIX
a} :: GetCredentialsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time
getCredentialsResponse_httpStatus :: Lens.Lens' GetCredentialsResponse Prelude.Int
getCredentialsResponse_httpStatus :: Lens' GetCredentialsResponse Int
getCredentialsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCredentialsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCredentialsResponse' :: GetCredentialsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCredentialsResponse
s@GetCredentialsResponse' {} Int
a -> GetCredentialsResponse
s {$sel:httpStatus:GetCredentialsResponse' :: Int
httpStatus = Int
a} :: GetCredentialsResponse)
instance Prelude.NFData GetCredentialsResponse where
rnf :: GetCredentialsResponse -> ()
rnf GetCredentialsResponse' {Int
Maybe (Sensitive Text)
Maybe POSIX
httpStatus :: Int
nextRefreshTime :: Maybe POSIX
expiration :: Maybe POSIX
dbUser :: Maybe (Sensitive Text)
dbPassword :: Maybe (Sensitive Text)
$sel:httpStatus:GetCredentialsResponse' :: GetCredentialsResponse -> Int
$sel:nextRefreshTime:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe POSIX
$sel:expiration:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe POSIX
$sel:dbUser:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe (Sensitive Text)
$sel:dbPassword:GetCredentialsResponse' :: GetCredentialsResponse -> Maybe (Sensitive Text)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
dbPassword
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
dbUser
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expiration
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
nextRefreshTime
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus