{-# 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.ComponentCandidate
-- 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.ComponentCandidate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a component that is a candidate to deploy to
-- a Greengrass core device.
--
-- /See:/ 'newComponentCandidate' smart constructor.
data ComponentCandidate = ComponentCandidate'
  { -- | The version of the component.
    ComponentCandidate -> Maybe Text
componentVersion :: Prelude.Maybe Prelude.Text,
    -- | The version requirements for the component\'s dependencies. Greengrass
    -- core devices get the version requirements from component recipes.
    --
    -- IoT Greengrass V2 uses semantic version constraints. For more
    -- information, see <https://semver.org/ Semantic Versioning>.
    ComponentCandidate -> Maybe (HashMap Text Text)
versionRequirements :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the component.
    ComponentCandidate -> Maybe Text
componentName :: Prelude.Maybe Prelude.Text
  }
  deriving (ComponentCandidate -> ComponentCandidate -> Bool
(ComponentCandidate -> ComponentCandidate -> Bool)
-> (ComponentCandidate -> ComponentCandidate -> Bool)
-> Eq ComponentCandidate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentCandidate -> ComponentCandidate -> Bool
$c/= :: ComponentCandidate -> ComponentCandidate -> Bool
== :: ComponentCandidate -> ComponentCandidate -> Bool
$c== :: ComponentCandidate -> ComponentCandidate -> Bool
Prelude.Eq, ReadPrec [ComponentCandidate]
ReadPrec ComponentCandidate
Int -> ReadS ComponentCandidate
ReadS [ComponentCandidate]
(Int -> ReadS ComponentCandidate)
-> ReadS [ComponentCandidate]
-> ReadPrec ComponentCandidate
-> ReadPrec [ComponentCandidate]
-> Read ComponentCandidate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentCandidate]
$creadListPrec :: ReadPrec [ComponentCandidate]
readPrec :: ReadPrec ComponentCandidate
$creadPrec :: ReadPrec ComponentCandidate
readList :: ReadS [ComponentCandidate]
$creadList :: ReadS [ComponentCandidate]
readsPrec :: Int -> ReadS ComponentCandidate
$creadsPrec :: Int -> ReadS ComponentCandidate
Prelude.Read, Int -> ComponentCandidate -> ShowS
[ComponentCandidate] -> ShowS
ComponentCandidate -> String
(Int -> ComponentCandidate -> ShowS)
-> (ComponentCandidate -> String)
-> ([ComponentCandidate] -> ShowS)
-> Show ComponentCandidate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentCandidate] -> ShowS
$cshowList :: [ComponentCandidate] -> ShowS
show :: ComponentCandidate -> String
$cshow :: ComponentCandidate -> String
showsPrec :: Int -> ComponentCandidate -> ShowS
$cshowsPrec :: Int -> ComponentCandidate -> ShowS
Prelude.Show, (forall x. ComponentCandidate -> Rep ComponentCandidate x)
-> (forall x. Rep ComponentCandidate x -> ComponentCandidate)
-> Generic ComponentCandidate
forall x. Rep ComponentCandidate x -> ComponentCandidate
forall x. ComponentCandidate -> Rep ComponentCandidate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentCandidate x -> ComponentCandidate
$cfrom :: forall x. ComponentCandidate -> Rep ComponentCandidate x
Prelude.Generic)

-- |
-- Create a value of 'ComponentCandidate' 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:
--
-- 'componentVersion', 'componentCandidate_componentVersion' - The version of the component.
--
-- 'versionRequirements', 'componentCandidate_versionRequirements' - The version requirements for the component\'s dependencies. Greengrass
-- core devices get the version requirements from component recipes.
--
-- IoT Greengrass V2 uses semantic version constraints. For more
-- information, see <https://semver.org/ Semantic Versioning>.
--
-- 'componentName', 'componentCandidate_componentName' - The name of the component.
newComponentCandidate ::
  ComponentCandidate
newComponentCandidate :: ComponentCandidate
newComponentCandidate =
  ComponentCandidate' :: Maybe Text
