{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.GroundStation.ListGroundStations
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of ground stations.
--
-- This operation returns paginated results.
module Amazonka.GroundStation.ListGroundStations
  ( -- * Creating a Request
    ListGroundStations (..),
    newListGroundStations,

    -- * Request Lenses
    listGroundStations_maxResults,
    listGroundStations_nextToken,
    listGroundStations_satelliteId,

    -- * Destructuring the Response
    ListGroundStationsResponse (..),
    newListGroundStationsResponse,

    -- * Response Lenses
    listGroundStationsResponse_groundStationList,
    listGroundStationsResponse_nextToken,
    listGroundStationsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GroundStation.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newListGroundStations' smart constructor.
data ListGroundStations = ListGroundStations'
  { -- | Maximum number of ground stations returned.
    ListGroundStations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Next token that can be supplied in the next call to get the next page of
    -- ground stations.
    ListGroundStations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Satellite ID to retrieve on-boarded ground stations.
    ListGroundStations -> Maybe Text
satelliteId :: Prelude.Maybe Prelude.Text
  }
  deriving (ListGroundStations -> ListGroundStations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroundStations -> ListGroundStations -> Bool
$c/= :: ListGroundStations -> ListGroundStations -> Bool
== :: ListGroundStations -> ListGroundStations -> Bool
$c== :: ListGroundStations -> ListGroundStations -> Bool
Prelude.Eq, ReadPrec [ListGroundStations]
ReadPrec ListGroundStations
Int -> ReadS ListGroundStations
ReadS [ListGroundStations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroundStations]
$creadListPrec :: ReadPrec [ListGroundStations]
readPrec :: ReadPrec ListGroundStations
$creadPrec :: ReadPrec ListGroundStations
readList :: ReadS [ListGroundStations]
$creadList :: ReadS [ListGroundStations]
readsPrec :: Int -> ReadS ListGroundStations
$creadsPrec :: Int -> ReadS ListGroundStations
Prelude.Read, Int -> ListGroundStations -> ShowS
[ListGroundStations] -> ShowS
ListGroundStations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroundStations] -> ShowS
$cshowList :: [ListGroundStations] -> ShowS
show :: ListGroundStations -> String
$cshow :: ListGroundStations -> String
showsPrec :: Int -> ListGroundStations -> ShowS
$cshowsPrec :: Int -> ListGroundStations -> ShowS
Prelude.Show, forall x. Rep ListGroundStations x -> ListGroundStations
forall x. ListGroundStations -> Rep ListGroundStations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGroundStations x -> ListGroundStations
$cfrom :: forall x. ListGroundStations -> Rep ListGroundStations x
Prelude.Generic)

-- |
-- Create a value of 'ListGroundStations' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxResults', 'listGroundStations_maxResults' - Maximum number of ground stations returned.
--
-- 'nextToken', 'listGroundStations_nextToken' - Next token that can be supplied in the next call to get the next page of
-- ground stations.
--
-- 'satelliteId', 'listGroundStations_satelliteId' - Satellite ID to retrieve on-boarded ground stations.
newListGroundStations ::
  ListGroundStations
newListGroundStations :: ListGroundStations
newListGroundStations =
  ListGroundStations'
    { $sel:maxResults:ListGroundStations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroundStations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:satelliteId:ListGroundStations' :: Maybe Text
satelliteId = forall a. Maybe a
Prelude.Nothing
    }

-- | Maximum number of ground stations returned.
listGroundStations_maxResults :: Lens.Lens' ListGroundStations (Prelude.Maybe Prelude.Natural)
listGroundStations_maxResults :: Lens' ListGroundStations (Maybe Natural)
listGroundStations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListGroundStations' :: ListGroundStations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListGroundStations
s@ListGroundStations' {} Maybe Natural
a -> ListGroundStations
s {$sel:maxResults:ListGroundStations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListGroundStations)

-- | Next token that can be supplied in the next call to get the next page of
-- ground stations.
listGroundStations_nextToken :: Lens.Lens' ListGroundStations (Prelude.Maybe Prelude.Text)
listGroundStations_nextToken :: Lens' ListGroundStations (Maybe Text)
listGroundStations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroundStations' :: ListGroundStations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroundStations
s@ListGroundStations' {} Maybe Text
a -> ListGroundStations
s {$sel:nextToken:ListGroundStations' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroundStations)

-- | Satellite ID to retrieve on-boarded ground stations.
listGroundStations_satelliteId :: Lens.Lens' ListGroundStations (Prelude.Maybe Prelude.Text)
listGroundStations_satelliteId :: Lens' ListGroundStations (Maybe Text)
listGroundStations_satelliteId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStations' {Maybe Text
satelliteId :: Maybe Text
$sel:satelliteId:ListGroundStations' :: ListGroundStations -> Maybe Text
satelliteId} -> Maybe Text
satelliteId) (\s :: ListGroundStations
s@ListGroundStations' {} Maybe Text
a -> ListGroundStations
s {$sel:satelliteId:ListGroundStations' :: Maybe Text
satelliteId = Maybe Text
a} :: ListGroundStations)

