{-# 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.Glue.BatchGetJobs
-- 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)
--
-- Returns a list of resource metadata for a given list of job names. After
-- calling the @ListJobs@ operation, you can call this operation to access
-- the data to which you have been granted permissions. This operation
-- supports all IAM permissions, including permission conditions that uses
-- tags.
module Amazonka.Glue.BatchGetJobs
  ( -- * Creating a Request
    BatchGetJobs (..),
    newBatchGetJobs,

    -- * Request Lenses
    batchGetJobs_jobNames,

    -- * Destructuring the Response
    BatchGetJobsResponse (..),
    newBatchGetJobsResponse,

    -- * Response Lenses
    batchGetJobsResponse_jobs,
    batchGetJobsResponse_jobsNotFound,
    batchGetJobsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newBatchGetJobs' smart constructor.
data BatchGetJobs = BatchGetJobs'
  { -- | A list of job names, which might be the names returned from the
    -- @ListJobs@ operation.
    BatchGetJobs -> [Text]
jobNames :: [Prelude.Text]
  }
  deriving (BatchGetJobs -> BatchGetJobs -> Bool
(BatchGetJobs -> BatchGetJobs -> Bool)
-> (BatchGetJobs -> BatchGetJobs -> Bool) -> Eq BatchGetJobs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetJobs -> BatchGetJobs -> Bool
$c/= :: BatchGetJobs -> BatchGetJobs -> Bool
== :: BatchGetJobs -> BatchGetJobs -> Bool
$c== :: BatchGetJobs -> BatchGetJobs -> Bool
Prelude.Eq, ReadPrec [BatchGetJobs]
ReadPrec BatchGetJobs
Int -> ReadS BatchGetJobs
ReadS [BatchGetJobs]
(Int -> ReadS BatchGetJobs)
-> ReadS [BatchGetJobs]
-> ReadPrec BatchGetJobs
-> ReadPrec [BatchGetJobs]
-> Read BatchGetJobs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetJobs]
$creadListPrec :: ReadPrec [BatchGetJobs]
readPrec :: ReadPrec BatchGetJobs
$creadPrec :: ReadPrec BatchGetJobs
readList :: ReadS [BatchGetJobs]
$creadList :: ReadS [BatchGetJobs]
readsPrec :: Int -> ReadS BatchGetJobs
$creadsPrec :: Int -> ReadS BatchGetJobs
Prelude.Read, Int -> BatchGetJobs -> ShowS
[BatchGetJobs] -> ShowS
BatchGetJobs -> String
(Int -> BatchGetJobs -> ShowS)
-> (BatchGetJobs -> String)
-> ([BatchGetJobs] -> ShowS)
-> Show BatchGetJobs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetJobs] -> ShowS
$cshowList :: [BatchGetJobs] -> ShowS
show :: BatchGetJobs -> String
$cshow :: BatchGetJobs -> String
showsPrec :: Int -> BatchGetJobs -> ShowS
$cshowsPrec :: Int -> BatchGetJobs -> ShowS
Prelude.Show, (forall x. BatchGetJobs -> Rep BatchGetJobs x)
-> (forall x. Rep BatchGetJobs x -> BatchGetJobs)
-> Generic BatchGetJobs
forall x. Rep BatchGetJobs x -> BatchGetJobs
forall x. BatchGetJobs -> Rep BatchGetJobs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetJobs x -> BatchGetJobs
$cfrom :: forall x. BatchGetJobs -> Rep BatchGetJobs x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetJobs' 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:
--
-- 'jobNames', 'batchGetJobs_jobNames' - A list of job names, which might be the names returned from the
-- @ListJobs@ operation.
newBatchGetJobs ::
  BatchGetJobs
newBatchGetJobs :: BatchGetJobs
newBatchGetJobs =
  BatchGetJobs' :: [Text] -> BatchGetJobs
BatchGetJobs' {$sel:jobNames:BatchGetJobs' :: [Text]
jobNames = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A list of job names, which might be the names returned from the
-- @ListJobs@ operation.
batchGetJobs_jobNames :: Lens.Lens' BatchGetJobs [Prelude.Text]
batchGetJobs_jobNames :: ([Text] -> f [Text]) -> BatchGetJobs -> f BatchGetJobs
batchGetJobs_jobNames = (BatchGetJobs -> [Text])
-> (BatchGetJobs -> [Text] -> BatchGetJobs)
-> Lens BatchGetJobs BatchGetJobs [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetJobs' {[Text]
jobNames :: [Text]
$sel:jobNames:BatchGetJobs' :: BatchGetJobs -> [Text]
jobNames} -> [Text]
jobNames) (\s :: BatchGetJobs
s@BatchGetJobs' {} [Text]
a -> BatchGetJobs
s {$sel:jobNames:BatchGetJobs' :: [Text]
jobNames = [Text]
a} :: BatchGetJobs) (([Text] -> f [Text]) -> BatchGetJobs -> f BatchGetJobs)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> BatchGetJobs
-> f BatchGetJobs
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 BatchGetJobs where
  type AWSResponse BatchGetJobs = BatchGetJobsResponse
  request :: BatchGetJobs -> Request BatchGetJobs
