{-# 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.ComponentConfiguration
-- 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.ImageBuilder.Types.ComponentConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.ImageBuilder.Types.ComponentParameter
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration details of the component.
--
-- /See:/ 'newComponentConfiguration' smart constructor.
data ComponentConfiguration = ComponentConfiguration'
  { -- | A group of parameter settings that are used to configure the component
    -- for a specific recipe.
    ComponentConfiguration -> Maybe (NonEmpty ComponentParameter)
parameters :: Prelude.Maybe (Prelude.NonEmpty ComponentParameter),
    -- | The Amazon Resource Name (ARN) of the component.
    ComponentConfiguration -> Text
componentArn :: Prelude.Text
  }
  deriving (ComponentConfiguration -> ComponentConfiguration -> Bool
(ComponentConfiguration -> ComponentConfiguration -> Bool)
-> (ComponentConfiguration -> ComponentConfiguration -> Bool)
-> Eq ComponentConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentConfiguration -> ComponentConfiguration -> Bool
$c/= :: ComponentConfiguration -> ComponentConfiguration -> Bool
== :: ComponentConfiguration -> ComponentConfiguration -> Bool
$c== :: ComponentConfiguration -> ComponentConfiguration -> Bool
Prelude.Eq, ReadPrec [ComponentConfiguration]
ReadPrec ComponentConfiguration
Int -> ReadS ComponentConfiguration
ReadS [ComponentConfiguration]
(Int -> ReadS ComponentConfiguration)
-> ReadS [ComponentConfiguration]
-> ReadPrec ComponentConfiguration
-> ReadPrec [ComponentConfiguration]
-> Read ComponentConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentConfiguration]
$creadListPrec :: ReadPrec [ComponentConfiguration]
readPrec :: ReadPrec ComponentConfiguration
$creadPrec :: ReadPrec ComponentConfiguration
readList :: ReadS [ComponentConfiguration]
$creadList :: ReadS [ComponentConfiguration]
readsPrec :: Int -> ReadS ComponentConfiguration
$creadsPrec :: Int -> ReadS ComponentConfiguration
Prelude.Read, Int -> ComponentConfiguration -> ShowS
[ComponentConfiguration] -> ShowS
ComponentConfiguration -> String
(Int -> ComponentConfiguration -> ShowS)
-> (ComponentConfiguration -> String)
-> ([ComponentConfiguration] -> ShowS)
-> Show ComponentConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentConfiguration] -> ShowS
$cshowList :: [ComponentConfiguration] -> ShowS
show :: ComponentConfiguration -> String
$cshow :: ComponentConfiguration -> String
showsPrec :: Int -> ComponentConfiguration -> ShowS
$cshowsPrec :: Int -> ComponentConfiguration -> ShowS
Prelude.Show, (forall x. ComponentConfiguration -> Rep ComponentConfiguration x)
-> (forall x.
    Rep ComponentConfiguration x -> ComponentConfiguration)
-> Generic ComponentConfiguration
forall x. Rep ComponentConfiguration x -> ComponentConfiguration
forall x. ComponentConfiguration -> Rep ComponentConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentConfiguration x -> ComponentConfiguration
$cfrom :: forall x. ComponentConfiguration -> Rep ComponentConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ComponentConfiguration' 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:
--
-- 'parameters', 'componentConfiguration_parameters' - A group of parameter settings that are used to configure the component
-- for a specific recipe.
--
-- 'componentArn', 'componentConfiguration_componentArn' - The Amazon Resource Name (ARN) of the component.
newComponentConfiguration ::
  -- | 'componentArn'
  Prelude.Text ->
  ComponentConfiguration
newComponentConfiguration :: Text -> ComponentConfiguration
newComponentConfiguration Text
pComponentArn_ =
  ComponentConfiguration' :: Maybe (NonEmpty ComponentParameter)
-> Text -> ComponentConfiguration
ComponentConfiguration'
    { $sel:parameters:ComponentConfiguration' :: Maybe (NonEmpty ComponentParameter)
parameters =
        Maybe (NonEmpty ComponentParameter)
forall a. Maybe a
Prelude.Nothing,
      $sel:componentArn:ComponentConfiguration' :: Text
componentArn = Text
pComponentArn_
    }

-- | A group of parameter settings that are used to configure the component
-- for a specific recipe.
componentConfiguration_parameters :: Lens.Lens' ComponentConfiguration (Prelude.Maybe (Prelude.NonEmpty ComponentParameter))
componentConfiguration_parameters :: (Maybe (NonEmpty ComponentParameter)
 -> f (Maybe (NonEmpty ComponentParameter)))
