{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateDocument
-- 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)
--
-- Creates a Amazon Web Services Systems Manager (SSM document). An SSM
-- document defines the actions that Systems Manager performs on your
-- managed instances. For more information about SSM documents, including
-- information about supported schemas, features, and syntax, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-ssm-docs.html Amazon Web Services Systems Manager Documents>
-- in the /Amazon Web Services Systems Manager User Guide/.
module Amazonka.SSM.CreateDocument
  ( -- * Creating a Request
    CreateDocument (..),
    newCreateDocument,

    -- * Request Lenses
    createDocument_documentType,
    createDocument_attachments,
    createDocument_versionName,
    createDocument_targetType,
    createDocument_documentFormat,
    createDocument_displayName,
    createDocument_requires,
    createDocument_tags,
    createDocument_content,
    createDocument_name,

    -- * Destructuring the Response
    CreateDocumentResponse (..),
    newCreateDocumentResponse,

    -- * Response Lenses
    createDocumentResponse_documentDescription,
    createDocumentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSM.Types

-- | /See:/ 'newCreateDocument' smart constructor.
data CreateDocument = CreateDocument'
  { -- | The type of document to create.
    CreateDocument -> Maybe DocumentType
documentType :: Prelude.Maybe DocumentType,
    -- | A list of key-value pairs that describe attachments to a version of a
    -- document.
    CreateDocument -> Maybe [AttachmentsSource]
attachments :: Prelude.Maybe [AttachmentsSource],
    -- | An optional field specifying the version of the artifact you are
    -- creating with the document. For example, \"Release 12, Update 6\". This
    -- value is unique across all versions of a document, and can\'t be
    -- changed.
    CreateDocument -> Maybe Text
versionName :: Prelude.Maybe Prelude.Text,
    -- | Specify a target type to define the kinds of resources the document can
    -- run on. For example, to run a document on EC2 instances, specify the
    -- following value: @\/AWS::EC2::Instance@. If you specify a value of
    -- \'\/\' the document can run on all types of resources. If you don\'t
    -- specify a value, the document can\'t run on any resources. For a list of
    -- valid resource types, see
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html Amazon Web Services resource and property types reference>
    -- in the /CloudFormation User Guide/.
    CreateDocument -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text,
    -- | Specify the document format for the request. The document format can be
    -- JSON, YAML, or TEXT. JSON is the default format.
    CreateDocument -> Maybe DocumentFormat
documentFormat :: Prelude.Maybe DocumentFormat,
    -- | An optional field where you can specify a friendly name for the SSM
    -- document. This value can differ for each version of the document. You
    -- can update this value at a later time using the UpdateDocument
    -- operation.
    CreateDocument -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | A list of SSM documents required by a document. This parameter is used
    -- exclusively by AppConfig. When a user creates an AppConfig configuration
    -- in an SSM document, the user must also specify a required document for
    -- validation purposes. In this case, an @ApplicationConfiguration@
    -- document requires an @ApplicationConfigurationSchema@ document for
    -- validation purposes. For more information, see
    -- <https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html What is AppConfig?>
    -- in the /AppConfig User Guide/.
    CreateDocument -> Maybe (NonEmpty DocumentRequires)
requires :: Prelude.Maybe (Prelude.NonEmpty DocumentRequires),
    -- | Optional metadata that you assign to a resource. Tags enable you to
    -- categorize a resource in different ways, such as by purpose, owner, or
    -- environment. For example, you might want to tag an SSM document to
    -- identify the types of targets or the environment where it will run. In
    -- this case, you could specify the following key-value pairs:
    --
    -- -   @Key=OS,Value=Windows@
    --
    -- -   @Key=Environment,Value=Production@
    --
    -- To add tags to an existing SSM document, use the AddTagsToResource
    -- operation.
    CreateDocument -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The content for the new SSM document in JSON or YAML format. We
    -- recommend storing the contents for your new document in an external JSON
    -- or YAML file and referencing the file in a command.
    --
    -- For examples, see the following topics in the /Amazon Web Services
    -- Systems Manager User Guide/.
    --
    -- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (Amazon Web Services API)>
    --
    -- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-cli.html Create an SSM document (Amazon Web Services CLI)>
    --
    -- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (API)>
    CreateDocument -> Text
content :: Prelude.Text,
    -- | A name for the SSM document.
    --
    -- You can\'t use the following strings as document name prefixes. These
    -- are reserved by Amazon Web Services for use as document name prefixes:
    --
    -- -   @aws-@
    --
    -- -   @amazon@
    --
    -- -   @amzn@
    CreateDocument -> Text
name :: Prelude.Text
  }
  deriving (CreateDocument -> CreateDocument -> Bool
(CreateDocument -> CreateDocument -> Bool)
-> (CreateDocument -> CreateDocument -> Bool) -> Eq CreateDocument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDocument -> CreateDocument -> Bool
$c/= :: CreateDocument -> CreateDocument -> Bool
== :: CreateDocument -> CreateDocument -> Bool
$c== :: CreateDocument -> CreateDocument -> Bool
Prelude.Eq, ReadPrec [CreateDocument]
ReadPrec CreateDocument
Int -> ReadS CreateDocument
ReadS [CreateDocument]
(Int -> ReadS CreateDocument)
-> ReadS [CreateDocument]
-> ReadPrec CreateDocument
-> ReadPrec [CreateDocument]
-> Read CreateDocument
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDocument]
$creadListPrec :: ReadPrec [CreateDocument]
readPrec :: ReadPrec CreateDocument
$creadPrec :: ReadPrec CreateDocument
readList :: ReadS [CreateDocument]
$creadList :: ReadS [CreateDocument]
readsPrec :: Int -> ReadS CreateDocument
$creadsPrec :: Int -> ReadS CreateDocument
Prelude.Read, Int -> CreateDocument -> ShowS
[CreateDocument] -> ShowS
CreateDocument -> String
(Int -> CreateDocument -> ShowS)
-> (CreateDocument -> String)
-> ([CreateDocument] -> ShowS)
-> Show CreateDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDocument] -> ShowS
$cshowList :: [CreateDocument] -> ShowS
show :: CreateDocument -> String
$cshow :: CreateDocument -> String
showsPrec :: Int -> CreateDocument -> ShowS
$cshowsPrec :: Int -> CreateDocument -> ShowS
Prelude.Show, (forall x. CreateDocument -> Rep CreateDocument x)
-> (forall x. Rep CreateDocument x -> CreateDocument)
-> Generic CreateDocument
forall x. Rep CreateDocument x -> CreateDocument
forall x. CreateDocument -> Rep CreateDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDocument x -> CreateDocument
$cfrom :: forall x. CreateDocument -> Rep CreateDocument x
Prelude.Generic)

