{-# 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.CoreDefinitionVersion
-- 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.CoreDefinitionVersion 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.Core
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'CoreDefinitionVersion' 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:
--
-- 'cores', 'coreDefinitionVersion_cores' - A list of cores in the core definition version.
newCoreDefinitionVersion ::
  CoreDefinitionVersion
newCoreDefinitionVersion :: CoreDefinitionVersion
newCoreDefinitionVersion =
  CoreDefinitionVersion' {$sel:cores:CoreDefinitionVersion' :: Maybe [Core]
cores = forall a. Maybe a
Prelude.Nothing}

-- | A list of cores in the core definition version.
coreDefinitionVersion_cores :: Lens.Lens' CoreDefinitionVersion (Prelude.Maybe [Core])
coreDefinitionVersion_cores :: Lens' CoreDefinitionVersion (Maybe [Core])
coreDefinitionVersion_cores = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoreDefinitionVersion' {Maybe [Core]
cores :: Maybe [Core]
$sel:cores:CoreDefinitionVersion' :: CoreDefinitionVersion -> Maybe [Core]
cores} -> Maybe [Core]
cores) (\s :: CoreDefinitionVersion
s@CoreDefinitionVersion' {} Maybe [Core]
a -> CoreDefinitionVersion
s {$sel:cores:CoreDefinitionVersion' :: Maybe [Core]
cores = Maybe [Core]
a} :: CoreDefinitionVersion) 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 CoreDefinitionVersion where
  parseJSON :: Value -> Parser CoreDefinitionVersion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CoreDefinitionVersion"
      ( \Object
x ->
          Maybe [Core] -> CoreDefinitionVersion
CoreDefinitionVersion'
            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
"Cores" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable CoreDefinitionVersion where
  hashWithSalt :: Int -> CoreDefinitionVersion -> Int
hashWithSalt Int
_salt CoreDefinitionVersion' {Maybe [Core]
cores :: Maybe [Core]
$sel:cores:CoreDefinitionVersion' :: CoreDefinitionVersion -> Maybe [Core]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Core]
cores

instance Prelude.NFData CoreDefinitionVersion where
  rnf :: CoreDefinitionVersion -> ()
rnf CoreDefinitionVersion' {Maybe [Core]
cores :: Maybe [Core]
$sel:cores:CoreDefinitionVersion' :: CoreDefinitionVersion -> Maybe [Core]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Core]
cores

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