{-# 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.AppConfig.ListDeployments
-- 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 the deployments for an environment in descending deployment number
-- order.
module Amazonka.AppConfig.ListDeployments
  ( -- * Creating a Request
    ListDeployments (..),
    newListDeployments,

    -- * Request Lenses
    listDeployments_maxResults,
    listDeployments_nextToken,
    listDeployments_applicationId,
    listDeployments_environmentId,

    -- * Destructuring the Response
    ListDeploymentsResponse (..),
    newListDeploymentsResponse,

    -- * Response Lenses
    listDeploymentsResponse_items,
    listDeploymentsResponse_nextToken,
    listDeploymentsResponse_httpStatus,
  )
where

import Amazonka.AppConfig.Types
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

-- | /See:/ 'newListDeployments' smart constructor.
data ListDeployments = ListDeployments'
  { -- | The maximum number of items that may be returned for this call. If there
    -- are items that have not yet been returned, the response will include a
    -- non-null @NextToken@ that you can provide in a subsequent call to get
    -- the next set of results.
    ListDeployments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token returned by a prior call to this operation indicating the next
    -- set of results to be returned. If not specified, the operation will
    -- return the first set of results.
    ListDeployments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The application ID.
    ListDeployments -> Text
applicationId :: Prelude.Text,
    -- | The environment ID.
    ListDeployments -> Text
environmentId :: Prelude.Text
  }
  deriving (ListDeployments -> ListDeployments -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDeployments -> ListDeployments -> Bool
$c/= :: ListDeployments -> ListDeployments -> Bool
== :: ListDeployments -> ListDeployments -> Bool
$c== :: ListDeployments -> ListDeployments -> Bool
Prelude.Eq, ReadPrec [ListDeployments]
ReadPrec ListDeployments
Int -> ReadS ListDeployments
ReadS [ListDeployments]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDeployments]
$creadListPrec :: ReadPrec [ListDeployments]
readPrec :: ReadPrec ListDeployments
$creadPrec :: ReadPrec ListDeployments
readList :: ReadS [ListDeployments]
$creadList :: ReadS [ListDeployments]
readsPrec :: Int -> ReadS ListDeployments
$creadsPrec :: Int -> ReadS ListDeployments
Prelude.Read, Int -> ListDeployments -> ShowS
[ListDeployments] -> ShowS
ListDeployments -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDeployments] -> ShowS
$cshowList :: [ListDeployments] -> ShowS
show :: ListDeployments -> String
$cshow :: ListDeployments -> String
showsPrec :: Int -> ListDeployments -> ShowS
$cshowsPrec :: Int -> ListDeployments -> ShowS
Prelude.Show, forall x. Rep ListDeployments x -> ListDeployments
forall x. ListDeployments -> Rep ListDeployments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDeployments x -> ListDeployments
$cfrom :: forall x. ListDeployments -> Rep ListDeployments x
Prelude.Generic)

-- |
-- Create a value of 'ListDeployments' 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', 'listDeployments_maxResults' - The maximum number of items that may be returned for this call. If there
-- are items that have not yet been returned, the response will include a
-- non-null @NextToken@ that you can provide in a subsequent call to get
-- the next set of results.
--
-- 'nextToken', 'listDeployments_nextToken' - The token returned by a prior call to this operation indicating the next
-- set of results to be returned. If not specified, the operation will
-- return the first set of results.
--
-- 'applicationId', 'listDeployments_applicationId' - The application ID.
--
-- 'environmentId', 'listDeployments_environmentId' - The environment ID.
newListDeployments ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'environmentId'
  Prelude.Text ->
  ListDeployments
newListDeployments :: Text -> Text -> ListDeployments
newListDeployments Text
pApplicationId_ Text
pEnvironmentId_ =
  ListDeployments'
    { $sel:maxResults:ListDeployments' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDeployments' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:ListDeployments' :: Text
applicationId = Text
pApplicationId_,
      $sel:environmentId:ListDeployments' :: Text
environmentId = Text
pEnvironmentId_
    }

