{-# 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-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.ComponentConfiguration 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.ComponentParameter
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
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]
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
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. 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'
    { $sel:parameters:ComponentConfiguration' :: Maybe (NonEmpty ComponentParameter)
parameters =
        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 :: Lens' ComponentConfiguration (Maybe (NonEmpty ComponentParameter))
componentConfiguration_parameters = 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) 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

-- | The Amazon Resource Name (ARN) of the component.
componentConfiguration_componentArn :: Lens.Lens' ComponentConfiguration Prelude.Text
componentConfiguration_componentArn :: Lens' ComponentConfiguration Text
componentConfiguration_componentArn = 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 Data.FromJSON ComponentConfiguration where
  parseJSON :: Value -> Parser ComponentConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty ComponentParameter)
-> Text -> ComponentConfiguration
ComponentConfiguration'
            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
"parameters")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"componentArn")
      )

instance Prelude.Hashable ComponentConfiguration where
  hashWithSalt :: Int -> ComponentConfiguration -> Int
hashWithSalt Int
_salt ComponentConfiguration' {Maybe (NonEmpty ComponentParameter)
Text
componentArn :: Text
parameters :: Maybe (NonEmpty ComponentParameter)
$sel:componentArn:ComponentConfiguration' :: ComponentConfiguration -> Text
$sel:parameters:ComponentConfiguration' :: ComponentConfiguration -> Maybe (NonEmpty ComponentParameter)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ComponentParameter)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
componentArn

instance Prelude.NFData ComponentConfiguration where
  rnf :: ComponentConfiguration -> ()
rnf ComponentConfiguration' {Maybe (NonEmpty ComponentParameter)
Text
componentArn :: Text
parameters :: Maybe (NonEmpty ComponentParameter)
$sel:componentArn:ComponentConfiguration' :: ComponentConfiguration -> Text
$sel:parameters:ComponentConfiguration' :: ComponentConfiguration -> Maybe (NonEmpty ComponentParameter)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ComponentParameter)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
componentArn

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"parameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ComponentParameter)
parameters,
            forall a. a -> Maybe a
Prelude.Just (Key
"componentArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
componentArn)
          ]
      )