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

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

-- | Contains information about a platform that a component supports.
--
-- /See:/ 'newComponentPlatform' smart constructor.
data ComponentPlatform = ComponentPlatform'
  { -- | A dictionary of attributes for the platform. The IoT Greengrass Core
    -- software defines the @os@ and @architecture@ by default. You can specify
    -- additional platform attributes for a core device when you deploy the
    -- Greengrass nucleus component. For more information, see the
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html Greengrass nucleus component>
    -- in the /IoT Greengrass V2 Developer Guide/.
    ComponentPlatform -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The friendly name of the platform. This name helps you identify the
    -- platform.
    --
    -- If you omit this parameter, IoT Greengrass creates a friendly name from
    -- the @os@ and @architecture@ of the platform.
    ComponentPlatform -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ComponentPlatform -> ComponentPlatform -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentPlatform -> ComponentPlatform -> Bool
$c/= :: ComponentPlatform -> ComponentPlatform -> Bool
== :: ComponentPlatform -> ComponentPlatform -> Bool
$c== :: ComponentPlatform -> ComponentPlatform -> Bool
Prelude.Eq, ReadPrec [ComponentPlatform]
ReadPrec ComponentPlatform
Int -> ReadS ComponentPlatform
ReadS [ComponentPlatform]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentPlatform]
$creadListPrec :: ReadPrec [ComponentPlatform]
readPrec :: ReadPrec ComponentPlatform
$creadPrec :: ReadPrec ComponentPlatform
readList :: ReadS [ComponentPlatform]
$creadList :: ReadS [ComponentPlatform]
readsPrec :: Int -> ReadS ComponentPlatform
$creadsPrec :: Int -> ReadS ComponentPlatform
Prelude.Read, Int -> ComponentPlatform -> ShowS
[ComponentPlatform] -> ShowS
ComponentPlatform -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentPlatform] -> ShowS
$cshowList :: [ComponentPlatform] -> ShowS
show :: ComponentPlatform -> String
$cshow :: ComponentPlatform -> String
showsPrec :: Int -> ComponentPlatform -> ShowS
$cshowsPrec :: Int -> ComponentPlatform -> ShowS
Prelude.Show, forall x. Rep ComponentPlatform x -> ComponentPlatform
forall x. ComponentPlatform -> Rep ComponentPlatform x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentPlatform x -> ComponentPlatform
$cfrom :: forall x. ComponentPlatform -> Rep ComponentPlatform x
Prelude.Generic)

-- |
-- Create a value of 'ComponentPlatform' 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:
--
-- 'attributes', 'componentPlatform_attributes' - A dictionary of attributes for the platform. The IoT Greengrass Core
-- software defines the @os@ and @architecture@ by default. You can specify
-- additional platform attributes for a core device when you deploy the
-- Greengrass nucleus component. For more information, see the
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html Greengrass nucleus component>
-- in the /IoT Greengrass V2 Developer Guide/.
--
-- 'name', 'componentPlatform_name' - The friendly name of the platform. This name helps you identify the
-- platform.
--
-- If you omit this parameter, IoT Greengrass creates a friendly name from
-- the @os@ and @architecture@ of the platform.
newComponentPlatform ::
  ComponentPlatform
newComponentPlatform :: ComponentPlatform
newComponentPlatform =
  ComponentPlatform'
    { $sel:attributes:ComponentPlatform' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ComponentPlatform' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | A dictionary of attributes for the platform. The IoT Greengrass Core
-- software defines the @os@ and @architecture@ by default. You can specify
-- additional platform attributes for a core device when you deploy the
-- Greengrass nucleus component. For more information, see the
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html Greengrass nucleus component>
-- in the /IoT Greengrass V2 Developer Guide/.
componentPlatform_attributes :: Lens.Lens' ComponentPlatform (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
componentPlatform_attributes :: Lens' ComponentPlatform (Maybe (HashMap Text Text))
componentPlatform_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentPlatform' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ComponentPlatform' :: ComponentPlatform -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ComponentPlatform
s@ComponentPlatform' {} Maybe (HashMap Text Text)
a -> ComponentPlatform
s {$sel:attributes:ComponentPlatform' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ComponentPlatform) 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 friendly name of the platform. This name helps you identify the
-- platform.
--
-- If you omit this parameter, IoT Greengrass creates a friendly name from
-- the @os@ and @architecture@ of the platform.
componentPlatform_name :: Lens.Lens' ComponentPlatform (Prelude.Maybe Prelude.Text)
componentPlatform_name :: Lens' ComponentPlatform (Maybe Text)
componentPlatform_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentPlatform' {Maybe Text
name :: Maybe Text
$sel:name:ComponentPlatform' :: ComponentPlatform -> Maybe Text
name} -> Maybe Text
name) (\s :: ComponentPlatform
s@ComponentPlatform' {} Maybe Text
a -> ComponentPlatform
s {$sel:name:ComponentPlatform' :: Maybe Text
name = Maybe Text
a} :: ComponentPlatform)

instance Data.FromJSON ComponentPlatform where
  parseJSON :: Value -> Parser ComponentPlatform
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentPlatform"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Maybe Text -> ComponentPlatform
ComponentPlatform'
            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
"attributes" 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
"name")
      )

instance Prelude.Hashable ComponentPlatform where
  hashWithSalt :: Int -> ComponentPlatform -> Int
hashWithSalt Int
_salt ComponentPlatform' {Maybe Text
Maybe (HashMap Text Text)
name :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:name:ComponentPlatform' :: ComponentPlatform -> Maybe Text
$sel:attributes:ComponentPlatform' :: ComponentPlatform -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ComponentPlatform where
  rnf :: ComponentPlatform -> ()
rnf ComponentPlatform' {Maybe Text
Maybe (HashMap Text Text)
name :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:name:ComponentPlatform' :: ComponentPlatform -> Maybe Text
$sel:attributes:ComponentPlatform' :: ComponentPlatform -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

instance Data.ToJSON ComponentPlatform where
  toJSON :: ComponentPlatform -> Value
toJSON ComponentPlatform' {Maybe Text
Maybe (HashMap Text Text)
name :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:name:ComponentPlatform' :: ComponentPlatform -> Maybe Text
$sel:attributes:ComponentPlatform' :: ComponentPlatform -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"attributes" 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 (HashMap Text Text)
attributes,
            (Key
"name" 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 Text
name
          ]
      )