{-# 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.BatchGetDeployments
-- 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)
--
-- Gets information about one or more deployments. The maximum number of
-- deployments that can be returned is 25.
module Amazonka.CodeDeploy.BatchGetDeployments
  ( -- * Creating a Request
    BatchGetDeployments (..),
    newBatchGetDeployments,

    -- * Request Lenses
    batchGetDeployments_deploymentIds,

    -- * Destructuring the Response
    BatchGetDeploymentsResponse (..),
    newBatchGetDeploymentsResponse,

    -- * Response Lenses
    batchGetDeploymentsResponse_deploymentsInfo,
    batchGetDeploymentsResponse_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 @BatchGetDeployments@ operation.
--
-- /See:/ 'newBatchGetDeployments' smart constructor.
data BatchGetDeployments = BatchGetDeployments'
  { -- | A list of deployment IDs, separated by spaces. The maximum number of
    -- deployment IDs you can specify is 25.
    BatchGetDeployments -> [Text]
deploymentIds :: [Prelude.Text]
  }
  deriving (BatchGetDeployments -> BatchGetDeployments -> Bool
(BatchGetDeployments -> BatchGetDeployments -> Bool)
-> (BatchGetDeployments -> BatchGetDeployments -> Bool)
-> Eq BatchGetDeployments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetDeployments -> BatchGetDeployments -> Bool
$c/= :: BatchGetDeployments -> BatchGetDeployments -> Bool
== :: BatchGetDeployments -> BatchGetDeployments -> Bool
$c== :: BatchGetDeployments -> BatchGetDeployments -> Bool
Prelude.Eq, ReadPrec [BatchGetDeployments]
ReadPrec BatchGetDeployments
Int -> ReadS BatchGetDeployments
ReadS [BatchGetDeployments]
(Int -> ReadS BatchGetDeployments)
-> ReadS [BatchGetDeployments]
-> ReadPrec BatchGetDeployments
-> ReadPrec [BatchGetDeployments]
-> Read BatchGetDeployments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetDeployments]
$creadListPrec :: ReadPrec [BatchGetDeployments]
readPrec :: ReadPrec BatchGetDeployments
$creadPrec :: ReadPrec BatchGetDeployments
readList :: ReadS [BatchGetDeployments]
$creadList :: ReadS [BatchGetDeployments]
readsPrec :: Int -> ReadS BatchGetDeployments
$creadsPrec :: Int -> ReadS BatchGetDeployments
Prelude.Read, Int -> BatchGetDeployments -> ShowS
[BatchGetDeployments] -> ShowS
BatchGetDeployments -> String
(Int -> BatchGetDeployments -> ShowS)
-> (BatchGetDeployments -> String)
-> ([BatchGetDeployments] -> ShowS)
-> Show BatchGetDeployments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetDeployments] -> ShowS
$cshowList :: [BatchGetDeployments] -> ShowS
show :: BatchGetDeployments -> String
$cshow :: BatchGetDeployments -> String
showsPrec :: Int -> BatchGetDeployments -> ShowS
$cshowsPrec :: Int -> BatchGetDeployments -> ShowS
Prelude.Show, (forall x. BatchGetDeployments -> Rep BatchGetDeployments x)
-> (forall x. Rep BatchGetDeployments x -> BatchGetDeployments)
-> Generic BatchGetDeployments
forall x. Rep BatchGetDeployments x -> BatchGetDeployments
forall x. BatchGetDeployments -> Rep BatchGetDeployments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetDeployments x -> BatchGetDeployments
$cfrom :: forall x. BatchGetDeployments -> Rep BatchGetDeployments x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetDeployments' 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:
--
-- 'deploymentIds', 'batchGetDeployments_deploymentIds' - A list of deployment IDs, separated by spaces. The maximum number of
-- deployment IDs you can specify is 25.
newBatchGetDeployments ::
  BatchGetDeployments
newBatchGetDeployments :: BatchGetDeployments
newBatchGetDeployments =
  BatchGetDeployments' :: [Text] -> BatchGetDeployments
BatchGetDeployments'
    { $sel:deploymentIds:BatchGetDeployments' :: [Text]
deploymentIds =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of deployment IDs, separated by spaces. The maximum number of
-- deployment IDs you can specify is 25.
batchGetDeployments_deploymentIds :: Lens.Lens' BatchGetDeployments [Prelude.Text]
batchGetDeployments_deploymentIds :: ([Text] -> f [Text])
-> BatchGetDeployments -> f BatchGetDeployments
batchGetDeployments_deploymentIds = (BatchGetDeployments -> [Text])
-> (BatchGetDeployments -> [Text] -> BatchGetDeployments)
-> Lens BatchGetDeployments BatchGetDeployments [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDeployments' {[Text]
deploymentIds :: [Text]
$sel:deploymentIds:BatchGetDeployments' :: BatchGetDeployments -> [Text]
deploymentIds} -> [Text]
deploymentIds) (\s :: BatchGetDeployments
s@BatchGetDeployments' {} [Text]
a -> BatchGetDeployments
s {$sel:deploymentIds:BatchGetDeployments' :: [Text]
deploymentIds = [Text]
a} :: BatchGetDeployments) (([Text] -> f [Text])
 -> BatchGetDeployments -> f BatchGetDeployments)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> BatchGetDeployments
