{-# 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.CodeDeploy.ListDeployments
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the deployments in a deployment group for an application
-- registered with the IAM user or AWS account.
--
-- This operation returns paginated results.
module Amazonka.CodeDeploy.ListDeployments
  ( -- * Creating a Request
    ListDeployments (..),
    newListDeployments,

    -- * Request Lenses
    listDeployments_createTimeRange,
    listDeployments_nextToken,
    listDeployments_includeOnlyStatuses,
    listDeployments_applicationName,
    listDeployments_externalId,
    listDeployments_deploymentGroupName,

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

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

import Amazonka.CodeDeploy.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @ListDeployments@ operation.
--
-- /See:/ 'newListDeployments' smart constructor.
data ListDeployments = ListDeployments'
  { -- | A time range (start and end) for returning a subset of the list of
    -- deployments.
    ListDeployments -> Maybe TimeRange
createTimeRange :: Prelude.Maybe TimeRange,
    -- | An identifier returned from the previous list deployments call. It can
    -- be used to return the next set of deployments in the list.
    ListDeployments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A subset of deployments to list by status:
    --
    -- -   @Created@: Include created deployments in the resulting list.
    --
    -- -   @Queued@: Include queued deployments in the resulting list.
    --
    -- -   @In Progress@: Include in-progress deployments in the resulting
    --     list.
    --
    -- -   @Succeeded@: Include successful deployments in the resulting list.
    --
    -- -   @Failed@: Include failed deployments in the resulting list.
    --
    -- -   @Stopped@: Include stopped deployments in the resulting list.
    ListDeployments -> Maybe [DeploymentStatus]
includeOnlyStatuses :: Prelude.Maybe [DeploymentStatus],
    -- | The name of an AWS CodeDeploy application associated with the IAM user
    -- or AWS account.
    --
    -- If @applicationName@ is specified, then @deploymentGroupName@ must be
    -- specified. If it is not specified, then @deploymentGroupName@ must not
    -- be specified.
    ListDeployments -> Maybe Text
applicationName :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of an external resource for returning deployments linked
    -- to the external resource.
    ListDeployments -> Maybe Text
externalId :: Prelude.Maybe Prelude.Text,
    -- | The name of a deployment group for the specified application.
    --
    -- If @deploymentGroupName@ is specified, then @applicationName@ must be
    -- specified. If it is not specified, then @applicationName@ must not be
    -- specified.
    ListDeployments -> Maybe Text
deploymentGroupName :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDeployments -> ListDeployments -> Bool
(ListDeployments -> ListDeployments -> Bool)
-> (ListDeployments -> ListDeployments -> Bool)
-> Eq ListDeployments
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]
(Int -> ReadS ListDeployments)
-> ReadS [ListDeployments]
-> ReadPrec ListDeployments
-> ReadPrec [ListDeployments]
-> Read 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
(Int -> ListDeployments -> ShowS)
-> (ListDeployments -> String)
-> ([ListDeployments] -> ShowS)
-> Show ListDeployments
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. ListDeployments -> Rep ListDeployments x)
-> (forall x. Rep ListDeployments x -> ListDeployments)
-> Generic ListDeployments
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:
--
-- 'createTimeRange', 'listDeployments_createTimeRange' - A time range (start and end) for returning a subset of the list of
-- deployments.
--
-- 'nextToken', 'listDeployments_nextToken' - An identifier returned from the previous list deployments call. It can
-- be used to return the next set of deployments in the list.
--
-- 'includeOnlyStatuses', 'listDeployments_includeOnlyStatuses' - A subset of deployments to list by status:
--
-- -   @Created@: Include created deployments in the resulting list.
--
-- -   @Queued@: Include queued deployments in the resulting list.
--
-- -   @In Progress@: Include in-progress deployments in the resulting
--     list.
--
-- -   @Succeeded@: Include successful deployments in the resulting list.
--
-- -   @Failed@: Include failed deployments in the resulting list.
--
-- -   @Stopped@: Include stopped deployments in the resulting list.
--
-- 'applicationName', 'listDeployments_applicationName' - The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
--
-- If @applicationName@ is specified, then @deploymentGroupName@ must be
-- specified. If it is not specified, then @deploymentGroupName@ must not
-- be specified.
--
-- 'externalId', 'listDeployments_externalId' - The unique ID of an external resource for returning deployments linked
-- to the external resource.
--
-- 'deploymentGroupName', 'listDeployments_deploymentGroupName' - The name of a deployment group for the specified application.
--
-- If @deploymentGroupName@ is specified, then @applicationName@ must be
-- specified. If it is not specified, then @applicationName@ must not be
-- specified.
newListDeployments ::
  ListDeployments
newListDeployments :: ListDeployments
newListDeployments =
  ListDeployments' :: Maybe TimeRange
-> Maybe Text
-> Maybe [DeploymentStatus]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ListDeployments
ListDeployments'
    { $sel:createTimeRange:ListDeployments' :: Maybe TimeRange
createTimeRange = Maybe TimeRange
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDeployments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:includeOnlyStatuses:ListDeployments' :: Maybe [DeploymentStatus]
includeOnlyStatuses = Maybe [DeploymentStatus]
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationName:ListDeployments' :: Maybe Text
applicationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:externalId:ListDeployments' :: Maybe Text
externalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentGroupName:ListDeployments' :: Maybe Text
deploymentGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A time range (start and end) for returning a subset of the list of
-- deployments.
listDeployments_createTimeRange :: Lens.Lens' ListDeployments (Prelude.Maybe TimeRange)
listDeployments_createTimeRange :: (Maybe TimeRange -> f (Maybe TimeRange))
-> ListDeployments -> f ListDeployments
listDeployments_createTimeRange = (ListDeployments -> Maybe TimeRange)
-> (ListDeployments -> Maybe TimeRange -> ListDeployments)
-> Lens
     ListDeployments ListDeployments (Maybe TimeRange) (Maybe TimeRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe TimeRange
createTimeRange :: Maybe TimeRange
$sel:createTimeRange:ListDeployments' :: ListDeployments -> Maybe TimeRange
createTimeRange} -> Maybe TimeRange
createTimeRange) (\s :: ListDeployments
s@ListDeployments' {} Maybe TimeRange
a -> ListDeployments
s {$sel:createTimeRange:ListDeployments' :: Maybe TimeRange
createTimeRange = Maybe TimeRange
a} :: ListDeployments)

-- | An identifier returned from the previous list deployments call. It can
-- be used to return the next set of deployments in the list.
listDeployments_nextToken :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Text)
listDeployments_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDeployments -> f ListDeployments
listDeployments_nextToken = (ListDeployments -> Maybe Text)
-> (ListDeployments -> Maybe Text -> ListDeployments)
-> Lens ListDeployments ListDeployments (Maybe Text) (Maybe Text)
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)

