{-# 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.CertificateManager.ExportCertificate
(
ExportCertificate (..),
newExportCertificate,
exportCertificate_certificateArn,
exportCertificate_passphrase,
ExportCertificateResponse (..),
newExportCertificateResponse,
exportCertificateResponse_privateKey,
exportCertificateResponse_certificate,
exportCertificateResponse_certificateChain,
exportCertificateResponse_httpStatus,
)
where
import Amazonka.CertificateManager.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ExportCertificate = ExportCertificate'
{
ExportCertificate -> Text
certificateArn :: Prelude.Text,
ExportCertificate -> Sensitive Base64
passphrase :: Core.Sensitive Core.Base64
}
deriving (ExportCertificate -> ExportCertificate -> Bool
(ExportCertificate -> ExportCertificate -> Bool)
-> (ExportCertificate -> ExportCertificate -> Bool)
-> Eq ExportCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportCertificate -> ExportCertificate -> Bool
$c/= :: ExportCertificate -> ExportCertificate -> Bool
== :: ExportCertificate -> ExportCertificate -> Bool
$c== :: ExportCertificate -> ExportCertificate -> Bool
Prelude.Eq, Int -> ExportCertificate -> ShowS
[ExportCertificate] -> ShowS
ExportCertificate -> String
(Int -> ExportCertificate -> ShowS)
-> (ExportCertificate -> String)
-> ([ExportCertificate] -> ShowS)
-> Show ExportCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportCertificate] -> ShowS
$cshowList :: [ExportCertificate] -> ShowS
show :: ExportCertificate -> String
$cshow :: ExportCertificate -> String
showsPrec :: Int -> ExportCertificate -> ShowS
$cshowsPrec :: Int -> ExportCertificate -> ShowS
Prelude.Show, (forall x. ExportCertificate -> Rep ExportCertificate x)
-> (forall x. Rep ExportCertificate x -> ExportCertificate)
-> Generic ExportCertificate
forall x. Rep ExportCertificate x -> ExportCertificate
forall x. ExportCertificate -> Rep ExportCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportCertificate x -> ExportCertificate
$cfrom :: forall x. ExportCertificate -> Rep ExportCertificate x
Prelude.Generic)
newExportCertificate ::
Prelude.Text ->
Prelude.ByteString ->
ExportCertificate
newExportCertificate :: Text -> ByteString -> ExportCertificate
newExportCertificate Text
pCertificateArn_ ByteString
pPassphrase_ =
ExportCertificate' :: Text -> Sensitive Base64 -> ExportCertificate
ExportCertificate'
{ $sel:certificateArn:ExportCertificate' :: Text
certificateArn =
Text
pCertificateArn_,
$sel:passphrase:ExportCertificate' :: Sensitive Base64
passphrase =
Tagged Base64 (Identity Base64)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Base64 (Identity Base64)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> (Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64))
-> Tagged ByteString (Identity ByteString)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64
(Tagged ByteString (Identity ByteString)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> ByteString -> Sensitive Base64
forall t b. AReview t b -> b -> t
Lens.# ByteString
pPassphrase_
}
exportCertificate_certificateArn :: Lens.Lens' ExportCertificate Prelude.Text
exportCertificate_certificateArn :: (Text -> f Text) -> ExportCertificate -> f ExportCertificate
exportCertificate_certificateArn = (ExportCertificate -> Text)
-> (ExportCertificate -> Text -> ExportCertificate)
-> Lens ExportCertificate ExportCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificate' {Text
certificateArn :: Text
$sel:certificateArn:ExportCertificate' :: ExportCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: ExportCertificate
s@ExportCertificate' {} Text
a -> ExportCertificate
s {$sel:certificateArn:ExportCertificate' :: Text
certificateArn = Text
a} :: ExportCertificate)
exportCertificate_passphrase :: Lens.Lens' ExportCertificate Prelude.ByteString
exportCertificate_passphrase :: (ByteString -> f ByteString)
-> ExportCertificate -> f ExportCertificate
exportCertificate_passphrase = (ExportCertificate -> Sensitive Base64)
-> (ExportCertificate -> Sensitive Base64 -> ExportCertificate)
-> Lens
ExportCertificate
ExportCertificate
(Sensitive Base64)
(Sensitive Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificate' {Sensitive Base64
passphrase :: Sensitive Base64
$sel:passphrase:ExportCertificate' :: ExportCertificate -> Sensitive Base64
passphrase} -> Sensitive Base64
passphrase) (\s :: ExportCertificate
s@ExportCertificate' {} Sensitive Base64
a -> ExportCertificate
s {$sel:passphrase:ExportCertificate' :: Sensitive Base64
passphrase = Sensitive Base64
a} :: ExportCertificate) ((Sensitive Base64 -> f (Sensitive Base64))
-> ExportCertificate -> f ExportCertificate)
-> ((ByteString -> f ByteString)
-> Sensitive Base64 -> f (Sensitive Base64))
-> (ByteString -> f ByteString)
-> ExportCertificate
-> f ExportCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64)
forall a. Iso' (Sensitive a) a
Core._Sensitive ((Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64))
-> ((ByteString -> f ByteString) -> Base64 -> f Base64)
-> (ByteString -> f ByteString)
-> Sensitive Base64
-> f (Sensitive Base64)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ByteString -> f ByteString) -> Base64 -> f Base64
Iso' Base64 ByteString
Core._Base64
instance Core.AWSRequest ExportCertificate where
type
AWSResponse ExportCertificate =
ExportCertificateResponse
request :: ExportCertificate -> Request ExportCertificate
request = Service -> ExportCertificate -> Request ExportCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ExportCertificate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ExportCertificate)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ExportCertificate))
-> Logger
-> Service
-> Proxy ExportCertificate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ExportCertificate)))
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 (Sensitive Text)
-> Maybe Text -> Maybe Text -> Int -> ExportCertificateResponse
ExportCertificateResponse'
(Maybe (Sensitive Text)
-> Maybe Text -> Maybe Text -> Int -> ExportCertificateResponse)
-> Either String (Maybe (Sensitive Text))
-> Either
String
(Maybe Text -> Maybe Text -> Int -> ExportCertificateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PrivateKey")
Either
String
(Maybe Text -> Maybe Text -> Int -> ExportCertificateResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> ExportCertificateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Certificate")
Either String (Maybe Text -> Int -> ExportCertificateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ExportCertificateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CertificateChain")
Either String (Int -> ExportCertificateResponse)
-> Either String Int -> Either String ExportCertificateResponse
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 ExportCertificate
instance Prelude.NFData ExportCertificate
instance Core.ToHeaders ExportCertificate where
toHeaders :: ExportCertificate -> ResponseHeaders
toHeaders =
ResponseHeaders -> ExportCertificate -> 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
"CertificateManager.ExportCertificate" ::
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 ExportCertificate where
toJSON :: ExportCertificate -> Value
toJSON ExportCertificate' {Text
Sensitive Base64
passphrase :: Sensitive Base64
certificateArn :: Text
$sel:passphrase:ExportCertificate' :: ExportCertificate -> Sensitive Base64
$sel:certificateArn:ExportCertificate' :: ExportCertificate -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"CertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Passphrase" Text -> Sensitive Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Base64
passphrase)
]
)
instance Core.ToPath ExportCertificate where
toPath :: ExportCertificate -> ByteString
toPath = ByteString -> ExportCertificate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ExportCertificate where
toQuery :: ExportCertificate -> QueryString
toQuery = QueryString -> ExportCertificate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ExportCertificateResponse = ExportCertificateResponse'
{
ExportCertificateResponse -> Maybe (Sensitive Text)
privateKey :: Prelude.Maybe (Core.Sensitive Prelude.Text),
ExportCertificateResponse -> Maybe Text
certificate :: Prelude.Maybe Prelude.Text,
ExportCertificateResponse -> Maybe Text
certificateChain :: Prelude.Maybe Prelude.Text,
ExportCertificateResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ExportCertificateResponse -> ExportCertificateResponse -> Bool
(ExportCertificateResponse -> ExportCertificateResponse -> Bool)
-> (ExportCertificateResponse -> ExportCertificateResponse -> Bool)
-> Eq ExportCertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportCertificateResponse -> ExportCertificateResponse -> Bool
$c/= :: ExportCertificateResponse -> ExportCertificateResponse -> Bool
== :: ExportCertificateResponse -> ExportCertificateResponse -> Bool
$c== :: ExportCertificateResponse -> ExportCertificateResponse -> Bool
Prelude.Eq, Int -> ExportCertificateResponse -> ShowS
[ExportCertificateResponse] -> ShowS
ExportCertificateResponse -> String
(Int -> ExportCertificateResponse -> ShowS)
-> (ExportCertificateResponse -> String)
-> ([ExportCertificateResponse] -> ShowS)
-> Show ExportCertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportCertificateResponse] -> ShowS
$cshowList :: [ExportCertificateResponse] -> ShowS
show :: ExportCertificateResponse -> String
$cshow :: ExportCertificateResponse -> String
showsPrec :: Int -> ExportCertificateResponse -> ShowS
$cshowsPrec :: Int -> ExportCertificateResponse -> ShowS
Prelude.Show, (forall x.
ExportCertificateResponse -> Rep ExportCertificateResponse x)
-> (forall x.
Rep ExportCertificateResponse x -> ExportCertificateResponse)
-> Generic ExportCertificateResponse
forall x.
Rep ExportCertificateResponse x -> ExportCertificateResponse
forall x.
ExportCertificateResponse -> Rep ExportCertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExportCertificateResponse x -> ExportCertificateResponse
$cfrom :: forall x.
ExportCertificateResponse -> Rep ExportCertificateResponse x
Prelude.Generic)
newExportCertificateResponse ::
Prelude.Int ->
ExportCertificateResponse
newExportCertificateResponse :: Int -> ExportCertificateResponse
newExportCertificateResponse Int
pHttpStatus_ =
ExportCertificateResponse' :: Maybe (Sensitive Text)
-> Maybe Text -> Maybe Text -> Int -> ExportCertificateResponse
ExportCertificateResponse'
{ $sel:privateKey:ExportCertificateResponse' :: Maybe (Sensitive Text)
privateKey =
Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
$sel:certificate:ExportCertificateResponse' :: Maybe Text
certificate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:certificateChain:ExportCertificateResponse' :: Maybe Text
certificateChain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ExportCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
}
exportCertificateResponse_privateKey :: Lens.Lens' ExportCertificateResponse (Prelude.Maybe Prelude.Text)
exportCertificateResponse_privateKey :: (Maybe Text -> f (Maybe Text))
-> ExportCertificateResponse -> f ExportCertificateResponse
exportCertificateResponse_privateKey = (ExportCertificateResponse -> Maybe (Sensitive Text))
-> (ExportCertificateResponse
-> Maybe (Sensitive Text) -> ExportCertificateResponse)
-> Lens
ExportCertificateResponse
ExportCertificateResponse
(Maybe (Sensitive Text))
(Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificateResponse' {Maybe (Sensitive Text)
privateKey :: Maybe (Sensitive Text)
$sel:privateKey:ExportCertificateResponse' :: ExportCertificateResponse -> Maybe (Sensitive Text)
privateKey} -> Maybe (Sensitive Text)
privateKey) (\s :: ExportCertificateResponse
s@ExportCertificateResponse' {} Maybe (Sensitive Text)
a -> ExportCertificateResponse
s {$sel:privateKey:ExportCertificateResponse' :: Maybe (Sensitive Text)
privateKey = Maybe (Sensitive Text)
a} :: ExportCertificateResponse) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> ExportCertificateResponse -> f ExportCertificateResponse)
-> ((Maybe Text -> f (Maybe Text))
-> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ExportCertificateResponse
-> f ExportCertificateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
(Maybe (Sensitive Text))
(Maybe (Sensitive Text))
(Maybe Text)
(Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive
exportCertificateResponse_certificate :: Lens.Lens' ExportCertificateResponse (Prelude.Maybe Prelude.Text)
exportCertificateResponse_certificate :: (Maybe Text -> f (Maybe Text))
-> ExportCertificateResponse -> f ExportCertificateResponse
exportCertificateResponse_certificate = (ExportCertificateResponse -> Maybe Text)
-> (ExportCertificateResponse
-> Maybe Text -> ExportCertificateResponse)
-> Lens
ExportCertificateResponse
ExportCertificateResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificateResponse' {Maybe Text
certificate :: Maybe Text
$sel:certificate:ExportCertificateResponse' :: ExportCertificateResponse -> Maybe Text
certificate} -> Maybe Text
certificate) (\s :: ExportCertificateResponse
s@ExportCertificateResponse' {} Maybe Text
a -> ExportCertificateResponse
s {$sel:certificate:ExportCertificateResponse' :: Maybe Text
certificate = Maybe Text
a} :: ExportCertificateResponse)
exportCertificateResponse_certificateChain :: Lens.Lens' ExportCertificateResponse (Prelude.Maybe Prelude.Text)
exportCertificateResponse_certificateChain :: (Maybe Text -> f (Maybe Text))
-> ExportCertificateResponse -> f ExportCertificateResponse
exportCertificateResponse_certificateChain = (ExportCertificateResponse -> Maybe Text)
-> (ExportCertificateResponse
-> Maybe Text -> ExportCertificateResponse)
-> Lens
ExportCertificateResponse
ExportCertificateResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificateResponse' {Maybe Text
certificateChain :: Maybe Text
$sel:certificateChain:ExportCertificateResponse' :: ExportCertificateResponse -> Maybe Text
certificateChain} -> Maybe Text
certificateChain) (\s :: ExportCertificateResponse
s@ExportCertificateResponse' {} Maybe Text
a -> ExportCertificateResponse
s {$sel:certificateChain:ExportCertificateResponse' :: Maybe Text
certificateChain = Maybe Text
a} :: ExportCertificateResponse)
exportCertificateResponse_httpStatus :: Lens.Lens' ExportCertificateResponse Prelude.Int
exportCertificateResponse_httpStatus :: (Int -> f Int)
-> ExportCertificateResponse -> f ExportCertificateResponse
exportCertificateResponse_httpStatus = (ExportCertificateResponse -> Int)
-> (ExportCertificateResponse -> Int -> ExportCertificateResponse)
-> Lens ExportCertificateResponse ExportCertificateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportCertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:ExportCertificateResponse' :: ExportCertificateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ExportCertificateResponse
s@ExportCertificateResponse' {} Int
a -> ExportCertificateResponse
s {$sel:httpStatus:ExportCertificateResponse' :: Int
httpStatus = Int
a} :: ExportCertificateResponse)
instance Prelude.NFData ExportCertificateResponse