{-# 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.Panorama.Types.Job
-- 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.Panorama.Types.Job where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A job for a device.
--
-- /See:/ 'newJob' smart constructor.
data Job = Job'
  { -- | The job\'s ID.
    Job -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The target device\'s ID.
    Job -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text
  }
  deriving (Job -> Job -> Bool
(Job -> Job -> Bool) -> (Job -> Job -> Bool) -> Eq Job
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Job -> Job -> Bool
$c/= :: Job -> Job -> Bool
== :: Job -> Job -> Bool
$c== :: Job -> Job -> Bool
Prelude.Eq, ReadPrec [Job]
ReadPrec Job
Int -> ReadS Job
ReadS [Job]
(Int -> ReadS Job)
-> ReadS [Job] -> ReadPrec Job -> ReadPrec [Job] -> Read Job
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Job]
$creadListPrec :: ReadPrec [Job]
readPrec :: ReadPrec Job
$creadPrec :: ReadPrec Job
readList :: ReadS [Job]
$creadList :: ReadS [Job]
readsPrec :: Int -> ReadS Job
$creadsPrec :: Int -> ReadS Job
Prelude.Read, Int -> Job -> ShowS
[Job] -> ShowS
Job -> String
(Int -> Job -> ShowS)
-> (Job -> String) -> ([Job] -> ShowS) -> Show Job
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Job] -> ShowS
$cshowList :: [Job] -> ShowS
show :: Job -> String
$cshow :: Job -> String
showsPrec :: Int -> Job -> ShowS
$cshowsPrec :: Int -> Job -> ShowS
Prelude.Show, (forall x. Job -> Rep Job x)
-> (forall x. Rep Job x -> Job) -> Generic Job
forall x. Rep Job x -> Job
forall x. Job -> Rep Job x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Job x -> Job
$cfrom :: forall x. Job -> Rep Job x
Prelude.Generic)

-- |
-- Create a value of 'Job' 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:
--
-- 'jobId', 'job_jobId' - The job\'s ID.
--
-- 'deviceId', 'job_deviceId' - The target device\'s ID.
newJob ::
  Job
newJob :: Job
newJob =
  Job' :: Maybe Text -> Maybe Text -> Job
Job'
    { $sel:jobId:Job' :: Maybe Text
jobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:Job' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The job\'s ID.
job_jobId :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_jobId :: (Maybe Text -> f (Maybe Text)) -> Job -> f Job
job_jobId = (Job -> Maybe Text)
-> (Job -> Maybe Text -> Job)
-> Lens Job Job (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe Text
jobId :: Maybe Text
$sel:jobId:Job' :: Job -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: Job
s@Job' {} Maybe Text
a -> Job
s {$sel:jobId:Job' :: Maybe Text
jobId = Maybe Text
a} :: Job)

-- | The target device\'s ID.
job_deviceId :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_deviceId :: (Maybe Text -> f (Maybe Text)) -> Job -> f Job
job_deviceId = (Job -> Maybe Text)
-> (Job -> Maybe Text -> Job)
-> Lens Job Job (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:Job' :: Job -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: Job
s@Job' {} Maybe Text
a -> Job
s {$sel:deviceId:Job' :: Maybe Text
deviceId = Maybe Text
a} :: Job)

instance Core.FromJSON Job where
  parseJSON :: Value -> Parser Job
parseJSON =
    String -> (Object -> Parser Job) -> Value -> Parser Job
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Job"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Job
Job'
            (Maybe Text -> Maybe Text -> Job)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Job)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JobId")
            Parser (Maybe Text -> Job) -> Parser (Maybe Text) -> Parser Job
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceId")
      )

instance Prelude.Hashable Job

instance Prelude.NFData Job