{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DataExchange.Types.JobEntry
-- 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)
module Amazonka.DataExchange.Types.JobEntry where

import qualified Amazonka.Core as Core
import Amazonka.DataExchange.Types.JobError
import Amazonka.DataExchange.Types.ResponseDetails
import Amazonka.DataExchange.Types.State
import Amazonka.DataExchange.Types.Type
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | AWS Data Exchange Jobs are asynchronous import or export operations used
-- to create or copy assets. A data set owner can both import and export as
-- they see fit. Someone with an entitlement to a data set can only export.
-- Jobs are deleted 90 days after they are created.
--
-- /See:/ 'newJobEntry' smart constructor.
data JobEntry = JobEntry'
  { -- | Errors for jobs.
    JobEntry -> Maybe [JobError]
errors :: Prelude.Maybe [JobError],
    -- | The job type.
    JobEntry -> Type
type' :: Type,
    -- | Details of the operation to be performed by the job, such as export
    -- destination details or import source details.
    JobEntry -> ResponseDetails
details :: ResponseDetails,
    -- | The state of the job.
    JobEntry -> State
state :: State,
    -- | The date and time that the job was created, in ISO 8601 format.
    JobEntry -> POSIX
createdAt :: Core.POSIX,
    -- | The unique identifier for the job.
    JobEntry -> Text
id :: Prelude.Text,
    -- | The ARN for the job.
    JobEntry -> Text
arn :: Prelude.Text,
    -- | The date and time that the job was last updated, in ISO 8601 format.
    JobEntry -> POSIX
updatedAt :: Core.POSIX
  }
  deriving (JobEntry -> JobEntry -> Bool
(JobEntry -> JobEntry -> Bool)
-> (JobEntry -> JobEntry -> Bool) -> Eq JobEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobEntry -> JobEntry -> Bool
$c/= :: JobEntry -> JobEntry -> Bool
== :: JobEntry -> JobEntry -> Bool
$c== :: JobEntry -> JobEntry -> Bool
Prelude.Eq, ReadPrec [JobEntry]
ReadPrec JobEntry
Int -> ReadS JobEntry
ReadS [JobEntry]
(Int -> ReadS JobEntry)
-> ReadS [JobEntry]
-> ReadPrec JobEntry
-> ReadPrec [JobEntry]
-> Read JobEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobEntry]
$creadListPrec :: ReadPrec [JobEntry]
readPrec :: ReadPrec JobEntry
$creadPrec :: ReadPrec JobEntry
readList :: ReadS [JobEntry]
$creadList :: ReadS [JobEntry]
readsPrec :: Int -> ReadS JobEntry
$creadsPrec :: Int -> ReadS JobEntry
Prelude.Read, Int -> JobEntry -> ShowS
[JobEntry] -> ShowS
JobEntry -> String
(Int -> JobEntry -> ShowS)
-> (JobEntry -> String) -> ([JobEntry] -> ShowS) -> Show JobEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobEntry] -> ShowS
$cshowList :: [JobEntry] -> ShowS
show :: JobEntry -> String
$cshow :: JobEntry -> String
showsPrec :: Int -> JobEntry -> ShowS
$cshowsPrec :: Int -> JobEntry -> ShowS
Prelude.Show, (forall x. JobEntry -> Rep JobEntry x)
-> (forall x. Rep JobEntry x -> JobEntry) -> Generic JobEntry
forall x. Rep JobEntry x -> JobEntry
forall x. JobEntry -> Rep JobEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobEntry x -> JobEntry
$cfrom :: forall x. JobEntry -> Rep JobEntry x
Prelude.Generic)

-- |
-- Create a value of 'JobEntry' 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:
--
-- 'errors', 'jobEntry_errors' - Errors for jobs.
--
-- 'type'', 'jobEntry_type' - The job type.
--
-- 'details', 'jobEntry_details' - Details of the operation to be performed by the job, such as export
-- destination details or import source details.
--
-- 'state', 'jobEntry_state' - The state of the job.
--
-- 'createdAt', 'jobEntry_createdAt' - The date and time that the job was created, in ISO 8601 format.
--
-- 'id', 'jobEntry_id' - The unique identifier for the job.
--
-- 'arn', 'jobEntry_arn' - The ARN for the job.
--
-- 'updatedAt', 'jobEntry_updatedAt' - The date and time that the job was last updated, in ISO 8601 format.
newJobEntry ::
  -- | 'type''
  Type ->
  -- | 'details'
  ResponseDetails ->
  -- | 'state'
  State ->
  -- | 'createdAt'
  Prelude.UTCTime ->
  -- | 'id'
  Prelude.Text ->
  -- | 'arn'
  Prelude.Text ->
  -- | 'updatedAt'
  Prelude.UTCTime ->
  JobEntry
newJobEntry :: Type
-> ResponseDetails
-> State
-> UTCTime
-> Text
-> Text
-> UTCTime
-> JobEntry
newJobEntry
  Type
pType_
  ResponseDetails