instance Core.AWSPager ListGroundStations where
  page :: ListGroundStations
-> AWSResponse ListGroundStations -> Maybe ListGroundStations
page ListGroundStations
rq AWSResponse ListGroundStations
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGroundStations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGroundStationsResponse (Maybe Text)
listGroundStationsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGroundStations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGroundStationsResponse (Maybe [GroundStationData])
listGroundStationsResponse_groundStationList
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListGroundStations
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListGroundStations (Maybe Text)
listGroundStations_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListGroundStations
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGroundStationsResponse (Maybe Text)
listGroundStationsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListGroundStations where
  type
    AWSResponse ListGroundStations =
      ListGroundStationsResponse
  request :: (Service -> Service)
-> ListGroundStations -> Request ListGroundStations
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListGroundStations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListGroundStations)))
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 [GroundStationData]
-> Maybe Text -> Int -> ListGroundStationsResponse
ListGroundStationsResponse'
            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
"groundStationList"
                            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            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 ListGroundStations where
  hashWithSalt :: Int -> ListGroundStations -> Int
hashWithSalt Int
_salt ListGroundStations' {Maybe Natural
Maybe Text
satelliteId :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:satelliteId:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:nextToken:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:maxResults:ListGroundStations' :: ListGroundStations -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
satelliteId

instance Prelude.NFData ListGroundStations where
  rnf :: ListGroundStations -> ()
rnf ListGroundStations' {Maybe Natural
Maybe Text
satelliteId :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:satelliteId:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:nextToken:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:maxResults:ListGroundStations' :: ListGroundStations -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
satelliteId

instance Data.ToHeaders ListGroundStations where
  toHeaders :: ListGroundStations -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListGroundStations where
  toPath :: ListGroundStations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/groundstation"

instance Data.ToQuery ListGroundStations where
  toQuery :: ListGroundStations -> QueryString
toQuery ListGroundStations' {Maybe Natural
Maybe Text
satelliteId :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:satelliteId:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:nextToken:ListGroundStations' :: ListGroundStations -> Maybe Text
$sel:maxResults:ListGroundStations' :: ListGroundStations -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"satelliteId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
satelliteId
      ]

