{-# 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.BatchGetApplications
-- 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 applications. The maximum number of
-- applications that can be returned is 100.
module Amazonka.CodeDeploy.BatchGetApplications
  ( -- * Creating a Request
    BatchGetApplications (..),
    newBatchGetApplications,

    -- * Request Lenses
    batchGetApplications_applicationNames,

    -- * Destructuring the Response
    BatchGetApplicationsResponse (..),
    newBatchGetApplicationsResponse,

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

-- |
-- Create a value of 'BatchGetApplications' 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:
--
-- 'applicationNames', 'batchGetApplications_applicationNames' - A list of application names separated by spaces. The maximum number of
-- application names you can specify is 100.
newBatchGetApplications ::
  BatchGetApplications
newBatchGetApplications :: BatchGetApplications
newBatchGetApplications =
  BatchGetApplications' :: [Text] -> BatchGetApplications
BatchGetApplications'
    { $sel:applicationNames:BatchGetApplications' :: [Text]
applicationNames =
        [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A list of application names separated by spaces. The maximum number of
-- application names you can specify is 100.
batchGetApplications_applicationNames :: Lens.Lens' BatchGetApplications [Prelude.Text]
batchGetApplications_applicationNames :: ([Text] -> f [Text])
-> BatchGetApplications -> f BatchGetApplications
batchGetApplications_applicationNames = (BatchGetApplications -> [Text])
-> (BatchGetApplications -> [Text] -> BatchGetApplications)
-> Lens BatchGetApplications BatchGetApplications [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetApplications' {[Text]
applicationNames :: [Text]
$sel:applicationNames:BatchGetApplications' :: BatchGetApplications -> [Text]
applicationNames} -> [Text]
applicationNames) (\s :: BatchGetApplications
s@BatchGetApplications' {} [Text]
a -> BatchGetApplications
s {$sel:applicationNames:BatchGetApplications' :: [Text]
applicationNames = [Text]
a} :: BatchGetApplications) (([Text] -> f [Text])
 -> BatchGetApplications -> f BatchGetApplications)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> BatchGetApplications
-> f BatchGetApplications
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 BatchGetApplications where
  type
    AWSResponse BatchGetApplications =
      BatchGetApplicationsResponse
  request :: BatchGetApplications -> Request BatchGetApplications
request = Service -> BatchGetApplications -> Request BatchGetApplications
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchGetApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetApplications)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchGetApplications))
-> Logger
-> Service
-> Proxy BatchGetApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetApplications)))
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 [ApplicationInfo] -> Int -> BatchGetApplicationsResponse
BatchGetApplicationsResponse'
            (Maybe [ApplicationInfo] -> Int -> BatchGetApplicationsResponse)
-> Either String (Maybe [ApplicationInfo])
-> Either String (Int -> BatchGetApplicationsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ApplicationInfo]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"applicationsInfo"
                            Either String (Maybe (Maybe [ApplicationInfo]))
-> Maybe [ApplicationInfo]
-> Either String (Maybe [ApplicationInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ApplicationInfo]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> BatchGetApplicationsResponse)
-> Either String Int -> Either String BatchGetApplicationsResponse
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 BatchGetApplications

instance Prelude.NFData BatchGetApplications

instance Core.ToHeaders BatchGetApplications where
  toHeaders :: BatchGetApplications -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BatchGetApplications -> 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.BatchGetApplications" ::
                          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 BatchGetApplications where
  toJSON :: BatchGetApplications -> Value
toJSON BatchGetApplications' {[Text]
applicationNames :: [Text]
$sel:applicationNames:BatchGetApplications' :: BatchGetApplications -> [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
"applicationNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
applicationNames)
          ]
      )

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

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

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

-- |
-- Create a value of 'BatchGetApplicationsResponse' 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:
--
-- 'applicationsInfo', 'batchGetApplicationsResponse_applicationsInfo' - Information about the applications.
--
-- 'httpStatus', 'batchGetApplicationsResponse_httpStatus' - The response's http status code.
newBatchGetApplicationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetApplicationsResponse
newBatchGetApplicationsResponse :: Int -> BatchGetApplicationsResponse
newBatchGetApplicationsResponse Int
pHttpStatus_ =
  BatchGetApplicationsResponse' :: Maybe [ApplicationInfo] -> Int -> BatchGetApplicationsResponse
BatchGetApplicationsResponse'
    { $sel:applicationsInfo:BatchGetApplicationsResponse' :: Maybe [ApplicationInfo]
applicationsInfo =
        Maybe [ApplicationInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetApplicationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData BatchGetApplicationsResponse