{-# 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.Greengrass.Types.ResourceDefinitionVersion
-- 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.Greengrass.Types.ResourceDefinitionVersion where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Greengrass.Types.Resource
import qualified Amazonka.Prelude as Prelude

-- | Information about a resource definition version.
--
-- /See:/ 'newResourceDefinitionVersion' smart constructor.
data ResourceDefinitionVersion = ResourceDefinitionVersion'
  { -- | A list of resources.
    ResourceDefinitionVersion -> Maybe [Resource]
resources :: Prelude.Maybe [Resource]
  }
  deriving (ResourceDefinitionVersion -> ResourceDefinitionVersion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceDefinitionVersion -> ResourceDefinitionVersion -> Bool
$c/= :: ResourceDefinitionVersion -> ResourceDefinitionVersion -> Bool
== :: ResourceDefinitionVersion -> ResourceDefinitionVersion -> Bool
$c== :: ResourceDefinitionVersion -> ResourceDefinitionVersion -> Bool
Prelude.Eq, ReadPrec [ResourceDefinitionVersion]
ReadPrec ResourceDefinitionVersion
Int -> ReadS ResourceDefinitionVersion
ReadS [ResourceDefinitionVersion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceDefinitionVersion]
$creadListPrec :: ReadPrec [ResourceDefinitionVersion]
readPrec :: ReadPrec ResourceDefinitionVersion
$creadPrec :: ReadPrec ResourceDefinitionVersion
readList :: ReadS [ResourceDefinitionVersion]
$creadList :: ReadS [ResourceDefinitionVersion]
readsPrec :: Int -> ReadS ResourceDefinitionVersion
$creadsPrec :: Int -> ReadS ResourceDefinitionVersion
Prelude.Read, Int -> ResourceDefinitionVersion -> ShowS
[ResourceDefinitionVersion] -> ShowS
ResourceDefinitionVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceDefinitionVersion] -> ShowS
$cshowList :: [ResourceDefinitionVersion] -> ShowS
show :: ResourceDefinitionVersion -> String
$cshow :: ResourceDefinitionVersion -> String
showsPrec :: Int -> ResourceDefinitionVersion -> ShowS
$cshowsPrec :: Int -> ResourceDefinitionVersion -> ShowS
Prelude.Show, forall x.
Rep ResourceDefinitionVersion x -> ResourceDefinitionVersion
forall x.
ResourceDefinitionVersion -> Rep ResourceDefinitionVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResourceDefinitionVersion x -> ResourceDefinitionVersion
$cfrom :: forall x.
ResourceDefinitionVersion -> Rep ResourceDefinitionVersion x
Prelude.Generic)

-- |
-- Create a value of 'ResourceDefinitionVersion' 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:
--
-- 'resources', 'resourceDefinitionVersion_resources' - A list of resources.
newResourceDefinitionVersion ::
  ResourceDefinitionVersion
newResourceDefinitionVersion :: ResourceDefinitionVersion
newResourceDefinitionVersion =
  ResourceDefinitionVersion'
    { $sel:resources:ResourceDefinitionVersion' :: Maybe [Resource]
resources =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A list of resources.
resourceDefinitionVersion_resources :: Lens.Lens' ResourceDefinitionVersion (Prelude.Maybe [Resource])
resourceDefinitionVersion_resources :: Lens' ResourceDefinitionVersion (Maybe [Resource])
resourceDefinitionVersion_resources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDefinitionVersion' {Maybe [Resource]
resources :: Maybe [Resource]
$sel:resources:ResourceDefinitionVersion' :: ResourceDefinitionVersion -> Maybe [Resource]
resources} -> Maybe [Resource]
resources) (\s :: ResourceDefinitionVersion
s@ResourceDefinitionVersion' {} Maybe [Resource]
a -> ResourceDefinitionVersion
s {$sel:resources:ResourceDefinitionVersion' :: Maybe [Resource]
resources = Maybe [Resource]
a} :: ResourceDefinitionVersion) 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

instance Data.FromJSON ResourceDefinitionVersion where
  parseJSON :: Value -> Parser ResourceDefinitionVersion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceDefinitionVersion"
      ( \Object
x ->
          Maybe [Resource] -> ResourceDefinitionVersion
ResourceDefinitionVersion'
            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
"Resources" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResourceDefinitionVersion where
  hashWithSalt :: Int -> ResourceDefinitionVersion -> Int
hashWithSalt Int
_salt ResourceDefinitionVersion' {Maybe [Resource]
resources :: Maybe [Resource]
$sel:resources:ResourceDefinitionVersion' :: ResourceDefinitionVersion -> Maybe [Resource]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Resource]
resources

instance Prelude.NFData ResourceDefinitionVersion where
  rnf :: ResourceDefinitionVersion -> ()
rnf ResourceDefinitionVersion' {Maybe [Resource]
resources :: Maybe [Resource]
$sel:resources:ResourceDefinitionVersion' :: ResourceDefinitionVersion -> Maybe [Resource]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Resource]
resources

instance Data.ToJSON ResourceDefinitionVersion where
  toJSON :: ResourceDefinitionVersion -> Value
toJSON ResourceDefinitionVersion' {Maybe [Resource]
resources :: Maybe [Resource]
$sel:resources:ResourceDefinitionVersion' :: ResourceDefinitionVersion -> Maybe [Resource]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Resources" 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 [Resource]
resources]
      )