pDetails_
  State
pState_
  UTCTime
pCreatedAt_
  Text
pId_
  Text
pArn_
  UTCTime
pUpdatedAt_ =
    JobEntry' :: Maybe [JobError]
-> Type
-> ResponseDetails
-> State
-> POSIX
-> Text
-> Text
-> POSIX
-> JobEntry
JobEntry'
      { $sel:errors:JobEntry' :: Maybe [JobError]
errors = Maybe [JobError]
forall a. Maybe a
Prelude.Nothing,
        $sel:type':JobEntry' :: Type
type' = Type
pType_,
        $sel:details:JobEntry' :: ResponseDetails
details = ResponseDetails
pDetails_,
        $sel:state:JobEntry' :: State
state = State
pState_,
        $sel:createdAt:JobEntry' :: POSIX
createdAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedAt_,
        $sel:id:JobEntry' :: Text
id = Text
pId_,
        $sel:arn:JobEntry' :: Text
arn = Text
pArn_,
        $sel:updatedAt:JobEntry' :: POSIX
updatedAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pUpdatedAt_
      }

-- | Errors for jobs.
jobEntry_errors :: Lens.Lens' JobEntry (Prelude.Maybe [JobError])
jobEntry_errors :: (Maybe [JobError] -> f (Maybe [JobError]))
-> JobEntry -> f JobEntry
jobEntry_errors = (JobEntry -> Maybe [JobError])
-> (JobEntry -> Maybe [JobError] -> JobEntry)
-> Lens JobEntry JobEntry (Maybe [JobError]) (Maybe [JobError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {Maybe [JobError]
errors :: Maybe [JobError]
$sel:errors:JobEntry' :: JobEntry -> Maybe [JobError]
errors} -> Maybe [JobError]
errors) (\s :: JobEntry
s@JobEntry' {} Maybe [JobError]
a -> JobEntry
s {$sel:errors:JobEntry' :: Maybe [JobError]
errors = Maybe [JobError]
a} :: JobEntry) ((Maybe [JobError] -> f (Maybe [JobError]))
 -> JobEntry -> f JobEntry)
-> ((Maybe [JobError] -> f (Maybe [JobError]))
    -> Maybe [JobError] -> f (Maybe [JobError]))
-> (Maybe [JobError] -> f (Maybe [JobError]))
-> JobEntry
-> f JobEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [JobError] [JobError] [JobError] [JobError]
-> Iso
     (Maybe [JobError])
     (Maybe [JobError])
     (Maybe [JobError])
     (Maybe [JobError])
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 [JobError] [JobError] [JobError] [JobError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The job type.
jobEntry_type :: Lens.Lens' JobEntry Type
jobEntry_type :: (Type -> f Type) -> JobEntry -> f JobEntry
jobEntry_type = (JobEntry -> Type)
-> (JobEntry -> Type -> JobEntry)
-> Lens JobEntry JobEntry Type Type
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {Type
type' :: Type
$sel:type':JobEntry' :: JobEntry -> Type
type'} -> Type
type') (\s :: JobEntry
s@JobEntry' {} Type
a -> JobEntry
s {$sel:type':JobEntry' :: Type
type' = Type
a} :: JobEntry)

-- | Details of the operation to be performed by the job, such as export
-- destination details or import source details.
jobEntry_details :: Lens.Lens' JobEntry ResponseDetails
jobEntry_details :: (ResponseDetails -> f ResponseDetails) -> JobEntry -> f JobEntry
jobEntry_details = (JobEntry -> ResponseDetails)
-> (JobEntry -> ResponseDetails -> JobEntry)
-> Lens JobEntry JobEntry ResponseDetails ResponseDetails
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {ResponseDetails
details :: ResponseDetails
$sel:details:JobEntry' :: JobEntry -> ResponseDetails
details} -> ResponseDetails
details) (\s :: JobEntry
s@JobEntry' {} ResponseDetails
a -> JobEntry
s {$sel:details:JobEntry' :: ResponseDetails
details = ResponseDetails
a} :: JobEntry)

-- | The state of the job.
jobEntry_state :: Lens.Lens' JobEntry State
jobEntry_state :: (State -> f State) -> JobEntry -> f JobEntry
jobEntry_state = (JobEntry -> State)
-> (JobEntry -> State -> JobEntry)
-> Lens JobEntry JobEntry State State
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {State
state :: State
$sel:state:JobEntry' :: JobEntry -> State
state} -> State
state) (\s :: JobEntry
s@JobEntry' {} State
a -> JobEntry
s {$sel:state:JobEntry' :: State
state = State
a} :: JobEntry)

