{-# 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.WorkSpaces.CreateIpGroup
(
CreateIpGroup (..),
newCreateIpGroup,
createIpGroup_groupDesc,
createIpGroup_userRules,
createIpGroup_tags,
createIpGroup_groupName,
CreateIpGroupResponse (..),
newCreateIpGroupResponse,
createIpGroupResponse_groupId,
createIpGroupResponse_httpStatus,
)
where
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
import Amazonka.WorkSpaces.Types
data CreateIpGroup = CreateIpGroup'
{
CreateIpGroup -> Maybe Text
groupDesc :: Prelude.Maybe Prelude.Text,
CreateIpGroup -> Maybe [IpRuleItem]
userRules :: Prelude.Maybe [IpRuleItem],
CreateIpGroup -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateIpGroup -> Text
groupName :: Prelude.Text
}
deriving (CreateIpGroup -> CreateIpGroup -> Bool
(CreateIpGroup -> CreateIpGroup -> Bool)
-> (CreateIpGroup -> CreateIpGroup -> Bool) -> Eq CreateIpGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIpGroup -> CreateIpGroup -> Bool
$c/= :: CreateIpGroup -> CreateIpGroup -> Bool
== :: CreateIpGroup -> CreateIpGroup -> Bool
$c== :: CreateIpGroup -> CreateIpGroup -> Bool
Prelude.Eq, ReadPrec [CreateIpGroup]
ReadPrec CreateIpGroup
Int -> ReadS CreateIpGroup
ReadS [CreateIpGroup]
(Int -> ReadS CreateIpGroup)
-> ReadS [CreateIpGroup]
-> ReadPrec CreateIpGroup
-> ReadPrec [CreateIpGroup]
-> Read CreateIpGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIpGroup]
$creadListPrec :: ReadPrec [CreateIpGroup]
readPrec :: ReadPrec CreateIpGroup
$creadPrec :: ReadPrec CreateIpGroup
readList :: ReadS [CreateIpGroup]
$creadList :: ReadS [CreateIpGroup]
readsPrec :: Int -> ReadS CreateIpGroup
$creadsPrec :: Int -> ReadS CreateIpGroup
Prelude.Read, Int -> CreateIpGroup -> ShowS
[CreateIpGroup] -> ShowS
CreateIpGroup -> String
(Int -> CreateIpGroup -> ShowS)
-> (CreateIpGroup -> String)
-> ([CreateIpGroup] -> ShowS)
-> Show CreateIpGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIpGroup] -> ShowS
$cshowList :: [CreateIpGroup] -> ShowS
show :: CreateIpGroup -> String
$cshow :: CreateIpGroup -> String
showsPrec :: Int -> CreateIpGroup -> ShowS
$cshowsPrec :: Int -> CreateIpGroup -> ShowS
Prelude.Show, (forall x. CreateIpGroup -> Rep CreateIpGroup x)
-> (forall x. Rep CreateIpGroup x -> CreateIpGroup)
-> Generic CreateIpGroup
forall x. Rep CreateIpGroup x -> CreateIpGroup
forall x. CreateIpGroup -> Rep CreateIpGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIpGroup x -> CreateIpGroup
$cfrom :: forall x. CreateIpGroup -> Rep CreateIpGroup x
Prelude.Generic)
newCreateIpGroup ::
Prelude.Text ->
CreateIpGroup
newCreateIpGroup :: Text -> CreateIpGroup
newCreateIpGroup Text
pGroupName_ =
CreateIpGroup' :: Maybe Text
-> Maybe [IpRuleItem] -> Maybe [Tag] -> Text -> CreateIpGroup
CreateIpGroup'
{ $sel:groupDesc:CreateIpGroup' :: Maybe Text
groupDesc = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:userRules:CreateIpGroup' :: Maybe [IpRuleItem]
userRules = Maybe [IpRuleItem]
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateIpGroup' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:groupName:CreateIpGroup' :: Text
groupName = Text
pGroupName_
}
createIpGroup_groupDesc :: Lens.Lens' CreateIpGroup (Prelude.Maybe Prelude.Text)
createIpGroup_groupDesc :: (Maybe Text -> f (Maybe Text)) -> CreateIpGroup -> f CreateIpGroup
createIpGroup_groupDesc = (CreateIpGroup -> Maybe Text)
-> (CreateIpGroup -> Maybe Text -> CreateIpGroup)
-> Lens CreateIpGroup CreateIpGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroup' {Maybe Text
groupDesc :: Maybe Text
$sel:groupDesc:CreateIpGroup' :: CreateIpGroup -> Maybe Text
groupDesc} -> Maybe Text
groupDesc) (\s :: CreateIpGroup
s@CreateIpGroup' {} Maybe Text
a -> CreateIpGroup
s {$sel:groupDesc:CreateIpGroup' :: Maybe Text
groupDesc = Maybe Text
a} :: CreateIpGroup)
createIpGroup_userRules :: Lens.Lens' CreateIpGroup (Prelude.Maybe [IpRuleItem])
createIpGroup_userRules :: (Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> CreateIpGroup -> f CreateIpGroup
createIpGroup_userRules = (CreateIpGroup -> Maybe [IpRuleItem])
-> (CreateIpGroup -> Maybe [IpRuleItem] -> CreateIpGroup)
-> Lens
CreateIpGroup
CreateIpGroup
(Maybe [IpRuleItem])
(Maybe [IpRuleItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroup' {Maybe [IpRuleItem]
userRules :: Maybe [IpRuleItem]
$sel:userRules:CreateIpGroup' :: CreateIpGroup -> Maybe [IpRuleItem]
userRules} -> Maybe [IpRuleItem]
userRules) (\s :: CreateIpGroup
s@CreateIpGroup' {} Maybe [IpRuleItem]
a -> CreateIpGroup
s {$sel:userRules:CreateIpGroup' :: Maybe [IpRuleItem]
userRules = Maybe [IpRuleItem]
a} :: CreateIpGroup) ((Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> CreateIpGroup -> f CreateIpGroup)
-> ((Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> (Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> CreateIpGroup
-> f CreateIpGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [IpRuleItem] [IpRuleItem] [IpRuleItem] [IpRuleItem]
-> Iso
(Maybe [IpRuleItem])
(Maybe [IpRuleItem])
(Maybe [IpRuleItem])
(Maybe [IpRuleItem])
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 [IpRuleItem] [IpRuleItem] [IpRuleItem] [IpRuleItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createIpGroup_tags :: Lens.Lens' CreateIpGroup (Prelude.Maybe [Tag])
createIpGroup_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateIpGroup -> f CreateIpGroup
createIpGroup_tags = (CreateIpGroup -> Maybe [Tag])
-> (CreateIpGroup -> Maybe [Tag] -> CreateIpGroup)
-> Lens CreateIpGroup CreateIpGroup (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroup' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateIpGroup' :: CreateIpGroup -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateIpGroup
s@CreateIpGroup' {} Maybe [Tag]
a -> CreateIpGroup
s {$sel:tags:CreateIpGroup' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateIpGroup) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateIpGroup -> f CreateIpGroup)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateIpGroup
-> f CreateIpGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createIpGroup_groupName :: Lens.Lens' CreateIpGroup Prelude.Text
createIpGroup_groupName :: (Text -> f Text) -> CreateIpGroup -> f CreateIpGroup
createIpGroup_groupName = (CreateIpGroup -> Text)
-> (CreateIpGroup -> Text -> CreateIpGroup)
-> Lens CreateIpGroup CreateIpGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroup' {Text
groupName :: Text
$sel:groupName:CreateIpGroup' :: CreateIpGroup -> Text
groupName} -> Text
groupName) (\s :: CreateIpGroup
s@CreateIpGroup' {} Text
a -> CreateIpGroup
s {$sel:groupName:CreateIpGroup' :: Text
groupName = Text
a} :: CreateIpGroup)
instance Core.AWSRequest CreateIpGroup where
type
AWSResponse CreateIpGroup =
CreateIpGroupResponse
request :: CreateIpGroup -> Request CreateIpGroup
request = Service -> CreateIpGroup -> Request CreateIpGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateIpGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIpGroup)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateIpGroup))
-> Logger
-> Service
-> Proxy CreateIpGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateIpGroup)))
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 -> Int -> CreateIpGroupResponse
CreateIpGroupResponse'
(Maybe Text -> Int -> CreateIpGroupResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateIpGroupResponse)
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
"GroupId")
Either String (Int -> CreateIpGroupResponse)
-> Either String Int -> Either String CreateIpGroupResponse
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 CreateIpGroup
instance Prelude.NFData CreateIpGroup
instance Core.ToHeaders CreateIpGroup where
toHeaders :: CreateIpGroup -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateIpGroup -> 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
"WorkspacesService.CreateIpGroup" ::
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 CreateIpGroup where
toJSON :: CreateIpGroup -> Value
toJSON CreateIpGroup' {Maybe [IpRuleItem]
Maybe [Tag]
Maybe Text
Text
groupName :: Text
tags :: Maybe [Tag]
userRules :: Maybe [IpRuleItem]
groupDesc :: Maybe Text
$sel:groupName:CreateIpGroup' :: CreateIpGroup -> Text
$sel:tags:CreateIpGroup' :: CreateIpGroup -> Maybe [Tag]
$sel:userRules:CreateIpGroup' :: CreateIpGroup -> Maybe [IpRuleItem]
$sel:groupDesc:CreateIpGroup' :: CreateIpGroup -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"GroupDesc" 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
groupDesc,
(Text
"UserRules" Text -> [IpRuleItem] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([IpRuleItem] -> Pair) -> Maybe [IpRuleItem] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [IpRuleItem]
userRules,
(Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupName)
]
)
instance Core.ToPath CreateIpGroup where
toPath :: CreateIpGroup -> ByteString
toPath = ByteString -> CreateIpGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateIpGroup where
toQuery :: CreateIpGroup -> QueryString
toQuery = QueryString -> CreateIpGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateIpGroupResponse = CreateIpGroupResponse'
{
CreateIpGroupResponse -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
CreateIpGroupResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateIpGroupResponse -> CreateIpGroupResponse -> Bool
(CreateIpGroupResponse -> CreateIpGroupResponse -> Bool)
-> (CreateIpGroupResponse -> CreateIpGroupResponse -> Bool)
-> Eq CreateIpGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIpGroupResponse -> CreateIpGroupResponse -> Bool
$c/= :: CreateIpGroupResponse -> CreateIpGroupResponse -> Bool
== :: CreateIpGroupResponse -> CreateIpGroupResponse -> Bool
$c== :: CreateIpGroupResponse -> CreateIpGroupResponse -> Bool
Prelude.Eq, ReadPrec [CreateIpGroupResponse]
ReadPrec CreateIpGroupResponse
Int -> ReadS CreateIpGroupResponse
ReadS [CreateIpGroupResponse]
(Int -> ReadS CreateIpGroupResponse)
-> ReadS [CreateIpGroupResponse]
-> ReadPrec CreateIpGroupResponse
-> ReadPrec [CreateIpGroupResponse]
-> Read CreateIpGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIpGroupResponse]
$creadListPrec :: ReadPrec [CreateIpGroupResponse]
readPrec :: ReadPrec CreateIpGroupResponse
$creadPrec :: ReadPrec CreateIpGroupResponse
readList :: ReadS [CreateIpGroupResponse]
$creadList :: ReadS [CreateIpGroupResponse]
readsPrec :: Int -> ReadS CreateIpGroupResponse
$creadsPrec :: Int -> ReadS CreateIpGroupResponse
Prelude.Read, Int -> CreateIpGroupResponse -> ShowS
[CreateIpGroupResponse] -> ShowS
CreateIpGroupResponse -> String
(Int -> CreateIpGroupResponse -> ShowS)
-> (CreateIpGroupResponse -> String)
-> ([CreateIpGroupResponse] -> ShowS)
-> Show CreateIpGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIpGroupResponse] -> ShowS
$cshowList :: [CreateIpGroupResponse] -> ShowS
show :: CreateIpGroupResponse -> String
$cshow :: CreateIpGroupResponse -> String
showsPrec :: Int -> CreateIpGroupResponse -> ShowS
$cshowsPrec :: Int -> CreateIpGroupResponse -> ShowS
Prelude.Show, (forall x. CreateIpGroupResponse -> Rep CreateIpGroupResponse x)
-> (forall x. Rep CreateIpGroupResponse x -> CreateIpGroupResponse)
-> Generic CreateIpGroupResponse
forall x. Rep CreateIpGroupResponse x -> CreateIpGroupResponse
forall x. CreateIpGroupResponse -> Rep CreateIpGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIpGroupResponse x -> CreateIpGroupResponse
$cfrom :: forall x. CreateIpGroupResponse -> Rep CreateIpGroupResponse x
Prelude.Generic)
newCreateIpGroupResponse ::
Prelude.Int ->
CreateIpGroupResponse
newCreateIpGroupResponse :: Int -> CreateIpGroupResponse
newCreateIpGroupResponse Int
pHttpStatus_ =
CreateIpGroupResponse' :: Maybe Text -> Int -> CreateIpGroupResponse
CreateIpGroupResponse'
{ $sel:groupId:CreateIpGroupResponse' :: Maybe Text
groupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateIpGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createIpGroupResponse_groupId :: Lens.Lens' CreateIpGroupResponse (Prelude.Maybe Prelude.Text)
createIpGroupResponse_groupId :: (Maybe Text -> f (Maybe Text))
-> CreateIpGroupResponse -> f CreateIpGroupResponse
createIpGroupResponse_groupId = (CreateIpGroupResponse -> Maybe Text)
-> (CreateIpGroupResponse -> Maybe Text -> CreateIpGroupResponse)
-> Lens
CreateIpGroupResponse
CreateIpGroupResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroupResponse' {Maybe Text
groupId :: Maybe Text
$sel:groupId:CreateIpGroupResponse' :: CreateIpGroupResponse -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: CreateIpGroupResponse
s@CreateIpGroupResponse' {} Maybe Text
a -> CreateIpGroupResponse
s {$sel:groupId:CreateIpGroupResponse' :: Maybe Text
groupId = Maybe Text
a} :: CreateIpGroupResponse)
createIpGroupResponse_httpStatus :: Lens.Lens' CreateIpGroupResponse Prelude.Int
createIpGroupResponse_httpStatus :: (Int -> f Int) -> CreateIpGroupResponse -> f CreateIpGroupResponse
createIpGroupResponse_httpStatus = (CreateIpGroupResponse -> Int)
-> (CreateIpGroupResponse -> Int -> CreateIpGroupResponse)
-> Lens CreateIpGroupResponse CreateIpGroupResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIpGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateIpGroupResponse' :: CreateIpGroupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateIpGroupResponse
s@CreateIpGroupResponse' {} Int
a -> CreateIpGroupResponse
s {$sel:httpStatus:CreateIpGroupResponse' :: Int
httpStatus = Int
a} :: CreateIpGroupResponse)
instance Prelude.NFData CreateIpGroupResponse