{-# 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.SSM.Types.DocumentParameter
-- 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.SSM.Types.DocumentParameter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.DocumentParameterType

-- | Parameters specified in a System Manager document that run on the server
-- when the command is run.
--
-- /See:/ 'newDocumentParameter' smart constructor.
data DocumentParameter = DocumentParameter'
  { -- | The name of the parameter.
    DocumentParameter -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | If specified, the default values for the parameters. Parameters without
    -- a default value are required. Parameters with a default value are
    -- optional.
    DocumentParameter -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | The type of parameter. The type can be either String or StringList.
    DocumentParameter -> Maybe DocumentParameterType
type' :: Prelude.Maybe DocumentParameterType,
    -- | A description of what the parameter does, how to use it, the default
    -- value, and whether or not the parameter is optional.
    DocumentParameter -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (DocumentParameter -> DocumentParameter -> Bool
(DocumentParameter -> DocumentParameter -> Bool)
-> (DocumentParameter -> DocumentParameter -> Bool)
-> Eq DocumentParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentParameter -> DocumentParameter -> Bool
$c/= :: DocumentParameter -> DocumentParameter -> Bool
== :: DocumentParameter -> DocumentParameter -> Bool
$c== :: DocumentParameter -> DocumentParameter -> Bool
Prelude.Eq, ReadPrec [DocumentParameter]
ReadPrec DocumentParameter
Int -> ReadS DocumentParameter
ReadS [DocumentParameter]
(Int -> ReadS DocumentParameter)
-> ReadS [DocumentParameter]
-> ReadPrec DocumentParameter
-> ReadPrec [DocumentParameter]
-> Read DocumentParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentParameter]
$creadListPrec :: ReadPrec [DocumentParameter]
readPrec :: ReadPrec DocumentParameter
$creadPrec :: ReadPrec DocumentParameter
readList :: ReadS [DocumentParameter]
$creadList :: ReadS [DocumentParameter]
readsPrec :: Int -> ReadS DocumentParameter
$creadsPrec :: Int -> ReadS DocumentParameter
Prelude.Read, Int -> DocumentParameter -> ShowS
[DocumentParameter] -> ShowS
DocumentParameter -> String
(Int -> DocumentParameter -> ShowS)
-> (DocumentParameter -> String)
-> ([DocumentParameter] -> ShowS)
-> Show DocumentParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentParameter] -> ShowS
$cshowList :: [DocumentParameter] -> ShowS
show :: DocumentParameter -> String
$cshow :: DocumentParameter -> String
showsPrec :: Int -> DocumentParameter -> ShowS
$cshowsPrec :: Int -> DocumentParameter -> ShowS
Prelude.Show, (forall x. DocumentParameter -> Rep DocumentParameter x)
-> (forall x. Rep DocumentParameter x -> DocumentParameter)
-> Generic DocumentParameter
forall x. Rep DocumentParameter x -> DocumentParameter
forall x. DocumentParameter -> Rep DocumentParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentParameter x -> DocumentParameter
$cfrom :: forall x. DocumentParameter -> Rep DocumentParameter x
Prelude.Generic)

-- |
-- Create a value of 'DocumentParameter' 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:
--
-- 'name', 'documentParameter_name' - The name of the parameter.
--
-- 'defaultValue', 'documentParameter_defaultValue' - If specified, the default values for the parameters. Parameters without
-- a default value are required. Parameters with a default value are
-- optional.
--
-- 'type'', 'documentParameter_type' - The type of parameter. The type can be either String or StringList.
--
-- 'description', 'documentParameter_description' - A description of what the parameter does, how to use it, the default
-- value, and whether or not the parameter is optional.
newDocumentParameter ::
  DocumentParameter
newDocumentParameter :: DocumentParameter
newDocumentParameter =
  DocumentParameter' :: Maybe Text