-- | A subset of deployments to list by status:
--
-- -   @Created@: Include created deployments in the resulting list.
--
-- -   @Queued@: Include queued deployments in the resulting list.
--
-- -   @In Progress@: Include in-progress deployments in the resulting
--     list.
--
-- -   @Succeeded@: Include successful deployments in the resulting list.
--
-- -   @Failed@: Include failed deployments in the resulting list.
--
-- -   @Stopped@: Include stopped deployments in the resulting list.
listDeployments_includeOnlyStatuses :: Lens.Lens' ListDeployments (Prelude.Maybe [DeploymentStatus])
listDeployments_includeOnlyStatuses :: (Maybe [DeploymentStatus] -> f (Maybe [DeploymentStatus]))
-> ListDeployments -> f ListDeployments
listDeployments_includeOnlyStatuses = (ListDeployments -> Maybe [DeploymentStatus])
-> (ListDeployments -> Maybe [DeploymentStatus] -> ListDeployments)
-> Lens
     ListDeployments
     ListDeployments
     (Maybe [DeploymentStatus])
     (Maybe [DeploymentStatus])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe [DeploymentStatus]
includeOnlyStatuses :: Maybe [DeploymentStatus]
$sel:includeOnlyStatuses:ListDeployments' :: ListDeployments -> Maybe [DeploymentStatus]
includeOnlyStatuses} -> Maybe [DeploymentStatus]
includeOnlyStatuses) (\s :: ListDeployments
s@ListDeployments' {} Maybe [DeploymentStatus]
a -> ListDeployments
s {$sel:includeOnlyStatuses:ListDeployments' :: Maybe [DeploymentStatus]
includeOnlyStatuses = Maybe [DeploymentStatus]
a} :: ListDeployments) ((Maybe [DeploymentStatus] -> f (Maybe [DeploymentStatus]))
 -> ListDeployments -> f ListDeployments)