-- |
-- Create a value of 'CreateDocument' 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:
--
-- 'documentType', 'createDocument_documentType' - The type of document to create.
--
-- 'attachments', 'createDocument_attachments' - A list of key-value pairs that describe attachments to a version of a
-- document.
--
-- 'versionName', 'createDocument_versionName' - An optional field specifying the version of the artifact you are
-- creating with the document. For example, \"Release 12, Update 6\". This
-- value is unique across all versions of a document, and can\'t be
-- changed.
--
-- 'targetType', 'createDocument_targetType' - Specify a target type to define the kinds of resources the document can
-- run on. For example, to run a document on EC2 instances, specify the
-- following value: @\/AWS::EC2::Instance@. If you specify a value of
-- \'\/\' the document can run on all types of resources. If you don\'t
-- specify a value, the document can\'t run on any resources. For a list of
-- valid resource types, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html Amazon Web Services resource and property types reference>
-- in the /CloudFormation User Guide/.
--
-- 'documentFormat', 'createDocument_documentFormat' - Specify the document format for the request. The document format can be
-- JSON, YAML, or TEXT. JSON is the default format.
--
-- 'displayName', 'createDocument_displayName' - An optional field where you can specify a friendly name for the SSM
-- document. This value can differ for each version of the document. You
-- can update this value at a later time using the UpdateDocument
-- operation.
--
-- 'requires', 'createDocument_requires' - A list of SSM documents required by a document. This parameter is used
-- exclusively by AppConfig. When a user creates an AppConfig configuration
-- in an SSM document, the user must also specify a required document for
-- validation purposes. In this case, an @ApplicationConfiguration@
-- document requires an @ApplicationConfigurationSchema@ document for
-- validation purposes. For more information, see
-- <https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html What is AppConfig?>
-- in the /AppConfig User Guide/.
--
-- 'tags', 'createDocument_tags' - Optional metadata that you assign to a resource. Tags enable you to
-- categorize a resource in different ways, such as by purpose, owner, or
-- environment. For example, you might want to tag an SSM document to
-- identify the types of targets or the environment where it will run. In
-- this case, you could specify the following key-value pairs:
--
-- -   @Key=OS,Value=Windows@
--
-- -   @Key=Environment,Value=Production@
--
-- To add tags to an existing SSM document, use the AddTagsToResource
-- operation.
--
-- 'content', 'createDocument_content' - The content for the new SSM document in JSON or YAML format. We
-- recommend storing the contents for your new document in an external JSON
-- or YAML file and referencing the file in a command.
--
-- For examples, see the following topics in the /Amazon Web Services
-- Systems Manager User Guide/.
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (Amazon Web Services API)>
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-cli.html Create an SSM document (Amazon Web Services CLI)>
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (API)>
--
-- 'name', 'createDocument_name' - A name for the SSM document.
--
-- You can\'t use the following strings as document name prefixes. These
-- are reserved by Amazon Web Services for use as document name prefixes:
--
-- -   @aws-@
--
-- -   @amazon@
--
-- -   @amzn@
newCreateDocument ::
  -- | 'content'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  CreateDocument
