{-# 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.SSMIncidents.ListReplicationSets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists details about the replication set configured in your account.
--
-- This operation returns paginated results.
module Amazonka.SSMIncidents.ListReplicationSets
  ( -- * Creating a Request
    ListReplicationSets (..),
    newListReplicationSets,

    -- * Request Lenses
    listReplicationSets_maxResults,
    listReplicationSets_nextToken,

    -- * Destructuring the Response
    ListReplicationSetsResponse (..),
    newListReplicationSetsResponse,

    -- * Response Lenses
    listReplicationSetsResponse_nextToken,
    listReplicationSetsResponse_httpStatus,
    listReplicationSetsResponse_replicationSetArns,
  )
where

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

-- | /See:/ 'newListReplicationSets' smart constructor.
data ListReplicationSets = ListReplicationSets'
  { -- | The maximum number of results per page.
    ListReplicationSets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token to continue to the next page of results.
    ListReplicationSets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListReplicationSets -> ListReplicationSets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListReplicationSets -> ListReplicationSets -> Bool
$c/= :: ListReplicationSets -> ListReplicationSets -> Bool
== :: ListReplicationSets -> ListReplicationSets -> Bool
$c== :: ListReplicationSets -> ListReplicationSets -> Bool
Prelude.Eq, ReadPrec [ListReplicationSets]
ReadPrec ListReplicationSets
Int -> ReadS ListReplicationSets
ReadS [ListReplicationSets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListReplicationSets]
$creadListPrec :: ReadPrec [ListReplicationSets]
readPrec :: ReadPrec ListReplicationSets
$creadPrec :: ReadPrec ListReplicationSets
readList :: ReadS [ListReplicationSets]
$creadList :: ReadS [ListReplicationSets]
readsPrec :: Int -> ReadS ListReplicationSets
$creadsPrec :: Int -> ReadS ListReplicationSets
Prelude.Read, Int -> ListReplicationSets -> ShowS
[ListReplicationSets] -> ShowS
ListReplicationSets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListReplicationSets] -> ShowS
$cshowList :: [ListReplicationSets] -> ShowS
show :: ListReplicationSets -> String
$cshow :: ListReplicationSets -> String
showsPrec :: Int -> ListReplicationSets -> ShowS
$cshowsPrec :: Int -> ListReplicationSets -> ShowS
Prelude.Show, forall x. Rep ListReplicationSets x -> ListReplicationSets
forall x. ListReplicationSets -> Rep ListReplicationSets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListReplicationSets x -> ListReplicationSets
$cfrom :: forall x. ListReplicationSets -> Rep ListReplicationSets x
Prelude.Generic)

-- |
-- Create a value of 'ListReplicationSets' 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', 'listReplicationSets_maxResults' - The maximum number of results per page.
--
-- 'nextToken', 'listReplicationSets_nextToken' - The pagination token to continue to the next page of results.
newListReplicationSets ::
  ListReplicationSets
