{-# 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.Config.Types.TemplateSSMDocumentDetails
-- 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.Config.Types.TemplateSSMDocumentDetails where

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

-- | This API allows you to create a conformance pack template with an Amazon
-- Web Services Systems Manager document (SSM document). To deploy a
-- conformance pack using an SSM document, first create an SSM document
-- with conformance pack content, and then provide the @DocumentName@ in
-- the
-- <https://docs.aws.amazon.com/config/latest/APIReference/API_PutConformancePack.html PutConformancePack API>.
-- You can also provide the @DocumentVersion@.
--
-- The @TemplateSSMDocumentDetails@ object contains the name of the SSM
-- document and the version of the SSM document.
--
-- /See:/ 'newTemplateSSMDocumentDetails' smart constructor.
data TemplateSSMDocumentDetails = TemplateSSMDocumentDetails'
  { -- | The version of the SSM document to use to create a conformance pack. By
    -- default, Config uses the latest version.
    --
    -- This field is optional.
    TemplateSSMDocumentDetails -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | The name or Amazon Resource Name (ARN) of the SSM document to use to
    -- create a conformance pack. If you use the document name, Config checks
    -- only your account and Amazon Web Services Region for the SSM document.
    -- If you want to use an SSM document from another Region or account, you
    -- must provide the ARN.
    TemplateSSMDocumentDetails -> Text
documentName :: Prelude.Text
  }
  deriving (TemplateSSMDocumentDetails -> TemplateSSMDocumentDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TemplateSSMDocumentDetails -> TemplateSSMDocumentDetails -> Bool
$c/= :: TemplateSSMDocumentDetails -> TemplateSSMDocumentDetails -> Bool
== :: TemplateSSMDocumentDetails -> TemplateSSMDocumentDetails -> Bool
$c== :: TemplateSSMDocumentDetails -> TemplateSSMDocumentDetails -> Bool
Prelude.Eq, ReadPrec [TemplateSSMDocumentDetails]
ReadPrec TemplateSSMDocumentDetails
Int -> ReadS TemplateSSMDocumentDetails
ReadS [TemplateSSMDocumentDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TemplateSSMDocumentDetails]
$creadListPrec :: ReadPrec [TemplateSSMDocumentDetails]
readPrec :: ReadPrec TemplateSSMDocumentDetails
$creadPrec :: ReadPrec TemplateSSMDocumentDetails
readList :: ReadS [TemplateSSMDocumentDetails]
$creadList :: ReadS [TemplateSSMDocumentDetails]
readsPrec :: Int -> ReadS TemplateSSMDocumentDetails
$creadsPrec :: Int -> ReadS TemplateSSMDocumentDetails
Prelude.Read, Int -> TemplateSSMDocumentDetails -> ShowS
[TemplateSSMDocumentDetails] -> ShowS
TemplateSSMDocumentDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TemplateSSMDocumentDetails] -> ShowS
$cshowList :: [TemplateSSMDocumentDetails] -> ShowS
show :: TemplateSSMDocumentDetails -> String
$cshow :: TemplateSSMDocumentDetails -> String
showsPrec :: Int -> TemplateSSMDocumentDetails -> ShowS
$cshowsPrec :: Int -> TemplateSSMDocumentDetails -> ShowS
Prelude.Show, forall x.
Rep TemplateSSMDocumentDetails x -> TemplateSSMDocumentDetails
forall x.
TemplateSSMDocumentDetails -> Rep TemplateSSMDocumentDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TemplateSSMDocumentDetails x -> TemplateSSMDocumentDetails
$cfrom :: forall x.
TemplateSSMDocumentDetails -> Rep TemplateSSMDocumentDetails x
Prelude.Generic)

-- |
-- Create a value of 'TemplateSSMDocumentDetails' 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:
--
-- 'documentVersion', 'templateSSMDocumentDetails_documentVersion' - The version of the SSM document to use to create a conformance pack. By
-- default, Config uses the latest version.
--
-- This field is optional.
--
-- 'documentName', 'templateSSMDocumentDetails_documentName' - The name or Amazon Resource Name (ARN) of the SSM document to use to
-- create a conformance pack. If you use the document name, Config checks
-- only your account and Amazon Web Services Region for the SSM document.
-- If you want to use an SSM document from another Region or account, you
-- must provide the ARN.
newTemplateSSMDocumentDetails ::
  -- | 'documentName'
  Prelude.Text ->
  TemplateSSMDocumentDetails