newCreateDocument :: Text -> Text -> CreateDocument
newCreateDocument Text
pContent_ Text
pName_ =
  CreateDocument' :: Maybe DocumentType
-> Maybe [AttachmentsSource]
-> Maybe Text
-> Maybe Text
-> Maybe DocumentFormat
-> Maybe Text
-> Maybe (NonEmpty DocumentRequires)
-> Maybe [Tag]
-> Text
-> Text
-> CreateDocument
CreateDocument'
    { $sel:documentType:CreateDocument' :: Maybe DocumentType
documentType = Maybe DocumentType
forall a. Maybe a
Prelude.Nothing,
      $sel:attachments:CreateDocument' :: Maybe [AttachmentsSource]
attachments = Maybe [AttachmentsSource]
forall a. Maybe a
Prelude.Nothing,
      $sel:versionName:CreateDocument' :: Maybe Text
versionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:CreateDocument' :: Maybe Text
targetType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:documentFormat:CreateDocument' :: Maybe DocumentFormat
documentFormat = Maybe DocumentFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:CreateDocument' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:requires:CreateDocument' :: Maybe (NonEmpty DocumentRequires)
requires = Maybe (NonEmpty DocumentRequires)
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateDocument' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:content:CreateDocument' :: Text
content = Text
pContent_,
      $sel:name:CreateDocument' :: Text
name = Text
pName_
    }

-- | The type of document to create.
createDocument_documentType :: Lens.Lens' CreateDocument (Prelude.Maybe DocumentType)
createDocument_documentType :: (Maybe DocumentType -> f (Maybe DocumentType))
-> CreateDocument -> f CreateDocument
createDocument_documentType = (CreateDocument -> Maybe DocumentType)
-> (CreateDocument -> Maybe DocumentType -> CreateDocument)
-> Lens
     CreateDocument
     CreateDocument
     (Maybe DocumentType)
     (Maybe DocumentType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe DocumentType
documentType :: Maybe DocumentType
$sel:documentType:CreateDocument' :: CreateDocument -> Maybe DocumentType
documentType} -> Maybe DocumentType
documentType) (\s :: CreateDocument
s@CreateDocument' {} Maybe DocumentType
a -> CreateDocument
s {$sel:documentType:CreateDocument' :: Maybe DocumentType
documentType = Maybe DocumentType
a} :: CreateDocument)