newListReplicationSets :: ListReplicationSets
newListReplicationSets =
  ListReplicationSets'
    { $sel:maxResults:ListReplicationSets' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListReplicationSets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results per page.
listReplicationSets_maxResults :: Lens.Lens' ListReplicationSets (Prelude.Maybe Prelude.Natural)
listReplicationSets_maxResults :: Lens' ListReplicationSets (Maybe Natural)
listReplicationSets_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReplicationSets' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListReplicationSets' :: ListReplicationSets -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListReplicationSets
s@ListReplicationSets' {} Maybe Natural
a -> ListReplicationSets
s {$sel:maxResults:ListReplicationSets' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListReplicationSets)

-- | The pagination token to continue to the next page of results.
listReplicationSets_nextToken :: Lens.Lens' ListReplicationSets (Prelude.Maybe Prelude.Text)
listReplicationSets_nextToken :: Lens' ListReplicationSets (Maybe Text)
listReplicationSets_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReplicationSets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListReplicationSets' :: ListReplicationSets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListReplicationSets
s@ListReplicationSets' {} Maybe Text
a -> ListReplicationSets
s {$sel:nextToken:ListReplicationSets' :: Maybe Text
nextToken = Maybe Text
a} :: ListReplicationSets)

instance Core.AWSPager ListReplicationSets where
  page :: ListReplicationSets
-> AWSResponse ListReplicationSets -> Maybe ListReplicationSets
page ListReplicationSets
rq AWSResponse ListReplicationSets
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListReplicationSets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListReplicationSetsResponse (Maybe Text)
listReplicationSetsResponse_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 ListReplicationSets
rs
            forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListReplicationSetsResponse [Text]
listReplicationSetsResponse_replicationSetArns
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListReplicationSets
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListReplicationSets (Maybe Text)
listReplicationSets_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListReplicationSets
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListReplicationSetsResponse (Maybe Text)
listReplicationSetsResponse_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 ListReplicationSets where
  type
    AWSResponse ListReplicationSets =
      ListReplicationSetsResponse
  request :: (Service -> Service)
-> ListReplicationSets -> Request ListReplicationSets
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 ListReplicationSets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListReplicationSets)))
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 Text -> Int -> [Text] -> ListReplicationSetsResponse
ListReplicationSetsResponse'
            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
"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))
            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
"replicationSetArns"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ListReplicationSets where
  hashWithSalt :: Int -> ListReplicationSets -> Int
hashWithSalt Int
_salt ListReplicationSets' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReplicationSets' :: ListReplicationSets -> Maybe Text
$sel:maxResults:ListReplicationSets' :: ListReplicationSets -> 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

instance Prelude.NFData ListReplicationSets where
  rnf :: ListReplicationSets -> ()
rnf ListReplicationSets' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReplicationSets' :: ListReplicationSets -> Maybe Text
$sel:maxResults:ListReplicationSets' :: ListReplicationSets -> 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

instance Data.ToHeaders ListReplicationSets where
  toHeaders :: ListReplicationSets -> 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.ToJSON ListReplicationSets where
  toJSON :: ListReplicationSets -> Value
toJSON ListReplicationSets' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListReplicationSets' :: ListReplicationSets -> Maybe Text
$sel:maxResults:ListReplicationSets' :: ListReplicationSets -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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

instance Data.ToQuery ListReplicationSets where
  toQuery :: ListReplicationSets -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListReplicationSetsResponse' smart constructor.