-> Maybe (HashMap Text Text) -> Maybe Text -> ComponentCandidate
ComponentCandidate'
    { $sel:componentVersion:ComponentCandidate' :: Maybe Text
componentVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:versionRequirements:ComponentCandidate' :: Maybe (HashMap Text Text)
versionRequirements = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:componentName:ComponentCandidate' :: Maybe Text
componentName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The version of the component.
componentCandidate_componentVersion :: Lens.Lens' ComponentCandidate (Prelude.Maybe Prelude.Text)
componentCandidate_componentVersion :: (Maybe Text -> f (Maybe Text))
-> ComponentCandidate -> f ComponentCandidate
componentCandidate_componentVersion = (ComponentCandidate -> Maybe Text)
-> (ComponentCandidate -> Maybe Text -> ComponentCandidate)
-> Lens
     ComponentCandidate ComponentCandidate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentCandidate' {Maybe Text
componentVersion :: Maybe Text
$sel:componentVersion:ComponentCandidate' :: ComponentCandidate -> Maybe Text
componentVersion} -> Maybe Text
componentVersion) (\s :: ComponentCandidate
s@ComponentCandidate' {} Maybe Text
a -> ComponentCandidate
s {$sel:componentVersion:ComponentCandidate' :: Maybe Text
componentVersion = Maybe Text
a} :: ComponentCandidate)

-- | The version requirements for the component\'s dependencies. Greengrass
-- core devices get the version requirements from component recipes.
--
-- IoT Greengrass V2 uses semantic version constraints. For more
-- information, see <https://semver.org/ Semantic Versioning>.
componentCandidate_versionRequirements :: Lens.Lens' ComponentCandidate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
componentCandidate_versionRequirements :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ComponentCandidate -> f ComponentCandidate
componentCandidate_versionRequirements = (ComponentCandidate -> Maybe (HashMap Text Text))
-> (ComponentCandidate
    -> Maybe (HashMap Text Text) -> ComponentCandidate)
-> Lens
     ComponentCandidate
     ComponentCandidate
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentCandidate' {Maybe (HashMap Text Text)
versionRequirements :: Maybe (HashMap Text Text)
$sel:versionRequirements:ComponentCandidate' :: ComponentCandidate -> Maybe (HashMap Text Text)
versionRequirements} -> Maybe (HashMap Text Text)
versionRequirements) (\s :: ComponentCandidate
s@ComponentCandidate' {} Maybe (HashMap Text Text)
a -> ComponentCandidate
s {$sel:versionRequirements:ComponentCandidate' :: Maybe (HashMap Text Text)
versionRequirements = Maybe (HashMap Text Text)
a} :: ComponentCandidate) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ComponentCandidate -> f ComponentCandidate)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ComponentCandidate
-> f ComponentCandidate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the component.
componentCandidate_componentName :: Lens.Lens' ComponentCandidate (Prelude.Maybe Prelude.Text)
componentCandidate_componentName :: (Maybe Text -> f (Maybe Text))
-> ComponentCandidate -> f ComponentCandidate
componentCandidate_componentName = (ComponentCandidate -> Maybe Text)
-> (ComponentCandidate -> Maybe Text -> ComponentCandidate)
-> Lens
     ComponentCandidate ComponentCandidate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentCandidate' {Maybe Text
componentName :: Maybe Text
$sel:componentName:ComponentCandidate' :: ComponentCandidate -> Maybe Text
componentName} -> Maybe Text
componentName) (\s :: ComponentCandidate
s@ComponentCandidate' {} Maybe Text
a -> ComponentCandidate
s {$sel:componentName:ComponentCandidate' :: Maybe Text
componentName = Maybe Text
a} :: ComponentCandidate)

instance Prelude.Hashable ComponentCandidate

instance Prelude.NFData ComponentCandidate

instance Core.ToJSON ComponentCandidate where
  toJSON :: ComponentCandidate -> Value
toJSON ComponentCandidate' {Maybe Text
Maybe (HashMap Text Text)
componentName :: Maybe Text
versionRequirements :: Maybe (HashMap Text Text)
componentVersion :: Maybe Text
$sel:componentName:ComponentCandidate' :: ComponentCandidate -> Maybe Text
$sel:versionRequirements:ComponentCandidate' :: ComponentCandidate -> Maybe (HashMap Text Text)
$sel:componentVersion:ComponentCandidate' :: ComponentCandidate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"componentVersion" 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
componentVersion,
            (Text
"versionRequirements" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
versionRequirements,
            (Text
"componentName" 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
componentName
          ]
      )