{-# 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.AttachStaticIp
(
AttachStaticIp (..),
newAttachStaticIp,
attachStaticIp_staticIpName,
attachStaticIp_instanceName,
AttachStaticIpResponse (..),
newAttachStaticIpResponse,
attachStaticIpResponse_operations,
attachStaticIpResponse_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 AttachStaticIp = AttachStaticIp'
{
AttachStaticIp -> Text
staticIpName :: Prelude.Text,
AttachStaticIp -> Text
instanceName :: Prelude.Text
}
deriving (AttachStaticIp -> AttachStaticIp -> Bool
(AttachStaticIp -> AttachStaticIp -> Bool)
-> (AttachStaticIp -> AttachStaticIp -> Bool) -> Eq AttachStaticIp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachStaticIp -> AttachStaticIp -> Bool
$c/= :: AttachStaticIp -> AttachStaticIp -> Bool
== :: AttachStaticIp -> AttachStaticIp -> Bool
$c== :: AttachStaticIp -> AttachStaticIp -> Bool
Prelude.Eq, ReadPrec [AttachStaticIp]
ReadPrec AttachStaticIp
Int -> ReadS AttachStaticIp
ReadS [AttachStaticIp]
(Int -> ReadS AttachStaticIp)
-> ReadS [AttachStaticIp]
-> ReadPrec AttachStaticIp
-> ReadPrec [AttachStaticIp]
-> Read AttachStaticIp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachStaticIp]
$creadListPrec :: ReadPrec [AttachStaticIp]
readPrec :: ReadPrec AttachStaticIp
$creadPrec :: ReadPrec AttachStaticIp
readList :: ReadS [AttachStaticIp]
$creadList :: ReadS [AttachStaticIp]
readsPrec :: Int -> ReadS AttachStaticIp
$creadsPrec :: Int -> ReadS AttachStaticIp
Prelude.Read, Int -> AttachStaticIp -> ShowS
[AttachStaticIp] -> ShowS
AttachStaticIp -> String
(Int -> AttachStaticIp -> ShowS)
-> (AttachStaticIp -> String)
-> ([AttachStaticIp] -> ShowS)
-> Show AttachStaticIp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachStaticIp] -> ShowS
$cshowList :: [AttachStaticIp] -> ShowS
show :: AttachStaticIp -> String
$cshow :: AttachStaticIp -> String
showsPrec :: Int -> AttachStaticIp -> ShowS
$cshowsPrec :: Int -> AttachStaticIp -> ShowS
Prelude.Show, (forall x. AttachStaticIp -> Rep AttachStaticIp x)
-> (forall x. Rep AttachStaticIp x -> AttachStaticIp)
-> Generic AttachStaticIp
forall x. Rep AttachStaticIp x -> AttachStaticIp
forall x. AttachStaticIp -> Rep AttachStaticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachStaticIp x -> AttachStaticIp
$cfrom :: forall x. AttachStaticIp -> Rep AttachStaticIp x
Prelude.Generic)
newAttachStaticIp ::
Prelude.Text ->
Prelude.Text ->
AttachStaticIp
newAttachStaticIp :: Text -> Text -> AttachStaticIp
newAttachStaticIp Text
pStaticIpName_ Text
pInstanceName_ =
AttachStaticIp' :: Text -> Text -> AttachStaticIp
AttachStaticIp'
{ $sel:staticIpName:AttachStaticIp' :: Text
staticIpName = Text
pStaticIpName_,
$sel:instanceName:AttachStaticIp' :: Text
instanceName = Text
pInstanceName_
}
attachStaticIp_staticIpName :: Lens.Lens' AttachStaticIp Prelude.Text
attachStaticIp_staticIpName :: (Text -> f Text) -> AttachStaticIp -> f AttachStaticIp
attachStaticIp_staticIpName = (AttachStaticIp -> Text)
-> (AttachStaticIp -> Text -> AttachStaticIp)
-> Lens AttachStaticIp AttachStaticIp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:AttachStaticIp' :: AttachStaticIp -> Text
staticIpName} -> Text
staticIpName) (\s :: AttachStaticIp
s@AttachStaticIp' {} Text
a -> AttachStaticIp
s {$sel:staticIpName:AttachStaticIp' :: Text
staticIpName = Text
a} :: AttachStaticIp)
attachStaticIp_instanceName :: Lens.Lens' AttachStaticIp Prelude.Text
attachStaticIp_instanceName :: (Text -> f Text) -> AttachStaticIp -> f AttachStaticIp
attachStaticIp_instanceName = (AttachStaticIp -> Text)
-> (AttachStaticIp -> Text -> AttachStaticIp)
-> Lens AttachStaticIp AttachStaticIp Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachStaticIp' {Text
instanceName :: Text
$sel:instanceName:AttachStaticIp' :: AttachStaticIp -> Text
instanceName} -> Text
instanceName) (\s :: AttachStaticIp
s@AttachStaticIp' {} Text
a -> AttachStaticIp
s {$sel:instanceName:AttachStaticIp' :: Text
instanceName = Text
a} :: AttachStaticIp)
instance Core.AWSRequest AttachStaticIp where
type
AWSResponse AttachStaticIp =
AttachStaticIpResponse
request :: AttachStaticIp -> Request AttachStaticIp
request = Service -> AttachStaticIp -> Request AttachStaticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AttachStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachStaticIp)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AttachStaticIp))
-> Logger
-> Service
-> Proxy AttachStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AttachStaticIp)))
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 -> AttachStaticIpResponse
AttachStaticIpResponse'
(Maybe [Operation] -> Int -> AttachStaticIpResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> AttachStaticIpResponse)
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 -> AttachStaticIpResponse)
-> Either String Int -> Either String AttachStaticIpResponse
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 AttachStaticIp
instance Prelude.NFData AttachStaticIp
instance Core.ToHeaders AttachStaticIp where
toHeaders :: AttachStaticIp -> ResponseHeaders
toHeaders =
ResponseHeaders -> AttachStaticIp -> 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.AttachStaticIp" ::
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 AttachStaticIp where
toJSON :: AttachStaticIp -> Value
toJSON AttachStaticIp' {Text
instanceName :: Text
staticIpName :: Text
$sel:instanceName:AttachStaticIp' :: AttachStaticIp -> Text
$sel:staticIpName:AttachStaticIp' :: AttachStaticIp -> 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),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"instanceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceName)
]
)
instance Core.ToPath AttachStaticIp where
toPath :: AttachStaticIp -> ByteString
toPath = ByteString -> AttachStaticIp -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AttachStaticIp where
toQuery :: AttachStaticIp -> QueryString
toQuery = QueryString -> AttachStaticIp -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AttachStaticIpResponse = AttachStaticIpResponse'
{
AttachStaticIpResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
AttachStaticIpResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AttachStaticIpResponse -> AttachStaticIpResponse -> Bool
(AttachStaticIpResponse -> AttachStaticIpResponse -> Bool)
-> (AttachStaticIpResponse -> AttachStaticIpResponse -> Bool)
-> Eq AttachStaticIpResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachStaticIpResponse -> AttachStaticIpResponse -> Bool
$c/= :: AttachStaticIpResponse -> AttachStaticIpResponse -> Bool
== :: AttachStaticIpResponse -> AttachStaticIpResponse -> Bool
$c== :: AttachStaticIpResponse -> AttachStaticIpResponse -> Bool
Prelude.Eq, ReadPrec [AttachStaticIpResponse]
ReadPrec AttachStaticIpResponse
Int -> ReadS AttachStaticIpResponse
ReadS [AttachStaticIpResponse]
(Int -> ReadS AttachStaticIpResponse)
-> ReadS [AttachStaticIpResponse]
-> ReadPrec AttachStaticIpResponse
-> ReadPrec [AttachStaticIpResponse]
-> Read AttachStaticIpResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachStaticIpResponse]
$creadListPrec :: ReadPrec [AttachStaticIpResponse]
readPrec :: ReadPrec AttachStaticIpResponse
$creadPrec :: ReadPrec AttachStaticIpResponse
readList :: ReadS [AttachStaticIpResponse]
$creadList :: ReadS [AttachStaticIpResponse]
readsPrec :: Int -> ReadS AttachStaticIpResponse
$creadsPrec :: Int -> ReadS AttachStaticIpResponse
Prelude.Read, Int -> AttachStaticIpResponse -> ShowS
[AttachStaticIpResponse] -> ShowS
AttachStaticIpResponse -> String
(Int -> AttachStaticIpResponse -> ShowS)
-> (AttachStaticIpResponse -> String)
-> ([AttachStaticIpResponse] -> ShowS)
-> Show AttachStaticIpResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachStaticIpResponse] -> ShowS
$cshowList :: [AttachStaticIpResponse] -> ShowS
show :: AttachStaticIpResponse -> String
$cshow :: AttachStaticIpResponse -> String
showsPrec :: Int -> AttachStaticIpResponse -> ShowS
$cshowsPrec :: Int -> AttachStaticIpResponse -> ShowS
Prelude.Show, (forall x. AttachStaticIpResponse -> Rep AttachStaticIpResponse x)
-> (forall x.
Rep AttachStaticIpResponse x -> AttachStaticIpResponse)
-> Generic AttachStaticIpResponse
forall x. Rep AttachStaticIpResponse x -> AttachStaticIpResponse
forall x. AttachStaticIpResponse -> Rep AttachStaticIpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachStaticIpResponse x -> AttachStaticIpResponse
$cfrom :: forall x. AttachStaticIpResponse -> Rep AttachStaticIpResponse x
Prelude.Generic)
newAttachStaticIpResponse ::
Prelude.Int ->
AttachStaticIpResponse
newAttachStaticIpResponse :: Int -> AttachStaticIpResponse
newAttachStaticIpResponse Int
pHttpStatus_ =
AttachStaticIpResponse' :: Maybe [Operation] -> Int -> AttachStaticIpResponse
AttachStaticIpResponse'
{ $sel:operations:AttachStaticIpResponse' :: Maybe [Operation]
operations =
Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AttachStaticIpResponse' :: Int
httpStatus = Int
pHttpStatus_
}
attachStaticIpResponse_operations :: Lens.Lens' AttachStaticIpResponse (Prelude.Maybe [Operation])
attachStaticIpResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> AttachStaticIpResponse -> f AttachStaticIpResponse
attachStaticIpResponse_operations = (AttachStaticIpResponse -> Maybe [Operation])
-> (AttachStaticIpResponse
-> Maybe [Operation] -> AttachStaticIpResponse)
-> Lens
AttachStaticIpResponse
AttachStaticIpResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachStaticIpResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:AttachStaticIpResponse' :: AttachStaticIpResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: AttachStaticIpResponse
s@AttachStaticIpResponse' {} Maybe [Operation]
a -> AttachStaticIpResponse
s {$sel:operations:AttachStaticIpResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: AttachStaticIpResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> AttachStaticIpResponse -> f AttachStaticIpResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> AttachStaticIpResponse
-> f AttachStaticIpResponse
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
attachStaticIpResponse_httpStatus :: Lens.Lens' AttachStaticIpResponse Prelude.Int
attachStaticIpResponse_httpStatus :: (Int -> f Int)
-> AttachStaticIpResponse -> f AttachStaticIpResponse
attachStaticIpResponse_httpStatus = (AttachStaticIpResponse -> Int)
-> (AttachStaticIpResponse -> Int -> AttachStaticIpResponse)
-> Lens AttachStaticIpResponse AttachStaticIpResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachStaticIpResponse' {Int
httpStatus :: Int
$sel:httpStatus:AttachStaticIpResponse' :: AttachStaticIpResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AttachStaticIpResponse
s@AttachStaticIpResponse' {} Int
a -> AttachStaticIpResponse
s {$sel:httpStatus:AttachStaticIpResponse' :: Int
httpStatus = Int
a} :: AttachStaticIpResponse)
instance Prelude.NFData AttachStaticIpResponse