data ListReplicationSetsResponse = ListReplicationSetsResponse'
  { -- | The pagination token to continue to the next page of results.
    ListReplicationSetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListReplicationSetsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Resource Name (ARN) of the list replication set.
    ListReplicationSetsResponse -> [Text]
replicationSetArns :: [Prelude.Text]
  }
  deriving (ListReplicationSetsResponse -> ListReplicationSetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListReplicationSetsResponse -> ListReplicationSetsResponse -> Bool
$c/= :: ListReplicationSetsResponse -> ListReplicationSetsResponse -> Bool
== :: ListReplicationSetsResponse -> ListReplicationSetsResponse -> Bool
$c== :: ListReplicationSetsResponse -> ListReplicationSetsResponse -> Bool
Prelude.Eq, ReadPrec [ListReplicationSetsResponse]
ReadPrec ListReplicationSetsResponse
Int -> ReadS ListReplicationSetsResponse
ReadS [ListReplicationSetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListReplicationSetsResponse]
$creadListPrec :: ReadPrec [ListReplicationSetsResponse]
readPrec :: ReadPrec ListReplicationSetsResponse
$creadPrec :: ReadPrec ListReplicationSetsResponse
readList :: ReadS [ListReplicationSetsResponse]
$creadList :: ReadS [ListReplicationSetsResponse]
readsPrec :: Int -> ReadS ListReplicationSetsResponse
$creadsPrec :: Int -> ReadS ListReplicationSetsResponse
Prelude.Read, Int -> ListReplicationSetsResponse -> ShowS
[ListReplicationSetsResponse] -> ShowS
ListReplicationSetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListReplicationSetsResponse] -> ShowS
$cshowList :: [ListReplicationSetsResponse] -> ShowS
show :: ListReplicationSetsResponse -> String
$cshow :: ListReplicationSetsResponse -> String
showsPrec :: Int -> ListReplicationSetsResponse -> ShowS
$cshowsPrec :: Int -> ListReplicationSetsResponse -> ShowS
Prelude.Show, forall x.
Rep ListReplicationSetsResponse x -> ListReplicationSetsResponse
forall x.
ListReplicationSetsResponse -> Rep ListReplicationSetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListReplicationSetsResponse x -> ListReplicationSetsResponse
$cfrom :: forall x.
ListReplicationSetsResponse -> Rep ListReplicationSetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListReplicationSetsResponse' 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:
--
-- 'nextToken', 'listReplicationSetsResponse_nextToken' - The pagination token to continue to the next page of results.
--
-- 'httpStatus', 'listReplicationSetsResponse_httpStatus' - The response's http status code.
--
-- 'replicationSetArns', 'listReplicationSetsResponse_replicationSetArns' - The Amazon Resource Name (ARN) of the list replication set.
newListReplicationSetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListReplicationSetsResponse
newListReplicationSetsResponse :: Int -> ListReplicationSetsResponse
newListReplicationSetsResponse Int
pHttpStatus_ =
  ListReplicationSetsResponse'
    { $sel:nextToken:ListReplicationSetsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListReplicationSetsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:replicationSetArns:ListReplicationSetsResponse' :: [Text]
replicationSetArns = forall a. Monoid a => a
Prelude.mempty
    }

-- | The pagination token to continue to the next page of results.
listReplicationSetsResponse_nextToken :: Lens.Lens' ListReplicationSetsResponse (Prelude.Maybe Prelude.Text)
listReplicationSetsResponse_nextToken :: Lens' ListReplicationSetsResponse (Maybe Text)
listReplicationSetsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReplicationSetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListReplicationSetsResponse' :: ListReplicationSetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListReplicationSetsResponse
s@ListReplicationSetsResponse' {} Maybe Text
a -> ListReplicationSetsResponse
s {$sel:nextToken:ListReplicationSetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListReplicationSetsResponse)

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

-- | The Amazon Resource Name (ARN) of the list replication set.
listReplicationSetsResponse_replicationSetArns :: Lens.Lens' ListReplicationSetsResponse [Prelude.Text]
listReplicationSetsResponse_replicationSetArns :: Lens' ListReplicationSetsResponse [Text]
listReplicationSetsResponse_replicationSetArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListReplicationSetsResponse' {[Text]
replicationSetArns :: [Text]
$sel:replicationSetArns:ListReplicationSetsResponse' :: ListReplicationSetsResponse -> [Text]
replicationSetArns} -> [Text]
replicationSetArns) (\s :: ListReplicationSetsResponse
s@ListReplicationSetsResponse' {} [Text]
a -> ListReplicationSetsResponse
s {$sel:replicationSetArns:ListReplicationSetsResponse' :: [Text]
replicationSetArns = [Text]
a} :: ListReplicationSetsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListReplicationSetsResponse where
  rnf :: ListReplicationSetsResponse -> ()
rnf ListReplicationSetsResponse' {Int
[Text]
Maybe Text
replicationSetArns :: [Text]
httpStatus :: Int
nextToken :: Maybe Text
$sel:replicationSetArns:ListReplicationSetsResponse' :: ListReplicationSetsResponse -> [Text]
$sel:httpStatus:ListReplicationSetsResponse' :: ListReplicationSetsResponse -> Int
$sel:nextToken:ListReplicationSetsResponse' :: ListReplicationSetsResponse -> Maybe Text
..} =
    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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
replicationSetArns