-- | A list of key-value pairs that describe attachments to a version of a
-- document.
createDocument_attachments :: Lens.Lens' CreateDocument (Prelude.Maybe [AttachmentsSource])
createDocument_attachments :: (Maybe [AttachmentsSource] -> f (Maybe [AttachmentsSource]))
-> CreateDocument -> f CreateDocument
createDocument_attachments = (CreateDocument -> Maybe [AttachmentsSource])
-> (CreateDocument -> Maybe [AttachmentsSource] -> CreateDocument)
-> Lens
     CreateDocument
     CreateDocument
     (Maybe [AttachmentsSource])
     (Maybe [AttachmentsSource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe [AttachmentsSource]
attachments :: Maybe [AttachmentsSource]
$sel:attachments:CreateDocument' :: CreateDocument -> Maybe [AttachmentsSource]
attachments} -> Maybe [AttachmentsSource]
attachments) (\s :: CreateDocument
s@CreateDocument' {} Maybe [AttachmentsSource]
a -> CreateDocument
s {$sel:attachments:CreateDocument' :: Maybe [AttachmentsSource]
attachments = Maybe [AttachmentsSource]
a} :: CreateDocument) ((Maybe [AttachmentsSource] -> f (Maybe [AttachmentsSource]))
 -> CreateDocument -> f CreateDocument)
-> ((Maybe [AttachmentsSource] -> f (Maybe [AttachmentsSource]))
    -> Maybe [AttachmentsSource] -> f (Maybe [AttachmentsSource]))
-> (Maybe [AttachmentsSource] -> f (Maybe [AttachmentsSource]))
-> CreateDocument
-> f CreateDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttachmentsSource]
  [AttachmentsSource]
  [AttachmentsSource]
  [AttachmentsSource]
-> Iso
     (Maybe [AttachmentsSource])
     (Maybe [AttachmentsSource])
     (Maybe [AttachmentsSource])
     (Maybe [AttachmentsSource])
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 AnIso
  [AttachmentsSource]
  [AttachmentsSource]
  [AttachmentsSource]
  [AttachmentsSource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An optional field specifying the version of the artifact you are
-- creating with the document. For example, \"Release 12, Update 6\". This
-- value is unique across all versions of a document, and can\'t be
-- changed.
createDocument_versionName :: Lens.Lens' CreateDocument (Prelude.Maybe Prelude.Text)
createDocument_versionName :: (Maybe Text -> f (Maybe Text))
-> CreateDocument -> f CreateDocument
createDocument_versionName = (CreateDocument -> Maybe Text)
-> (CreateDocument -> Maybe Text -> CreateDocument)
-> Lens CreateDocument CreateDocument (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe Text
versionName :: Maybe Text
$sel:versionName:CreateDocument' :: CreateDocument -> Maybe Text
versionName} -> Maybe Text
versionName) (\s :: CreateDocument
s@CreateDocument' {} Maybe Text
a -> CreateDocument
s {$sel:versionName:CreateDocument' :: Maybe Text
versionName = Maybe Text
a} :: CreateDocument)

-- | Specify a target type to define the kinds of resources the document can
-- run on. For example, to run a document on EC2 instances, specify the
-- following value: @\/AWS::EC2::Instance@. If you specify a value of
-- \'\/\' the document can run on all types of resources. If you don\'t
-- specify a value, the document can\'t run on any resources. For a list of
-- valid resource types, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html Amazon Web Services resource and property types reference>
-- in the /CloudFormation User Guide/.
createDocument_targetType :: Lens.Lens' CreateDocument (Prelude.Maybe Prelude.Text)
createDocument_targetType :: (Maybe Text -> f (Maybe Text))
-> CreateDocument -> f CreateDocument
createDocument_targetType = (CreateDocument -> Maybe Text)
-> (CreateDocument -> Maybe Text -> CreateDocument)
-> Lens CreateDocument CreateDocument (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe Text
targetType :: Maybe Text
$sel:targetType:CreateDocument' :: CreateDocument -> Maybe Text
targetType} -> Maybe Text
targetType) (\s :: CreateDocument
s@CreateDocument' {} Maybe Text
a -> CreateDocument
s {$sel:targetType:CreateDocument' :: Maybe Text
targetType = Maybe Text
a} :: CreateDocument)

