{-# 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.GreengrassV2.Types.ComponentDependencyRequirement
-- 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.GreengrassV2.Types.ComponentDependencyRequirement where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.ComponentDependencyType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a component dependency for a Lambda function
-- component.
--
-- /See:/ 'newComponentDependencyRequirement' smart constructor.
data ComponentDependencyRequirement = ComponentDependencyRequirement'
  { -- | The type of this dependency. Choose from the following options:
    --
    -- -   @SOFT@ – The component doesn\'t restart if the dependency changes
    --     state.
    --
    -- -   @HARD@ – The component restarts if the dependency changes state.
    --
    -- Default: @HARD@
    ComponentDependencyRequirement -> Maybe ComponentDependencyType
dependencyType :: Prelude.Maybe ComponentDependencyType,
    -- | The component version requirement for the component dependency.
    --
    -- IoT Greengrass V2 uses semantic version constraints. For more
    -- information, see <https://semver.org/ Semantic Versioning>.
    ComponentDependencyRequirement -> Maybe Text
versionRequirement :: Prelude.Maybe Prelude.Text
  }
  deriving (ComponentDependencyRequirement
-> ComponentDependencyRequirement -> Bool
(ComponentDependencyRequirement
 -> ComponentDependencyRequirement -> Bool)
-> (ComponentDependencyRequirement
    -> ComponentDependencyRequirement -> Bool)
-> Eq ComponentDependencyRequirement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentDependencyRequirement
-> ComponentDependencyRequirement -> Bool
$c/= :: ComponentDependencyRequirement
-> ComponentDependencyRequirement -> Bool
== :: ComponentDependencyRequirement
-> ComponentDependencyRequirement -> Bool
$c== :: ComponentDependencyRequirement
-> ComponentDependencyRequirement -> Bool
Prelude.Eq, ReadPrec [ComponentDependencyRequirement]
ReadPrec ComponentDependencyRequirement
Int -> ReadS ComponentDependencyRequirement
ReadS [ComponentDependencyRequirement]
(Int -> ReadS ComponentDependencyRequirement)
-> ReadS [ComponentDependencyRequirement]
-> ReadPrec ComponentDependencyRequirement
-> ReadPrec [ComponentDependencyRequirement]
-> Read ComponentDependencyRequirement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentDependencyRequirement]
$creadListPrec :: ReadPrec [ComponentDependencyRequirement]
readPrec :: ReadPrec ComponentDependencyRequirement
$creadPrec :: ReadPrec ComponentDependencyRequirement
readList :: ReadS [ComponentDependencyRequirement]
$creadList :: ReadS [ComponentDependencyRequirement]
readsPrec :: Int -> ReadS ComponentDependencyRequirement
$creadsPrec :: Int -> ReadS ComponentDependencyRequirement
Prelude.Read, Int -> ComponentDependencyRequirement -> ShowS
[ComponentDependencyRequirement] -> ShowS
ComponentDependencyRequirement -> String
(Int -> ComponentDependencyRequirement -> ShowS)
-> (ComponentDependencyRequirement -> String)
-> ([ComponentDependencyRequirement] -> ShowS)
-> Show ComponentDependencyRequirement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentDependencyRequirement] -> ShowS
$cshowList :: [ComponentDependencyRequirement] -> ShowS
show :: ComponentDependencyRequirement -> String
$cshow :: ComponentDependencyRequirement -> String
showsPrec :: Int -> ComponentDependencyRequirement -> ShowS
$cshowsPrec :: Int -> ComponentDependencyRequirement -> ShowS
Prelude.Show, (forall x.
 ComponentDependencyRequirement
 -> Rep ComponentDependencyRequirement x)
-> (forall x.
    Rep ComponentDependencyRequirement x
    -> ComponentDependencyRequirement)
-> Generic ComponentDependencyRequirement
forall x.
Rep ComponentDependencyRequirement x
-> ComponentDependencyRequirement
forall x.
ComponentDependencyRequirement
-> Rep ComponentDependencyRequirement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ComponentDependencyRequirement x
-> ComponentDependencyRequirement
$cfrom :: forall x.
ComponentDependencyRequirement
-> Rep ComponentDependencyRequirement x
Prelude.Generic)

-- |
-- Create a value of 'ComponentDependencyRequirement' 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:
--
-- 'dependencyType', 'componentDependencyRequirement_dependencyType' - The type of this dependency. Choose from the following options:
--
-- -   @SOFT@ – The component doesn\'t restart if the dependency changes
--     state.
--
-- -   @HARD@ – The component restarts if the dependency changes state.
--
-- Default: @HARD@
--
-- 'versionRequirement', 'componentDependencyRequirement_versionRequirement' - The component version requirement for the component dependency.
--
-- IoT Greengrass V2 uses semantic version constraints. For more
-- information, see <https://semver.org/ Semantic Versioning>.
newComponentDependencyRequirement ::
  ComponentDependencyRequirement