-- | The maximum number of items that may be returned for this call. If there
-- are items that have not yet been returned, the response will include a
-- non-null @NextToken@ that you can provide in a subsequent call to get
-- the next set of results.
listDeployments_maxResults :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Natural)
listDeployments_maxResults :: Lens' ListDeployments (Maybe Natural)
listDeployments_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDeployments' :: ListDeployments -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDeployments
s@ListDeployments' {} Maybe Natural
a -> ListDeployments
s {$sel:maxResults:ListDeployments' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDeployments)

-- | The token returned by a prior call to this operation indicating the next
-- set of results to be returned. If not specified, the operation will
-- return the first set of results.
listDeployments_nextToken :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Text)
listDeployments_nextToken :: Lens' ListDeployments (Maybe Text)
listDeployments_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDeployments' :: ListDeployments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDeployments
s@ListDeployments' {} Maybe Text
a -> ListDeployments
s {$sel:nextToken:ListDeployments' :: Maybe Text
nextToken = Maybe Text
a} :: ListDeployments)

-- | The application ID.
listDeployments_applicationId :: Lens.Lens' ListDeployments Prelude.Text
listDeployments_applicationId :: Lens' ListDeployments Text
listDeployments_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Text
applicationId :: Text
$sel:applicationId:ListDeployments' :: ListDeployments -> Text
applicationId} -> Text
applicationId) (\s :: ListDeployments
s@ListDeployments' {} Text
a -> ListDeployments
s {$sel:applicationId:ListDeployments' :: Text
applicationId = Text
a} :: ListDeployments)

-- | The environment ID.
listDeployments_environmentId :: Lens.Lens' ListDeployments Prelude.Text
listDeployments_environmentId :: Lens' ListDeployments Text
listDeployments_environmentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Text
environmentId :: Text
$sel:environmentId:ListDeployments' :: ListDeployments -> Text
environmentId} -> Text
environmentId) (\s :: ListDeployments
s@ListDeployments' {} Text
a -> ListDeployments
s {$sel:environmentId:ListDeployments' :: Text
environmentId = Text
a} :: ListDeployments)

instance Core.AWSRequest ListDeployments where
  type
    AWSResponse ListDeployments =
      ListDeploymentsResponse
  request :: (Service -> Service) -> ListDeployments -> Request ListDeployments
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 ListDeployments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDeployments)))
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 [DeploymentSummary]
-> Maybe Text -> Int -> ListDeploymentsResponse
ListDeploymentsResponse'
            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
"Items" 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 ListDeployments where
  hashWithSalt :: Int -> ListDeployments -> Int
hashWithSalt Int
_salt ListDeployments' {Maybe Natural
Maybe Text
Text
environmentId :: Text
applicationId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:environmentId:ListDeployments' :: ListDeployments -> Text
$sel:applicationId:ListDeployments' :: ListDeployments -> Text
$sel:nextToken:ListDeployments' :: ListDeployments -> Maybe Text
$sel:maxResults:ListDeployments' :: ListDeployments -> 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` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
environmentId

instance Prelude.NFData ListDeployments where
  rnf :: ListDeployments -> ()
rnf ListDeployments' {Maybe Natural
Maybe Text
Text
environmentId :: Text
applicationId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:environmentId:ListDeployments' :: ListDeployments -> Text
$sel:applicationId:ListDeployments' :: ListDeployments -> Text
$sel:nextToken:ListDeployments' :: ListDeployments -> Maybe Text
$sel:maxResults:ListDeployments' :: ListDeployments -> 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 Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
environmentId

instance Data.ToHeaders ListDeployments where
  toHeaders :: ListDeployments -> 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 ListDeployments where
  toPath :: ListDeployments -> ByteString
toPath ListDeployments' {Maybe Natural
Maybe Text
Text
environmentId :: Text
applicationId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:environmentId:ListDeployments' :: ListDeployments -> Text
$sel:applicationId:ListDeployments' :: ListDeployments -> Text
$sel:nextToken:ListDeployments' :: ListDeployments -> Maybe Text
$sel:maxResults:ListDeployments' :: ListDeployments -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/environments/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
environmentId,
        ByteString
"/deployments"
      ]

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