-- | Specify the document format for the request. The document format can be
-- JSON, YAML, or TEXT. JSON is the default format.
createDocument_documentFormat :: Lens.Lens' CreateDocument (Prelude.Maybe DocumentFormat)
createDocument_documentFormat :: (Maybe DocumentFormat -> f (Maybe DocumentFormat))
-> CreateDocument -> f CreateDocument
createDocument_documentFormat = (CreateDocument -> Maybe DocumentFormat)
-> (CreateDocument -> Maybe DocumentFormat -> CreateDocument)
-> Lens
     CreateDocument
     CreateDocument
     (Maybe DocumentFormat)
     (Maybe DocumentFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe DocumentFormat
documentFormat :: Maybe DocumentFormat
$sel:documentFormat:CreateDocument' :: CreateDocument -> Maybe DocumentFormat
documentFormat} -> Maybe DocumentFormat
documentFormat) (\s :: CreateDocument
s@CreateDocument' {} Maybe DocumentFormat
a -> CreateDocument
s {$sel:documentFormat:CreateDocument' :: Maybe DocumentFormat
documentFormat = Maybe DocumentFormat
a} :: CreateDocument)

-- | An optional field where you can specify a friendly name for the SSM
-- document. This value can differ for each version of the document. You
-- can update this value at a later time using the UpdateDocument
-- operation.
createDocument_displayName :: Lens.Lens' CreateDocument (Prelude.Maybe Prelude.Text)
createDocument_displayName :: (Maybe Text -> f (Maybe Text))
-> CreateDocument -> f CreateDocument
createDocument_displayName = (CreateDocument -> Maybe Text)
-> (CreateDocument -> Maybe Text -> CreateDocument)
-> Lens CreateDocument CreateDocument (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe Text
displayName :: Maybe Text
$sel:displayName:CreateDocument' :: CreateDocument -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: CreateDocument
s@CreateDocument' {} Maybe Text
a -> CreateDocument
s {$sel:displayName:CreateDocument' :: Maybe Text
displayName = Maybe Text
a} :: CreateDocument)

-- | A list of SSM documents required by a document. This parameter is used
-- exclusively by AppConfig. When a user creates an AppConfig configuration
-- in an SSM document, the user must also specify a required document for
-- validation purposes. In this case, an @ApplicationConfiguration@
-- document requires an @ApplicationConfigurationSchema@ document for
-- validation purposes. For more information, see
-- <https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html What is AppConfig?>
-- in the /AppConfig User Guide/.
createDocument_requires :: Lens.Lens' CreateDocument (Prelude.Maybe (Prelude.NonEmpty DocumentRequires))
createDocument_requires :: (Maybe (NonEmpty DocumentRequires)
 -> f (Maybe (NonEmpty DocumentRequires)))
-> CreateDocument -> f CreateDocument
createDocument_requires = (CreateDocument -> Maybe (NonEmpty DocumentRequires))
-> (CreateDocument
    -> Maybe (NonEmpty DocumentRequires) -> CreateDocument)
-> Lens
     CreateDocument
     CreateDocument
     (Maybe (NonEmpty DocumentRequires))
     (Maybe (NonEmpty DocumentRequires))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe (NonEmpty DocumentRequires)
requires :: Maybe (NonEmpty DocumentRequires)
$sel:requires:CreateDocument' :: CreateDocument -> Maybe (NonEmpty DocumentRequires)
requires} -> Maybe (NonEmpty DocumentRequires)
requires) (\s :: CreateDocument
s@CreateDocument' {} Maybe (NonEmpty DocumentRequires)
a -> CreateDocument
s {$sel:requires:CreateDocument' :: Maybe (NonEmpty DocumentRequires)
requires = Maybe (NonEmpty DocumentRequires)
a} :: CreateDocument) ((Maybe (NonEmpty DocumentRequires)
  -> f (Maybe (NonEmpty DocumentRequires)))
 -> CreateDocument -> f CreateDocument)
-> ((Maybe (NonEmpty DocumentRequires)
     -> f (Maybe (NonEmpty DocumentRequires)))
    -> Maybe (NonEmpty DocumentRequires)
    -> f (Maybe (NonEmpty DocumentRequires)))
-> (Maybe (NonEmpty DocumentRequires)
    -> f (Maybe (NonEmpty DocumentRequires)))
