{-# 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.GetInstancePortStates
(
GetInstancePortStates (..),
newGetInstancePortStates,
getInstancePortStates_instanceName,
GetInstancePortStatesResponse (..),
newGetInstancePortStatesResponse,
getInstancePortStatesResponse_portStates,
getInstancePortStatesResponse_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 GetInstancePortStates = GetInstancePortStates'
{
GetInstancePortStates -> Text
instanceName :: Prelude.Text
}
deriving (GetInstancePortStates -> GetInstancePortStates -> Bool
(GetInstancePortStates -> GetInstancePortStates -> Bool)
-> (GetInstancePortStates -> GetInstancePortStates -> Bool)
-> Eq GetInstancePortStates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstancePortStates -> GetInstancePortStates -> Bool
$c/= :: GetInstancePortStates -> GetInstancePortStates -> Bool
== :: GetInstancePortStates -> GetInstancePortStates -> Bool
$c== :: GetInstancePortStates -> GetInstancePortStates -> Bool
Prelude.Eq, ReadPrec [GetInstancePortStates]
ReadPrec GetInstancePortStates
Int -> ReadS GetInstancePortStates
ReadS [GetInstancePortStates]
(Int -> ReadS GetInstancePortStates)
-> ReadS [GetInstancePortStates]
-> ReadPrec GetInstancePortStates
-> ReadPrec [GetInstancePortStates]
-> Read GetInstancePortStates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstancePortStates]
$creadListPrec :: ReadPrec [GetInstancePortStates]
readPrec :: ReadPrec GetInstancePortStates
$creadPrec :: ReadPrec GetInstancePortStates
readList :: ReadS [GetInstancePortStates]
$creadList :: ReadS [GetInstancePortStates]
readsPrec :: Int -> ReadS GetInstancePortStates
$creadsPrec :: Int -> ReadS GetInstancePortStates
Prelude.Read, Int -> GetInstancePortStates -> ShowS
[GetInstancePortStates] -> ShowS
GetInstancePortStates -> String
(Int -> GetInstancePortStates -> ShowS)
-> (GetInstancePortStates -> String)
-> ([GetInstancePortStates] -> ShowS)
-> Show GetInstancePortStates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstancePortStates] -> ShowS
$cshowList :: [GetInstancePortStates] -> ShowS
show :: GetInstancePortStates -> String
$cshow :: GetInstancePortStates -> String
showsPrec :: Int -> GetInstancePortStates -> ShowS
$cshowsPrec :: Int -> GetInstancePortStates -> ShowS
Prelude.Show, (forall x. GetInstancePortStates -> Rep GetInstancePortStates x)
-> (forall x. Rep GetInstancePortStates x -> GetInstancePortStates)
-> Generic GetInstancePortStates
forall x. Rep GetInstancePortStates x -> GetInstancePortStates
forall x. GetInstancePortStates -> Rep GetInstancePortStates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInstancePortStates x -> GetInstancePortStates
$cfrom :: forall x. GetInstancePortStates -> Rep GetInstancePortStates x
Prelude.Generic)
newGetInstancePortStates ::
Prelude.Text ->
GetInstancePortStates
newGetInstancePortStates :: Text -> GetInstancePortStates
newGetInstancePortStates Text
pInstanceName_ =
GetInstancePortStates' :: Text -> GetInstancePortStates
GetInstancePortStates'
{ $sel:instanceName:GetInstancePortStates' :: Text
instanceName =
Text
pInstanceName_
}
getInstancePortStates_instanceName :: Lens.Lens' GetInstancePortStates Prelude.Text
getInstancePortStates_instanceName :: (Text -> f Text)
-> GetInstancePortStates -> f GetInstancePortStates
getInstancePortStates_instanceName = (GetInstancePortStates -> Text)
-> (GetInstancePortStates -> Text -> GetInstancePortStates)
-> Lens GetInstancePortStates GetInstancePortStates Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancePortStates' {Text
instanceName :: Text
$sel:instanceName:GetInstancePortStates' :: GetInstancePortStates -> Text
instanceName} -> Text
instanceName) (\s :: GetInstancePortStates
s@GetInstancePortStates' {} Text
a -> GetInstancePortStates
s {$sel:instanceName:GetInstancePortStates' :: Text
instanceName = Text
a} :: GetInstancePortStates)
instance Core.AWSRequest GetInstancePortStates where
type
AWSResponse GetInstancePortStates =
GetInstancePortStatesResponse
request :: GetInstancePortStates -> Request GetInstancePortStates
request = Service -> GetInstancePortStates -> Request GetInstancePortStates
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetInstancePortStates
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetInstancePortStates)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetInstancePortStates))
-> Logger
-> Service
-> Proxy GetInstancePortStates
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetInstancePortStates)))
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 [InstancePortState] -> Int -> GetInstancePortStatesResponse
GetInstancePortStatesResponse'
(Maybe [InstancePortState] -> Int -> GetInstancePortStatesResponse)
-> Either String (Maybe [InstancePortState])
-> Either String (Int -> GetInstancePortStatesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [InstancePortState]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"portStates" Either String (Maybe (Maybe [InstancePortState]))
-> Maybe [InstancePortState]
-> Either String (Maybe [InstancePortState])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [InstancePortState]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetInstancePortStatesResponse)
-> Either String Int -> Either String GetInstancePortStatesResponse
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 GetInstancePortStates
instance Prelude.NFData GetInstancePortStates
instance Core.ToHeaders GetInstancePortStates where
toHeaders :: GetInstancePortStates -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetInstancePortStates -> 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.GetInstancePortStates" ::
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 GetInstancePortStates where
toJSON :: GetInstancePortStates -> Value
toJSON GetInstancePortStates' {Text
instanceName :: Text
$sel:instanceName:GetInstancePortStates' :: GetInstancePortStates -> 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
"instanceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceName)]
)
instance Core.ToPath GetInstancePortStates where
toPath :: GetInstancePortStates -> ByteString
toPath = ByteString -> GetInstancePortStates -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetInstancePortStates where
toQuery :: GetInstancePortStates -> QueryString
toQuery = QueryString -> GetInstancePortStates -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetInstancePortStatesResponse = GetInstancePortStatesResponse'
{
GetInstancePortStatesResponse -> Maybe [InstancePortState]
portStates :: Prelude.Maybe [InstancePortState],
GetInstancePortStatesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool
(GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool)
-> (GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool)
-> Eq GetInstancePortStatesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool
$c/= :: GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool
== :: GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool
$c== :: GetInstancePortStatesResponse
-> GetInstancePortStatesResponse -> Bool
Prelude.Eq, ReadPrec [GetInstancePortStatesResponse]
ReadPrec GetInstancePortStatesResponse
Int -> ReadS GetInstancePortStatesResponse
ReadS [GetInstancePortStatesResponse]
(Int -> ReadS GetInstancePortStatesResponse)
-> ReadS [GetInstancePortStatesResponse]
-> ReadPrec GetInstancePortStatesResponse
-> ReadPrec [GetInstancePortStatesResponse]
-> Read GetInstancePortStatesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstancePortStatesResponse]
$creadListPrec :: ReadPrec [GetInstancePortStatesResponse]
readPrec :: ReadPrec GetInstancePortStatesResponse
$creadPrec :: ReadPrec GetInstancePortStatesResponse
readList :: ReadS [GetInstancePortStatesResponse]
$creadList :: ReadS [GetInstancePortStatesResponse]
readsPrec :: Int -> ReadS GetInstancePortStatesResponse
$creadsPrec :: Int -> ReadS GetInstancePortStatesResponse
Prelude.Read, Int -> GetInstancePortStatesResponse -> ShowS
[GetInstancePortStatesResponse] -> ShowS
GetInstancePortStatesResponse -> String
(Int -> GetInstancePortStatesResponse -> ShowS)
-> (GetInstancePortStatesResponse -> String)
-> ([GetInstancePortStatesResponse] -> ShowS)
-> Show GetInstancePortStatesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstancePortStatesResponse] -> ShowS
$cshowList :: [GetInstancePortStatesResponse] -> ShowS
show :: GetInstancePortStatesResponse -> String
$cshow :: GetInstancePortStatesResponse -> String
showsPrec :: Int -> GetInstancePortStatesResponse -> ShowS
$cshowsPrec :: Int -> GetInstancePortStatesResponse -> ShowS
Prelude.Show, (forall x.
GetInstancePortStatesResponse
-> Rep GetInstancePortStatesResponse x)
-> (forall x.
Rep GetInstancePortStatesResponse x
-> GetInstancePortStatesResponse)
-> Generic GetInstancePortStatesResponse
forall x.
Rep GetInstancePortStatesResponse x
-> GetInstancePortStatesResponse
forall x.
GetInstancePortStatesResponse
-> Rep GetInstancePortStatesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetInstancePortStatesResponse x
-> GetInstancePortStatesResponse
$cfrom :: forall x.
GetInstancePortStatesResponse
-> Rep GetInstancePortStatesResponse x
Prelude.Generic)
newGetInstancePortStatesResponse ::
Prelude.Int ->
GetInstancePortStatesResponse
newGetInstancePortStatesResponse :: Int -> GetInstancePortStatesResponse
newGetInstancePortStatesResponse Int
pHttpStatus_ =
GetInstancePortStatesResponse' :: Maybe [InstancePortState] -> Int -> GetInstancePortStatesResponse
GetInstancePortStatesResponse'
{ $sel:portStates:GetInstancePortStatesResponse' :: Maybe [InstancePortState]
portStates =
Maybe [InstancePortState]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetInstancePortStatesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getInstancePortStatesResponse_portStates :: Lens.Lens' GetInstancePortStatesResponse (Prelude.Maybe [InstancePortState])
getInstancePortStatesResponse_portStates :: (Maybe [InstancePortState] -> f (Maybe [InstancePortState]))
-> GetInstancePortStatesResponse -> f GetInstancePortStatesResponse
getInstancePortStatesResponse_portStates = (GetInstancePortStatesResponse -> Maybe [InstancePortState])
-> (GetInstancePortStatesResponse
-> Maybe [InstancePortState] -> GetInstancePortStatesResponse)
-> Lens
GetInstancePortStatesResponse
GetInstancePortStatesResponse
(Maybe [InstancePortState])
(Maybe [InstancePortState])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancePortStatesResponse' {Maybe [InstancePortState]
portStates :: Maybe [InstancePortState]
$sel:portStates:GetInstancePortStatesResponse' :: GetInstancePortStatesResponse -> Maybe [InstancePortState]
portStates} -> Maybe [InstancePortState]
portStates) (\s :: GetInstancePortStatesResponse
s@GetInstancePortStatesResponse' {} Maybe [InstancePortState]
a -> GetInstancePortStatesResponse
s {$sel:portStates:GetInstancePortStatesResponse' :: Maybe [InstancePortState]
portStates = Maybe [InstancePortState]
a} :: GetInstancePortStatesResponse) ((Maybe [InstancePortState] -> f (Maybe [InstancePortState]))
-> GetInstancePortStatesResponse
-> f GetInstancePortStatesResponse)
-> ((Maybe [InstancePortState] -> f (Maybe [InstancePortState]))
-> Maybe [InstancePortState] -> f (Maybe [InstancePortState]))
-> (Maybe [InstancePortState] -> f (Maybe [InstancePortState]))
-> GetInstancePortStatesResponse
-> f GetInstancePortStatesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[InstancePortState]
[InstancePortState]
[InstancePortState]
[InstancePortState]
-> Iso
(Maybe [InstancePortState])
(Maybe [InstancePortState])
(Maybe [InstancePortState])
(Maybe [InstancePortState])
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
[InstancePortState]
[InstancePortState]
[InstancePortState]
[InstancePortState]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getInstancePortStatesResponse_httpStatus :: Lens.Lens' GetInstancePortStatesResponse Prelude.Int
getInstancePortStatesResponse_httpStatus :: (Int -> f Int)
-> GetInstancePortStatesResponse -> f GetInstancePortStatesResponse
getInstancePortStatesResponse_httpStatus = (GetInstancePortStatesResponse -> Int)
-> (GetInstancePortStatesResponse
-> Int -> GetInstancePortStatesResponse)
-> Lens
GetInstancePortStatesResponse GetInstancePortStatesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancePortStatesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetInstancePortStatesResponse' :: GetInstancePortStatesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetInstancePortStatesResponse
s@GetInstancePortStatesResponse' {} Int
a -> GetInstancePortStatesResponse
s {$sel:httpStatus:GetInstancePortStatesResponse' :: Int
httpStatus = Int
a} :: GetInstancePortStatesResponse)
instance Prelude.NFData GetInstancePortStatesResponse