{-# 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.CertificateManagerPCA.CreatePermission
(
CreatePermission (..),
newCreatePermission,
createPermission_sourceAccount,
createPermission_certificateAuthorityArn,
createPermission_principal,
createPermission_actions,
CreatePermissionResponse (..),
newCreatePermissionResponse,
)
where
import Amazonka.CertificateManagerPCA.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 CreatePermission = CreatePermission'
{
CreatePermission -> Maybe Text
sourceAccount :: Prelude.Maybe Prelude.Text,
CreatePermission -> Text
certificateAuthorityArn :: Prelude.Text,
CreatePermission -> Text
principal :: Prelude.Text,
CreatePermission -> NonEmpty ActionType
actions :: Prelude.NonEmpty ActionType
}
deriving (CreatePermission -> CreatePermission -> Bool
(CreatePermission -> CreatePermission -> Bool)
-> (CreatePermission -> CreatePermission -> Bool)
-> Eq CreatePermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePermission -> CreatePermission -> Bool
$c/= :: CreatePermission -> CreatePermission -> Bool
== :: CreatePermission -> CreatePermission -> Bool
$c== :: CreatePermission -> CreatePermission -> Bool
Prelude.Eq, ReadPrec [CreatePermission]
ReadPrec CreatePermission
Int -> ReadS CreatePermission
ReadS [CreatePermission]
(Int -> ReadS CreatePermission)
-> ReadS [CreatePermission]
-> ReadPrec CreatePermission
-> ReadPrec [CreatePermission]
-> Read CreatePermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePermission]
$creadListPrec :: ReadPrec [CreatePermission]
readPrec :: ReadPrec CreatePermission
$creadPrec :: ReadPrec CreatePermission
readList :: ReadS [CreatePermission]
$creadList :: ReadS [CreatePermission]
readsPrec :: Int -> ReadS CreatePermission
$creadsPrec :: Int -> ReadS CreatePermission
Prelude.Read, Int -> CreatePermission -> ShowS
[CreatePermission] -> ShowS
CreatePermission -> String
(Int -> CreatePermission -> ShowS)
-> (CreatePermission -> String)
-> ([CreatePermission] -> ShowS)
-> Show CreatePermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePermission] -> ShowS
$cshowList :: [CreatePermission] -> ShowS
show :: CreatePermission -> String
$cshow :: CreatePermission -> String
showsPrec :: Int -> CreatePermission -> ShowS
$cshowsPrec :: Int -> CreatePermission -> ShowS
Prelude.Show, (forall x. CreatePermission -> Rep CreatePermission x)
-> (forall x. Rep CreatePermission x -> CreatePermission)
-> Generic CreatePermission
forall x. Rep CreatePermission x -> CreatePermission
forall x. CreatePermission -> Rep CreatePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePermission x -> CreatePermission
$cfrom :: forall x. CreatePermission -> Rep CreatePermission x
Prelude.Generic)
newCreatePermission ::
Prelude.Text ->
Prelude.Text ->
Prelude.NonEmpty ActionType ->
CreatePermission
newCreatePermission :: Text -> Text -> NonEmpty ActionType -> CreatePermission
newCreatePermission
Text
pCertificateAuthorityArn_
Text
pPrincipal_
NonEmpty ActionType
pActions_ =
CreatePermission' :: Maybe Text
-> Text -> Text -> NonEmpty ActionType -> CreatePermission
CreatePermission'
{ $sel:sourceAccount:CreatePermission' :: Maybe Text
sourceAccount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:certificateAuthorityArn:CreatePermission' :: Text
certificateAuthorityArn = Text
pCertificateAuthorityArn_,
$sel:principal:CreatePermission' :: Text
principal = Text
pPrincipal_,
$sel:actions:CreatePermission' :: NonEmpty ActionType
actions = Tagged (NonEmpty ActionType) (Identity (NonEmpty ActionType))
-> Tagged (NonEmpty ActionType) (Identity (NonEmpty ActionType))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty ActionType) (Identity (NonEmpty ActionType))
-> Tagged (NonEmpty ActionType) (Identity (NonEmpty ActionType)))
-> NonEmpty ActionType -> NonEmpty ActionType
forall t b. AReview t b -> b -> t
Lens.# NonEmpty ActionType
pActions_
}
createPermission_sourceAccount :: Lens.Lens' CreatePermission (Prelude.Maybe Prelude.Text)
createPermission_sourceAccount :: (Maybe Text -> f (Maybe Text))
-> CreatePermission -> f CreatePermission
createPermission_sourceAccount = (CreatePermission -> Maybe Text)
-> (CreatePermission -> Maybe Text -> CreatePermission)
-> Lens CreatePermission CreatePermission (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePermission' {Maybe Text
sourceAccount :: Maybe Text
$sel:sourceAccount:CreatePermission' :: CreatePermission -> Maybe Text
sourceAccount} -> Maybe Text
sourceAccount) (\s :: CreatePermission
s@CreatePermission' {} Maybe Text
a -> CreatePermission
s {$sel:sourceAccount:CreatePermission' :: Maybe Text
sourceAccount = Maybe Text
a} :: CreatePermission)
createPermission_certificateAuthorityArn :: Lens.Lens' CreatePermission Prelude.Text
createPermission_certificateAuthorityArn :: (Text -> f Text) -> CreatePermission -> f CreatePermission
createPermission_certificateAuthorityArn = (CreatePermission -> Text)
-> (CreatePermission -> Text -> CreatePermission)
-> Lens CreatePermission CreatePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePermission' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:CreatePermission' :: CreatePermission -> Text
certificateAuthorityArn} -> Text
certificateAuthorityArn) (\s :: CreatePermission
s@CreatePermission' {} Text
a -> CreatePermission
s {$sel:certificateAuthorityArn:CreatePermission' :: Text
certificateAuthorityArn = Text
a} :: CreatePermission)
createPermission_principal :: Lens.Lens' CreatePermission Prelude.Text
createPermission_principal :: (Text -> f Text) -> CreatePermission -> f CreatePermission
createPermission_principal = (CreatePermission -> Text)
-> (CreatePermission -> Text -> CreatePermission)
-> Lens CreatePermission CreatePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePermission' {Text
principal :: Text
$sel:principal:CreatePermission' :: CreatePermission -> Text
principal} -> Text
principal) (\s :: CreatePermission
s@CreatePermission' {} Text
a -> CreatePermission
s {$sel:principal:CreatePermission' :: Text
principal = Text
a} :: CreatePermission)
createPermission_actions :: Lens.Lens' CreatePermission (Prelude.NonEmpty ActionType)
createPermission_actions :: (NonEmpty ActionType -> f (NonEmpty ActionType))
-> CreatePermission -> f CreatePermission
createPermission_actions = (CreatePermission -> NonEmpty ActionType)
-> (CreatePermission -> NonEmpty ActionType -> CreatePermission)
-> Lens
CreatePermission
CreatePermission
(NonEmpty ActionType)
(NonEmpty ActionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePermission' {NonEmpty ActionType
actions :: NonEmpty ActionType
$sel:actions:CreatePermission' :: CreatePermission -> NonEmpty ActionType
actions} -> NonEmpty ActionType
actions) (\s :: CreatePermission
s@CreatePermission' {} NonEmpty ActionType
a -> CreatePermission
s {$sel:actions:CreatePermission' :: NonEmpty ActionType
actions = NonEmpty ActionType
a} :: CreatePermission) ((NonEmpty ActionType -> f (NonEmpty ActionType))
-> CreatePermission -> f CreatePermission)
-> ((NonEmpty ActionType -> f (NonEmpty ActionType))
-> NonEmpty ActionType -> f (NonEmpty ActionType))
-> (NonEmpty ActionType -> f (NonEmpty ActionType))
-> CreatePermission
-> f CreatePermission
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty ActionType -> f (NonEmpty ActionType))
-> NonEmpty ActionType -> f (NonEmpty ActionType)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreatePermission where
type
AWSResponse CreatePermission =
CreatePermissionResponse
request :: CreatePermission -> Request CreatePermission
request = Service -> CreatePermission -> Request CreatePermission
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreatePermission
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePermission)))
response =
AWSResponse CreatePermission
-> Logger
-> Service
-> Proxy CreatePermission
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePermission)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse CreatePermission
CreatePermissionResponse
CreatePermissionResponse'
instance Prelude.Hashable CreatePermission
instance Prelude.NFData CreatePermission
instance Core.ToHeaders CreatePermission where
toHeaders :: CreatePermission -> [Header]
toHeaders =
[Header] -> CreatePermission -> [Header]
forall a b. a -> b -> a
Prelude.const
( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"ACMPrivateCA.CreatePermission" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreatePermission where
toJSON :: CreatePermission -> Value
toJSON CreatePermission' {Maybe Text
NonEmpty ActionType
Text
actions :: NonEmpty ActionType
principal :: Text
certificateAuthorityArn :: Text
sourceAccount :: Maybe Text
$sel:actions:CreatePermission' :: CreatePermission -> NonEmpty ActionType
$sel:principal:CreatePermission' :: CreatePermission -> Text
$sel:certificateAuthorityArn:CreatePermission' :: CreatePermission -> Text
$sel:sourceAccount:CreatePermission' :: CreatePermission -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"SourceAccount" 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
sourceAccount,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"CertificateAuthorityArn"
Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateAuthorityArn
),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Principal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
principal),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Actions" Text -> NonEmpty ActionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty ActionType
actions)
]
)
instance Core.ToPath CreatePermission where
toPath :: CreatePermission -> ByteString
toPath = ByteString -> CreatePermission -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreatePermission where
toQuery :: CreatePermission -> QueryString
toQuery = QueryString -> CreatePermission -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreatePermissionResponse = CreatePermissionResponse'
{
}
deriving (CreatePermissionResponse -> CreatePermissionResponse -> Bool
(CreatePermissionResponse -> CreatePermissionResponse -> Bool)
-> (CreatePermissionResponse -> CreatePermissionResponse -> Bool)
-> Eq CreatePermissionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePermissionResponse -> CreatePermissionResponse -> Bool
$c/= :: CreatePermissionResponse -> CreatePermissionResponse -> Bool
== :: CreatePermissionResponse -> CreatePermissionResponse -> Bool
$c== :: CreatePermissionResponse -> CreatePermissionResponse -> Bool
Prelude.Eq, ReadPrec [CreatePermissionResponse]
ReadPrec CreatePermissionResponse
Int -> ReadS CreatePermissionResponse
ReadS [CreatePermissionResponse]
(Int -> ReadS CreatePermissionResponse)
-> ReadS [CreatePermissionResponse]
-> ReadPrec CreatePermissionResponse
-> ReadPrec [CreatePermissionResponse]
-> Read CreatePermissionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePermissionResponse]
$creadListPrec :: ReadPrec [CreatePermissionResponse]
readPrec :: ReadPrec CreatePermissionResponse
$creadPrec :: ReadPrec CreatePermissionResponse
readList :: ReadS [CreatePermissionResponse]
$creadList :: ReadS [CreatePermissionResponse]
readsPrec :: Int -> ReadS CreatePermissionResponse
$creadsPrec :: Int -> ReadS CreatePermissionResponse
Prelude.Read, Int -> CreatePermissionResponse -> ShowS
[CreatePermissionResponse] -> ShowS
CreatePermissionResponse -> String
(Int -> CreatePermissionResponse -> ShowS)
-> (CreatePermissionResponse -> String)
-> ([CreatePermissionResponse] -> ShowS)
-> Show CreatePermissionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePermissionResponse] -> ShowS
$cshowList :: [CreatePermissionResponse] -> ShowS
show :: CreatePermissionResponse -> String
$cshow :: CreatePermissionResponse -> String
showsPrec :: Int -> CreatePermissionResponse -> ShowS
$cshowsPrec :: Int -> CreatePermissionResponse -> ShowS
Prelude.Show, (forall x.
CreatePermissionResponse -> Rep CreatePermissionResponse x)
-> (forall x.
Rep CreatePermissionResponse x -> CreatePermissionResponse)
-> Generic CreatePermissionResponse
forall x.
Rep CreatePermissionResponse x -> CreatePermissionResponse
forall x.
CreatePermissionResponse -> Rep CreatePermissionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePermissionResponse x -> CreatePermissionResponse
$cfrom :: forall x.
CreatePermissionResponse -> Rep CreatePermissionResponse x
Prelude.Generic)
newCreatePermissionResponse ::
CreatePermissionResponse
newCreatePermissionResponse :: CreatePermissionResponse
newCreatePermissionResponse =
CreatePermissionResponse
CreatePermissionResponse'
instance Prelude.NFData CreatePermissionResponse