{-# 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.Greengrass.ListBulkDeployments
-- 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 bulk deployments.
--
-- This operation returns paginated results.
module Amazonka.Greengrass.ListBulkDeployments
  ( -- * Creating a Request
    ListBulkDeployments (..),
    newListBulkDeployments,

    -- * Request Lenses
    listBulkDeployments_maxResults,
    listBulkDeployments_nextToken,

    -- * Destructuring the Response
    ListBulkDeploymentsResponse (..),
    newListBulkDeploymentsResponse,

    -- * Response Lenses
    listBulkDeploymentsResponse_bulkDeployments,
    listBulkDeploymentsResponse_nextToken,
    listBulkDeploymentsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListBulkDeployments' smart constructor.
data ListBulkDeployments = ListBulkDeployments'
  { -- | The maximum number of results to be returned per request.
    ListBulkDeployments -> Maybe Text
maxResults :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of results, or \'\'null\'\' if there are no
    -- additional results.
    ListBulkDeployments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListBulkDeployments -> ListBulkDeployments -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBulkDeployments -> ListBulkDeployments -> Bool
$c/= :: ListBulkDeployments -> ListBulkDeployments -> Bool
== :: ListBulkDeployments -> ListBulkDeployments -> Bool
$c== :: ListBulkDeployments -> ListBulkDeployments -> Bool
Prelude.Eq, ReadPrec [ListBulkDeployments]
ReadPrec ListBulkDeployments
Int -> ReadS ListBulkDeployments
ReadS [ListBulkDeployments]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBulkDeployments]
$creadListPrec :: ReadPrec [ListBulkDeployments]
readPrec :: ReadPrec ListBulkDeployments
$creadPrec :: ReadPrec ListBulkDeployments
readList :: ReadS [ListBulkDeployments]
$creadList :: ReadS [ListBulkDeployments]
readsPrec :: Int -> ReadS ListBulkDeployments
$creadsPrec :: Int -> ReadS ListBulkDeployments
Prelude.Read, Int -> ListBulkDeployments -> ShowS
[ListBulkDeployments] -> ShowS
ListBulkDeployments -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBulkDeployments] -> ShowS
$cshowList :: [ListBulkDeployments] -> ShowS
show :: ListBulkDeployments -> String
$cshow :: ListBulkDeployments -> String
showsPrec :: Int -> ListBulkDeployments -> ShowS
$cshowsPrec :: Int -> ListBulkDeployments -> ShowS
Prelude.Show, forall x. Rep ListBulkDeployments x -> ListBulkDeployments
forall x. ListBulkDeployments -> Rep ListBulkDeployments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBulkDeployments x -> ListBulkDeployments
$cfrom :: forall x. ListBulkDeployments -> Rep ListBulkDeployments x
Prelude.Generic)

-- |
-- Create a value of 'ListBulkDeployments' 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', 'listBulkDeployments_maxResults' - The maximum number of results to be returned per request.
--
-- 'nextToken', 'listBulkDeployments_nextToken' - The token for the next set of results, or \'\'null\'\' if there are no
-- additional results.
newListBulkDeployments ::
  ListBulkDeployments
newListBulkDeployments :: ListBulkDeployments
newListBulkDeployments =
  ListBulkDeployments'
    { $sel:maxResults:ListBulkDeployments' :: Maybe Text
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBulkDeployments' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to be returned per request.
listBulkDeployments_maxResults :: Lens.Lens' ListBulkDeployments (Prelude.Maybe Prelude.Text)
listBulkDeployments_maxResults :: Lens' ListBulkDeployments (Maybe Text)
listBulkDeployments_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBulkDeployments' {Maybe Text
maxResults :: Maybe Text
$sel:maxResults:ListBulkDeployments' :: ListBulkDeployments -> Maybe Text
maxResults} -> Maybe Text
maxResults) (\s :: ListBulkDeployments
s@ListBulkDeployments' {} Maybe Text
a -> ListBulkDeployments
s {$sel:maxResults:ListBulkDeployments' :: Maybe Text
maxResults = Maybe Text
a} :: ListBulkDeployments)

