{-# 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.IoT.RegisterCertificate
(
RegisterCertificate (..),
newRegisterCertificate,
registerCertificate_status,
registerCertificate_caCertificatePem,
registerCertificate_setAsActive,
registerCertificate_certificatePem,
RegisterCertificateResponse (..),
newRegisterCertificateResponse,
registerCertificateResponse_certificateArn,
registerCertificateResponse_certificateId,
registerCertificateResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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 RegisterCertificate = RegisterCertificate'
{
RegisterCertificate -> Maybe CertificateStatus
status :: Prelude.Maybe CertificateStatus,
RegisterCertificate -> Maybe Text
caCertificatePem :: Prelude.Maybe Prelude.Text,
RegisterCertificate -> Maybe Bool
setAsActive :: Prelude.Maybe Prelude.Bool,
RegisterCertificate -> Text
certificatePem :: Prelude.Text
}
deriving (RegisterCertificate -> RegisterCertificate -> Bool
(RegisterCertificate -> RegisterCertificate -> Bool)
-> (RegisterCertificate -> RegisterCertificate -> Bool)
-> Eq RegisterCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterCertificate -> RegisterCertificate -> Bool
$c/= :: RegisterCertificate -> RegisterCertificate -> Bool
== :: RegisterCertificate -> RegisterCertificate -> Bool
$c== :: RegisterCertificate -> RegisterCertificate -> Bool
Prelude.Eq, ReadPrec [RegisterCertificate]
ReadPrec RegisterCertificate
Int -> ReadS RegisterCertificate
ReadS [RegisterCertificate]
(Int -> ReadS RegisterCertificate)
-> ReadS [RegisterCertificate]
-> ReadPrec RegisterCertificate
-> ReadPrec [RegisterCertificate]
-> Read RegisterCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterCertificate]
$creadListPrec :: ReadPrec [RegisterCertificate]
readPrec :: ReadPrec RegisterCertificate
$creadPrec :: ReadPrec RegisterCertificate
readList :: ReadS [RegisterCertificate]
$creadList :: ReadS [RegisterCertificate]
readsPrec :: Int -> ReadS RegisterCertificate
$creadsPrec :: Int -> ReadS RegisterCertificate
Prelude.Read, Int -> RegisterCertificate -> ShowS
[RegisterCertificate] -> ShowS
RegisterCertificate -> String
(Int -> RegisterCertificate -> ShowS)
-> (RegisterCertificate -> String)
-> ([RegisterCertificate] -> ShowS)
-> Show RegisterCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterCertificate] -> ShowS
$cshowList :: [RegisterCertificate] -> ShowS
show :: RegisterCertificate -> String
$cshow :: RegisterCertificate -> String
showsPrec :: Int -> RegisterCertificate -> ShowS
$cshowsPrec :: Int -> RegisterCertificate -> ShowS
Prelude.Show, (forall x. RegisterCertificate -> Rep RegisterCertificate x)
-> (forall x. Rep RegisterCertificate x -> RegisterCertificate)
-> Generic RegisterCertificate
forall x. Rep RegisterCertificate x -> RegisterCertificate
forall x. RegisterCertificate -> Rep RegisterCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterCertificate x -> RegisterCertificate
$cfrom :: forall x. RegisterCertificate -> Rep RegisterCertificate x
Prelude.Generic)
newRegisterCertificate ::
Prelude.Text ->
RegisterCertificate
newRegisterCertificate :: Text -> RegisterCertificate
newRegisterCertificate Text
pCertificatePem_ =
RegisterCertificate' :: Maybe CertificateStatus
-> Maybe Text -> Maybe Bool -> Text -> RegisterCertificate
RegisterCertificate'
{ $sel:status:RegisterCertificate' :: Maybe CertificateStatus
status = Maybe CertificateStatus
forall a. Maybe a
Prelude.Nothing,
$sel:caCertificatePem:RegisterCertificate' :: Maybe Text
caCertificatePem = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:setAsActive:RegisterCertificate' :: Maybe Bool
setAsActive = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:certificatePem:RegisterCertificate' :: Text
certificatePem = Text
pCertificatePem_
}
registerCertificate_status :: Lens.Lens' RegisterCertificate (Prelude.Maybe CertificateStatus)
registerCertificate_status :: (Maybe CertificateStatus -> f (Maybe CertificateStatus))
-> RegisterCertificate -> f RegisterCertificate
registerCertificate_status = (RegisterCertificate -> Maybe CertificateStatus)
-> (RegisterCertificate
-> Maybe CertificateStatus -> RegisterCertificate)
-> Lens
RegisterCertificate
RegisterCertificate
(Maybe CertificateStatus)
(Maybe CertificateStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificate' {Maybe CertificateStatus
status :: Maybe CertificateStatus
$sel:status:RegisterCertificate' :: RegisterCertificate -> Maybe CertificateStatus
status} -> Maybe CertificateStatus
status) (\s :: RegisterCertificate
s@RegisterCertificate' {} Maybe CertificateStatus
a -> RegisterCertificate
s {$sel:status:RegisterCertificate' :: Maybe CertificateStatus
status = Maybe CertificateStatus
a} :: RegisterCertificate)
registerCertificate_caCertificatePem :: Lens.Lens' RegisterCertificate (Prelude.Maybe Prelude.Text)
registerCertificate_caCertificatePem :: (Maybe Text -> f (Maybe Text))
-> RegisterCertificate -> f RegisterCertificate
registerCertificate_caCertificatePem = (RegisterCertificate -> Maybe Text)
-> (RegisterCertificate -> Maybe Text -> RegisterCertificate)
-> Lens
RegisterCertificate RegisterCertificate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificate' {Maybe Text
caCertificatePem :: Maybe Text
$sel:caCertificatePem:RegisterCertificate' :: RegisterCertificate -> Maybe Text
caCertificatePem} -> Maybe Text
caCertificatePem) (\s :: RegisterCertificate
s@RegisterCertificate' {} Maybe Text
a -> RegisterCertificate
s {$sel:caCertificatePem:RegisterCertificate' :: Maybe Text
caCertificatePem = Maybe Text
a} :: RegisterCertificate)
registerCertificate_setAsActive :: Lens.Lens' RegisterCertificate (Prelude.Maybe Prelude.Bool)
registerCertificate_setAsActive :: (Maybe Bool -> f (Maybe Bool))
-> RegisterCertificate -> f RegisterCertificate
registerCertificate_setAsActive = (RegisterCertificate -> Maybe Bool)
-> (RegisterCertificate -> Maybe Bool -> RegisterCertificate)
-> Lens
RegisterCertificate RegisterCertificate (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificate' {Maybe Bool
setAsActive :: Maybe Bool
$sel:setAsActive:RegisterCertificate' :: RegisterCertificate -> Maybe Bool
setAsActive} -> Maybe Bool
setAsActive) (\s :: RegisterCertificate
s@RegisterCertificate' {} Maybe Bool
a -> RegisterCertificate
s {$sel:setAsActive:RegisterCertificate' :: Maybe Bool
setAsActive = Maybe Bool
a} :: RegisterCertificate)
registerCertificate_certificatePem :: Lens.Lens' RegisterCertificate Prelude.Text
registerCertificate_certificatePem :: (Text -> f Text) -> RegisterCertificate -> f RegisterCertificate
registerCertificate_certificatePem = (RegisterCertificate -> Text)
-> (RegisterCertificate -> Text -> RegisterCertificate)
-> Lens RegisterCertificate RegisterCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificate' {Text
certificatePem :: Text
$sel:certificatePem:RegisterCertificate' :: RegisterCertificate -> Text
certificatePem} -> Text
certificatePem) (\s :: RegisterCertificate
s@RegisterCertificate' {} Text
a -> RegisterCertificate
s {$sel:certificatePem:RegisterCertificate' :: Text
certificatePem = Text
a} :: RegisterCertificate)
instance Core.AWSRequest RegisterCertificate where
type
AWSResponse RegisterCertificate =
RegisterCertificateResponse
request :: RegisterCertificate -> Request RegisterCertificate
request = Service -> RegisterCertificate -> Request RegisterCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy RegisterCertificate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse RegisterCertificate)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse RegisterCertificate))
-> Logger
-> Service
-> Proxy RegisterCertificate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse RegisterCertificate)))
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 Text -> Maybe Text -> Int -> RegisterCertificateResponse
RegisterCertificateResponse'
(Maybe Text -> Maybe Text -> Int -> RegisterCertificateResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> RegisterCertificateResponse)
forall (f :: * -> *) a b. Functor 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
"certificateArn")
Either String (Maybe Text -> Int -> RegisterCertificateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RegisterCertificateResponse)
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
"certificateId")
Either String (Int -> RegisterCertificateResponse)
-> Either String Int -> Either String RegisterCertificateResponse
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 RegisterCertificate
instance Prelude.NFData RegisterCertificate
instance Core.ToHeaders RegisterCertificate where
toHeaders :: RegisterCertificate -> ResponseHeaders
toHeaders = ResponseHeaders -> RegisterCertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON RegisterCertificate where
toJSON :: RegisterCertificate -> Value
toJSON RegisterCertificate' {Maybe Bool
Maybe Text
Maybe CertificateStatus
Text
certificatePem :: Text
setAsActive :: Maybe Bool
caCertificatePem :: Maybe Text
status :: Maybe CertificateStatus
$sel:certificatePem:RegisterCertificate' :: RegisterCertificate -> Text
$sel:setAsActive:RegisterCertificate' :: RegisterCertificate -> Maybe Bool
$sel:caCertificatePem:RegisterCertificate' :: RegisterCertificate -> Maybe Text
$sel:status:RegisterCertificate' :: RegisterCertificate -> Maybe CertificateStatus
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"status" Text -> CertificateStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CertificateStatus -> Pair)
-> Maybe CertificateStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CertificateStatus
status,
(Text
"caCertificatePem" 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
caCertificatePem,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"certificatePem" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificatePem)
]
)
instance Core.ToPath RegisterCertificate where
toPath :: RegisterCertificate -> ByteString
toPath = ByteString -> RegisterCertificate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/certificate/register"
instance Core.ToQuery RegisterCertificate where
toQuery :: RegisterCertificate -> QueryString
toQuery RegisterCertificate' {Maybe Bool
Maybe Text
Maybe CertificateStatus
Text
certificatePem :: Text
setAsActive :: Maybe Bool
caCertificatePem :: Maybe Text
status :: Maybe CertificateStatus
$sel:certificatePem:RegisterCertificate' :: RegisterCertificate -> Text
$sel:setAsActive:RegisterCertificate' :: RegisterCertificate -> Maybe Bool
$sel:caCertificatePem:RegisterCertificate' :: RegisterCertificate -> Maybe Text
$sel:status:RegisterCertificate' :: RegisterCertificate -> Maybe CertificateStatus
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"setAsActive" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
setAsActive]
data RegisterCertificateResponse = RegisterCertificateResponse'
{
RegisterCertificateResponse -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
RegisterCertificateResponse -> Maybe Text
certificateId :: Prelude.Maybe Prelude.Text,
RegisterCertificateResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RegisterCertificateResponse -> RegisterCertificateResponse -> Bool
(RegisterCertificateResponse
-> RegisterCertificateResponse -> Bool)
-> (RegisterCertificateResponse
-> RegisterCertificateResponse -> Bool)
-> Eq RegisterCertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterCertificateResponse -> RegisterCertificateResponse -> Bool
$c/= :: RegisterCertificateResponse -> RegisterCertificateResponse -> Bool
== :: RegisterCertificateResponse -> RegisterCertificateResponse -> Bool
$c== :: RegisterCertificateResponse -> RegisterCertificateResponse -> Bool
Prelude.Eq, ReadPrec [RegisterCertificateResponse]
ReadPrec RegisterCertificateResponse
Int -> ReadS RegisterCertificateResponse
ReadS [RegisterCertificateResponse]
(Int -> ReadS RegisterCertificateResponse)
-> ReadS [RegisterCertificateResponse]
-> ReadPrec RegisterCertificateResponse
-> ReadPrec [RegisterCertificateResponse]
-> Read RegisterCertificateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterCertificateResponse]
$creadListPrec :: ReadPrec [RegisterCertificateResponse]
readPrec :: ReadPrec RegisterCertificateResponse
$creadPrec :: ReadPrec RegisterCertificateResponse
readList :: ReadS [RegisterCertificateResponse]
$creadList :: ReadS [RegisterCertificateResponse]
readsPrec :: Int -> ReadS RegisterCertificateResponse
$creadsPrec :: Int -> ReadS RegisterCertificateResponse
Prelude.Read, Int -> RegisterCertificateResponse -> ShowS
[RegisterCertificateResponse] -> ShowS
RegisterCertificateResponse -> String
(Int -> RegisterCertificateResponse -> ShowS)
-> (RegisterCertificateResponse -> String)
-> ([RegisterCertificateResponse] -> ShowS)
-> Show RegisterCertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterCertificateResponse] -> ShowS
$cshowList :: [RegisterCertificateResponse] -> ShowS
show :: RegisterCertificateResponse -> String
$cshow :: RegisterCertificateResponse -> String
showsPrec :: Int -> RegisterCertificateResponse -> ShowS
$cshowsPrec :: Int -> RegisterCertificateResponse -> ShowS
Prelude.Show, (forall x.
RegisterCertificateResponse -> Rep RegisterCertificateResponse x)
-> (forall x.
Rep RegisterCertificateResponse x -> RegisterCertificateResponse)
-> Generic RegisterCertificateResponse
forall x.
Rep RegisterCertificateResponse x -> RegisterCertificateResponse
forall x.
RegisterCertificateResponse -> Rep RegisterCertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterCertificateResponse x -> RegisterCertificateResponse
$cfrom :: forall x.
RegisterCertificateResponse -> Rep RegisterCertificateResponse x
Prelude.Generic)
newRegisterCertificateResponse ::
Prelude.Int ->
RegisterCertificateResponse
newRegisterCertificateResponse :: Int -> RegisterCertificateResponse
newRegisterCertificateResponse Int
pHttpStatus_ =
RegisterCertificateResponse' :: Maybe Text -> Maybe Text -> Int -> RegisterCertificateResponse
RegisterCertificateResponse'
{ $sel:certificateArn:RegisterCertificateResponse' :: Maybe Text
certificateArn =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:certificateId:RegisterCertificateResponse' :: Maybe Text
certificateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RegisterCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
}
registerCertificateResponse_certificateArn :: Lens.Lens' RegisterCertificateResponse (Prelude.Maybe Prelude.Text)
registerCertificateResponse_certificateArn :: (Maybe Text -> f (Maybe Text))
-> RegisterCertificateResponse -> f RegisterCertificateResponse
registerCertificateResponse_certificateArn = (RegisterCertificateResponse -> Maybe Text)
-> (RegisterCertificateResponse
-> Maybe Text -> RegisterCertificateResponse)
-> Lens
RegisterCertificateResponse
RegisterCertificateResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificateResponse' {Maybe Text
certificateArn :: Maybe Text
$sel:certificateArn:RegisterCertificateResponse' :: RegisterCertificateResponse -> Maybe Text
certificateArn} -> Maybe Text
certificateArn) (\s :: RegisterCertificateResponse
s@RegisterCertificateResponse' {} Maybe Text
a -> RegisterCertificateResponse
s {$sel:certificateArn:RegisterCertificateResponse' :: Maybe Text
certificateArn = Maybe Text
a} :: RegisterCertificateResponse)
registerCertificateResponse_certificateId :: Lens.Lens' RegisterCertificateResponse (Prelude.Maybe Prelude.Text)
registerCertificateResponse_certificateId :: (Maybe Text -> f (Maybe Text))
-> RegisterCertificateResponse -> f RegisterCertificateResponse
registerCertificateResponse_certificateId = (RegisterCertificateResponse -> Maybe Text)
-> (RegisterCertificateResponse
-> Maybe Text -> RegisterCertificateResponse)
-> Lens
RegisterCertificateResponse
RegisterCertificateResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificateResponse' {Maybe Text
certificateId :: Maybe Text
$sel:certificateId:RegisterCertificateResponse' :: RegisterCertificateResponse -> Maybe Text
certificateId} -> Maybe Text
certificateId) (\s :: RegisterCertificateResponse
s@RegisterCertificateResponse' {} Maybe Text
a -> RegisterCertificateResponse
s {$sel:certificateId:RegisterCertificateResponse' :: Maybe Text
certificateId = Maybe Text
a} :: RegisterCertificateResponse)
registerCertificateResponse_httpStatus :: Lens.Lens' RegisterCertificateResponse Prelude.Int
registerCertificateResponse_httpStatus :: (Int -> f Int)
-> RegisterCertificateResponse -> f RegisterCertificateResponse
registerCertificateResponse_httpStatus = (RegisterCertificateResponse -> Int)
-> (RegisterCertificateResponse
-> Int -> RegisterCertificateResponse)
-> Lens
RegisterCertificateResponse RegisterCertificateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterCertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:RegisterCertificateResponse' :: RegisterCertificateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RegisterCertificateResponse
s@RegisterCertificateResponse' {} Int
a -> RegisterCertificateResponse
s {$sel:httpStatus:RegisterCertificateResponse' :: Int
httpStatus = Int
a} :: RegisterCertificateResponse)
instance Prelude.NFData RegisterCertificateResponse