-- |
--
-- /See:/ 'newListGroundStationsResponse' smart constructor.
data ListGroundStationsResponse = ListGroundStationsResponse'
  { -- | List of ground stations.
    ListGroundStationsResponse -> Maybe [GroundStationData]
groundStationList :: Prelude.Maybe [GroundStationData],
    -- | Next token that can be supplied in the next call to get the next page of
    -- ground stations.
    ListGroundStationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListGroundStationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListGroundStationsResponse -> ListGroundStationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroundStationsResponse -> ListGroundStationsResponse -> Bool
$c/= :: ListGroundStationsResponse -> ListGroundStationsResponse -> Bool
== :: ListGroundStationsResponse -> ListGroundStationsResponse -> Bool
$c== :: ListGroundStationsResponse -> ListGroundStationsResponse -> Bool
Prelude.Eq, ReadPrec [ListGroundStationsResponse]
ReadPrec ListGroundStationsResponse
Int -> ReadS ListGroundStationsResponse
ReadS [ListGroundStationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroundStationsResponse]
$creadListPrec :: ReadPrec [ListGroundStationsResponse]
readPrec :: ReadPrec ListGroundStationsResponse
$creadPrec :: ReadPrec ListGroundStationsResponse
readList :: ReadS [ListGroundStationsResponse]
$creadList :: ReadS [ListGroundStationsResponse]
readsPrec :: Int -> ReadS ListGroundStationsResponse
$creadsPrec :: Int -> ReadS ListGroundStationsResponse
Prelude.Read, Int -> ListGroundStationsResponse -> ShowS
[ListGroundStationsResponse] -> ShowS
ListGroundStationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroundStationsResponse] -> ShowS
$cshowList :: [ListGroundStationsResponse] -> ShowS
show :: ListGroundStationsResponse -> String
$cshow :: ListGroundStationsResponse -> String
showsPrec :: Int -> ListGroundStationsResponse -> ShowS
$cshowsPrec :: Int -> ListGroundStationsResponse -> ShowS
Prelude.Show, forall x.
Rep ListGroundStationsResponse x -> ListGroundStationsResponse
forall x.
ListGroundStationsResponse -> Rep ListGroundStationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListGroundStationsResponse x -> ListGroundStationsResponse
$cfrom :: forall x.
ListGroundStationsResponse -> Rep ListGroundStationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListGroundStationsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'groundStationList', 'listGroundStationsResponse_groundStationList' - List of ground stations.
--
-- 'nextToken', 'listGroundStationsResponse_nextToken' - Next token that can be supplied in the next call to get the next page of
-- ground stations.
--
-- 'httpStatus', 'listGroundStationsResponse_httpStatus' - The response's http status code.
newListGroundStationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListGroundStationsResponse
newListGroundStationsResponse :: Int -> ListGroundStationsResponse
newListGroundStationsResponse Int
pHttpStatus_ =
  ListGroundStationsResponse'
    { $sel:groundStationList:ListGroundStationsResponse' :: Maybe [GroundStationData]
groundStationList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroundStationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListGroundStationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of ground stations.
listGroundStationsResponse_groundStationList :: Lens.Lens' ListGroundStationsResponse (Prelude.Maybe [GroundStationData])
listGroundStationsResponse_groundStationList :: Lens' ListGroundStationsResponse (Maybe [GroundStationData])
listGroundStationsResponse_groundStationList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStationsResponse' {Maybe [GroundStationData]
groundStationList :: Maybe [GroundStationData]
$sel:groundStationList:ListGroundStationsResponse' :: ListGroundStationsResponse -> Maybe [GroundStationData]
groundStationList} -> Maybe [GroundStationData]
groundStationList) (\s :: ListGroundStationsResponse
s@ListGroundStationsResponse' {} Maybe [GroundStationData]
a -> ListGroundStationsResponse
s {$sel:groundStationList:ListGroundStationsResponse' :: Maybe [GroundStationData]
groundStationList = Maybe [GroundStationData]
a} :: ListGroundStationsResponse) 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

-- | Next token that can be supplied in the next call to get the next page of
-- ground stations.
listGroundStationsResponse_nextToken :: Lens.Lens' ListGroundStationsResponse (Prelude.Maybe Prelude.Text)
listGroundStationsResponse_nextToken :: Lens' ListGroundStationsResponse (Maybe Text)
listGroundStationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroundStationsResponse' :: ListGroundStationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroundStationsResponse
s@ListGroundStationsResponse' {} Maybe Text
a -> ListGroundStationsResponse
s {$sel:nextToken:ListGroundStationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroundStationsResponse)

-- | The response's http status code.
listGroundStationsResponse_httpStatus :: Lens.Lens' ListGroundStationsResponse Prelude.Int
listGroundStationsResponse_httpStatus :: Lens' ListGroundStationsResponse Int
listGroundStationsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroundStationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListGroundStationsResponse' :: ListGroundStationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListGroundStationsResponse
s@ListGroundStationsResponse' {} Int
a -> ListGroundStationsResponse
s {$sel:httpStatus:ListGroundStationsResponse' :: Int
httpStatus = Int
a} :: ListGroundStationsResponse)

instance Prelude.NFData ListGroundStationsResponse where
  rnf :: ListGroundStationsResponse -> ()
rnf ListGroundStationsResponse' {Int
Maybe [GroundStationData]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
groundStationList :: Maybe [GroundStationData]
$sel:httpStatus:ListGroundStationsResponse' :: ListGroundStationsResponse -> Int
$sel:nextToken:ListGroundStationsResponse' :: ListGroundStationsResponse -> Maybe Text
$sel:groundStationList:ListGroundStationsResponse' :: ListGroundStationsResponse -> Maybe [GroundStationData]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GroundStationData]
groundStationList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus