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

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

-- | Contains information about a component.
--
-- /See:/ 'newComponent' smart constructor.
data Component = Component'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the component version.
    Component -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the component.
    Component -> Maybe Text
componentName :: Prelude.Maybe Prelude.Text,
    -- | The latest version of the component and its details.
    Component -> Maybe ComponentLatestVersion
latestVersion :: Prelude.Maybe ComponentLatestVersion
  }
  deriving (Component -> Component -> Bool
(Component -> Component -> Bool)
-> (Component -> Component -> Bool) -> Eq Component
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Component -> Component -> Bool
$c/= :: Component -> Component -> Bool
== :: Component -> Component -> Bool
$c== :: Component -> Component -> Bool
Prelude.Eq, ReadPrec [Component]
ReadPrec Component
Int -> ReadS Component
ReadS [Component]
(Int -> ReadS Component)
-> ReadS [Component]
-> ReadPrec Component
-> ReadPrec [Component]
-> Read Component
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Component]
$creadListPrec :: ReadPrec [Component]
readPrec :: ReadPrec Component
$creadPrec :: ReadPrec Component
readList :: ReadS [Component]
$creadList :: ReadS [Component]
readsPrec :: Int -> ReadS Component
$creadsPrec :: Int -> ReadS Component
Prelude.Read, Int -> Component -> ShowS
[Component] -> ShowS
Component -> String
(Int -> Component -> ShowS)
-> (Component -> String)
-> ([Component] -> ShowS)
-> Show Component
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Component] -> ShowS
$cshowList :: [Component] -> ShowS
show :: Component -> String
$cshow :: Component -> String
showsPrec :: Int -> Component -> ShowS
$cshowsPrec :: Int -> Component -> ShowS
Prelude.Show, (forall x. Component -> Rep Component x)
-> (forall x. Rep Component x -> Component) -> Generic Component
forall x. Rep Component x -> Component
forall x. Component -> Rep Component x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Component x -> Component
$cfrom :: forall x. Component -> Rep Component x
Prelude.Generic)

-- |
-- Create a value of 'Component' 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:
--
-- 'arn', 'component_arn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the component version.
--
-- 'componentName', 'component_componentName' - The name of the component.
--
-- 'latestVersion', 'component_latestVersion' - The latest version of the component and its details.
newComponent ::
  Component
newComponent :: Component
newComponent =
  Component' :: Maybe Text
-> Maybe Text -> Maybe ComponentLatestVersion -> Component
Component'
    { $sel:arn:Component' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:componentName:Component' :: Maybe Text
componentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:latestVersion:Component' :: Maybe ComponentLatestVersion
latestVersion = Maybe ComponentLatestVersion
forall a. Maybe a
Prelude.Nothing
    }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the component version.
component_arn :: Lens.Lens' Component (Prelude.Maybe Prelude.Text)
component_arn :: (Maybe Text -> f (Maybe Text)) -> Component -> f Component
component_arn = (Component -> Maybe Text)
-> (Component -> Maybe Text -> Component)
-> Lens Component Component (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Component' {Maybe Text
arn :: Maybe Text
$sel:arn:Component' :: Component -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Component
s@Component' {} Maybe Text
a -> Component
s {$sel:arn:Component' :: Maybe Text
arn = Maybe Text
a} :: Component)

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

-- | The latest version of the component and its details.
component_latestVersion :: Lens.Lens' Component (Prelude.Maybe ComponentLatestVersion)
component_latestVersion :: (Maybe ComponentLatestVersion -> f (Maybe ComponentLatestVersion))
-> Component -> f Component
component_latestVersion = (Component -> Maybe ComponentLatestVersion)
-> (Component -> Maybe ComponentLatestVersion -> Component)
-> Lens
     Component
     Component
     (Maybe ComponentLatestVersion)
     (Maybe ComponentLatestVersion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Component' {Maybe ComponentLatestVersion
latestVersion :: Maybe ComponentLatestVersion
$sel:latestVersion:Component' :: Component -> Maybe ComponentLatestVersion
latestVersion} -> Maybe ComponentLatestVersion
latestVersion) (\s :: Component
s@Component' {} Maybe ComponentLatestVersion
a -> Component
s {$sel:latestVersion:Component' :: Maybe ComponentLatestVersion
latestVersion = Maybe ComponentLatestVersion
a} :: Component)

instance Core.FromJSON Component where
  parseJSON :: Value -> Parser Component
parseJSON =
    String -> (Object -> Parser Component) -> Value -> Parser Component
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Component"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe ComponentLatestVersion -> Component
Component'
            (Maybe Text
 -> Maybe Text -> Maybe ComponentLatestVersion -> Component)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe ComponentLatestVersion -> Component)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arn")
            Parser (Maybe Text -> Maybe ComponentLatestVersion -> Component)
-> Parser (Maybe Text)
-> Parser (Maybe ComponentLatestVersion -> Component)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"componentName")
            Parser (Maybe ComponentLatestVersion -> Component)
-> Parser (Maybe ComponentLatestVersion) -> Parser Component
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComponentLatestVersion)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"latestVersion")
      )

instance Prelude.Hashable Component

instance Prelude.NFData Component