-> Maybe Text
-> Maybe DocumentParameterType
-> Maybe Text
-> DocumentParameter
DocumentParameter'
    { $sel:name:DocumentParameter' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:DocumentParameter' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DocumentParameter' :: Maybe DocumentParameterType
type' = Maybe DocumentParameterType
forall a. Maybe a
Prelude.Nothing,
      $sel:description:DocumentParameter' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | If specified, the default values for the parameters. Parameters without
-- a default value are required. Parameters with a default value are
-- optional.
documentParameter_defaultValue :: Lens.Lens' DocumentParameter (Prelude.Maybe Prelude.Text)
documentParameter_defaultValue :: (Maybe Text -> f (Maybe Text))
-> DocumentParameter -> f DocumentParameter
documentParameter_defaultValue = (DocumentParameter -> Maybe Text)
-> (DocumentParameter -> Maybe Text -> DocumentParameter)
-> Lens
     DocumentParameter DocumentParameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentParameter' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:DocumentParameter' :: DocumentParameter -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: DocumentParameter
s@DocumentParameter' {} Maybe Text
a -> DocumentParameter
s {$sel:defaultValue:DocumentParameter' :: Maybe Text
defaultValue = Maybe Text
a} :: DocumentParameter)

-- | The type of parameter. The type can be either String or StringList.
documentParameter_type :: Lens.Lens' DocumentParameter (Prelude.Maybe DocumentParameterType)
documentParameter_type :: (Maybe DocumentParameterType -> f (Maybe DocumentParameterType))
-> DocumentParameter -> f DocumentParameter
documentParameter_type = (DocumentParameter -> Maybe DocumentParameterType)
-> (DocumentParameter
    -> Maybe DocumentParameterType -> DocumentParameter)
-> Lens
     DocumentParameter
     DocumentParameter
     (Maybe DocumentParameterType)
     (Maybe DocumentParameterType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentParameter' {Maybe DocumentParameterType
type' :: Maybe DocumentParameterType
$sel:type':DocumentParameter' :: DocumentParameter -> Maybe DocumentParameterType
type'} -> Maybe DocumentParameterType
type') (\s :: DocumentParameter
s@DocumentParameter' {} Maybe DocumentParameterType
a -> DocumentParameter
s {$sel:type':DocumentParameter' :: Maybe DocumentParameterType
type' = Maybe DocumentParameterType
a} :: DocumentParameter)

-- | A description of what the parameter does, how to use it, the default
-- value, and whether or not the parameter is optional.
documentParameter_description :: Lens.Lens' DocumentParameter (Prelude.Maybe Prelude.Text)
documentParameter_description :: (Maybe Text -> f (Maybe Text))
-> DocumentParameter -> f DocumentParameter
documentParameter_description = (DocumentParameter -> Maybe Text)
-> (DocumentParameter -> Maybe Text -> DocumentParameter)
-> Lens
     DocumentParameter DocumentParameter (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentParameter' {Maybe Text
description :: Maybe Text
$sel:description:DocumentParameter' :: DocumentParameter -> Maybe Text
description} -> Maybe Text
description) (\s :: DocumentParameter
s@DocumentParameter' {} Maybe Text
a -> DocumentParameter
s {$sel:description:DocumentParameter' :: Maybe Text
description = Maybe Text
a} :: DocumentParameter)

instance Core.FromJSON DocumentParameter where
  parseJSON :: Value -> Parser DocumentParameter
parseJSON =
    String
-> (Object -> Parser DocumentParameter)
-> Value
-> Parser DocumentParameter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DocumentParameter"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe DocumentParameterType
-> Maybe Text
-> DocumentParameter
DocumentParameter'
            (Maybe Text
 -> Maybe Text
 -> Maybe DocumentParameterType
 -> Maybe Text
 -> DocumentParameter)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe DocumentParameterType -> Maybe Text -> DocumentParameter)
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
"Name")
            Parser
  (Maybe Text
   -> Maybe DocumentParameterType -> Maybe Text -> DocumentParameter)
-> Parser (Maybe Text)
-> Parser
     (Maybe DocumentParameterType -> Maybe Text -> DocumentParameter)
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
"DefaultValue")
            Parser
  (Maybe DocumentParameterType -> Maybe Text -> DocumentParameter)
-> Parser (Maybe DocumentParameterType)
-> Parser (Maybe Text -> DocumentParameter)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DocumentParameterType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> DocumentParameter)
-> Parser (Maybe Text) -> Parser DocumentParameter
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
"Description")
      )

instance Prelude.Hashable DocumentParameter

instance Prelude.NFData DocumentParameter