newTemplateSSMDocumentDetails :: Text -> TemplateSSMDocumentDetails
newTemplateSSMDocumentDetails Text
pDocumentName_ =
  TemplateSSMDocumentDetails'
    { $sel:documentVersion:TemplateSSMDocumentDetails' :: Maybe Text
documentVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:documentName:TemplateSSMDocumentDetails' :: Text
documentName = Text
pDocumentName_
    }

-- | The version of the SSM document to use to create a conformance pack. By
-- default, Config uses the latest version.
--
-- This field is optional.
templateSSMDocumentDetails_documentVersion :: Lens.Lens' TemplateSSMDocumentDetails (Prelude.Maybe Prelude.Text)
templateSSMDocumentDetails_documentVersion :: Lens' TemplateSSMDocumentDetails (Maybe Text)
templateSSMDocumentDetails_documentVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateSSMDocumentDetails' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: TemplateSSMDocumentDetails
s@TemplateSSMDocumentDetails' {} Maybe Text
a -> TemplateSSMDocumentDetails
s {$sel:documentVersion:TemplateSSMDocumentDetails' :: Maybe Text
documentVersion = Maybe Text
a} :: TemplateSSMDocumentDetails)

-- | The name or Amazon Resource Name (ARN) of the SSM document to use to
-- create a conformance pack. If you use the document name, Config checks
-- only your account and Amazon Web Services Region for the SSM document.
-- If you want to use an SSM document from another Region or account, you
-- must provide the ARN.
templateSSMDocumentDetails_documentName :: Lens.Lens' TemplateSSMDocumentDetails Prelude.Text
templateSSMDocumentDetails_documentName :: Lens' TemplateSSMDocumentDetails Text
templateSSMDocumentDetails_documentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TemplateSSMDocumentDetails' {Text
documentName :: Text
$sel:documentName:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Text
documentName} -> Text
documentName) (\s :: TemplateSSMDocumentDetails
s@TemplateSSMDocumentDetails' {} Text
a -> TemplateSSMDocumentDetails
s {$sel:documentName:TemplateSSMDocumentDetails' :: Text
documentName = Text
a} :: TemplateSSMDocumentDetails)

instance Data.FromJSON TemplateSSMDocumentDetails where
  parseJSON :: Value -> Parser TemplateSSMDocumentDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TemplateSSMDocumentDetails"
      ( \Object
x ->
          Maybe Text -> Text -> TemplateSSMDocumentDetails
TemplateSSMDocumentDetails'
            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
"DocumentVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DocumentName")
      )

instance Prelude.Hashable TemplateSSMDocumentDetails where
  hashWithSalt :: Int -> TemplateSSMDocumentDetails -> Int
hashWithSalt Int
_salt TemplateSSMDocumentDetails' {Maybe Text
Text
documentName :: Text
documentVersion :: Maybe Text
$sel:documentName:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Text
$sel:documentVersion:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
documentVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentName

instance Prelude.NFData TemplateSSMDocumentDetails where
  rnf :: TemplateSSMDocumentDetails -> ()
rnf TemplateSSMDocumentDetails' {Maybe Text
Text
documentName :: Text
documentVersion :: Maybe Text
$sel:documentName:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Text
$sel:documentVersion:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
documentVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentName

instance Data.ToJSON TemplateSSMDocumentDetails where
  toJSON :: TemplateSSMDocumentDetails -> Value
toJSON TemplateSSMDocumentDetails' {Maybe Text
Text
documentName :: Text
documentVersion :: Maybe Text
$sel:documentName:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Text
$sel:documentVersion:TemplateSSMDocumentDetails' :: TemplateSSMDocumentDetails -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DocumentVersion" 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 Text
documentVersion,
            forall a. a -> Maybe a
Prelude.Just (Key
"DocumentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
documentName)
          ]
      )