-> CreateDocument
-> f CreateDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
-> Iso
     (Maybe (NonEmpty DocumentRequires))
     (Maybe (NonEmpty DocumentRequires))
     (Maybe (NonEmpty DocumentRequires))
     (Maybe (NonEmpty DocumentRequires))
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 AnIso
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
  (NonEmpty DocumentRequires)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Optional metadata that you assign to a resource. Tags enable you to
-- categorize a resource in different ways, such as by purpose, owner, or
-- environment. For example, you might want to tag an SSM document to
-- identify the types of targets or the environment where it will run. In
-- this case, you could specify the following key-value pairs:
--
-- -   @Key=OS,Value=Windows@
--
-- -   @Key=Environment,Value=Production@
--
-- To add tags to an existing SSM document, use the AddTagsToResource
-- operation.
createDocument_tags :: Lens.Lens' CreateDocument (Prelude.Maybe [Tag])
createDocument_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDocument -> f CreateDocument
createDocument_tags = (CreateDocument -> Maybe [Tag])
-> (CreateDocument -> Maybe [Tag] -> CreateDocument)
-> Lens CreateDocument CreateDocument (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDocument' :: CreateDocument -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDocument
s@CreateDocument' {} Maybe [Tag]
a -> CreateDocument
s {$sel:tags:CreateDocument' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDocument) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateDocument -> f CreateDocument)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDocument
-> f CreateDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The content for the new SSM document in JSON or YAML format. We
-- recommend storing the contents for your new document in an external JSON
-- or YAML file and referencing the file in a command.
--
-- For examples, see the following topics in the /Amazon Web Services
-- Systems Manager User Guide/.
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (Amazon Web Services API)>
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-cli.html Create an SSM document (Amazon Web Services CLI)>
--
-- -   <https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html Create an SSM document (API)>
createDocument_content :: Lens.Lens' CreateDocument Prelude.Text
createDocument_content :: (Text -> f Text) -> CreateDocument -> f CreateDocument
createDocument_content = (CreateDocument -> Text)
-> (CreateDocument -> Text -> CreateDocument)
-> Lens CreateDocument CreateDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Text
content :: Text
$sel:content:CreateDocument' :: CreateDocument -> Text
content} -> Text
content) (\s :: CreateDocument
s@CreateDocument' {} Text
a -> CreateDocument
s {$sel:content:CreateDocument' :: Text
content = Text
a} :: CreateDocument)

-- | A name for the SSM document.
--
-- You can\'t use the following strings as document name prefixes. These
-- are reserved by Amazon Web Services for use as document name prefixes:
--
-- -   @aws-@
--
-- -   @amazon@
--
-- -   @amzn@
createDocument_name :: Lens.Lens' CreateDocument Prelude.Text
createDocument_name :: (Text -> f Text) -> CreateDocument -> f CreateDocument
createDocument_name = (CreateDocument -> Text)
-> (CreateDocument -> Text -> CreateDocument)
-> Lens CreateDocument CreateDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocument' {Text
name :: Text
$sel:name:CreateDocument' :: CreateDocument -> Text
name} -> Text
name) (\s :: CreateDocument
s@CreateDocument' {} Text
a -> CreateDocument
s {$sel:name:CreateDocument' :: Text
name = Text
a} :: CreateDocument)

instance Core.AWSRequest CreateDocument where
  type
    AWSResponse CreateDocument =
      CreateDocumentResponse
  request :: CreateDocument -> Request CreateDocument
request = Service -> CreateDocument -> Request CreateDocument
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDocument)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDocument))
-> Logger
-> Service
-> Proxy CreateDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDocument)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DocumentDescription -> Int -> CreateDocumentResponse
CreateDocumentResponse'
            (Maybe DocumentDescription -> Int -> CreateDocumentResponse)