-> ComponentConfiguration -> f ComponentConfiguration
componentConfiguration_parameters = (ComponentConfiguration -> Maybe (NonEmpty ComponentParameter))
-> (ComponentConfiguration
    -> Maybe (NonEmpty ComponentParameter) -> ComponentConfiguration)
-> Lens
     ComponentConfiguration
     ComponentConfiguration
     (Maybe (NonEmpty ComponentParameter))
     (Maybe (NonEmpty ComponentParameter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentConfiguration' {Maybe (NonEmpty ComponentParameter)
parameters :: Maybe (NonEmpty ComponentParameter)
$sel:parameters:ComponentConfiguration' :: ComponentConfiguration -> Maybe (NonEmpty ComponentParameter)
parameters} -> Maybe (NonEmpty ComponentParameter)
parameters) (\s :: ComponentConfiguration
s@ComponentConfiguration' {} Maybe (NonEmpty ComponentParameter)
a -> ComponentConfiguration
s {$sel:parameters:ComponentConfiguration' :: Maybe (NonEmpty ComponentParameter)
parameters = Maybe (NonEmpty ComponentParameter)
a} :: ComponentConfiguration) ((Maybe (NonEmpty ComponentParameter)
  -> f (Maybe (NonEmpty ComponentParameter)))
 -> ComponentConfiguration -> f ComponentConfiguration)
-> ((Maybe (NonEmpty ComponentParameter)
     -> f (Maybe (NonEmpty ComponentParameter)))
    -> Maybe (NonEmpty ComponentParameter)
    -> f (Maybe (NonEmpty ComponentParameter)))
-> (Maybe (NonEmpty ComponentParameter)
    -> f (Maybe (NonEmpty ComponentParameter)))
-> ComponentConfiguration
-> f ComponentConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
-> Iso
     (Maybe (NonEmpty ComponentParameter))
     (Maybe (NonEmpty ComponentParameter))
     (Maybe (NonEmpty ComponentParameter))
     (Maybe (NonEmpty ComponentParameter))
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
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
  (NonEmpty ComponentParameter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the component.
componentConfiguration_componentArn :: Lens.Lens' ComponentConfiguration Prelude.Text
componentConfiguration_componentArn :: (Text -> f Text)
-> ComponentConfiguration -> f ComponentConfiguration
componentConfiguration_componentArn = (ComponentConfiguration -> Text)
-> (ComponentConfiguration -> Text -> ComponentConfiguration)
-> Lens ComponentConfiguration ComponentConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentConfiguration' {Text
componentArn :: Text
$sel:componentArn:ComponentConfiguration' :: ComponentConfiguration -> Text
componentArn} -> Text
componentArn) (\s :: ComponentConfiguration
s@ComponentConfiguration' {} Text
a -> ComponentConfiguration
s {$sel:componentArn:ComponentConfiguration' :: Text
componentArn = Text
a} :: ComponentConfiguration)

instance Core.FromJSON ComponentConfiguration where
  parseJSON :: Value -> Parser ComponentConfiguration
parseJSON =
    String
-> (Object -> Parser ComponentConfiguration)
-> Value
-> Parser ComponentConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ComponentConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty ComponentParameter)
-> Text -> ComponentConfiguration
ComponentConfiguration'
            (Maybe (NonEmpty ComponentParameter)
 -> Text -> ComponentConfiguration)
-> Parser (Maybe (NonEmpty ComponentParameter))
-> Parser (Text -> ComponentConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty ComponentParameter))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parameters")
            Parser (Text -> ComponentConfiguration)
-> Parser Text -> Parser ComponentConfiguration
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
"componentArn")
      )

instance Prelude.Hashable ComponentConfiguration

instance Prelude.NFData ComponentConfiguration

instance Core.ToJSON ComponentConfiguration where
  toJSON :: ComponentConfiguration -> Value
toJSON ComponentConfiguration' {Maybe (NonEmpty ComponentParameter)
Text
componentArn :: Text
parameters :: Maybe (NonEmpty ComponentParameter)
$sel:componentArn:ComponentConfiguration' :: ComponentConfiguration -> Text
$sel:parameters:ComponentConfiguration' :: ComponentConfiguration -> Maybe (NonEmpty ComponentParameter)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"parameters" Text -> NonEmpty ComponentParameter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ComponentParameter -> Pair)
-> Maybe (NonEmpty ComponentParameter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ComponentParameter)
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"componentArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
componentArn)
          ]
      )