{-# 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.Snowball.Types.JobResource
-- 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.Snowball.Types.JobResource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Snowball.Types.Ec2AmiResource
import Amazonka.Snowball.Types.LambdaResource
import Amazonka.Snowball.Types.S3Resource

-- | Contains an array of AWS resource objects. Each object represents an
-- Amazon S3 bucket, an AWS Lambda function, or an Amazon Machine Image
-- (AMI) based on Amazon EC2 that is associated with a particular job.
--
-- /See:/ 'newJobResource' smart constructor.
data JobResource = JobResource'
  { -- | The Amazon Machine Images (AMIs) associated with this job.
    JobResource -> Maybe [Ec2AmiResource]
ec2AmiResources :: Prelude.Maybe [Ec2AmiResource],
    -- | The Python-language Lambda functions for this job.
    JobResource -> Maybe [LambdaResource]
lambdaResources :: Prelude.Maybe [LambdaResource],
    -- | An array of @S3Resource@ objects.
    JobResource -> Maybe [S3Resource]
s3Resources :: Prelude.Maybe [S3Resource]
  }
  deriving (JobResource -> JobResource -> Bool
(JobResource -> JobResource -> Bool)
-> (JobResource -> JobResource -> Bool) -> Eq JobResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobResource -> JobResource -> Bool
$c/= :: JobResource -> JobResource -> Bool
== :: JobResource -> JobResource -> Bool
$c== :: JobResource -> JobResource -> Bool
Prelude.Eq, ReadPrec [JobResource]
ReadPrec JobResource
Int -> ReadS JobResource
ReadS [JobResource]
(Int -> ReadS JobResource)
-> ReadS [JobResource]
-> ReadPrec JobResource
-> ReadPrec [JobResource]
-> Read JobResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobResource]
$creadListPrec :: ReadPrec [JobResource]
readPrec :: ReadPrec JobResource
$creadPrec :: ReadPrec JobResource
readList :: ReadS [JobResource]
$creadList :: ReadS [JobResource]
readsPrec :: Int -> ReadS JobResource
$creadsPrec :: Int -> ReadS JobResource
Prelude.Read, Int -> JobResource -> ShowS
[JobResource] -> ShowS
JobResource -> String
(Int -> JobResource -> ShowS)
-> (JobResource -> String)
-> ([JobResource] -> ShowS)
-> Show JobResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobResource] -> ShowS
$cshowList :: [JobResource] -> ShowS
show :: JobResource -> String
$cshow :: JobResource -> String
showsPrec :: Int -> JobResource -> ShowS
$cshowsPrec :: Int -> JobResource -> ShowS
Prelude.Show, (forall x. JobResource -> Rep JobResource x)
-> (forall x. Rep JobResource x -> JobResource)
-> Generic JobResource
forall x. Rep JobResource x -> JobResource
forall x. JobResource -> Rep JobResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobResource x -> JobResource
$cfrom :: forall x. JobResource -> Rep JobResource x
Prelude.Generic)

-- |
-- Create a value of 'JobResource' 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:
--
-- 'ec2AmiResources', 'jobResource_ec2AmiResources' - The Amazon Machine Images (AMIs) associated with this job.
--
-- 'lambdaResources', 'jobResource_lambdaResources' - The Python-language Lambda functions for this job.
--
-- 's3Resources', 'jobResource_s3Resources' - An array of @S3Resource@ objects.
newJobResource ::
  JobResource
newJobResource :: JobResource
newJobResource =
  JobResource' :: Maybe [Ec2AmiResource]
-> Maybe [LambdaResource] -> Maybe [S3Resource] -> JobResource
JobResource'
    { $sel:ec2AmiResources:JobResource' :: Maybe [Ec2AmiResource]
ec2AmiResources = Maybe [Ec2AmiResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaResources:JobResource' :: Maybe [LambdaResource]
lambdaResources = Maybe [LambdaResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Resources:JobResource' :: Maybe [S3Resource]
s3Resources = Maybe [S3Resource]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Machine Images (AMIs) associated with this job.
jobResource_ec2AmiResources :: Lens.Lens' JobResource (Prelude.Maybe [Ec2AmiResource])
jobResource_ec2AmiResources :: (Maybe [Ec2AmiResource] -> f (Maybe [Ec2AmiResource]))
-> JobResource -> f JobResource
jobResource_ec2AmiResources = (JobResource -> Maybe [Ec2AmiResource])
-> (JobResource -> Maybe [Ec2AmiResource] -> JobResource)
-> Lens
     JobResource
     JobResource
     (Maybe [Ec2AmiResource])
     (Maybe [Ec2AmiResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobResource' {Maybe [Ec2AmiResource]
ec2AmiResources :: Maybe [Ec2AmiResource]
$sel:ec2AmiResources:JobResource' :: JobResource -> Maybe [Ec2AmiResource]
ec2AmiResources} -> Maybe [Ec2AmiResource]
ec2AmiResources) (\s :: JobResource
s@JobResource' {} Maybe [Ec2AmiResource]
a -> JobResource
s {$sel:ec2AmiResources:JobResource' :: Maybe [Ec2AmiResource]
ec2AmiResources = Maybe [Ec2AmiResource]
a} :: JobResource) ((Maybe [Ec2AmiResource] -> f (Maybe [Ec2AmiResource]))
 -> JobResource -> f JobResource)
-> ((Maybe [Ec2AmiResource] -> f (Maybe [Ec2AmiResource]))
    -> Maybe [Ec2AmiResource] -> f (Maybe [Ec2AmiResource]))
-> (Maybe [Ec2AmiResource] -> f (Maybe [Ec2AmiResource]))
-> JobResource
-> f JobResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Ec2AmiResource] [Ec2AmiResource] [Ec2AmiResource] [Ec2AmiResource]
-> Iso
     (Maybe [Ec2AmiResource])
     (Maybe [Ec2AmiResource])
     (Maybe [Ec2AmiResource])
     (Maybe [Ec2AmiResource])
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
  [Ec2AmiResource] [Ec2AmiResource] [Ec2AmiResource] [Ec2AmiResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Python-language Lambda functions for this job.
jobResource_lambdaResources :: Lens.Lens' JobResource (Prelude.Maybe [LambdaResource])
jobResource_lambdaResources :: (Maybe [LambdaResource] -> f (Maybe [LambdaResource]))
-> JobResource -> f JobResource
jobResource_lambdaResources = (JobResource -> Maybe [LambdaResource])
-> (JobResource -> Maybe [LambdaResource] -> JobResource)
-> Lens
     JobResource
     JobResource
     (Maybe [LambdaResource])
     (Maybe [LambdaResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobResource' {Maybe [LambdaResource]
lambdaResources :: Maybe [LambdaResource]
$sel:lambdaResources:JobResource' :: JobResource -> Maybe [LambdaResource]
lambdaResources} -> Maybe [LambdaResource]
lambdaResources) (\s :: JobResource
s@JobResource' {} Maybe [LambdaResource]
a -> JobResource
s {$sel:lambdaResources:JobResource' :: Maybe [LambdaResource]
lambdaResources = Maybe [LambdaResource]
a} :: JobResource) ((Maybe [LambdaResource] -> f (Maybe [LambdaResource]))
 -> JobResource -> f JobResource)
-> ((Maybe [LambdaResource] -> f (Maybe [LambdaResource]))
    -> Maybe [LambdaResource] -> f (Maybe [LambdaResource]))
-> (Maybe [LambdaResource] -> f (Maybe [LambdaResource]))
-> JobResource
-> f JobResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LambdaResource] [LambdaResource] [LambdaResource] [LambdaResource]
-> Iso
     (Maybe [LambdaResource])
     (Maybe [LambdaResource])
     (Maybe [LambdaResource])
     (Maybe [LambdaResource])
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
  [LambdaResource] [LambdaResource] [LambdaResource] [LambdaResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of @S3Resource@ objects.
jobResource_s3Resources :: Lens.Lens' JobResource (Prelude.Maybe [S3Resource])
jobResource_s3Resources :: (Maybe [S3Resource] -> f (Maybe [S3Resource]))
-> JobResource -> f JobResource
jobResource_s3Resources = (JobResource -> Maybe [S3Resource])
-> (JobResource -> Maybe [S3Resource] -> JobResource)
-> Lens
     JobResource JobResource (Maybe [S3Resource]) (Maybe [S3Resource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobResource' {Maybe [S3Resource]
s3Resources :: Maybe [S3Resource]
$sel:s3Resources:JobResource' :: JobResource -> Maybe [S3Resource]
s3Resources} -> Maybe [S3Resource]
s3Resources) (\s :: JobResource
s@JobResource' {} Maybe [S3Resource]
a -> JobResource
s {$sel:s3Resources:JobResource' :: Maybe [S3Resource]
s3Resources = Maybe [S3Resource]
a} :: JobResource) ((Maybe [S3Resource] -> f (Maybe [S3Resource]))
 -> JobResource -> f JobResource)
-> ((Maybe [S3Resource] -> f (Maybe [S3Resource]))
    -> Maybe [S3Resource] -> f (Maybe [S3Resource]))
-> (Maybe [S3Resource] -> f (Maybe [S3Resource]))
-> JobResource
-> f JobResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [S3Resource] [S3Resource] [S3Resource] [S3Resource]
-> Iso
     (Maybe [S3Resource])
     (Maybe [S3Resource])
     (Maybe [S3Resource])
     (Maybe [S3Resource])
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 [S3Resource] [S3Resource] [S3Resource] [S3Resource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON JobResource where
  parseJSON :: Value -> Parser JobResource
parseJSON =
    String
-> (Object -> Parser JobResource) -> Value -> Parser JobResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"JobResource"
      ( \Object
x ->
          Maybe [Ec2AmiResource]
-> Maybe [LambdaResource] -> Maybe [S3Resource] -> JobResource
JobResource'
            (Maybe [Ec2AmiResource]
 -> Maybe [LambdaResource] -> Maybe [S3Resource] -> JobResource)
-> Parser (Maybe [Ec2AmiResource])
-> Parser
     (Maybe [LambdaResource] -> Maybe [S3Resource] -> JobResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Ec2AmiResource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Ec2AmiResources"
                            Parser (Maybe (Maybe [Ec2AmiResource]))
-> Maybe [Ec2AmiResource] -> Parser (Maybe [Ec2AmiResource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Ec2AmiResource]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [LambdaResource] -> Maybe [S3Resource] -> JobResource)
-> Parser (Maybe [LambdaResource])
-> Parser (Maybe [S3Resource] -> JobResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [LambdaResource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LambdaResources"
                            Parser (Maybe (Maybe [LambdaResource]))
-> Maybe [LambdaResource] -> Parser (Maybe [LambdaResource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LambdaResource]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [S3Resource] -> JobResource)
-> Parser (Maybe [S3Resource]) -> Parser JobResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [S3Resource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3Resources" Parser (Maybe (Maybe [S3Resource]))
-> Maybe [S3Resource] -> Parser (Maybe [S3Resource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [S3Resource]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable JobResource

instance Prelude.NFData JobResource

instance Core.ToJSON JobResource where
  toJSON :: JobResource -> Value
toJSON JobResource' {Maybe [Ec2AmiResource]
Maybe [LambdaResource]
Maybe [S3Resource]
s3Resources :: Maybe [S3Resource]
lambdaResources :: Maybe [LambdaResource]
ec2AmiResources :: Maybe [Ec2AmiResource]
$sel:s3Resources:JobResource' :: JobResource -> Maybe [S3Resource]
$sel:lambdaResources:JobResource' :: JobResource -> Maybe [LambdaResource]
$sel:ec2AmiResources:JobResource' :: JobResource -> Maybe [Ec2AmiResource]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Ec2AmiResources" Text -> [Ec2AmiResource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Ec2AmiResource] -> Pair) -> Maybe [Ec2AmiResource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Ec2AmiResource]
ec2AmiResources,
            (Text
"LambdaResources" Text -> [LambdaResource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([LambdaResource] -> Pair) -> Maybe [LambdaResource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LambdaResource]
lambdaResources,
            (Text
"S3Resources" Text -> [S3Resource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([S3Resource] -> Pair) -> Maybe [S3Resource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [S3Resource]
s3Resources
          ]
      )