-- | The date and time that the job was created, in ISO 8601 format.
jobEntry_createdAt :: Lens.Lens' JobEntry Prelude.UTCTime
jobEntry_createdAt :: (UTCTime -> f UTCTime) -> JobEntry -> f JobEntry
jobEntry_createdAt = (JobEntry -> POSIX)
-> (JobEntry -> POSIX -> JobEntry)
-> Lens JobEntry JobEntry POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {POSIX
createdAt :: POSIX
$sel:createdAt:JobEntry' :: JobEntry -> POSIX
createdAt} -> POSIX
createdAt) (\s :: JobEntry
s@JobEntry' {} POSIX
a -> JobEntry
s {$sel:createdAt:JobEntry' :: POSIX
createdAt = POSIX
a} :: JobEntry) ((POSIX -> f POSIX) -> JobEntry -> f JobEntry)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> JobEntry
-> f JobEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The unique identifier for the job.
jobEntry_id :: Lens.Lens' JobEntry Prelude.Text
jobEntry_id :: (Text -> f Text) -> JobEntry -> f JobEntry
jobEntry_id = (JobEntry -> Text)
-> (JobEntry -> Text -> JobEntry)
-> Lens JobEntry JobEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {Text
id :: Text
$sel:id:JobEntry' :: JobEntry -> Text
id} -> Text
id) (\s :: JobEntry
s@JobEntry' {} Text
a -> JobEntry
s {$sel:id:JobEntry' :: Text
id = Text
a} :: JobEntry)

-- | The ARN for the job.
jobEntry_arn :: Lens.Lens' JobEntry Prelude.Text
jobEntry_arn :: (Text -> f Text) -> JobEntry -> f JobEntry
jobEntry_arn = (JobEntry -> Text)
-> (JobEntry -> Text -> JobEntry)
-> Lens JobEntry JobEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {Text
arn :: Text
$sel:arn:JobEntry' :: JobEntry -> Text
arn} -> Text
arn) (\s :: JobEntry
s@JobEntry' {} Text
a -> JobEntry
s {$sel:arn:JobEntry' :: Text
arn = Text
a} :: JobEntry)

-- | The date and time that the job was last updated, in ISO 8601 format.
jobEntry_updatedAt :: Lens.Lens' JobEntry Prelude.UTCTime
jobEntry_updatedAt :: (UTCTime -> f UTCTime) -> JobEntry -> f JobEntry
jobEntry_updatedAt = (JobEntry -> POSIX)
-> (JobEntry -> POSIX -> JobEntry)
-> Lens JobEntry JobEntry POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobEntry' {POSIX
updatedAt :: POSIX
$sel:updatedAt:JobEntry' :: JobEntry -> POSIX
updatedAt} -> POSIX
updatedAt) (\s :: JobEntry
s@JobEntry' {} POSIX
a -> JobEntry
s {$sel:updatedAt:JobEntry' :: POSIX
updatedAt = POSIX
a} :: JobEntry) ((POSIX -> f POSIX) -> JobEntry -> f JobEntry)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> JobEntry
-> f JobEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON JobEntry where
  parseJSON :: Value -> Parser JobEntry
parseJSON =
    String -> (Object -> Parser JobEntry) -> Value -> Parser JobEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobEntry"
      ( \Object
x ->
          Maybe [JobError]
-> Type
-> ResponseDetails
-> State
-> POSIX
-> Text
-> Text
-> POSIX
-> JobEntry
JobEntry'
            (Maybe [JobError]
 -> Type
 -> ResponseDetails
 -> State
 -> POSIX
 -> Text
 -> Text
 -> POSIX
 -> JobEntry)
-> Parser (Maybe [JobError])
-> Parser
     (Type
      -> ResponseDetails
      -> State
      -> POSIX
      -> Text
      -> Text
      -> POSIX
      -> JobEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [JobError]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Errors" Parser (Maybe (Maybe [JobError]))
-> Maybe [JobError] -> Parser (Maybe [JobError])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [JobError]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Type
   -> ResponseDetails
   -> State
   -> POSIX
   -> Text
   -> Text
   -> POSIX
   -> JobEntry)
-> Parser Type
-> Parser
     (ResponseDetails
      -> State -> POSIX -> Text -> Text -> POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Type
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
            Parser
  (ResponseDetails
   -> State -> POSIX -> Text -> Text -> POSIX -> JobEntry)
-> Parser ResponseDetails
-> Parser (State -> POSIX -> Text -> Text -> POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResponseDetails
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Details")
            Parser (State -> POSIX -> Text -> Text -> POSIX -> JobEntry)
-> Parser State
-> Parser (POSIX -> Text -> Text -> POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser State
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"State")
            Parser (POSIX -> Text -> Text -> POSIX -> JobEntry)
-> Parser POSIX -> Parser (Text -> Text -> POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CreatedAt")
            Parser (Text -> Text -> POSIX -> JobEntry)
-> Parser Text -> Parser (Text -> POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
            Parser (Text -> POSIX -> JobEntry)
-> Parser Text -> Parser (POSIX -> JobEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Arn")
            Parser (POSIX -> JobEntry) -> Parser POSIX -> Parser JobEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"UpdatedAt")
      )

instance Prelude.Hashable JobEntry

instance Prelude.NFData JobEntry