{-# 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.Location.ListGeofences
(
ListGeofences (..),
newListGeofences,
listGeofences_nextToken,
listGeofences_collectionName,
ListGeofencesResponse (..),
newListGeofencesResponse,
listGeofencesResponse_nextToken,
listGeofencesResponse_httpStatus,
listGeofencesResponse_entries,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListGeofences = ListGeofences'
{
ListGeofences -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListGeofences -> Text
collectionName :: Prelude.Text
}
deriving (ListGeofences -> ListGeofences -> Bool
(ListGeofences -> ListGeofences -> Bool)
-> (ListGeofences -> ListGeofences -> Bool) -> Eq ListGeofences
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGeofences -> ListGeofences -> Bool
$c/= :: ListGeofences -> ListGeofences -> Bool
== :: ListGeofences -> ListGeofences -> Bool
$c== :: ListGeofences -> ListGeofences -> Bool
Prelude.Eq, ReadPrec [ListGeofences]
ReadPrec ListGeofences
Int -> ReadS ListGeofences
ReadS [ListGeofences]
(Int -> ReadS ListGeofences)
-> ReadS [ListGeofences]
-> ReadPrec ListGeofences
-> ReadPrec [ListGeofences]
-> Read ListGeofences
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGeofences]
$creadListPrec :: ReadPrec [ListGeofences]
readPrec :: ReadPrec ListGeofences
$creadPrec :: ReadPrec ListGeofences
readList :: ReadS [ListGeofences]
$creadList :: ReadS [ListGeofences]
readsPrec :: Int -> ReadS ListGeofences
$creadsPrec :: Int -> ReadS ListGeofences
Prelude.Read, Int -> ListGeofences -> ShowS
[ListGeofences] -> ShowS
ListGeofences -> String
(Int -> ListGeofences -> ShowS)
-> (ListGeofences -> String)
-> ([ListGeofences] -> ShowS)
-> Show ListGeofences
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGeofences] -> ShowS
$cshowList :: [ListGeofences] -> ShowS
show :: ListGeofences -> String
$cshow :: ListGeofences -> String
showsPrec :: Int -> ListGeofences -> ShowS
$cshowsPrec :: Int -> ListGeofences -> ShowS
Prelude.Show, (forall x. ListGeofences -> Rep ListGeofences x)
-> (forall x. Rep ListGeofences x -> ListGeofences)
-> Generic ListGeofences
forall x. Rep ListGeofences x -> ListGeofences
forall x. ListGeofences -> Rep ListGeofences x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGeofences x -> ListGeofences
$cfrom :: forall x. ListGeofences -> Rep ListGeofences x
Prelude.Generic)
newListGeofences ::
Prelude.Text ->
ListGeofences
newListGeofences :: Text -> ListGeofences
newListGeofences Text
pCollectionName_ =
ListGeofences' :: Maybe Text -> Text -> ListGeofences
ListGeofences'
{ $sel:nextToken:ListGeofences' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:collectionName:ListGeofences' :: Text
collectionName = Text
pCollectionName_
}
listGeofences_nextToken :: Lens.Lens' ListGeofences (Prelude.Maybe Prelude.Text)
listGeofences_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListGeofences -> f ListGeofences
listGeofences_nextToken = (ListGeofences -> Maybe Text)
-> (ListGeofences -> Maybe Text -> ListGeofences)
-> Lens ListGeofences ListGeofences (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGeofences' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGeofences' :: ListGeofences -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGeofences
s@ListGeofences' {} Maybe Text
a -> ListGeofences
s {$sel:nextToken:ListGeofences' :: Maybe Text
nextToken = Maybe Text
a} :: ListGeofences)
listGeofences_collectionName :: Lens.Lens' ListGeofences Prelude.Text
listGeofences_collectionName :: (Text -> f Text) -> ListGeofences -> f ListGeofences
listGeofences_collectionName = (ListGeofences -> Text)
-> (ListGeofences -> Text -> ListGeofences)
-> Lens ListGeofences ListGeofences Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGeofences' {Text
collectionName :: Text
$sel:collectionName:ListGeofences' :: ListGeofences -> Text
collectionName} -> Text
collectionName) (\s :: ListGeofences
s@ListGeofences' {} Text
a -> ListGeofences
s {$sel:collectionName:ListGeofences' :: Text
collectionName = Text
a} :: ListGeofences)
instance Core.AWSPager ListGeofences where
page :: ListGeofences -> AWSResponse ListGeofences -> Maybe ListGeofences
page ListGeofences
rq AWSResponse ListGeofences
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListGeofences
ListGeofencesResponse
rs
ListGeofencesResponse
-> Getting (First Text) ListGeofencesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGeofencesResponse
-> Const (First Text) ListGeofencesResponse
Lens' ListGeofencesResponse (Maybe Text)
listGeofencesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListGeofencesResponse
-> Const (First Text) ListGeofencesResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGeofencesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListGeofences
forall a. Maybe a
Prelude.Nothing
| [ListGeofenceResponseEntry] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
(AWSResponse ListGeofences
ListGeofencesResponse
rs ListGeofencesResponse
-> Getting
[ListGeofenceResponseEntry]
ListGeofencesResponse
[ListGeofenceResponseEntry]
-> [ListGeofenceResponseEntry]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
[ListGeofenceResponseEntry]
ListGeofencesResponse
[ListGeofenceResponseEntry]
Lens' ListGeofencesResponse [ListGeofenceResponseEntry]
listGeofencesResponse_entries) =
Maybe ListGeofences
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListGeofences -> Maybe ListGeofences
forall a. a -> Maybe a
Prelude.Just (ListGeofences -> Maybe ListGeofences)
-> ListGeofences -> Maybe ListGeofences
forall a b. (a -> b) -> a -> b
Prelude.$
ListGeofences
rq
ListGeofences -> (ListGeofences -> ListGeofences) -> ListGeofences
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListGeofences -> Identity ListGeofences
Lens ListGeofences ListGeofences (Maybe Text) (Maybe Text)
listGeofences_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListGeofences -> Identity ListGeofences)
-> Maybe Text -> ListGeofences -> ListGeofences
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListGeofences
ListGeofencesResponse
rs
ListGeofencesResponse
-> Getting (First Text) ListGeofencesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGeofencesResponse
-> Const (First Text) ListGeofencesResponse
Lens' ListGeofencesResponse (Maybe Text)
listGeofencesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListGeofencesResponse
-> Const (First Text) ListGeofencesResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGeofencesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListGeofences where
type
AWSResponse ListGeofences =
ListGeofencesResponse
request :: ListGeofences -> Request ListGeofences
request = Service -> ListGeofences -> Request ListGeofences
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListGeofences
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGeofences)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListGeofences))
-> Logger
-> Service
-> Proxy ListGeofences
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGeofences)))
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
-> Int -> [ListGeofenceResponseEntry] -> ListGeofencesResponse
ListGeofencesResponse'
(Maybe Text
-> Int -> [ListGeofenceResponseEntry] -> ListGeofencesResponse)
-> Either String (Maybe Text)
-> Either
String
(Int -> [ListGeofenceResponseEntry] -> ListGeofencesResponse)
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
"NextToken")
Either
String
(Int -> [ListGeofenceResponseEntry] -> ListGeofencesResponse)
-> Either String Int
-> Either
String ([ListGeofenceResponseEntry] -> ListGeofencesResponse)
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))
Either
String ([ListGeofenceResponseEntry] -> ListGeofencesResponse)
-> Either String [ListGeofenceResponseEntry]
-> Either String ListGeofencesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [ListGeofenceResponseEntry])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Entries" Either String (Maybe [ListGeofenceResponseEntry])
-> [ListGeofenceResponseEntry]
-> Either String [ListGeofenceResponseEntry]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ListGeofenceResponseEntry]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable ListGeofences
instance Prelude.NFData ListGeofences
instance Core.ToHeaders ListGeofences where
toHeaders :: ListGeofences -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListGeofences -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 ListGeofences where
toJSON :: ListGeofences -> Value
toJSON ListGeofences' {Maybe Text
Text
collectionName :: Text
nextToken :: Maybe Text
$sel:collectionName:ListGeofences' :: ListGeofences -> Text
$sel:nextToken:ListGeofences' :: ListGeofences -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"NextToken" 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
nextToken]
)
instance Core.ToPath ListGeofences where
toPath :: ListGeofences -> ByteString
toPath ListGeofences' {Maybe Text
Text
collectionName :: Text
nextToken :: Maybe Text
$sel:collectionName:ListGeofences' :: ListGeofences -> Text
$sel:nextToken:ListGeofences' :: ListGeofences -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/geofencing/v0/collections/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
collectionName,
ByteString
"/list-geofences"
]
instance Core.ToQuery ListGeofences where
toQuery :: ListGeofences -> QueryString
toQuery = QueryString -> ListGeofences -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListGeofencesResponse = ListGeofencesResponse'
{
ListGeofencesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListGeofencesResponse -> Int
httpStatus :: Prelude.Int,
ListGeofencesResponse -> [ListGeofenceResponseEntry]
entries :: [ListGeofenceResponseEntry]
}
deriving (ListGeofencesResponse -> ListGeofencesResponse -> Bool
(ListGeofencesResponse -> ListGeofencesResponse -> Bool)
-> (ListGeofencesResponse -> ListGeofencesResponse -> Bool)
-> Eq ListGeofencesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGeofencesResponse -> ListGeofencesResponse -> Bool
$c/= :: ListGeofencesResponse -> ListGeofencesResponse -> Bool
== :: ListGeofencesResponse -> ListGeofencesResponse -> Bool
$c== :: ListGeofencesResponse -> ListGeofencesResponse -> Bool
Prelude.Eq, Int -> ListGeofencesResponse -> ShowS
[ListGeofencesResponse] -> ShowS
ListGeofencesResponse -> String
(Int -> ListGeofencesResponse -> ShowS)
-> (ListGeofencesResponse -> String)
-> ([ListGeofencesResponse] -> ShowS)
-> Show ListGeofencesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGeofencesResponse] -> ShowS
$cshowList :: [ListGeofencesResponse] -> ShowS
show :: ListGeofencesResponse -> String
$cshow :: ListGeofencesResponse -> String
showsPrec :: Int -> ListGeofencesResponse -> ShowS
$cshowsPrec :: Int -> ListGeofencesResponse -> ShowS
Prelude.Show, (forall x. ListGeofencesResponse -> Rep ListGeofencesResponse x)
-> (forall x. Rep ListGeofencesResponse x -> ListGeofencesResponse)
-> Generic ListGeofencesResponse
forall x. Rep ListGeofencesResponse x -> ListGeofencesResponse
forall x. ListGeofencesResponse -> Rep ListGeofencesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGeofencesResponse x -> ListGeofencesResponse
$cfrom :: forall x. ListGeofencesResponse -> Rep ListGeofencesResponse x
Prelude.Generic)
newListGeofencesResponse ::
Prelude.Int ->
ListGeofencesResponse
newListGeofencesResponse :: Int -> ListGeofencesResponse
newListGeofencesResponse Int
pHttpStatus_ =
ListGeofencesResponse' :: Maybe Text
-> Int -> [ListGeofenceResponseEntry] -> ListGeofencesResponse
ListGeofencesResponse'
{ $sel:nextToken:ListGeofencesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListGeofencesResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:entries:ListGeofencesResponse' :: [ListGeofenceResponseEntry]
entries = [ListGeofenceResponseEntry]
forall a. Monoid a => a
Prelude.mempty
}
listGeofencesResponse_nextToken :: Lens.Lens' ListGeofencesResponse (Prelude.Maybe Prelude.Text)
listGeofencesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListGeofencesResponse -> f ListGeofencesResponse
listGeofencesResponse_nextToken = (ListGeofencesResponse -> Maybe Text)
-> (ListGeofencesResponse -> Maybe Text -> ListGeofencesResponse)
-> Lens' ListGeofencesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGeofencesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGeofencesResponse' :: ListGeofencesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGeofencesResponse
s@ListGeofencesResponse' {} Maybe Text
a -> ListGeofencesResponse
s {$sel:nextToken:ListGeofencesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListGeofencesResponse)
listGeofencesResponse_httpStatus :: Lens.Lens' ListGeofencesResponse Prelude.Int
listGeofencesResponse_httpStatus :: (Int -> f Int) -> ListGeofencesResponse -> f ListGeofencesResponse
listGeofencesResponse_httpStatus = (ListGeofencesResponse -> Int)
-> (ListGeofencesResponse -> Int -> ListGeofencesResponse)
-> Lens ListGeofencesResponse ListGeofencesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGeofencesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListGeofencesResponse' :: ListGeofencesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListGeofencesResponse
s@ListGeofencesResponse' {} Int
a -> ListGeofencesResponse
s {$sel:httpStatus:ListGeofencesResponse' :: Int
httpStatus = Int
a} :: ListGeofencesResponse)
listGeofencesResponse_entries :: Lens.Lens' ListGeofencesResponse [ListGeofenceResponseEntry]
listGeofencesResponse_entries :: ([ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> ListGeofencesResponse -> f ListGeofencesResponse
listGeofencesResponse_entries = (ListGeofencesResponse -> [ListGeofenceResponseEntry])
-> (ListGeofencesResponse
-> [ListGeofenceResponseEntry] -> ListGeofencesResponse)
-> Lens' ListGeofencesResponse [ListGeofenceResponseEntry]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGeofencesResponse' {[ListGeofenceResponseEntry]
entries :: [ListGeofenceResponseEntry]
$sel:entries:ListGeofencesResponse' :: ListGeofencesResponse -> [ListGeofenceResponseEntry]
entries} -> [ListGeofenceResponseEntry]
entries) (\s :: ListGeofencesResponse
s@ListGeofencesResponse' {} [ListGeofenceResponseEntry]
a -> ListGeofencesResponse
s {$sel:entries:ListGeofencesResponse' :: [ListGeofenceResponseEntry]
entries = [ListGeofenceResponseEntry]
a} :: ListGeofencesResponse) (([ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> ListGeofencesResponse -> f ListGeofencesResponse)
-> (([ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> [ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> ([ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> ListGeofencesResponse
-> f ListGeofencesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry])
-> [ListGeofenceResponseEntry] -> f [ListGeofenceResponseEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData ListGeofencesResponse