-> ((Maybe [DeploymentStatus] -> f (Maybe [DeploymentStatus]))
    -> Maybe [DeploymentStatus] -> f (Maybe [DeploymentStatus]))
-> (Maybe [DeploymentStatus] -> f (Maybe [DeploymentStatus]))
-> ListDeployments
-> f ListDeployments
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DeploymentStatus]
  [DeploymentStatus]
  [DeploymentStatus]
  [DeploymentStatus]
-> Iso
     (Maybe [DeploymentStatus])
     (Maybe [DeploymentStatus])
     (Maybe [DeploymentStatus])
     (Maybe [DeploymentStatus])
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 AnIso
  [DeploymentStatus]
  [DeploymentStatus]
  [DeploymentStatus]
  [DeploymentStatus]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
--
-- If @applicationName@ is specified, then @deploymentGroupName@ must be
-- specified. If it is not specified, then @deploymentGroupName@ must not
-- be specified.
listDeployments_applicationName :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Text)
listDeployments_applicationName :: (Maybe Text -> f (Maybe Text))
-> ListDeployments -> f ListDeployments
listDeployments_applicationName = (ListDeployments -> Maybe Text)
-> (ListDeployments -> Maybe Text -> ListDeployments)
-> Lens ListDeployments ListDeployments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe Text
applicationName :: Maybe Text
$sel:applicationName:ListDeployments' :: ListDeployments -> Maybe Text
applicationName} -> Maybe Text
applicationName) (\s :: ListDeployments
s@ListDeployments' {} Maybe Text
a -> ListDeployments
s {$sel:applicationName:ListDeployments' :: Maybe Text
applicationName = Maybe Text
a} :: ListDeployments)

-- | The unique ID of an external resource for returning deployments linked
-- to the external resource.
listDeployments_externalId :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Text)
listDeployments_externalId :: (Maybe Text -> f (Maybe Text))
-> ListDeployments -> f ListDeployments
listDeployments_externalId = (ListDeployments -> Maybe Text)
-> (ListDeployments -> Maybe Text -> ListDeployments)
-> Lens ListDeployments ListDeployments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe Text
externalId :: Maybe Text
$sel:externalId:ListDeployments' :: ListDeployments -> Maybe Text
externalId} -> Maybe Text
externalId) (\s :: ListDeployments
s@ListDeployments' {} Maybe Text
a -> ListDeployments
s {$sel:externalId:ListDeployments' :: Maybe Text
externalId = Maybe Text
a} :: ListDeployments)

-- | The name of a deployment group for the specified application.
--
-- If @deploymentGroupName@ is specified, then @applicationName@ must be
-- specified. If it is not specified, then @applicationName@ must not be
-- specified.
listDeployments_deploymentGroupName :: Lens.Lens' ListDeployments (Prelude.Maybe Prelude.Text)
listDeployments_deploymentGroupName :: (Maybe Text -> f (Maybe Text))
-> ListDeployments -> f ListDeployments
listDeployments_deploymentGroupName = (ListDeployments -> Maybe Text)
-> (ListDeployments -> Maybe Text -> ListDeployments)
-> Lens ListDeployments ListDeployments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeployments' {Maybe Text
deploymentGroupName :: Maybe Text
$sel:deploymentGroupName:ListDeployments' :: ListDeployments -> Maybe Text
deploymentGroupName} -> Maybe Text
deploymentGroupName) (\s :: ListDeployments
s@ListDeployments' {} Maybe Text
a -> ListDeployments
s {$sel:deploymentGroupName:ListDeployments' :: Maybe Text
deploymentGroupName = Maybe Text
a} :: ListDeployments)

instance Core.AWSPager ListDeployments where
  page :: ListDeployments
-> AWSResponse ListDeployments -> Maybe ListDeployments
page ListDeployments
rq AWSResponse ListDeployments
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDeployments
ListDeploymentsResponse
rs
            ListDeploymentsResponse
-> Getting (First Text) ListDeploymentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDeploymentsResponse
-> Const (First Text) ListDeploymentsResponse
Lens' ListDeploymentsResponse (Maybe Text)
listDeploymentsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDeploymentsResponse
 -> Const (First Text) ListDeploymentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDeploymentsResponse 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 ListDeployments
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDeployments
ListDeploymentsResponse
rs
            ListDeploymentsResponse