request = Service -> BatchGetJobs -> Request BatchGetJobs
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchGetJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetJobs)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchGetJobs))
-> Logger
-> Service
-> Proxy BatchGetJobs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchGetJobs)))
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 [Job] -> Maybe [Text] -> Int -> BatchGetJobsResponse
BatchGetJobsResponse'
            (Maybe [Job] -> Maybe [Text] -> Int -> BatchGetJobsResponse)
-> Either String (Maybe [Job])
-> Either String (Maybe [Text] -> Int -> BatchGetJobsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Job]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Jobs" Either String (Maybe (Maybe [Job]))
-> Maybe [Job] -> Either String (Maybe [Job])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Job]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe [Text] -> Int -> BatchGetJobsResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> BatchGetJobsResponse)
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
"JobsNotFound" 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 -> BatchGetJobsResponse)
-> Either String Int -> Either String BatchGetJobsResponse
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 BatchGetJobs

instance Prelude.NFData BatchGetJobs

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

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

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

-- | /See:/ 'newBatchGetJobsResponse' smart constructor.
data BatchGetJobsResponse = BatchGetJobsResponse'
  { -- | A list of job definitions.
    BatchGetJobsResponse -> Maybe [Job]
jobs :: Prelude.Maybe [Job],
    -- | A list of names of jobs not found.
    BatchGetJobsResponse -> Maybe [Text]
jobsNotFound :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    BatchGetJobsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchGetJobsResponse -> BatchGetJobsResponse -> Bool
(BatchGetJobsResponse -> BatchGetJobsResponse -> Bool)
-> (BatchGetJobsResponse -> BatchGetJobsResponse -> Bool)
-> Eq BatchGetJobsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchGetJobsResponse -> BatchGetJobsResponse -> Bool
$c/= :: BatchGetJobsResponse -> BatchGetJobsResponse -> Bool
== :: BatchGetJobsResponse -> BatchGetJobsResponse -> Bool
$c== :: BatchGetJobsResponse -> BatchGetJobsResponse -> Bool
Prelude.Eq, ReadPrec [BatchGetJobsResponse]
ReadPrec BatchGetJobsResponse
Int -> ReadS BatchGetJobsResponse
ReadS [BatchGetJobsResponse]
(Int -> ReadS BatchGetJobsResponse)
-> ReadS [BatchGetJobsResponse]
-> ReadPrec BatchGetJobsResponse
-> ReadPrec [BatchGetJobsResponse]
-> Read BatchGetJobsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchGetJobsResponse]
$creadListPrec :: ReadPrec [BatchGetJobsResponse]
readPrec :: ReadPrec BatchGetJobsResponse
$creadPrec :: ReadPrec BatchGetJobsResponse
readList :: ReadS [BatchGetJobsResponse]
$creadList :: ReadS [BatchGetJobsResponse]
readsPrec :: Int -> ReadS BatchGetJobsResponse
$creadsPrec :: Int -> ReadS BatchGetJobsResponse
Prelude.Read, Int -> BatchGetJobsResponse -> ShowS
[BatchGetJobsResponse] -> ShowS
BatchGetJobsResponse -> String
(Int -> BatchGetJobsResponse -> ShowS)
-> (BatchGetJobsResponse -> String)
-> ([BatchGetJobsResponse] -> ShowS)
-> Show BatchGetJobsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchGetJobsResponse] -> ShowS
$cshowList :: [BatchGetJobsResponse] -> ShowS
show :: BatchGetJobsResponse -> String
$cshow :: BatchGetJobsResponse -> String
showsPrec :: Int -> BatchGetJobsResponse -> ShowS
$cshowsPrec :: Int -> BatchGetJobsResponse -> ShowS
Prelude.Show, (forall x. BatchGetJobsResponse -> Rep BatchGetJobsResponse x)
-> (forall x. Rep BatchGetJobsResponse x -> BatchGetJobsResponse)
-> Generic BatchGetJobsResponse
forall x. Rep BatchGetJobsResponse x -> BatchGetJobsResponse
forall x. BatchGetJobsResponse -> Rep BatchGetJobsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchGetJobsResponse x -> BatchGetJobsResponse
$cfrom :: forall x. BatchGetJobsResponse -> Rep BatchGetJobsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchGetJobsResponse' 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:
--
-- 'jobs', 'batchGetJobsResponse_jobs' - A list of job definitions.
--
-- 'jobsNotFound', 'batchGetJobsResponse_jobsNotFound' - A list of names of jobs not found.
--
-- 'httpStatus', 'batchGetJobsResponse_httpStatus' - The response's http status code.
newBatchGetJobsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchGetJobsResponse
newBatchGetJobsResponse :: Int -> BatchGetJobsResponse
newBatchGetJobsResponse Int
pHttpStatus_ =
  BatchGetJobsResponse' :: Maybe [Job] -> Maybe [Text] -> Int -> BatchGetJobsResponse