-> f BatchGetDeployments
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchGetDeployments where
  type
    AWSResponse BatchGetDeployments =
      BatchGetDeploymentsResponse
  request :: BatchGetDeployments -> Request BatchGetDeployments
request = Service -> BatchGetDeployments -> Request BatchGetDeployments
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchGetDeployments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetDeployments)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchGetDeployments))
-> Logger
-> Service
-> Proxy BatchGetDeployments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetDeployments)))
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 [DeploymentInfo] -> Int -> BatchGetDeploymentsResponse
BatchGetDeploymentsResponse'
            (Maybe [DeploymentInfo] -> Int -> BatchGetDeploymentsResponse)
-> Either String (Maybe [DeploymentInfo])
-> Either String (Int -> BatchGetDeploymentsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [DeploymentInfo]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deploymentsInfo"
                            Either String (Maybe (Maybe [DeploymentInfo]))
-> Maybe [DeploymentInfo] -> Either String (Maybe [DeploymentInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DeploymentInfo]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> BatchGetDeploymentsResponse)
-> Either String Int -> Either String BatchGetDeploymentsResponse
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 BatchGetDeployments

instance Prelude.NFData BatchGetDeployments

instance Core.ToHeaders BatchGetDeployments where
  toHeaders :: BatchGetDeployments -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BatchGetDeployments -> 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.BatchGetDeployments" ::
                          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 BatchGetDeployments where
  toJSON :: BatchGetDeployments -> Value
toJSON BatchGetDeployments' {[Text]
deploymentIds :: [Text]
$sel:deploymentIds:BatchGetDeployments' :: BatchGetDeployments -> [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"deploymentIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
deploymentIds)
          ]
      )

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

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

-- | Represents the output of a @BatchGetDeployments@ operation.
--
-- /See:/ 'newBatchGetDeploymentsResponse' smart constructor.
data BatchGetDeploymentsResponse = BatchGetDeploymentsResponse'
  { -- | Information about the deployments.
    BatchGetDeploymentsResponse -> Maybe [DeploymentInfo]
deploymentsInfo :: Prelude.Maybe [DeploymentInfo],
    -- | The response's http status code.
    BatchGetDeploymentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetDeploymentsResponse -> BatchGetDeploymentsResponse -> Bool
(BatchGetDeploymentsResponse
 -> BatchGetDeploymentsResponse -> Bool)
-> (BatchGetDeploymentsResponse
    -> BatchGetDeploymentsResponse -> Bool)
-> Eq BatchGetDeploymentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetDeploymentsResponse -> BatchGetDeploymentsResponse -> Bool
$c/= :: BatchGetDeploymentsResponse -> BatchGetDeploymentsResponse -> Bool
== :: BatchGetDeploymentsResponse -> BatchGetDeploymentsResponse -> Bool
$c== :: BatchGetDeploymentsResponse -> BatchGetDeploymentsResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetDeploymentsResponse]
ReadPrec BatchGetDeploymentsResponse
Int -> ReadS BatchGetDeploymentsResponse
ReadS [BatchGetDeploymentsResponse]
(Int -> ReadS BatchGetDeploymentsResponse)
-> ReadS [BatchGetDeploymentsResponse]
-> ReadPrec BatchGetDeploymentsResponse
-> ReadPrec [BatchGetDeploymentsResponse]
-> Read BatchGetDeploymentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetDeploymentsResponse]
$creadListPrec :: ReadPrec [BatchGetDeploymentsResponse]
readPrec :: ReadPrec BatchGetDeploymentsResponse
$creadPrec :: ReadPrec BatchGetDeploymentsResponse
readList :: ReadS [BatchGetDeploymentsResponse]
$creadList :: ReadS [BatchGetDeploymentsResponse]
readsPrec :: Int -> ReadS BatchGetDeploymentsResponse
$creadsPrec :: Int -> ReadS BatchGetDeploymentsResponse
Prelude.Read, Int -> BatchGetDeploymentsResponse -> ShowS
[BatchGetDeploymentsResponse] -> ShowS
BatchGetDeploymentsResponse -> String
(Int -> BatchGetDeploymentsResponse -> ShowS)
-> (BatchGetDeploymentsResponse -> String)
-> ([BatchGetDeploymentsResponse] -> ShowS)
-> Show BatchGetDeploymentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetDeploymentsResponse] -> ShowS
$cshowList :: [BatchGetDeploymentsResponse] -> ShowS
show :: BatchGetDeploymentsResponse -> String
$cshow :: BatchGetDeploymentsResponse -> String
showsPrec :: Int -> BatchGetDeploymentsResponse -> ShowS
$cshowsPrec :: Int -> BatchGetDeploymentsResponse -> ShowS
Prelude.Show, (forall x.
 BatchGetDeploymentsResponse -> Rep BatchGetDeploymentsResponse x)