-- | /See:/ 'newListDeploymentsResponse' smart constructor.
data ListDeploymentsResponse = ListDeploymentsResponse'
  { -- | The elements from this collection.
    ListDeploymentsResponse -> Maybe [DeploymentSummary]
items :: Prelude.Maybe [DeploymentSummary],
    -- | The token for the next set of items to return. Use this token to get the
    -- next set of results.
    ListDeploymentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDeploymentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
$c/= :: ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
== :: ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
$c== :: ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
Prelude.Eq, ReadPrec [ListDeploymentsResponse]
ReadPrec ListDeploymentsResponse
Int -> ReadS ListDeploymentsResponse
ReadS [ListDeploymentsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDeploymentsResponse]
$creadListPrec :: ReadPrec [ListDeploymentsResponse]
readPrec :: ReadPrec ListDeploymentsResponse
$creadPrec :: ReadPrec ListDeploymentsResponse
readList :: ReadS [ListDeploymentsResponse]
$creadList :: ReadS [ListDeploymentsResponse]
readsPrec :: Int -> ReadS ListDeploymentsResponse
$creadsPrec :: Int -> ReadS ListDeploymentsResponse
Prelude.Read, Int -> ListDeploymentsResponse -> ShowS
[ListDeploymentsResponse] -> ShowS
ListDeploymentsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDeploymentsResponse] -> ShowS
$cshowList :: [ListDeploymentsResponse] -> ShowS
show :: ListDeploymentsResponse -> String
$cshow :: ListDeploymentsResponse -> String
showsPrec :: Int -> ListDeploymentsResponse -> ShowS
$cshowsPrec :: Int -> ListDeploymentsResponse -> ShowS
Prelude.Show, forall x. Rep ListDeploymentsResponse x -> ListDeploymentsResponse
forall x. ListDeploymentsResponse -> Rep ListDeploymentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDeploymentsResponse x -> ListDeploymentsResponse
$cfrom :: forall x. ListDeploymentsResponse -> Rep ListDeploymentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDeploymentsResponse' 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:
--
-- 'items', 'listDeploymentsResponse_items' - The elements from this collection.
--
-- 'nextToken', 'listDeploymentsResponse_nextToken' - The token for the next set of items to return. Use this token to get the
-- next set of results.
--
-- 'httpStatus', 'listDeploymentsResponse_httpStatus' - The response's http status code.
newListDeploymentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDeploymentsResponse
newListDeploymentsResponse :: Int -> ListDeploymentsResponse
newListDeploymentsResponse Int
pHttpStatus_ =
  ListDeploymentsResponse'
    { $sel:items:ListDeploymentsResponse' :: Maybe [DeploymentSummary]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDeploymentsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDeploymentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The elements from this collection.
listDeploymentsResponse_items :: Lens.Lens' ListDeploymentsResponse (Prelude.Maybe [DeploymentSummary])
listDeploymentsResponse_items :: Lens' ListDeploymentsResponse (Maybe [DeploymentSummary])
listDeploymentsResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeploymentsResponse' {Maybe [DeploymentSummary]
items :: Maybe [DeploymentSummary]
$sel:items:ListDeploymentsResponse' :: ListDeploymentsResponse -> Maybe [DeploymentSummary]
items} -> Maybe [DeploymentSummary]
items) (\s :: ListDeploymentsResponse
s@ListDeploymentsResponse' {} Maybe [DeploymentSummary]
a -> ListDeploymentsResponse
s {$sel:items:ListDeploymentsResponse' :: Maybe [DeploymentSummary]
items = Maybe [DeploymentSummary]
a} :: ListDeploymentsResponse) 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 items to return. Use this token to get the
-- next set of results.
listDeploymentsResponse_nextToken :: Lens.Lens' ListDeploymentsResponse (Prelude.Maybe Prelude.Text)
listDeploymentsResponse_nextToken :: Lens' ListDeploymentsResponse (Maybe Text)
listDeploymentsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeploymentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDeploymentsResponse' :: ListDeploymentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDeploymentsResponse
s@ListDeploymentsResponse' {} Maybe Text
a -> ListDeploymentsResponse
s {$sel:nextToken:ListDeploymentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDeploymentsResponse)

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

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