BatchGetJobsResponse'
    { $sel:jobs:BatchGetJobsResponse' :: Maybe [Job]
jobs = Maybe [Job]
forall a. Maybe a
Prelude.Nothing,
      $sel:jobsNotFound:BatchGetJobsResponse' :: Maybe [Text]
jobsNotFound = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchGetJobsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of job definitions.
batchGetJobsResponse_jobs :: Lens.Lens' BatchGetJobsResponse (Prelude.Maybe [Job])
batchGetJobsResponse_jobs :: (Maybe [Job] -> f (Maybe [Job]))
-> BatchGetJobsResponse -> f BatchGetJobsResponse
batchGetJobsResponse_jobs = (BatchGetJobsResponse -> Maybe [Job])
-> (BatchGetJobsResponse -> Maybe [Job] -> BatchGetJobsResponse)
-> Lens
     BatchGetJobsResponse
     BatchGetJobsResponse
     (Maybe [Job])
     (Maybe [Job])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetJobsResponse' {Maybe [Job]
jobs :: Maybe [Job]
$sel:jobs:BatchGetJobsResponse' :: BatchGetJobsResponse -> Maybe [Job]
jobs} -> Maybe [Job]
jobs) (\s :: BatchGetJobsResponse
s@BatchGetJobsResponse' {} Maybe [Job]
a -> BatchGetJobsResponse
s {$sel:jobs:BatchGetJobsResponse' :: Maybe [Job]
jobs = Maybe [Job]
a} :: BatchGetJobsResponse) ((Maybe [Job] -> f (Maybe [Job]))
 -> BatchGetJobsResponse -> f BatchGetJobsResponse)
-> ((Maybe [Job] -> f (Maybe [Job]))
    -> Maybe [Job] -> f (Maybe [Job]))
-> (Maybe [Job] -> f (Maybe [Job]))
-> BatchGetJobsResponse
-> f BatchGetJobsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Job] [Job] [Job] [Job]
-> Iso (Maybe [Job]) (Maybe [Job]) (Maybe [Job]) (Maybe [Job])
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 [Job] [Job] [Job] [Job]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of names of jobs not found.
batchGetJobsResponse_jobsNotFound :: Lens.Lens' BatchGetJobsResponse (Prelude.Maybe [Prelude.Text])
batchGetJobsResponse_jobsNotFound :: (Maybe [Text] -> f (Maybe [Text]))
-> BatchGetJobsResponse -> f BatchGetJobsResponse
batchGetJobsResponse_jobsNotFound = (BatchGetJobsResponse -> Maybe [Text])
-> (BatchGetJobsResponse -> Maybe [Text] -> BatchGetJobsResponse)
-> Lens
     BatchGetJobsResponse
     BatchGetJobsResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetJobsResponse' {Maybe [Text]
jobsNotFound :: Maybe [Text]
$sel:jobsNotFound:BatchGetJobsResponse' :: BatchGetJobsResponse -> Maybe [Text]
jobsNotFound} -> Maybe [Text]
jobsNotFound) (\s :: BatchGetJobsResponse
s@BatchGetJobsResponse' {} Maybe [Text]
a -> BatchGetJobsResponse
s {$sel:jobsNotFound:BatchGetJobsResponse' :: Maybe [Text]
jobsNotFound = Maybe [Text]
a} :: BatchGetJobsResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> BatchGetJobsResponse -> f BatchGetJobsResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BatchGetJobsResponse
-> f BatchGetJobsResponse
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.
batchGetJobsResponse_httpStatus :: Lens.Lens' BatchGetJobsResponse Prelude.Int
batchGetJobsResponse_httpStatus :: (Int -> f Int) -> BatchGetJobsResponse -> f BatchGetJobsResponse
batchGetJobsResponse_httpStatus = (BatchGetJobsResponse -> Int)
-> (BatchGetJobsResponse -> Int -> BatchGetJobsResponse)
-> Lens BatchGetJobsResponse BatchGetJobsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchGetJobsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchGetJobsResponse' :: BatchGetJobsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchGetJobsResponse
s@BatchGetJobsResponse' {} Int
a -> BatchGetJobsResponse
s {$sel:httpStatus:BatchGetJobsResponse' :: Int
httpStatus = Int
a} :: BatchGetJobsResponse)

instance Prelude.NFData BatchGetJobsResponse