-> (forall x.
    Rep BatchGetDeploymentsResponse x -> BatchGetDeploymentsResponse)
-> Generic BatchGetDeploymentsResponse
forall x.
Rep BatchGetDeploymentsResponse x -> BatchGetDeploymentsResponse
forall x.
BatchGetDeploymentsResponse -> Rep BatchGetDeploymentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchGetDeploymentsResponse x -> BatchGetDeploymentsResponse
$cfrom :: forall x.
BatchGetDeploymentsResponse -> Rep BatchGetDeploymentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetDeploymentsResponse' 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:
--
-- 'deploymentsInfo', 'batchGetDeploymentsResponse_deploymentsInfo' - Information about the deployments.
--
-- 'httpStatus', 'batchGetDeploymentsResponse_httpStatus' - The response's http status code.
newBatchGetDeploymentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetDeploymentsResponse
newBatchGetDeploymentsResponse :: Int -> BatchGetDeploymentsResponse
newBatchGetDeploymentsResponse Int
pHttpStatus_ =
  BatchGetDeploymentsResponse' :: Maybe [DeploymentInfo] -> Int -> BatchGetDeploymentsResponse
BatchGetDeploymentsResponse'
    { $sel:deploymentsInfo:BatchGetDeploymentsResponse' :: Maybe [DeploymentInfo]
deploymentsInfo =
        Maybe [DeploymentInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetDeploymentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deployments.
batchGetDeploymentsResponse_deploymentsInfo :: Lens.Lens' BatchGetDeploymentsResponse (Prelude.Maybe [DeploymentInfo])
batchGetDeploymentsResponse_deploymentsInfo :: (Maybe [DeploymentInfo] -> f (Maybe [DeploymentInfo]))
-> BatchGetDeploymentsResponse -> f BatchGetDeploymentsResponse
batchGetDeploymentsResponse_deploymentsInfo = (BatchGetDeploymentsResponse -> Maybe [DeploymentInfo])
-> (BatchGetDeploymentsResponse
    -> Maybe [DeploymentInfo] -> BatchGetDeploymentsResponse)
-> Lens
     BatchGetDeploymentsResponse
     BatchGetDeploymentsResponse
     (Maybe [DeploymentInfo])
     (Maybe [DeploymentInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetDeploymentsResponse' {Maybe [DeploymentInfo]
deploymentsInfo :: Maybe [DeploymentInfo]
$sel:deploymentsInfo:BatchGetDeploymentsResponse' :: BatchGetDeploymentsResponse -> Maybe [DeploymentInfo]
deploymentsInfo} -> Maybe [DeploymentInfo]
deploymentsInfo) (\s :: BatchGetDeploymentsResponse
s@BatchGetDeploymentsResponse' {} Maybe [DeploymentInfo]
a -> BatchGetDeploymentsResponse
s {$sel:deploymentsInfo:BatchGetDeploymentsResponse' :: Maybe [DeploymentInfo]
deploymentsInfo = Maybe [DeploymentInfo]
a} :: BatchGetDeploymentsResponse) ((Maybe [DeploymentInfo] -> f (Maybe [DeploymentInfo]))
 -> BatchGetDeploymentsResponse -> f BatchGetDeploymentsResponse)
-> ((Maybe [DeploymentInfo] -> f (Maybe [DeploymentInfo]))
    -> Maybe [DeploymentInfo] -> f (Maybe [DeploymentInfo]))
-> (Maybe [DeploymentInfo] -> f (Maybe [DeploymentInfo]))
-> BatchGetDeploymentsResponse
-> f BatchGetDeploymentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DeploymentInfo] [DeploymentInfo] [DeploymentInfo] [DeploymentInfo]
-> Iso
     (Maybe [DeploymentInfo])
     (Maybe [DeploymentInfo])
     (Maybe [DeploymentInfo])
     (Maybe [DeploymentInfo])
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
  [DeploymentInfo] [DeploymentInfo] [DeploymentInfo] [DeploymentInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchGetDeploymentsResponse