{-# 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.Lightsail.AllocateStaticIp
(
AllocateStaticIp (..),
newAllocateStaticIp,
allocateStaticIp_staticIpName,
AllocateStaticIpResponse (..),
newAllocateStaticIpResponse,
allocateStaticIpResponse_operations,
allocateStaticIpResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data AllocateStaticIp = AllocateStaticIp'
{
AllocateStaticIp -> Text
staticIpName :: Prelude.Text
}
deriving (AllocateStaticIp -> AllocateStaticIp -> Bool
(AllocateStaticIp -> AllocateStaticIp -> Bool)
-> (AllocateStaticIp -> AllocateStaticIp -> Bool)
-> Eq AllocateStaticIp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocateStaticIp -> AllocateStaticIp -> Bool
$c/= :: AllocateStaticIp -> AllocateStaticIp -> Bool
== :: AllocateStaticIp -> AllocateStaticIp -> Bool
$c== :: AllocateStaticIp -> AllocateStaticIp -> Bool
Prelude.Eq, ReadPrec [AllocateStaticIp]
ReadPrec AllocateStaticIp
Int -> ReadS AllocateStaticIp
ReadS [AllocateStaticIp]
(Int -> ReadS AllocateStaticIp)
-> ReadS [AllocateStaticIp]
-> ReadPrec AllocateStaticIp
-> ReadPrec [AllocateStaticIp]
-> Read AllocateStaticIp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AllocateStaticIp]
$creadListPrec :: ReadPrec [AllocateStaticIp]
readPrec :: ReadPrec AllocateStaticIp
$creadPrec :: ReadPrec AllocateStaticIp
readList :: ReadS [AllocateStaticIp]
$creadList :: ReadS [AllocateStaticIp]
readsPrec :: Int -> ReadS AllocateStaticIp
$creadsPrec :: Int -> ReadS AllocateStaticIp
Prelude.Read, Int -> AllocateStaticIp -> ShowS
[AllocateStaticIp] -> ShowS
AllocateStaticIp -> String
(Int -> AllocateStaticIp -> ShowS)
-> (AllocateStaticIp -> String)
-> ([AllocateStaticIp] -> ShowS)
-> Show AllocateStaticIp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllocateStaticIp] -> ShowS
$cshowList :: [AllocateStaticIp] -> ShowS
show :: AllocateStaticIp -> String
$cshow :: AllocateStaticIp -> String
showsPrec :: Int -> AllocateStaticIp -> ShowS
$cshowsPrec :: Int -> AllocateStaticIp -> ShowS
Prelude.Show, (forall x. AllocateStaticIp -> Rep AllocateStaticIp x)
-> (forall x. Rep AllocateStaticIp x -> AllocateStaticIp)
-> Generic AllocateStaticIp
forall x. Rep AllocateStaticIp x -> AllocateStaticIp
forall x. AllocateStaticIp -> Rep AllocateStaticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AllocateStaticIp x -> AllocateStaticIp
$cfrom :: forall x. AllocateStaticIp -> Rep AllocateStaticIp x
Prelude.Generic)
newAllocateStaticIp ::
Prelude.Text ->
AllocateStaticIp
newAllocateStaticIp :: Text -> AllocateStaticIp
newAllocateStaticIp Text
pStaticIpName_ =
AllocateStaticIp' :: Text -> AllocateStaticIp
AllocateStaticIp' {$sel:staticIpName:AllocateStaticIp' :: Text
staticIpName = Text
pStaticIpName_}
allocateStaticIp_staticIpName :: Lens.Lens' AllocateStaticIp Prelude.Text
allocateStaticIp_staticIpName :: (Text -> f Text) -> AllocateStaticIp -> f AllocateStaticIp
allocateStaticIp_staticIpName = (AllocateStaticIp -> Text)
-> (AllocateStaticIp -> Text -> AllocateStaticIp)
-> Lens AllocateStaticIp AllocateStaticIp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocateStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:AllocateStaticIp' :: AllocateStaticIp -> Text
staticIpName} -> Text
staticIpName) (\s :: AllocateStaticIp
s@AllocateStaticIp' {} Text
a -> AllocateStaticIp
s {$sel:staticIpName:AllocateStaticIp' :: Text
staticIpName = Text
a} :: AllocateStaticIp)
instance Core.AWSRequest AllocateStaticIp where
type
AWSResponse AllocateStaticIp =
AllocateStaticIpResponse
request :: AllocateStaticIp -> Request AllocateStaticIp
request = Service -> AllocateStaticIp -> Request AllocateStaticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AllocateStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AllocateStaticIp)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AllocateStaticIp))
-> Logger
-> Service
-> Proxy AllocateStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AllocateStaticIp)))
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 [Operation] -> Int -> AllocateStaticIpResponse
AllocateStaticIpResponse'
(Maybe [Operation] -> Int -> AllocateStaticIpResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> AllocateStaticIpResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> AllocateStaticIpResponse)
-> Either String Int -> Either String AllocateStaticIpResponse
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 AllocateStaticIp
instance Prelude.NFData AllocateStaticIp
instance Core.ToHeaders AllocateStaticIp where
toHeaders :: AllocateStaticIp -> ResponseHeaders
toHeaders =
ResponseHeaders -> AllocateStaticIp -> 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
"Lightsail_20161128.AllocateStaticIp" ::
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 AllocateStaticIp where
toJSON :: AllocateStaticIp -> Value
toJSON AllocateStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:AllocateStaticIp' :: AllocateStaticIp -> 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
"staticIpName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
staticIpName)]
)
instance Core.ToPath AllocateStaticIp where
toPath :: AllocateStaticIp -> ByteString
toPath = ByteString -> AllocateStaticIp -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AllocateStaticIp where
toQuery :: AllocateStaticIp -> QueryString
toQuery = QueryString -> AllocateStaticIp -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AllocateStaticIpResponse = AllocateStaticIpResponse'
{
AllocateStaticIpResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
AllocateStaticIpResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool
(AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool)
-> (AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool)
-> Eq AllocateStaticIpResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool
$c/= :: AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool
== :: AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool
$c== :: AllocateStaticIpResponse -> AllocateStaticIpResponse -> Bool
Prelude.Eq, ReadPrec [AllocateStaticIpResponse]
ReadPrec AllocateStaticIpResponse
Int -> ReadS AllocateStaticIpResponse
ReadS [AllocateStaticIpResponse]
(Int -> ReadS AllocateStaticIpResponse)
-> ReadS [AllocateStaticIpResponse]
-> ReadPrec AllocateStaticIpResponse
-> ReadPrec [AllocateStaticIpResponse]
-> Read AllocateStaticIpResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AllocateStaticIpResponse]
$creadListPrec :: ReadPrec [AllocateStaticIpResponse]
readPrec :: ReadPrec AllocateStaticIpResponse
$creadPrec :: ReadPrec AllocateStaticIpResponse
readList :: ReadS [AllocateStaticIpResponse]
$creadList :: ReadS [AllocateStaticIpResponse]
readsPrec :: Int -> ReadS AllocateStaticIpResponse
$creadsPrec :: Int -> ReadS AllocateStaticIpResponse
Prelude.Read, Int -> AllocateStaticIpResponse -> ShowS
[AllocateStaticIpResponse] -> ShowS
AllocateStaticIpResponse -> String
(Int -> AllocateStaticIpResponse -> ShowS)
-> (AllocateStaticIpResponse -> String)
-> ([AllocateStaticIpResponse] -> ShowS)
-> Show AllocateStaticIpResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllocateStaticIpResponse] -> ShowS
$cshowList :: [AllocateStaticIpResponse] -> ShowS
show :: AllocateStaticIpResponse -> String
$cshow :: AllocateStaticIpResponse -> String
showsPrec :: Int -> AllocateStaticIpResponse -> ShowS
$cshowsPrec :: Int -> AllocateStaticIpResponse -> ShowS
Prelude.Show, (forall x.
AllocateStaticIpResponse -> Rep AllocateStaticIpResponse x)
-> (forall x.
Rep AllocateStaticIpResponse x -> AllocateStaticIpResponse)
-> Generic AllocateStaticIpResponse
forall x.
Rep AllocateStaticIpResponse x -> AllocateStaticIpResponse
forall x.
AllocateStaticIpResponse -> Rep AllocateStaticIpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AllocateStaticIpResponse x -> AllocateStaticIpResponse
$cfrom :: forall x.
AllocateStaticIpResponse -> Rep AllocateStaticIpResponse x
Prelude.Generic)
newAllocateStaticIpResponse ::
Prelude.Int ->
AllocateStaticIpResponse
newAllocateStaticIpResponse :: Int -> AllocateStaticIpResponse
newAllocateStaticIpResponse Int
pHttpStatus_ =
AllocateStaticIpResponse' :: Maybe [Operation] -> Int -> AllocateStaticIpResponse
AllocateStaticIpResponse'
{ $sel:operations:AllocateStaticIpResponse' :: Maybe [Operation]
operations =
Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AllocateStaticIpResponse' :: Int
httpStatus = Int
pHttpStatus_
}
allocateStaticIpResponse_operations :: Lens.Lens' AllocateStaticIpResponse (Prelude.Maybe [Operation])
allocateStaticIpResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> AllocateStaticIpResponse -> f AllocateStaticIpResponse
allocateStaticIpResponse_operations = (AllocateStaticIpResponse -> Maybe [Operation])
-> (AllocateStaticIpResponse
-> Maybe [Operation] -> AllocateStaticIpResponse)
-> Lens
AllocateStaticIpResponse
AllocateStaticIpResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocateStaticIpResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:AllocateStaticIpResponse' :: AllocateStaticIpResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: AllocateStaticIpResponse
s@AllocateStaticIpResponse' {} Maybe [Operation]
a -> AllocateStaticIpResponse
s {$sel:operations:AllocateStaticIpResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: AllocateStaticIpResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> AllocateStaticIpResponse -> f AllocateStaticIpResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> AllocateStaticIpResponse
-> f AllocateStaticIpResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
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 [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
allocateStaticIpResponse_httpStatus :: Lens.Lens' AllocateStaticIpResponse Prelude.Int
allocateStaticIpResponse_httpStatus :: (Int -> f Int)
-> AllocateStaticIpResponse -> f AllocateStaticIpResponse
allocateStaticIpResponse_httpStatus = (AllocateStaticIpResponse -> Int)
-> (AllocateStaticIpResponse -> Int -> AllocateStaticIpResponse)
-> Lens AllocateStaticIpResponse AllocateStaticIpResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllocateStaticIpResponse' {Int
httpStatus :: Int
$sel:httpStatus:AllocateStaticIpResponse' :: AllocateStaticIpResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AllocateStaticIpResponse
s@AllocateStaticIpResponse' {} Int
a -> AllocateStaticIpResponse
s {$sel:httpStatus:AllocateStaticIpResponse' :: Int
httpStatus = Int
a} :: AllocateStaticIpResponse)
instance Prelude.NFData AllocateStaticIpResponse