{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:instanceName:GetInstancePortStates' :: Text
instanceName =
Text
pInstanceName_
}
getInstancePortStates_instanceName :: Lens.Lens' GetInstancePortStates Prelude.Text
getInstancePortStates_instanceName :: Lens' GetInstancePortStates Text
getInstancePortStates_instanceName = 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 :: (Service -> Service)
-> GetInstancePortStates -> Request GetInstancePortStates
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetInstancePortStates
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetInstancePortStates)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe [InstancePortState] -> Int -> GetInstancePortStatesResponse
GetInstancePortStatesResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"portStates" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable GetInstancePortStates where
hashWithSalt :: Int -> GetInstancePortStates -> Int
hashWithSalt Int
_salt GetInstancePortStates' {Text
instanceName :: Text
$sel:instanceName:GetInstancePortStates' :: GetInstancePortStates -> Text
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceName
instance Prelude.NFData GetInstancePortStates where
rnf :: GetInstancePortStates -> ()
rnf GetInstancePortStates' {Text
instanceName :: Text
$sel:instanceName:GetInstancePortStates' :: GetInstancePortStates -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
instanceName
instance Data.ToHeaders GetInstancePortStates where
toHeaders :: GetInstancePortStates -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.GetInstancePortStates" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON GetInstancePortStates where
toJSON :: GetInstancePortStates -> Value
toJSON GetInstancePortStates' {Text
instanceName :: Text
$sel:instanceName:GetInstancePortStates' :: GetInstancePortStates -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"instanceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceName)]
)
instance Data.ToPath GetInstancePortStates where
toPath :: GetInstancePortStates -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetInstancePortStates where
toQuery :: GetInstancePortStates -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
{ $sel:portStates:GetInstancePortStatesResponse' :: Maybe [InstancePortState]
portStates =
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetInstancePortStatesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getInstancePortStatesResponse_portStates :: Lens.Lens' GetInstancePortStatesResponse (Prelude.Maybe [InstancePortState])
getInstancePortStatesResponse_portStates :: Lens' GetInstancePortStatesResponse (Maybe [InstancePortState])
getInstancePortStatesResponse_portStates = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' GetInstancePortStatesResponse Int
getInstancePortStatesResponse_httpStatus = 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 where
rnf :: GetInstancePortStatesResponse -> ()
rnf GetInstancePortStatesResponse' {Int
Maybe [InstancePortState]
httpStatus :: Int
portStates :: Maybe [InstancePortState]
$sel:httpStatus:GetInstancePortStatesResponse' :: GetInstancePortStatesResponse -> Int
$sel:portStates:GetInstancePortStatesResponse' :: GetInstancePortStatesResponse -> Maybe [InstancePortState]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [InstancePortState]
portStates
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus