{-# 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.ImageBuilder.Types.OutputResources
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ImageBuilder.Types.OutputResources where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ImageBuilder.Types.Ami
import Amazonka.ImageBuilder.Types.Container
import qualified Amazonka.Prelude as Prelude

-- | The resources produced by this image.
--
-- /See:/ 'newOutputResources' smart constructor.
data OutputResources = OutputResources'
  { -- | The Amazon EC2 AMIs created by this image.
    OutputResources -> Maybe [Ami]
amis :: Prelude.Maybe [Ami],
    -- | Container images that the pipeline has generated and stored in the
    -- output repository.
    OutputResources -> Maybe [Container]
containers :: Prelude.Maybe [Container]
  }
  deriving (OutputResources -> OutputResources -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputResources -> OutputResources -> Bool
$c/= :: OutputResources -> OutputResources -> Bool
== :: OutputResources -> OutputResources -> Bool
$c== :: OutputResources -> OutputResources -> Bool
Prelude.Eq, ReadPrec [OutputResources]
ReadPrec OutputResources
Int -> ReadS OutputResources
ReadS [OutputResources]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputResources]
$creadListPrec :: ReadPrec [OutputResources]
readPrec :: ReadPrec OutputResources
$creadPrec :: ReadPrec OutputResources
readList :: ReadS [OutputResources]
$creadList :: ReadS [OutputResources]
readsPrec :: Int -> ReadS OutputResources
$creadsPrec :: Int -> ReadS OutputResources
Prelude.Read, Int -> OutputResources -> ShowS
[OutputResources] -> ShowS
OutputResources -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputResources] -> ShowS
$cshowList :: [OutputResources] -> ShowS
show :: OutputResources -> String
$cshow :: OutputResources -> String
showsPrec :: Int -> OutputResources -> ShowS
$cshowsPrec :: Int -> OutputResources -> ShowS
Prelude.Show, forall x. Rep OutputResources x -> OutputResources
forall x. OutputResources -> Rep OutputResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputResources x -> OutputResources
$cfrom :: forall x. OutputResources -> Rep OutputResources x
Prelude.Generic)

-- |
-- Create a value of 'OutputResources' 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:
--
-- 'amis', 'outputResources_amis' - The Amazon EC2 AMIs created by this image.
--
-- 'containers', 'outputResources_containers' - Container images that the pipeline has generated and stored in the
-- output repository.
newOutputResources ::
  OutputResources
newOutputResources :: OutputResources
newOutputResources =
  OutputResources'
    { $sel:amis:OutputResources' :: Maybe [Ami]
amis = forall a. Maybe a
Prelude.Nothing,
      $sel:containers:OutputResources' :: Maybe [Container]
containers = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon EC2 AMIs created by this image.
outputResources_amis :: Lens.Lens' OutputResources (Prelude.Maybe [Ami])
outputResources_amis :: Lens' OutputResources (Maybe [Ami])
outputResources_amis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputResources' {Maybe [Ami]
amis :: Maybe [Ami]
$sel:amis:OutputResources' :: OutputResources -> Maybe [Ami]
amis} -> Maybe [Ami]
amis) (\s :: OutputResources
s@OutputResources' {} Maybe [Ami]
a -> OutputResources
s {$sel:amis:OutputResources' :: Maybe [Ami]
amis = Maybe [Ami]
a} :: OutputResources) 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

-- | Container images that the pipeline has generated and stored in the
-- output repository.
outputResources_containers :: Lens.Lens' OutputResources (Prelude.Maybe [Container])
outputResources_containers :: Lens' OutputResources (Maybe [Container])
outputResources_containers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputResources' {Maybe [Container]
containers :: Maybe [Container]
$sel:containers:OutputResources' :: OutputResources -> Maybe [Container]
containers} -> Maybe [Container]
containers) (\s :: OutputResources
s@OutputResources' {} Maybe [Container]
a -> OutputResources
s {$sel:containers:OutputResources' :: Maybe [Container]
containers = Maybe [Container]
a} :: OutputResources) 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

instance Data.FromJSON OutputResources where
  parseJSON :: Value -> Parser OutputResources
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OutputResources"
      ( \Object
x ->
          Maybe [Ami] -> Maybe [Container] -> OutputResources
OutputResources'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"amis" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"containers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable OutputResources where
  hashWithSalt :: Int -> OutputResources -> Int
hashWithSalt Int
_salt OutputResources' {Maybe [Container]
Maybe [Ami]
containers :: Maybe [Container]
amis :: Maybe [Ami]
$sel:containers:OutputResources' :: OutputResources -> Maybe [Container]
$sel:amis:OutputResources' :: OutputResources -> Maybe [Ami]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Ami]
amis
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Container]
containers

instance Prelude.NFData OutputResources where
  rnf :: OutputResources -> ()
rnf OutputResources' {Maybe [Container]
Maybe [Ami]
containers :: Maybe [Container]
amis :: Maybe [Ami]
$sel:containers:OutputResources' :: OutputResources -> Maybe [Container]
$sel:amis:OutputResources' :: OutputResources -> Maybe [Ami]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Ami]
amis
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Container]
containers