-- | The token for the next set of results, or \'\'null\'\' if there are no
-- additional results.
listBulkDeployments_nextToken :: Lens.Lens' ListBulkDeployments (Prelude.Maybe Prelude.Text)
listBulkDeployments_nextToken :: Lens' ListBulkDeployments (Maybe Text)
listBulkDeployments_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBulkDeployments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBulkDeployments' :: ListBulkDeployments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBulkDeployments
s@ListBulkDeployments' {} Maybe Text
a -> ListBulkDeployments
s {$sel:nextToken:ListBulkDeployments' :: Maybe Text
nextToken = Maybe Text
a} :: ListBulkDeployments)

instance Core.AWSPager ListBulkDeployments where
  page :: ListBulkDeployments
-> AWSResponse ListBulkDeployments -> Maybe ListBulkDeployments
page ListBulkDeployments
rq AWSResponse ListBulkDeployments
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBulkDeployments
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBulkDeploymentsResponse (Maybe Text)
listBulkDeploymentsResponse_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 ListBulkDeployments
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBulkDeploymentsResponse (Maybe [BulkDeployment])
listBulkDeploymentsResponse_bulkDeployments
            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.$ ListBulkDeployments
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListBulkDeployments (Maybe Text)
listBulkDeployments_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListBulkDeployments
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListBulkDeploymentsResponse (Maybe Text)
listBulkDeploymentsResponse_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 ListBulkDeployments where
  type
    AWSResponse ListBulkDeployments =
      ListBulkDeploymentsResponse
  request :: (Service -> Service)
-> ListBulkDeployments -> Request ListBulkDeployments
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 ListBulkDeployments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListBulkDeployments)))
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 [BulkDeployment]
-> Maybe Text -> Int -> ListBulkDeploymentsResponse
ListBulkDeploymentsResponse'
            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
"BulkDeployments"
                            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 ListBulkDeployments where
  hashWithSalt :: Int -> ListBulkDeployments -> Int
hashWithSalt Int
_salt ListBulkDeployments' {Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:nextToken:ListBulkDeployments' :: ListBulkDeployments -> Maybe Text
$sel:maxResults:ListBulkDeployments' :: ListBulkDeployments -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

instance Data.ToHeaders ListBulkDeployments where
  toHeaders :: ListBulkDeployments -> 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 ListBulkDeployments where
  toPath :: ListBulkDeployments -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/greengrass/bulk/deployments"

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

-- | /See:/ 'newListBulkDeploymentsResponse' smart constructor.
data ListBulkDeploymentsResponse = ListBulkDeploymentsResponse'
  { -- | A list of bulk deployments.
    ListBulkDeploymentsResponse -> Maybe [BulkDeployment]
bulkDeployments :: Prelude.Maybe [BulkDeployment],
    -- | The token for the next set of results, or \'\'null\'\' if there are no
    -- additional results.
    ListBulkDeploymentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBulkDeploymentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBulkDeploymentsResponse -> ListBulkDeploymentsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBulkDeploymentsResponse -> ListBulkDeploymentsResponse -> Bool
$c/= :: ListBulkDeploymentsResponse -> ListBulkDeploymentsResponse -> Bool
== :: ListBulkDeploymentsResponse -> ListBulkDeploymentsResponse -> Bool
$c== :: ListBulkDeploymentsResponse -> ListBulkDeploymentsResponse -> Bool
Prelude.Eq, ReadPrec [ListBulkDeploymentsResponse]
ReadPrec ListBulkDeploymentsResponse
Int -> ReadS ListBulkDeploymentsResponse
ReadS [ListBulkDeploymentsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBulkDeploymentsResponse]
$creadListPrec :: ReadPrec [ListBulkDeploymentsResponse]
readPrec :: ReadPrec ListBulkDeploymentsResponse
$creadPrec :: ReadPrec ListBulkDeploymentsResponse
readList :: ReadS [ListBulkDeploymentsResponse]
$creadList :: ReadS [ListBulkDeploymentsResponse]
readsPrec :: Int -> ReadS ListBulkDeploymentsResponse
$creadsPrec :: Int -> ReadS ListBulkDeploymentsResponse
Prelude.Read, Int -> ListBulkDeploymentsResponse -> ShowS
[ListBulkDeploymentsResponse] -> ShowS
ListBulkDeploymentsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBulkDeploymentsResponse] -> ShowS
$cshowList :: [ListBulkDeploymentsResponse] -> ShowS
show :: ListBulkDeploymentsResponse -> String
$cshow :: ListBulkDeploymentsResponse -> String
showsPrec :: Int -> ListBulkDeploymentsResponse -> ShowS
$cshowsPrec :: Int -> ListBulkDeploymentsResponse -> ShowS
Prelude.Show, forall x.
Rep ListBulkDeploymentsResponse x -> ListBulkDeploymentsResponse
forall x.
ListBulkDeploymentsResponse -> Rep ListBulkDeploymentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListBulkDeploymentsResponse x -> ListBulkDeploymentsResponse
$cfrom :: forall x.
ListBulkDeploymentsResponse -> Rep ListBulkDeploymentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBulkDeploymentsResponse' 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:
--
-- 'bulkDeployments', 'listBulkDeploymentsResponse_bulkDeployments' - A list of bulk deployments.
--
-- 'nextToken', 'listBulkDeploymentsResponse_nextToken' - The token for the next set of results, or \'\'null\'\' if there are no
-- additional results.
--
-- 'httpStatus', 'listBulkDeploymentsResponse_httpStatus' - The response's http status code.
newListBulkDeploymentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBulkDeploymentsResponse
newListBulkDeploymentsResponse :: Int -> ListBulkDeploymentsResponse
newListBulkDeploymentsResponse Int
pHttpStatus_ =
  ListBulkDeploymentsResponse'
    { $sel:bulkDeployments:ListBulkDeploymentsResponse' :: Maybe [BulkDeployment]
bulkDeployments =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBulkDeploymentsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBulkDeploymentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of bulk deployments.
listBulkDeploymentsResponse_bulkDeployments :: Lens.Lens' ListBulkDeploymentsResponse (Prelude.Maybe [BulkDeployment])
listBulkDeploymentsResponse_bulkDeployments :: Lens' ListBulkDeploymentsResponse (Maybe [BulkDeployment])
listBulkDeploymentsResponse_bulkDeployments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBulkDeploymentsResponse' {Maybe [BulkDeployment]
bulkDeployments :: Maybe [BulkDeployment]
$sel:bulkDeployments:ListBulkDeploymentsResponse' :: ListBulkDeploymentsResponse -> Maybe [BulkDeployment]
bulkDeployments} -> Maybe [BulkDeployment]
bulkDeployments) (\s :: ListBulkDeploymentsResponse
s@ListBulkDeploymentsResponse' {} Maybe [BulkDeployment]
a -> ListBulkDeploymentsResponse
s {$sel:bulkDeployments:ListBulkDeploymentsResponse' :: Maybe [BulkDeployment]
bulkDeployments = Maybe [BulkDeployment]
a} :: ListBulkDeploymentsResponse) 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

-- | The token for the next set of results, or \'\'null\'\' if there are no
-- additional results.
listBulkDeploymentsResponse_nextToken :: Lens.Lens' ListBulkDeploymentsResponse (Prelude.Maybe Prelude.Text)
listBulkDeploymentsResponse_nextToken :: Lens' ListBulkDeploymentsResponse (Maybe Text)
listBulkDeploymentsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBulkDeploymentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBulkDeploymentsResponse' :: ListBulkDeploymentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBulkDeploymentsResponse
s@ListBulkDeploymentsResponse' {} Maybe Text
a -> ListBulkDeploymentsResponse
s {$sel:nextToken:ListBulkDeploymentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListBulkDeploymentsResponse)

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

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