{-# 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.GroundStation.Types.DecodeConfig
-- 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.GroundStation.Types.DecodeConfig where

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

-- | Information about the decode @Config@.
--
-- /See:/ 'newDecodeConfig' smart constructor.
data DecodeConfig = DecodeConfig'
  { -- | Unvalidated JSON of a decode @Config@.
    DecodeConfig -> Text
unvalidatedJSON :: Prelude.Text
  }
  deriving (DecodeConfig -> DecodeConfig -> Bool
(DecodeConfig -> DecodeConfig -> Bool)
-> (DecodeConfig -> DecodeConfig -> Bool) -> Eq DecodeConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DecodeConfig -> DecodeConfig -> Bool
$c/= :: DecodeConfig -> DecodeConfig -> Bool
== :: DecodeConfig -> DecodeConfig -> Bool
$c== :: DecodeConfig -> DecodeConfig -> Bool
Prelude.Eq, ReadPrec [DecodeConfig]
ReadPrec DecodeConfig
Int -> ReadS DecodeConfig
ReadS [DecodeConfig]
(Int -> ReadS DecodeConfig)
-> ReadS [DecodeConfig]
-> ReadPrec DecodeConfig
-> ReadPrec [DecodeConfig]
-> Read DecodeConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DecodeConfig]
$creadListPrec :: ReadPrec [DecodeConfig]
readPrec :: ReadPrec DecodeConfig
$creadPrec :: ReadPrec DecodeConfig
readList :: ReadS [DecodeConfig]
$creadList :: ReadS [DecodeConfig]
readsPrec :: Int -> ReadS DecodeConfig
$creadsPrec :: Int -> ReadS DecodeConfig
Prelude.Read, Int -> DecodeConfig -> ShowS
[DecodeConfig] -> ShowS
DecodeConfig -> String
(Int -> DecodeConfig -> ShowS)
-> (DecodeConfig -> String)
-> ([DecodeConfig] -> ShowS)
-> Show DecodeConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecodeConfig] -> ShowS
$cshowList :: [DecodeConfig] -> ShowS
show :: DecodeConfig -> String
$cshow :: DecodeConfig -> String
showsPrec :: Int -> DecodeConfig -> ShowS
$cshowsPrec :: Int -> DecodeConfig -> ShowS
Prelude.Show, (forall x. DecodeConfig -> Rep DecodeConfig x)
-> (forall x. Rep DecodeConfig x -> DecodeConfig)
-> Generic DecodeConfig
forall x. Rep DecodeConfig x -> DecodeConfig
forall x. DecodeConfig -> Rep DecodeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DecodeConfig x -> DecodeConfig
$cfrom :: forall x. DecodeConfig -> Rep DecodeConfig x
Prelude.Generic)

-- |
-- Create a value of 'DecodeConfig' 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:
--
-- 'unvalidatedJSON', 'decodeConfig_unvalidatedJSON' - Unvalidated JSON of a decode @Config@.
newDecodeConfig ::
  -- | 'unvalidatedJSON'
  Prelude.Text ->
  DecodeConfig
newDecodeConfig :: Text -> DecodeConfig
newDecodeConfig Text
pUnvalidatedJSON_ =
  DecodeConfig' :: Text -> DecodeConfig
DecodeConfig' {$sel:unvalidatedJSON:DecodeConfig' :: Text
unvalidatedJSON = Text
pUnvalidatedJSON_}

-- | Unvalidated JSON of a decode @Config@.
decodeConfig_unvalidatedJSON :: Lens.Lens' DecodeConfig Prelude.Text
decodeConfig_unvalidatedJSON :: (Text -> f Text) -> DecodeConfig -> f DecodeConfig
decodeConfig_unvalidatedJSON = (DecodeConfig -> Text)
-> (DecodeConfig -> Text -> DecodeConfig)
-> Lens DecodeConfig DecodeConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecodeConfig' {Text
unvalidatedJSON :: Text
$sel:unvalidatedJSON:DecodeConfig' :: DecodeConfig -> Text
unvalidatedJSON} -> Text
unvalidatedJSON) (\s :: DecodeConfig
s@DecodeConfig' {} Text
a -> DecodeConfig
s {$sel:unvalidatedJSON:DecodeConfig' :: Text
unvalidatedJSON = Text
a} :: DecodeConfig)

instance Core.FromJSON DecodeConfig where
  parseJSON :: Value -> Parser DecodeConfig
parseJSON =
    String
-> (Object -> Parser DecodeConfig) -> Value -> Parser DecodeConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DecodeConfig"
      ( \Object
x ->
          Text -> DecodeConfig
DecodeConfig'
            (Text -> DecodeConfig) -> Parser Text -> Parser DecodeConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"unvalidatedJSON")
      )

instance Prelude.Hashable DecodeConfig

instance Prelude.NFData DecodeConfig

instance Core.ToJSON DecodeConfig where
  toJSON :: DecodeConfig -> Value
toJSON DecodeConfig' {Text
unvalidatedJSON :: Text
$sel:unvalidatedJSON:DecodeConfig' :: DecodeConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"unvalidatedJSON" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
unvalidatedJSON)
          ]
      )