newComponentDependencyRequirement :: ComponentDependencyRequirement
newComponentDependencyRequirement =
  ComponentDependencyRequirement' :: Maybe ComponentDependencyType
-> Maybe Text -> ComponentDependencyRequirement
ComponentDependencyRequirement'
    { $sel:dependencyType:ComponentDependencyRequirement' :: Maybe ComponentDependencyType
dependencyType =
        Maybe ComponentDependencyType
forall a. Maybe a
Prelude.Nothing,
      $sel:versionRequirement:ComponentDependencyRequirement' :: Maybe Text
versionRequirement = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of this dependency. Choose from the following options:
--
-- -   @SOFT@ – The component doesn\'t restart if the dependency changes
--     state.
--
-- -   @HARD@ – The component restarts if the dependency changes state.
--
-- Default: @HARD@
componentDependencyRequirement_dependencyType :: Lens.Lens' ComponentDependencyRequirement (Prelude.Maybe ComponentDependencyType)
componentDependencyRequirement_dependencyType :: (Maybe ComponentDependencyType
 -> f (Maybe ComponentDependencyType))
-> ComponentDependencyRequirement
-> f ComponentDependencyRequirement
componentDependencyRequirement_dependencyType = (ComponentDependencyRequirement -> Maybe ComponentDependencyType)
-> (ComponentDependencyRequirement
    -> Maybe ComponentDependencyType -> ComponentDependencyRequirement)
-> Lens
     ComponentDependencyRequirement
     ComponentDependencyRequirement
     (Maybe ComponentDependencyType)
     (Maybe ComponentDependencyType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentDependencyRequirement' {Maybe ComponentDependencyType
dependencyType :: Maybe ComponentDependencyType
$sel:dependencyType:ComponentDependencyRequirement' :: ComponentDependencyRequirement -> Maybe ComponentDependencyType
dependencyType} -> Maybe ComponentDependencyType
dependencyType) (\s :: ComponentDependencyRequirement
s@ComponentDependencyRequirement' {} Maybe ComponentDependencyType
a -> ComponentDependencyRequirement
s {$sel:dependencyType:ComponentDependencyRequirement' :: Maybe ComponentDependencyType
dependencyType = Maybe ComponentDependencyType
a} :: ComponentDependencyRequirement)

-- | The component version requirement for the component dependency.
--
-- IoT Greengrass V2 uses semantic version constraints. For more
-- information, see <https://semver.org/ Semantic Versioning>.
componentDependencyRequirement_versionRequirement :: Lens.Lens' ComponentDependencyRequirement (Prelude.Maybe Prelude.Text)
componentDependencyRequirement_versionRequirement :: (Maybe Text -> f (Maybe Text))
-> ComponentDependencyRequirement
-> f ComponentDependencyRequirement
componentDependencyRequirement_versionRequirement = (ComponentDependencyRequirement -> Maybe Text)
-> (ComponentDependencyRequirement
    -> Maybe Text -> ComponentDependencyRequirement)
-> Lens
     ComponentDependencyRequirement
     ComponentDependencyRequirement
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentDependencyRequirement' {Maybe Text
versionRequirement :: Maybe Text
$sel:versionRequirement:ComponentDependencyRequirement' :: ComponentDependencyRequirement -> Maybe Text
versionRequirement} -> Maybe Text
versionRequirement) (\s :: ComponentDependencyRequirement
s@ComponentDependencyRequirement' {} Maybe Text
a -> ComponentDependencyRequirement
s {$sel:versionRequirement:ComponentDependencyRequirement' :: Maybe Text
versionRequirement = Maybe Text
a} :: ComponentDependencyRequirement)

instance
  Prelude.Hashable
    ComponentDependencyRequirement

instance
  Prelude.NFData
    ComponentDependencyRequirement

instance Core.ToJSON ComponentDependencyRequirement where
  toJSON :: ComponentDependencyRequirement -> Value
toJSON ComponentDependencyRequirement' {Maybe Text
Maybe ComponentDependencyType
versionRequirement :: Maybe Text
dependencyType :: Maybe ComponentDependencyType
$sel:versionRequirement:ComponentDependencyRequirement' :: ComponentDependencyRequirement -> Maybe Text
$sel:dependencyType:ComponentDependencyRequirement' :: ComponentDependencyRequirement -> Maybe ComponentDependencyType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"dependencyType" Text -> ComponentDependencyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ComponentDependencyType -> Pair)
-> Maybe ComponentDependencyType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComponentDependencyType
dependencyType,
            (Text
"versionRequirement" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
versionRequirement
          ]
      )