{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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

-- | 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
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]
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
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. 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'
    { $sel:applicationNames:BatchGetApplications' :: [Text]
applicationNames =
        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 :: Lens' BatchGetApplications [Text]
batchGetApplications_applicationNames = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: (Service -> Service)
-> BatchGetApplications -> Request BatchGetApplications
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchGetApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchGetApplications)))
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 [ApplicationInfo] -> Int -> BatchGetApplicationsResponse
BatchGetApplicationsResponse'
            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
"applicationsInfo"
                            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable BatchGetApplications where
  hashWithSalt :: Int -> BatchGetApplications -> Int
hashWithSalt Int
_salt BatchGetApplications' {[Text]
applicationNames :: [Text]
$sel:applicationNames:BatchGetApplications' :: BatchGetApplications -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
applicationNames

instance Prelude.NFData BatchGetApplications where
  rnf :: BatchGetApplications -> ()
rnf BatchGetApplications' {[Text]
applicationNames :: [Text]
$sel:applicationNames:BatchGetApplications' :: BatchGetApplications -> [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [Text]
applicationNames

instance Data.ToHeaders BatchGetApplications where
  toHeaders :: BatchGetApplications -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"CodeDeploy_20141006.BatchGetApplications" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchGetApplications where
  toJSON :: BatchGetApplications -> Value
toJSON BatchGetApplications' {[Text]
applicationNames :: [Text]
$sel:applicationNames:BatchGetApplications' :: BatchGetApplications -> [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"applicationNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
applicationNames)
          ]
      )

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

instance Data.ToQuery BatchGetApplications where
  toQuery :: BatchGetApplications -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:applicationsInfo:BatchGetApplicationsResponse' :: Maybe [ApplicationInfo]
applicationsInfo =
        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 :: Lens' BatchGetApplicationsResponse (Maybe [ApplicationInfo])
batchGetApplicationsResponse_applicationsInfo = 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) 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 response's http status code.
batchGetApplicationsResponse_httpStatus :: Lens.Lens' BatchGetApplicationsResponse Prelude.Int
batchGetApplicationsResponse_httpStatus :: Lens' BatchGetApplicationsResponse Int
batchGetApplicationsResponse_httpStatus = 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 where
  rnf :: BatchGetApplicationsResponse -> ()
rnf BatchGetApplicationsResponse' {Int
Maybe [ApplicationInfo]
httpStatus :: Int
applicationsInfo :: Maybe [ApplicationInfo]
$sel:httpStatus:BatchGetApplicationsResponse' :: BatchGetApplicationsResponse -> Int
$sel:applicationsInfo:BatchGetApplicationsResponse' :: BatchGetApplicationsResponse -> Maybe [ApplicationInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ApplicationInfo]
applicationsInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus