{-# 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.GetDistributions
(
GetDistributions (..),
newGetDistributions,
getDistributions_distributionName,
getDistributions_pageToken,
GetDistributionsResponse (..),
newGetDistributionsResponse,
getDistributionsResponse_nextPageToken,
getDistributionsResponse_distributions,
getDistributionsResponse_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 GetDistributions = GetDistributions'
{
GetDistributions -> Maybe Text
distributionName :: Prelude.Maybe Prelude.Text,
GetDistributions -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text
}
deriving (GetDistributions -> GetDistributions -> Bool
(GetDistributions -> GetDistributions -> Bool)
-> (GetDistributions -> GetDistributions -> Bool)
-> Eq GetDistributions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDistributions -> GetDistributions -> Bool
$c/= :: GetDistributions -> GetDistributions -> Bool
== :: GetDistributions -> GetDistributions -> Bool
$c== :: GetDistributions -> GetDistributions -> Bool
Prelude.Eq, ReadPrec [GetDistributions]
ReadPrec GetDistributions
Int -> ReadS GetDistributions
ReadS [GetDistributions]
(Int -> ReadS GetDistributions)
-> ReadS [GetDistributions]
-> ReadPrec GetDistributions
-> ReadPrec [GetDistributions]
-> Read GetDistributions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDistributions]
$creadListPrec :: ReadPrec [GetDistributions]
readPrec :: ReadPrec GetDistributions
$creadPrec :: ReadPrec GetDistributions
readList :: ReadS [GetDistributions]
$creadList :: ReadS [GetDistributions]
readsPrec :: Int -> ReadS GetDistributions
$creadsPrec :: Int -> ReadS GetDistributions
Prelude.Read, Int -> GetDistributions -> ShowS
[GetDistributions] -> ShowS
GetDistributions -> String
(Int -> GetDistributions -> ShowS)
-> (GetDistributions -> String)
-> ([GetDistributions] -> ShowS)
-> Show GetDistributions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDistributions] -> ShowS
$cshowList :: [GetDistributions] -> ShowS
show :: GetDistributions -> String
$cshow :: GetDistributions -> String
showsPrec :: Int -> GetDistributions -> ShowS
$cshowsPrec :: Int -> GetDistributions -> ShowS
Prelude.Show, (forall x. GetDistributions -> Rep GetDistributions x)
-> (forall x. Rep GetDistributions x -> GetDistributions)
-> Generic GetDistributions
forall x. Rep GetDistributions x -> GetDistributions
forall x. GetDistributions -> Rep GetDistributions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDistributions x -> GetDistributions
$cfrom :: forall x. GetDistributions -> Rep GetDistributions x
Prelude.Generic)
newGetDistributions ::
GetDistributions
newGetDistributions :: GetDistributions
newGetDistributions =
GetDistributions' :: Maybe Text -> Maybe Text -> GetDistributions
GetDistributions'
{ $sel:distributionName:GetDistributions' :: Maybe Text
distributionName =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:pageToken:GetDistributions' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
getDistributions_distributionName :: Lens.Lens' GetDistributions (Prelude.Maybe Prelude.Text)
getDistributions_distributionName :: (Maybe Text -> f (Maybe Text))
-> GetDistributions -> f GetDistributions
getDistributions_distributionName = (GetDistributions -> Maybe Text)
-> (GetDistributions -> Maybe Text -> GetDistributions)
-> Lens GetDistributions GetDistributions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributions' {Maybe Text
distributionName :: Maybe Text
$sel:distributionName:GetDistributions' :: GetDistributions -> Maybe Text
distributionName} -> Maybe Text
distributionName) (\s :: GetDistributions
s@GetDistributions' {} Maybe Text
a -> GetDistributions
s {$sel:distributionName:GetDistributions' :: Maybe Text
distributionName = Maybe Text
a} :: GetDistributions)
getDistributions_pageToken :: Lens.Lens' GetDistributions (Prelude.Maybe Prelude.Text)
getDistributions_pageToken :: (Maybe Text -> f (Maybe Text))
-> GetDistributions -> f GetDistributions
getDistributions_pageToken = (GetDistributions -> Maybe Text)
-> (GetDistributions -> Maybe Text -> GetDistributions)
-> Lens GetDistributions GetDistributions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributions' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetDistributions' :: GetDistributions -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: GetDistributions
s@GetDistributions' {} Maybe Text
a -> GetDistributions
s {$sel:pageToken:GetDistributions' :: Maybe Text
pageToken = Maybe Text
a} :: GetDistributions)
instance Core.AWSRequest GetDistributions where
type
AWSResponse GetDistributions =
GetDistributionsResponse
request :: GetDistributions -> Request GetDistributions
request = Service -> GetDistributions -> Request GetDistributions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetDistributions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDistributions)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetDistributions))
-> Logger
-> Service
-> Proxy GetDistributions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDistributions)))
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
-> Maybe [LightsailDistribution] -> Int -> GetDistributionsResponse
GetDistributionsResponse'
(Maybe Text
-> Maybe [LightsailDistribution]
-> Int
-> GetDistributionsResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe [LightsailDistribution] -> Int -> GetDistributionsResponse)
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
"nextPageToken")
Either
String
(Maybe [LightsailDistribution] -> Int -> GetDistributionsResponse)
-> Either String (Maybe [LightsailDistribution])
-> Either String (Int -> GetDistributionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [LightsailDistribution]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"distributions" Either String (Maybe (Maybe [LightsailDistribution]))
-> Maybe [LightsailDistribution]
-> Either String (Maybe [LightsailDistribution])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [LightsailDistribution]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetDistributionsResponse)
-> Either String Int -> Either String GetDistributionsResponse
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 GetDistributions
instance Prelude.NFData GetDistributions
instance Core.ToHeaders GetDistributions where
toHeaders :: GetDistributions -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetDistributions -> 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.GetDistributions" ::
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 GetDistributions where
toJSON :: GetDistributions -> Value
toJSON GetDistributions' {Maybe Text
pageToken :: Maybe Text
distributionName :: Maybe Text
$sel:pageToken:GetDistributions' :: GetDistributions -> Maybe Text
$sel:distributionName:GetDistributions' :: GetDistributions -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"distributionName" 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
distributionName,
(Text
"pageToken" 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
pageToken
]
)
instance Core.ToPath GetDistributions where
toPath :: GetDistributions -> ByteString
toPath = ByteString -> GetDistributions -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetDistributions where
toQuery :: GetDistributions -> QueryString
toQuery = QueryString -> GetDistributions -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetDistributionsResponse = GetDistributionsResponse'
{
GetDistributionsResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
GetDistributionsResponse -> Maybe [LightsailDistribution]
distributions :: Prelude.Maybe [LightsailDistribution],
GetDistributionsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetDistributionsResponse -> GetDistributionsResponse -> Bool
(GetDistributionsResponse -> GetDistributionsResponse -> Bool)
-> (GetDistributionsResponse -> GetDistributionsResponse -> Bool)
-> Eq GetDistributionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDistributionsResponse -> GetDistributionsResponse -> Bool
$c/= :: GetDistributionsResponse -> GetDistributionsResponse -> Bool
== :: GetDistributionsResponse -> GetDistributionsResponse -> Bool
$c== :: GetDistributionsResponse -> GetDistributionsResponse -> Bool
Prelude.Eq, ReadPrec [GetDistributionsResponse]
ReadPrec GetDistributionsResponse
Int -> ReadS GetDistributionsResponse
ReadS [GetDistributionsResponse]
(Int -> ReadS GetDistributionsResponse)
-> ReadS [GetDistributionsResponse]
-> ReadPrec GetDistributionsResponse
-> ReadPrec [GetDistributionsResponse]
-> Read GetDistributionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDistributionsResponse]
$creadListPrec :: ReadPrec [GetDistributionsResponse]
readPrec :: ReadPrec GetDistributionsResponse
$creadPrec :: ReadPrec GetDistributionsResponse
readList :: ReadS [GetDistributionsResponse]
$creadList :: ReadS [GetDistributionsResponse]
readsPrec :: Int -> ReadS GetDistributionsResponse
$creadsPrec :: Int -> ReadS GetDistributionsResponse
Prelude.Read, Int -> GetDistributionsResponse -> ShowS
[GetDistributionsResponse] -> ShowS
GetDistributionsResponse -> String
(Int -> GetDistributionsResponse -> ShowS)
-> (GetDistributionsResponse -> String)
-> ([GetDistributionsResponse] -> ShowS)
-> Show GetDistributionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDistributionsResponse] -> ShowS
$cshowList :: [GetDistributionsResponse] -> ShowS
show :: GetDistributionsResponse -> String
$cshow :: GetDistributionsResponse -> String
showsPrec :: Int -> GetDistributionsResponse -> ShowS
$cshowsPrec :: Int -> GetDistributionsResponse -> ShowS
Prelude.Show, (forall x.
GetDistributionsResponse -> Rep GetDistributionsResponse x)
-> (forall x.
Rep GetDistributionsResponse x -> GetDistributionsResponse)
-> Generic GetDistributionsResponse
forall x.
Rep GetDistributionsResponse x -> GetDistributionsResponse
forall x.
GetDistributionsResponse -> Rep GetDistributionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDistributionsResponse x -> GetDistributionsResponse
$cfrom :: forall x.
GetDistributionsResponse -> Rep GetDistributionsResponse x
Prelude.Generic)
newGetDistributionsResponse ::
Prelude.Int ->
GetDistributionsResponse
newGetDistributionsResponse :: Int -> GetDistributionsResponse
newGetDistributionsResponse Int
pHttpStatus_ =
GetDistributionsResponse' :: Maybe Text
-> Maybe [LightsailDistribution] -> Int -> GetDistributionsResponse
GetDistributionsResponse'
{ $sel:nextPageToken:GetDistributionsResponse' :: Maybe Text
nextPageToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:distributions:GetDistributionsResponse' :: Maybe [LightsailDistribution]
distributions = Maybe [LightsailDistribution]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetDistributionsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getDistributionsResponse_nextPageToken :: Lens.Lens' GetDistributionsResponse (Prelude.Maybe Prelude.Text)
getDistributionsResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> GetDistributionsResponse -> f GetDistributionsResponse
getDistributionsResponse_nextPageToken = (GetDistributionsResponse -> Maybe Text)
-> (GetDistributionsResponse
-> Maybe Text -> GetDistributionsResponse)
-> Lens
GetDistributionsResponse
GetDistributionsResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionsResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetDistributionsResponse' :: GetDistributionsResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetDistributionsResponse
s@GetDistributionsResponse' {} Maybe Text
a -> GetDistributionsResponse
s {$sel:nextPageToken:GetDistributionsResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetDistributionsResponse)
getDistributionsResponse_distributions :: Lens.Lens' GetDistributionsResponse (Prelude.Maybe [LightsailDistribution])
getDistributionsResponse_distributions :: (Maybe [LightsailDistribution]
-> f (Maybe [LightsailDistribution]))
-> GetDistributionsResponse -> f GetDistributionsResponse
getDistributionsResponse_distributions = (GetDistributionsResponse -> Maybe [LightsailDistribution])
-> (GetDistributionsResponse
-> Maybe [LightsailDistribution] -> GetDistributionsResponse)
-> Lens
GetDistributionsResponse
GetDistributionsResponse
(Maybe [LightsailDistribution])
(Maybe [LightsailDistribution])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionsResponse' {Maybe [LightsailDistribution]
distributions :: Maybe [LightsailDistribution]
$sel:distributions:GetDistributionsResponse' :: GetDistributionsResponse -> Maybe [LightsailDistribution]
distributions} -> Maybe [LightsailDistribution]
distributions) (\s :: GetDistributionsResponse
s@GetDistributionsResponse' {} Maybe [LightsailDistribution]
a -> GetDistributionsResponse
s {$sel:distributions:GetDistributionsResponse' :: Maybe [LightsailDistribution]
distributions = Maybe [LightsailDistribution]
a} :: GetDistributionsResponse) ((Maybe [LightsailDistribution]
-> f (Maybe [LightsailDistribution]))
-> GetDistributionsResponse -> f GetDistributionsResponse)
-> ((Maybe [LightsailDistribution]
-> f (Maybe [LightsailDistribution]))
-> Maybe [LightsailDistribution]
-> f (Maybe [LightsailDistribution]))
-> (Maybe [LightsailDistribution]
-> f (Maybe [LightsailDistribution]))
-> GetDistributionsResponse
-> f GetDistributionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[LightsailDistribution]
[LightsailDistribution]
[LightsailDistribution]
[LightsailDistribution]
-> Iso
(Maybe [LightsailDistribution])
(Maybe [LightsailDistribution])
(Maybe [LightsailDistribution])
(Maybe [LightsailDistribution])
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
[LightsailDistribution]
[LightsailDistribution]
[LightsailDistribution]
[LightsailDistribution]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getDistributionsResponse_httpStatus :: Lens.Lens' GetDistributionsResponse Prelude.Int
getDistributionsResponse_httpStatus :: (Int -> f Int)
-> GetDistributionsResponse -> f GetDistributionsResponse
getDistributionsResponse_httpStatus = (GetDistributionsResponse -> Int)
-> (GetDistributionsResponse -> Int -> GetDistributionsResponse)
-> Lens GetDistributionsResponse GetDistributionsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDistributionsResponse' :: GetDistributionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDistributionsResponse
s@GetDistributionsResponse' {} Int
a -> GetDistributionsResponse
s {$sel:httpStatus:GetDistributionsResponse' :: Int
httpStatus = Int
a} :: GetDistributionsResponse)
instance Prelude.NFData GetDistributionsResponse