-> Getting (First [Text]) ListDeploymentsResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListDeploymentsResponse
-> Const (First [Text]) ListDeploymentsResponse
Lens' ListDeploymentsResponse (Maybe [Text])
listDeploymentsResponse_deployments
              ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListDeploymentsResponse
 -> Const (First [Text]) ListDeploymentsResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListDeploymentsResponse [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 ListDeployments
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListDeployments -> Maybe ListDeployments
forall a. a -> Maybe a
Prelude.Just (ListDeployments -> Maybe ListDeployments)
-> ListDeployments -> Maybe ListDeployments
forall a b. (a -> b) -> a -> b
Prelude.$
        ListDeployments
rq
          ListDeployments
-> (ListDeployments -> ListDeployments) -> ListDeployments
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListDeployments -> Identity ListDeployments
Lens ListDeployments ListDeployments (Maybe Text) (Maybe Text)
listDeployments_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListDeployments -> Identity ListDeployments)
-> Maybe Text -> ListDeployments -> ListDeployments
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDeployments
ListDeploymentsResponse
rs
          ListDeploymentsResponse
-> Getting (First Text) ListDeploymentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDeploymentsResponse
-> Const (First Text) ListDeploymentsResponse
Lens' ListDeploymentsResponse (Maybe Text)
listDeploymentsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDeploymentsResponse
 -> Const (First Text) ListDeploymentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDeploymentsResponse 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 ListDeployments where
  type
    AWSResponse ListDeployments =
      ListDeploymentsResponse
  request :: ListDeployments -> Request ListDeployments
request = Service -> ListDeployments -> Request ListDeployments
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDeployments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDeployments)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDeployments))
-> Logger
-> Service
-> Proxy ListDeployments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDeployments)))
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 -> Maybe [Text] -> Int -> ListDeploymentsResponse
ListDeploymentsResponse'
            (Maybe Text -> Maybe [Text] -> Int -> ListDeploymentsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Text] -> Int -> ListDeploymentsResponse)
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 (Maybe [Text] -> Int -> ListDeploymentsResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> ListDeploymentsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deployments" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListDeploymentsResponse)
-> Either String Int -> Either String ListDeploymentsResponse
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))
      )

instance Prelude.Hashable ListDeployments

instance Prelude.NFData ListDeployments

instance Core.ToHeaders ListDeployments where
  toHeaders :: ListDeployments -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListDeployments -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeDeploy_20141006.ListDeployments" ::
                          Prelude.ByteString
                      ),
            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 ListDeployments where
  toJSON :: ListDeployments -> Value
toJSON ListDeployments' {Maybe [DeploymentStatus]
Maybe Text
Maybe TimeRange
deploymentGroupName :: Maybe Text
externalId :: Maybe Text
applicationName :: Maybe Text
includeOnlyStatuses :: Maybe [DeploymentStatus]
nextToken :: Maybe Text
createTimeRange :: Maybe TimeRange
$sel:deploymentGroupName:ListDeployments' :: ListDeployments -> Maybe Text
$sel:externalId:ListDeployments' :: ListDeployments -> Maybe Text
$sel:applicationName:ListDeployments' :: ListDeployments -> Maybe Text
$sel:includeOnlyStatuses:ListDeployments' :: ListDeployments -> Maybe [DeploymentStatus]
$sel:nextToken:ListDeployments' :: ListDeployments -> Maybe Text
$sel:createTimeRange:ListDeployments' :: ListDeployments -> Maybe TimeRange
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"createTimeRange" Text -> TimeRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TimeRange -> Pair) -> Maybe TimeRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeRange
createTimeRange,
            (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,
            (Text
"includeOnlyStatuses" Text -> [DeploymentStatus] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([DeploymentStatus] -> Pair)
-> Maybe [DeploymentStatus] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DeploymentStatus]
includeOnlyStatuses,
            (Text
"applicationName" 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
applicationName,
            (Text
"externalId" 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
externalId,
            (Text
"deploymentGroupName" 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
deploymentGroupName
          ]
      )

instance Core.ToPath ListDeployments where
  toPath :: ListDeployments -> ByteString
toPath = ByteString -> ListDeployments -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | Represents the output of a @ListDeployments@ operation.
--
-- /See:/ 'newListDeploymentsResponse' smart constructor.
data ListDeploymentsResponse = ListDeploymentsResponse'
  { -- | If a large amount of information is returned, an identifier is also
    -- returned. It can be used in a subsequent list deployments call to return
    -- the next set of deployments in the list.
    ListDeploymentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of deployment IDs.
    ListDeploymentsResponse -> Maybe [Text]
deployments :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListDeploymentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDeploymentsResponse -> ListDeploymentsResponse -> Bool
(ListDeploymentsResponse -> ListDeploymentsResponse -> Bool)
-> (ListDeploymentsResponse -> ListDeploymentsResponse -> Bool)
-> Eq ListDeploymentsResponse
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]
(Int -> ReadS ListDeploymentsResponse)
-> ReadS [ListDeploymentsResponse]
-> ReadPrec ListDeploymentsResponse
-> ReadPrec [ListDeploymentsResponse]
-> Read 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
(Int -> ListDeploymentsResponse -> ShowS)
-> (ListDeploymentsResponse -> String)
-> ([ListDeploymentsResponse] -> ShowS)
-> Show ListDeploymentsResponse
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.
 ListDeploymentsResponse -> Rep ListDeploymentsResponse x)
-> (forall x.
    Rep ListDeploymentsResponse x -> ListDeploymentsResponse)
-> Generic ListDeploymentsResponse
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:
--
-- 'nextToken', 'listDeploymentsResponse_nextToken' - If a large amount of information is returned, an identifier is also
-- returned. It can be used in a subsequent list deployments call to return
-- the next set of deployments in the list.
--
-- 'deployments', 'listDeploymentsResponse_deployments' - A list of deployment IDs.
--
-- 'httpStatus', 'listDeploymentsResponse_httpStatus' - The response's http status code.
newListDeploymentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDeploymentsResponse
newListDeploymentsResponse :: Int -> ListDeploymentsResponse
newListDeploymentsResponse Int
pHttpStatus_ =
  ListDeploymentsResponse' :: Maybe Text -> Maybe [Text] -> Int -> ListDeploymentsResponse
ListDeploymentsResponse'
    { $sel:nextToken:ListDeploymentsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deployments:ListDeploymentsResponse' :: Maybe [Text]
deployments = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDeploymentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If a large amount of information is returned, an identifier is also
-- returned. It can be used in a subsequent list deployments call to return
-- the next set of deployments in the list.
listDeploymentsResponse_nextToken :: Lens.Lens' ListDeploymentsResponse (Prelude.Maybe Prelude.Text)
listDeploymentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDeploymentsResponse -> f ListDeploymentsResponse
listDeploymentsResponse_nextToken = (ListDeploymentsResponse -> Maybe Text)
-> (ListDeploymentsResponse
    -> Maybe Text -> ListDeploymentsResponse)
-> Lens' ListDeploymentsResponse (Maybe Text)
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)

-- | A list of deployment IDs.
listDeploymentsResponse_deployments :: Lens.Lens' ListDeploymentsResponse (Prelude.Maybe [Prelude.Text])
listDeploymentsResponse_deployments :: (Maybe [Text] -> f (Maybe [Text]))
-> ListDeploymentsResponse -> f ListDeploymentsResponse
listDeploymentsResponse_deployments = (ListDeploymentsResponse -> Maybe [Text])
-> (ListDeploymentsResponse
    -> Maybe [Text] -> ListDeploymentsResponse)
-> Lens' ListDeploymentsResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeploymentsResponse' {Maybe [Text]
deployments :: Maybe [Text]
$sel:deployments:ListDeploymentsResponse' :: ListDeploymentsResponse -> Maybe [Text]
deployments} -> Maybe [Text]
deployments) (\s :: ListDeploymentsResponse
s@ListDeploymentsResponse' {} Maybe [Text]
a -> ListDeploymentsResponse
s {$sel:deployments:ListDeploymentsResponse' :: Maybe [Text]
deployments = Maybe [Text]
a} :: ListDeploymentsResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListDeploymentsResponse -> f ListDeploymentsResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListDeploymentsResponse
-> f ListDeploymentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listDeploymentsResponse_httpStatus :: Lens.Lens' ListDeploymentsResponse Prelude.Int
listDeploymentsResponse_httpStatus :: (Int -> f Int)
-> ListDeploymentsResponse -> f ListDeploymentsResponse
listDeploymentsResponse_httpStatus = (ListDeploymentsResponse -> Int)
-> (ListDeploymentsResponse -> Int -> ListDeploymentsResponse)
-> Lens ListDeploymentsResponse ListDeploymentsResponse Int Int
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