-> Either String (Maybe DocumentDescription)
-> Either String (Int -> CreateDocumentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DocumentDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DocumentDescription")
            Either String (Int -> CreateDocumentResponse)
-> Either String Int -> Either String CreateDocumentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateDocument

instance Prelude.NFData CreateDocument

instance Core.ToHeaders CreateDocument where
  toHeaders :: CreateDocument -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDocument -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AmazonSSM.CreateDocument" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateDocument where
  toJSON :: CreateDocument -> Value
toJSON CreateDocument' {Maybe [AttachmentsSource]
Maybe [Tag]
Maybe (NonEmpty DocumentRequires)
Maybe Text
Maybe DocumentFormat
Maybe DocumentType
Text
name :: Text
content :: Text
tags :: Maybe [Tag]
requires :: Maybe (NonEmpty DocumentRequires)
displayName :: Maybe Text
documentFormat :: Maybe DocumentFormat
targetType :: Maybe Text
versionName :: Maybe Text
attachments :: Maybe [AttachmentsSource]
documentType :: Maybe DocumentType
$sel:name:CreateDocument' :: CreateDocument -> Text
$sel:content:CreateDocument' :: CreateDocument -> Text
$sel:tags:CreateDocument' :: CreateDocument -> Maybe [Tag]
$sel:requires:CreateDocument' :: CreateDocument -> Maybe (NonEmpty DocumentRequires)
$sel:displayName:CreateDocument' :: CreateDocument -> Maybe Text
$sel:documentFormat:CreateDocument' :: CreateDocument -> Maybe DocumentFormat
$sel:targetType:CreateDocument' :: CreateDocument -> Maybe Text
$sel:versionName:CreateDocument' :: CreateDocument -> Maybe Text
$sel:attachments:CreateDocument' :: CreateDocument -> Maybe [AttachmentsSource]
$sel:documentType:CreateDocument' :: CreateDocument -> Maybe DocumentType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DocumentType" Text -> DocumentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DocumentType -> Pair) -> Maybe DocumentType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentType
documentType,
            (Text
"Attachments" Text -> [AttachmentsSource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AttachmentsSource] -> Pair)
-> Maybe [AttachmentsSource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AttachmentsSource]
attachments,
            (Text
"VersionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
versionName,
            (Text
"TargetType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetType,
            (Text
"DocumentFormat" Text -> DocumentFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DocumentFormat -> Pair) -> Maybe DocumentFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentFormat
documentFormat,
            (Text
"DisplayName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
displayName,
            (Text
"Requires" Text -> NonEmpty DocumentRequires -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty DocumentRequires -> Pair)
-> Maybe (NonEmpty DocumentRequires) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty DocumentRequires)
requires,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Content" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
content),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath CreateDocument where
  toPath :: CreateDocument -> ByteString
toPath = ByteString -> CreateDocument -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateDocument where
  toQuery :: CreateDocument -> QueryString
toQuery = QueryString -> CreateDocument -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateDocumentResponse' smart constructor.
data CreateDocumentResponse = CreateDocumentResponse'
  { -- | Information about the SSM document.
    CreateDocumentResponse -> Maybe DocumentDescription
documentDescription :: Prelude.Maybe DocumentDescription,
    -- | The response's http status code.
    CreateDocumentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDocumentResponse -> CreateDocumentResponse -> Bool
(CreateDocumentResponse -> CreateDocumentResponse -> Bool)
-> (CreateDocumentResponse -> CreateDocumentResponse -> Bool)
-> Eq CreateDocumentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDocumentResponse -> CreateDocumentResponse -> Bool
$c/= :: CreateDocumentResponse -> CreateDocumentResponse -> Bool
== :: CreateDocumentResponse -> CreateDocumentResponse -> Bool
$c== :: CreateDocumentResponse -> CreateDocumentResponse -> Bool
Prelude.Eq, ReadPrec [CreateDocumentResponse]
ReadPrec CreateDocumentResponse
Int -> ReadS CreateDocumentResponse
ReadS [CreateDocumentResponse]
(Int -> ReadS CreateDocumentResponse)
-> ReadS [CreateDocumentResponse]
-> ReadPrec CreateDocumentResponse
-> ReadPrec [CreateDocumentResponse]
-> Read CreateDocumentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDocumentResponse]
$creadListPrec :: ReadPrec [CreateDocumentResponse]
readPrec :: ReadPrec CreateDocumentResponse
$creadPrec :: ReadPrec CreateDocumentResponse
readList :: ReadS [CreateDocumentResponse]
$creadList :: ReadS [CreateDocumentResponse]
readsPrec :: Int -> ReadS CreateDocumentResponse
$creadsPrec :: Int -> ReadS CreateDocumentResponse
Prelude.Read, Int -> CreateDocumentResponse -> ShowS
[CreateDocumentResponse] -> ShowS
CreateDocumentResponse -> String
(Int -> CreateDocumentResponse -> ShowS)
-> (CreateDocumentResponse -> String)
-> ([CreateDocumentResponse] -> ShowS)
-> Show CreateDocumentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDocumentResponse] -> ShowS
$cshowList :: [CreateDocumentResponse] -> ShowS
show :: CreateDocumentResponse -> String
$cshow :: CreateDocumentResponse -> String
showsPrec :: Int -> CreateDocumentResponse -> ShowS
$cshowsPrec :: Int -> CreateDocumentResponse -> ShowS
Prelude.Show, (forall x. CreateDocumentResponse -> Rep CreateDocumentResponse x)
-> (forall x.
    Rep CreateDocumentResponse x -> CreateDocumentResponse)
-> Generic CreateDocumentResponse
forall x. Rep CreateDocumentResponse x -> CreateDocumentResponse
forall x. CreateDocumentResponse -> Rep CreateDocumentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDocumentResponse x -> CreateDocumentResponse
$cfrom :: forall x. CreateDocumentResponse -> Rep CreateDocumentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDocumentResponse' 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:
--
-- 'documentDescription', 'createDocumentResponse_documentDescription' - Information about the SSM document.
--
-- 'httpStatus', 'createDocumentResponse_httpStatus' - The response's http status code.
newCreateDocumentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDocumentResponse
newCreateDocumentResponse :: Int -> CreateDocumentResponse
newCreateDocumentResponse Int
pHttpStatus_ =
  CreateDocumentResponse' :: Maybe DocumentDescription -> Int -> CreateDocumentResponse
CreateDocumentResponse'
    { $sel:documentDescription:CreateDocumentResponse' :: Maybe DocumentDescription
documentDescription =
        Maybe DocumentDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the SSM document.
createDocumentResponse_documentDescription :: Lens.Lens' CreateDocumentResponse (Prelude.Maybe DocumentDescription)
createDocumentResponse_documentDescription :: (Maybe DocumentDescription -> f (Maybe DocumentDescription))
-> CreateDocumentResponse -> f CreateDocumentResponse
createDocumentResponse_documentDescription = (CreateDocumentResponse -> Maybe DocumentDescription)
-> (CreateDocumentResponse
    -> Maybe DocumentDescription -> CreateDocumentResponse)
-> Lens
     CreateDocumentResponse
     CreateDocumentResponse
     (Maybe DocumentDescription)
     (Maybe DocumentDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocumentResponse' {Maybe DocumentDescription
documentDescription :: Maybe DocumentDescription
$sel:documentDescription:CreateDocumentResponse' :: CreateDocumentResponse -> Maybe DocumentDescription
documentDescription} -> Maybe DocumentDescription
documentDescription) (\s :: CreateDocumentResponse
s@CreateDocumentResponse' {} Maybe DocumentDescription
a -> CreateDocumentResponse
s {$sel:documentDescription:CreateDocumentResponse' :: Maybe DocumentDescription
documentDescription = Maybe DocumentDescription
a} :: CreateDocumentResponse)

-- | The response's http status code.
createDocumentResponse_httpStatus :: Lens.Lens' CreateDocumentResponse Prelude.Int
createDocumentResponse_httpStatus :: (Int -> f Int)
-> CreateDocumentResponse -> f CreateDocumentResponse
createDocumentResponse_httpStatus = (CreateDocumentResponse -> Int)
-> (CreateDocumentResponse -> Int -> CreateDocumentResponse)
-> Lens CreateDocumentResponse CreateDocumentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocumentResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDocumentResponse' :: CreateDocumentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateDocumentResponse
s@CreateDocumentResponse' {} Int
a -> CreateDocumentResponse
s {$sel:httpStatus:CreateDocumentResponse' :: Int
httpStatus = Int
a} :: CreateDocumentResponse)

instance Prelude.NFData CreateDocumentResponse