{-# 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.CreateAssociation
-- 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)
--
-- A State Manager association defines the state that you want to maintain
-- on your instances. For example, an association can specify that
-- anti-virus software must be installed and running on your instances, or
-- that certain ports must be closed. For static targets, the association
-- specifies a schedule for when the configuration is reapplied. For
-- dynamic targets, such as an Amazon Web Services resource group or an
-- Amazon Web Services autoscaling group, State Manager, a capability of
-- Amazon Web Services Systems Manager applies the configuration when new
-- instances are added to the group. The association also specifies actions
-- to take when applying the configuration. For example, an association for
-- anti-virus software might run once a day. If the software isn\'t
-- installed, then State Manager installs it. If the software is installed,
-- but the service isn\'t running, then the association might instruct
-- State Manager to start the service.
module Amazonka.SSM.CreateAssociation
  ( -- * Creating a Request
    CreateAssociation (..),
    newCreateAssociation,

    -- * Request Lenses
    createAssociation_instanceId,
    createAssociation_targetLocations,
    createAssociation_applyOnlyAtCronInterval,
    createAssociation_maxErrors,
    createAssociation_scheduleExpression,
    createAssociation_outputLocation,
    createAssociation_syncCompliance,
    createAssociation_targets,
    createAssociation_parameters,
    createAssociation_documentVersion,
    createAssociation_automationTargetParameterName,
    createAssociation_associationName,
    createAssociation_calendarNames,
    createAssociation_complianceSeverity,
    createAssociation_maxConcurrency,
    createAssociation_name,

    -- * Destructuring the Response
    CreateAssociationResponse (..),
    newCreateAssociationResponse,

    -- * Response Lenses
    createAssociationResponse_associationDescription,
    createAssociationResponse_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:/ 'newCreateAssociation' smart constructor.
data CreateAssociation = CreateAssociation'
  { -- | The instance ID.
    --
    -- @InstanceId@ has been deprecated. To specify an instance ID for an
    -- association, use the @Targets@ parameter. Requests that include the
    -- parameter @InstanceID@ with Systems Manager documents (SSM documents)
    -- that use schema version 2.0 or later will fail. In addition, if you use
    -- the parameter @InstanceId@, you can\'t use the parameters
    -- @AssociationName@, @DocumentVersion@, @MaxErrors@, @MaxConcurrency@,
    -- @OutputLocation@, or @ScheduleExpression@. To use these parameters, you
    -- must use the @Targets@ parameter.
    CreateAssociation -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | A location is a combination of Amazon Web Services Regions and Amazon
    -- Web Services accounts where you want to run the association. Use this
    -- action to create an association in multiple Regions and multiple
    -- accounts.
    CreateAssociation -> Maybe (NonEmpty TargetLocation)
targetLocations :: Prelude.Maybe (Prelude.NonEmpty TargetLocation),
    -- | By default, when you create a new association, the system runs it
    -- immediately after it is created and then according to the schedule you
    -- specified. Specify this option if you don\'t want an association to run
    -- immediately after you create it. This parameter isn\'t supported for
    -- rate expressions.
    CreateAssociation -> Maybe Bool
applyOnlyAtCronInterval :: Prelude.Maybe Prelude.Bool,
    -- | The number of errors that are allowed before the system stops sending
    -- requests to run the association on additional targets. You can specify
    -- either an absolute number of errors, for example 10, or a percentage of
    -- the target set, for example 10%. If you specify 3, for example, the
    -- system stops sending requests when the fourth error is received. If you
    -- specify 0, then the system stops sending requests after the first error
    -- is returned. If you run an association on 50 instances and set
    -- @MaxError@ to 10%, then the system stops sending the request when the
    -- sixth error is received.
    --
    -- Executions that are already running an association when @MaxErrors@ is
    -- reached are allowed to complete, but some of these executions may fail
    -- as well. If you need to ensure that there won\'t be more than max-errors
    -- failed executions, set @MaxConcurrency@ to 1 so that executions proceed
    -- one at a time.
    CreateAssociation -> Maybe Text
maxErrors :: Prelude.Maybe Prelude.Text,
    -- | A cron expression when the association will be applied to the target(s).
    CreateAssociation -> Maybe Text
scheduleExpression :: Prelude.Maybe Prelude.Text,
    -- | An Amazon Simple Storage Service (Amazon S3) bucket where you want to
    -- store the output details of the request.
    CreateAssociation -> Maybe InstanceAssociationOutputLocation
outputLocation :: Prelude.Maybe InstanceAssociationOutputLocation,
    -- | The mode for generating association compliance. You can specify @AUTO@
    -- or @MANUAL@. In @AUTO@ mode, the system uses the status of the
    -- association execution to determine the compliance status. If the
    -- association execution runs successfully, then the association is
    -- @COMPLIANT@. If the association execution doesn\'t run successfully, the
    -- association is @NON-COMPLIANT@.
    --
    -- In @MANUAL@ mode, you must specify the @AssociationId@ as a parameter
    -- for the PutComplianceItems API operation. In this case, compliance data
    -- isn\'t managed by State Manager. It is managed by your direct call to
    -- the PutComplianceItems API operation.
    --
    -- By default, all associations use @AUTO@ mode.
    CreateAssociation -> Maybe AssociationSyncCompliance
syncCompliance :: Prelude.Maybe AssociationSyncCompliance,
    -- | The targets for the association. You can target instances by using tags,
    -- Amazon Web Services resource groups, all instances in an Amazon Web
    -- Services account, or individual instance IDs. You can target all
    -- instances in an Amazon Web Services account by specifying the
    -- @InstanceIds@ key with a value of @*@. For more information about
    -- choosing targets for an association, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-state-manager-targets-and-rate-controls.html Using targets and rate controls with State Manager associations>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    CreateAssociation -> Maybe [Target]
targets :: Prelude.Maybe [Target],
    -- | The parameters for the runtime configuration of the document.
    CreateAssociation -> Maybe (HashMap Text [Text])
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The document version you want to associate with the target(s). Can be a
    -- specific version or the default version.
    CreateAssociation -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | Specify the target for the association. This target is required for
    -- associations that use an Automation runbook and target resources by
    -- using rate controls. Automation is a capability of Amazon Web Services
    -- Systems Manager.
    CreateAssociation -> Maybe Text
automationTargetParameterName :: Prelude.Maybe Prelude.Text,
    -- | Specify a descriptive name for the association.
    CreateAssociation -> Maybe Text
associationName :: Prelude.Maybe Prelude.Text,
    -- | The names or Amazon Resource Names (ARNs) of the Change Calendar type
    -- documents you want to gate your associations under. The associations
    -- only run when that change calendar is open. For more information, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-change-calendar Amazon Web Services Systems Manager Change Calendar>.
    CreateAssociation -> Maybe [Text]
calendarNames :: Prelude.Maybe [Prelude.Text],
    -- | The severity level to assign to the association.
    CreateAssociation -> Maybe AssociationComplianceSeverity
complianceSeverity :: Prelude.Maybe AssociationComplianceSeverity,
    -- | The maximum number of targets allowed to run the association at the same
    -- time. You can specify a number, for example 10, or a percentage of the
    -- target set, for example 10%. The default value is 100%, which means all
    -- targets run the association at the same time.
    --
    -- If a new instance starts and attempts to run an association while
    -- Systems Manager is running @MaxConcurrency@ associations, the
    -- association is allowed to run. During the next association interval, the
    -- new instance will process its association within the limit specified for
    -- @MaxConcurrency@.
    CreateAssociation -> Maybe Text
maxConcurrency :: Prelude.Maybe Prelude.Text,
    -- | The name of the SSM Command document or Automation runbook that contains
    -- the configuration information for the instance.
    --
    -- You can specify Amazon Web Services-predefined documents, documents you
    -- created, or a document that is shared with you from another account.
    --
    -- For Systems Manager documents (SSM documents) that are shared with you
    -- from other Amazon Web Services accounts, you must specify the complete
    -- SSM document ARN, in the following format:
    --
    -- @arn:partition:ssm:region:account-id:document\/document-name @
    --
    -- For example:
    --
    -- @arn:aws:ssm:us-east-2:12345678912:document\/My-Shared-Document@
    --
    -- For Amazon Web Services-predefined documents and SSM documents you
    -- created in your account, you only need to specify the document name. For
    -- example, @AWS-ApplyPatchBaseline@ or @My-Document@.
    CreateAssociation -> Text
name :: Prelude.Text
  }
  deriving (CreateAssociation -> CreateAssociation -> Bool
(CreateAssociation -> CreateAssociation -> Bool)
-> (CreateAssociation -> CreateAssociation -> Bool)
-> Eq CreateAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAssociation -> CreateAssociation -> Bool
$c/= :: CreateAssociation -> CreateAssociation -> Bool
== :: CreateAssociation -> CreateAssociation -> Bool
$c== :: CreateAssociation -> CreateAssociation -> Bool
Prelude.Eq, ReadPrec [CreateAssociation]
ReadPrec CreateAssociation
Int -> ReadS CreateAssociation
ReadS [CreateAssociation]
(Int -> ReadS CreateAssociation)
-> ReadS [CreateAssociation]
-> ReadPrec CreateAssociation
-> ReadPrec [CreateAssociation]
-> Read CreateAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAssociation]
$creadListPrec :: ReadPrec [CreateAssociation]
readPrec :: ReadPrec CreateAssociation
$creadPrec :: ReadPrec CreateAssociation
readList :: ReadS [CreateAssociation]
$creadList :: ReadS [CreateAssociation]
readsPrec :: Int -> ReadS CreateAssociation
$creadsPrec :: Int -> ReadS CreateAssociation
Prelude.Read, Int -> CreateAssociation -> ShowS
[CreateAssociation] -> ShowS
CreateAssociation -> String
(Int -> CreateAssociation -> ShowS)
-> (CreateAssociation -> String)
-> ([CreateAssociation] -> ShowS)
-> Show CreateAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAssociation] -> ShowS
$cshowList :: [CreateAssociation] -> ShowS
show :: CreateAssociation -> String
$cshow :: CreateAssociation -> String
showsPrec :: Int -> CreateAssociation -> ShowS
$cshowsPrec :: Int -> CreateAssociation -> ShowS
Prelude.Show, (forall x. CreateAssociation -> Rep CreateAssociation x)
-> (forall x. Rep CreateAssociation x -> CreateAssociation)
-> Generic CreateAssociation
forall x. Rep CreateAssociation x -> CreateAssociation
forall x. CreateAssociation -> Rep CreateAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAssociation x -> CreateAssociation
$cfrom :: forall x. CreateAssociation -> Rep CreateAssociation x
Prelude.Generic)

-- |
-- Create a value of 'CreateAssociation' 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:
--
-- 'instanceId', 'createAssociation_instanceId' - The instance ID.
--
-- @InstanceId@ has been deprecated. To specify an instance ID for an
-- association, use the @Targets@ parameter. Requests that include the
-- parameter @InstanceID@ with Systems Manager documents (SSM documents)
-- that use schema version 2.0 or later will fail. In addition, if you use
-- the parameter @InstanceId@, you can\'t use the parameters
-- @AssociationName@, @DocumentVersion@, @MaxErrors@, @MaxConcurrency@,
-- @OutputLocation@, or @ScheduleExpression@. To use these parameters, you
-- must use the @Targets@ parameter.
--
-- 'targetLocations', 'createAssociation_targetLocations' - A location is a combination of Amazon Web Services Regions and Amazon
-- Web Services accounts where you want to run the association. Use this
-- action to create an association in multiple Regions and multiple
-- accounts.
--
-- 'applyOnlyAtCronInterval', 'createAssociation_applyOnlyAtCronInterval' - By default, when you create a new association, the system runs it
-- immediately after it is created and then according to the schedule you
-- specified. Specify this option if you don\'t want an association to run
-- immediately after you create it. This parameter isn\'t supported for
-- rate expressions.
--
-- 'maxErrors', 'createAssociation_maxErrors' - The number of errors that are allowed before the system stops sending
-- requests to run the association on additional targets. You can specify
-- either an absolute number of errors, for example 10, or a percentage of
-- the target set, for example 10%. If you specify 3, for example, the
-- system stops sending requests when the fourth error is received. If you
-- specify 0, then the system stops sending requests after the first error
-- is returned. If you run an association on 50 instances and set
-- @MaxError@ to 10%, then the system stops sending the request when the
-- sixth error is received.
--
-- Executions that are already running an association when @MaxErrors@ is
-- reached are allowed to complete, but some of these executions may fail
-- as well. If you need to ensure that there won\'t be more than max-errors
-- failed executions, set @MaxConcurrency@ to 1 so that executions proceed
-- one at a time.
--
-- 'scheduleExpression', 'createAssociation_scheduleExpression' - A cron expression when the association will be applied to the target(s).
--
-- 'outputLocation', 'createAssociation_outputLocation' - An Amazon Simple Storage Service (Amazon S3) bucket where you want to
-- store the output details of the request.
--
-- 'syncCompliance', 'createAssociation_syncCompliance' - The mode for generating association compliance. You can specify @AUTO@
-- or @MANUAL@. In @AUTO@ mode, the system uses the status of the
-- association execution to determine the compliance status. If the
-- association execution runs successfully, then the association is
-- @COMPLIANT@. If the association execution doesn\'t run successfully, the
-- association is @NON-COMPLIANT@.
--
-- In @MANUAL@ mode, you must specify the @AssociationId@ as a parameter
-- for the PutComplianceItems API operation. In this case, compliance data
-- isn\'t managed by State Manager. It is managed by your direct call to
-- the PutComplianceItems API operation.
--
-- By default, all associations use @AUTO@ mode.
--
-- 'targets', 'createAssociation_targets' - The targets for the association. You can target instances by using tags,
-- Amazon Web Services resource groups, all instances in an Amazon Web
-- Services account, or individual instance IDs. You can target all
-- instances in an Amazon Web Services account by specifying the
-- @InstanceIds@ key with a value of @*@. For more information about
-- choosing targets for an association, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-state-manager-targets-and-rate-controls.html Using targets and rate controls with State Manager associations>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- 'parameters', 'createAssociation_parameters' - The parameters for the runtime configuration of the document.
--
-- 'documentVersion', 'createAssociation_documentVersion' - The document version you want to associate with the target(s). Can be a
-- specific version or the default version.
--
-- 'automationTargetParameterName', 'createAssociation_automationTargetParameterName' - Specify the target for the association. This target is required for
-- associations that use an Automation runbook and target resources by
-- using rate controls. Automation is a capability of Amazon Web Services
-- Systems Manager.
--
-- 'associationName', 'createAssociation_associationName' - Specify a descriptive name for the association.
--
-- 'calendarNames', 'createAssociation_calendarNames' - The names or Amazon Resource Names (ARNs) of the Change Calendar type
-- documents you want to gate your associations under. The associations
-- only run when that change calendar is open. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-change-calendar Amazon Web Services Systems Manager Change Calendar>.
--
-- 'complianceSeverity', 'createAssociation_complianceSeverity' - The severity level to assign to the association.
--
-- 'maxConcurrency', 'createAssociation_maxConcurrency' - The maximum number of targets allowed to run the association at the same
-- time. You can specify a number, for example 10, or a percentage of the
-- target set, for example 10%. The default value is 100%, which means all
-- targets run the association at the same time.
--
-- If a new instance starts and attempts to run an association while
-- Systems Manager is running @MaxConcurrency@ associations, the
-- association is allowed to run. During the next association interval, the
-- new instance will process its association within the limit specified for
-- @MaxConcurrency@.
--
-- 'name', 'createAssociation_name' - The name of the SSM Command document or Automation runbook that contains
-- the configuration information for the instance.
--
-- You can specify Amazon Web Services-predefined documents, documents you
-- created, or a document that is shared with you from another account.
--
-- For Systems Manager documents (SSM documents) that are shared with you
-- from other Amazon Web Services accounts, you must specify the complete
-- SSM document ARN, in the following format:
--
-- @arn:partition:ssm:region:account-id:document\/document-name @
--
-- For example:
--
-- @arn:aws:ssm:us-east-2:12345678912:document\/My-Shared-Document@
--
-- For Amazon Web Services-predefined documents and SSM documents you
-- created in your account, you only need to specify the document name. For
-- example, @AWS-ApplyPatchBaseline@ or @My-Document@.
newCreateAssociation ::
  -- | 'name'
  Prelude.Text ->
  CreateAssociation
newCreateAssociation :: Text -> CreateAssociation
newCreateAssociation Text
pName_ =
  CreateAssociation' :: Maybe Text
-> Maybe (NonEmpty TargetLocation)
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe InstanceAssociationOutputLocation
-> Maybe AssociationSyncCompliance
-> Maybe [Target]
-> Maybe (HashMap Text [Text])
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe AssociationComplianceSeverity
-> Maybe Text
-> Text
-> CreateAssociation
CreateAssociation'
    { $sel:instanceId:CreateAssociation' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetLocations:CreateAssociation' :: Maybe (NonEmpty TargetLocation)
targetLocations = Maybe (NonEmpty TargetLocation)
forall a. Maybe a
Prelude.Nothing,
      $sel:applyOnlyAtCronInterval:CreateAssociation' :: Maybe Bool
applyOnlyAtCronInterval = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxErrors:CreateAssociation' :: Maybe Text
maxErrors = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scheduleExpression:CreateAssociation' :: Maybe Text
scheduleExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputLocation:CreateAssociation' :: Maybe InstanceAssociationOutputLocation
outputLocation = Maybe InstanceAssociationOutputLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:syncCompliance:CreateAssociation' :: Maybe AssociationSyncCompliance
syncCompliance = Maybe AssociationSyncCompliance
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:CreateAssociation' :: Maybe [Target]
targets = Maybe [Target]
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:CreateAssociation' :: Maybe (HashMap Text [Text])
parameters = Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:documentVersion:CreateAssociation' :: Maybe Text
documentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:automationTargetParameterName:CreateAssociation' :: Maybe Text
automationTargetParameterName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associationName:CreateAssociation' :: Maybe Text
associationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:calendarNames:CreateAssociation' :: Maybe [Text]
calendarNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:complianceSeverity:CreateAssociation' :: Maybe AssociationComplianceSeverity
complianceSeverity = Maybe AssociationComplianceSeverity
forall a. Maybe a
Prelude.Nothing,
      $sel:maxConcurrency:CreateAssociation' :: Maybe Text
maxConcurrency = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateAssociation' :: Text
name = Text
pName_
    }

-- | The instance ID.
--
-- @InstanceId@ has been deprecated. To specify an instance ID for an
-- association, use the @Targets@ parameter. Requests that include the
-- parameter @InstanceID@ with Systems Manager documents (SSM documents)
-- that use schema version 2.0 or later will fail. In addition, if you use
-- the parameter @InstanceId@, you can\'t use the parameters
-- @AssociationName@, @DocumentVersion@, @MaxErrors@, @MaxConcurrency@,
-- @OutputLocation@, or @ScheduleExpression@. To use these parameters, you
-- must use the @Targets@ parameter.
createAssociation_instanceId :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_instanceId :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_instanceId = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:CreateAssociation' :: CreateAssociation -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:instanceId:CreateAssociation' :: Maybe Text
instanceId = Maybe Text
a} :: CreateAssociation)

-- | A location is a combination of Amazon Web Services Regions and Amazon
-- Web Services accounts where you want to run the association. Use this
-- action to create an association in multiple Regions and multiple
-- accounts.
createAssociation_targetLocations :: Lens.Lens' CreateAssociation (Prelude.Maybe (Prelude.NonEmpty TargetLocation))
createAssociation_targetLocations :: (Maybe (NonEmpty TargetLocation)
 -> f (Maybe (NonEmpty TargetLocation)))
-> CreateAssociation -> f CreateAssociation
createAssociation_targetLocations = (CreateAssociation -> Maybe (NonEmpty TargetLocation))
-> (CreateAssociation
    -> Maybe (NonEmpty TargetLocation) -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe (NonEmpty TargetLocation)
targetLocations :: Maybe (NonEmpty TargetLocation)
$sel:targetLocations:CreateAssociation' :: CreateAssociation -> Maybe (NonEmpty TargetLocation)
targetLocations} -> Maybe (NonEmpty TargetLocation)
targetLocations) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe (NonEmpty TargetLocation)
a -> CreateAssociation
s {$sel:targetLocations:CreateAssociation' :: Maybe (NonEmpty TargetLocation)
targetLocations = Maybe (NonEmpty TargetLocation)
a} :: CreateAssociation) ((Maybe (NonEmpty TargetLocation)
  -> f (Maybe (NonEmpty TargetLocation)))
 -> CreateAssociation -> f CreateAssociation)
-> ((Maybe (NonEmpty TargetLocation)
     -> f (Maybe (NonEmpty TargetLocation)))
    -> Maybe (NonEmpty TargetLocation)
    -> f (Maybe (NonEmpty TargetLocation)))
-> (Maybe (NonEmpty TargetLocation)
    -> f (Maybe (NonEmpty TargetLocation)))
-> CreateAssociation
-> f CreateAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
-> Iso
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
     (Maybe (NonEmpty TargetLocation))
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 TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
  (NonEmpty TargetLocation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | By default, when you create a new association, the system runs it
-- immediately after it is created and then according to the schedule you
-- specified. Specify this option if you don\'t want an association to run
-- immediately after you create it. This parameter isn\'t supported for
-- rate expressions.
createAssociation_applyOnlyAtCronInterval :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Bool)
createAssociation_applyOnlyAtCronInterval :: (Maybe Bool -> f (Maybe Bool))
-> CreateAssociation -> f CreateAssociation
createAssociation_applyOnlyAtCronInterval = (CreateAssociation -> Maybe Bool)
-> (CreateAssociation -> Maybe Bool -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Bool
applyOnlyAtCronInterval :: Maybe Bool
$sel:applyOnlyAtCronInterval:CreateAssociation' :: CreateAssociation -> Maybe Bool
applyOnlyAtCronInterval} -> Maybe Bool
applyOnlyAtCronInterval) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Bool
a -> CreateAssociation
s {$sel:applyOnlyAtCronInterval:CreateAssociation' :: Maybe Bool
applyOnlyAtCronInterval = Maybe Bool
a} :: CreateAssociation)

-- | The number of errors that are allowed before the system stops sending
-- requests to run the association on additional targets. You can specify
-- either an absolute number of errors, for example 10, or a percentage of
-- the target set, for example 10%. If you specify 3, for example, the
-- system stops sending requests when the fourth error is received. If you
-- specify 0, then the system stops sending requests after the first error
-- is returned. If you run an association on 50 instances and set
-- @MaxError@ to 10%, then the system stops sending the request when the
-- sixth error is received.
--
-- Executions that are already running an association when @MaxErrors@ is
-- reached are allowed to complete, but some of these executions may fail
-- as well. If you need to ensure that there won\'t be more than max-errors
-- failed executions, set @MaxConcurrency@ to 1 so that executions proceed
-- one at a time.
createAssociation_maxErrors :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_maxErrors :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_maxErrors = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
maxErrors :: Maybe Text
$sel:maxErrors:CreateAssociation' :: CreateAssociation -> Maybe Text
maxErrors} -> Maybe Text
maxErrors) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:maxErrors:CreateAssociation' :: Maybe Text
maxErrors = Maybe Text
a} :: CreateAssociation)

-- | A cron expression when the association will be applied to the target(s).
createAssociation_scheduleExpression :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_scheduleExpression :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_scheduleExpression = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
scheduleExpression :: Maybe Text
$sel:scheduleExpression:CreateAssociation' :: CreateAssociation -> Maybe Text
scheduleExpression} -> Maybe Text
scheduleExpression) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:scheduleExpression:CreateAssociation' :: Maybe Text
scheduleExpression = Maybe Text
a} :: CreateAssociation)

-- | An Amazon Simple Storage Service (Amazon S3) bucket where you want to
-- store the output details of the request.
createAssociation_outputLocation :: Lens.Lens' CreateAssociation (Prelude.Maybe InstanceAssociationOutputLocation)
createAssociation_outputLocation :: (Maybe InstanceAssociationOutputLocation
 -> f (Maybe InstanceAssociationOutputLocation))
-> CreateAssociation -> f CreateAssociation
createAssociation_outputLocation = (CreateAssociation -> Maybe InstanceAssociationOutputLocation)
-> (CreateAssociation
    -> Maybe InstanceAssociationOutputLocation -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe InstanceAssociationOutputLocation)
     (Maybe InstanceAssociationOutputLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe InstanceAssociationOutputLocation
outputLocation :: Maybe InstanceAssociationOutputLocation
$sel:outputLocation:CreateAssociation' :: CreateAssociation -> Maybe InstanceAssociationOutputLocation
outputLocation} -> Maybe InstanceAssociationOutputLocation
outputLocation) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe InstanceAssociationOutputLocation
a -> CreateAssociation
s {$sel:outputLocation:CreateAssociation' :: Maybe InstanceAssociationOutputLocation
outputLocation = Maybe InstanceAssociationOutputLocation
a} :: CreateAssociation)

-- | The mode for generating association compliance. You can specify @AUTO@
-- or @MANUAL@. In @AUTO@ mode, the system uses the status of the
-- association execution to determine the compliance status. If the
-- association execution runs successfully, then the association is
-- @COMPLIANT@. If the association execution doesn\'t run successfully, the
-- association is @NON-COMPLIANT@.
--
-- In @MANUAL@ mode, you must specify the @AssociationId@ as a parameter
-- for the PutComplianceItems API operation. In this case, compliance data
-- isn\'t managed by State Manager. It is managed by your direct call to
-- the PutComplianceItems API operation.
--
-- By default, all associations use @AUTO@ mode.
createAssociation_syncCompliance :: Lens.Lens' CreateAssociation (Prelude.Maybe AssociationSyncCompliance)
createAssociation_syncCompliance :: (Maybe AssociationSyncCompliance
 -> f (Maybe AssociationSyncCompliance))
-> CreateAssociation -> f CreateAssociation
createAssociation_syncCompliance = (CreateAssociation -> Maybe AssociationSyncCompliance)
-> (CreateAssociation
    -> Maybe AssociationSyncCompliance -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe AssociationSyncCompliance)
     (Maybe AssociationSyncCompliance)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe AssociationSyncCompliance
syncCompliance :: Maybe AssociationSyncCompliance
$sel:syncCompliance:CreateAssociation' :: CreateAssociation -> Maybe AssociationSyncCompliance
syncCompliance} -> Maybe AssociationSyncCompliance
syncCompliance) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe AssociationSyncCompliance
a -> CreateAssociation
s {$sel:syncCompliance:CreateAssociation' :: Maybe AssociationSyncCompliance
syncCompliance = Maybe AssociationSyncCompliance
a} :: CreateAssociation)

-- | The targets for the association. You can target instances by using tags,
-- Amazon Web Services resource groups, all instances in an Amazon Web
-- Services account, or individual instance IDs. You can target all
-- instances in an Amazon Web Services account by specifying the
-- @InstanceIds@ key with a value of @*@. For more information about
-- choosing targets for an association, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-state-manager-targets-and-rate-controls.html Using targets and rate controls with State Manager associations>
-- in the /Amazon Web Services Systems Manager User Guide/.
createAssociation_targets :: Lens.Lens' CreateAssociation (Prelude.Maybe [Target])
createAssociation_targets :: (Maybe [Target] -> f (Maybe [Target]))
-> CreateAssociation -> f CreateAssociation
createAssociation_targets = (CreateAssociation -> Maybe [Target])
-> (CreateAssociation -> Maybe [Target] -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe [Target])
     (Maybe [Target])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe [Target]
targets :: Maybe [Target]
$sel:targets:CreateAssociation' :: CreateAssociation -> Maybe [Target]
targets} -> Maybe [Target]
targets) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe [Target]
a -> CreateAssociation
s {$sel:targets:CreateAssociation' :: Maybe [Target]
targets = Maybe [Target]
a} :: CreateAssociation) ((Maybe [Target] -> f (Maybe [Target]))
 -> CreateAssociation -> f CreateAssociation)
-> ((Maybe [Target] -> f (Maybe [Target]))
    -> Maybe [Target] -> f (Maybe [Target]))
-> (Maybe [Target] -> f (Maybe [Target]))
-> CreateAssociation
-> f CreateAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Target] [Target] [Target] [Target]
-> Iso
     (Maybe [Target]) (Maybe [Target]) (Maybe [Target]) (Maybe [Target])
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 [Target] [Target] [Target] [Target]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The parameters for the runtime configuration of the document.
createAssociation_parameters :: Lens.Lens' CreateAssociation (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
createAssociation_parameters :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> CreateAssociation -> f CreateAssociation
createAssociation_parameters = (CreateAssociation -> Maybe (HashMap Text [Text]))
-> (CreateAssociation
    -> Maybe (HashMap Text [Text]) -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe (HashMap Text [Text])
parameters :: Maybe (HashMap Text [Text])
$sel:parameters:CreateAssociation' :: CreateAssociation -> Maybe (HashMap Text [Text])
parameters} -> Maybe (HashMap Text [Text])
parameters) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe (HashMap Text [Text])
a -> CreateAssociation
s {$sel:parameters:CreateAssociation' :: Maybe (HashMap Text [Text])
parameters = Maybe (HashMap Text [Text])
a} :: CreateAssociation) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> CreateAssociation -> f CreateAssociation)
-> ((Maybe (HashMap Text [Text])
     -> f (Maybe (HashMap Text [Text])))
    -> Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> CreateAssociation
-> f CreateAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
-> Iso
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
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
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The document version you want to associate with the target(s). Can be a
-- specific version or the default version.
createAssociation_documentVersion :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_documentVersion :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_documentVersion = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:CreateAssociation' :: CreateAssociation -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:documentVersion:CreateAssociation' :: Maybe Text
documentVersion = Maybe Text
a} :: CreateAssociation)

-- | Specify the target for the association. This target is required for
-- associations that use an Automation runbook and target resources by
-- using rate controls. Automation is a capability of Amazon Web Services
-- Systems Manager.
createAssociation_automationTargetParameterName :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_automationTargetParameterName :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_automationTargetParameterName = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
automationTargetParameterName :: Maybe Text
$sel:automationTargetParameterName:CreateAssociation' :: CreateAssociation -> Maybe Text
automationTargetParameterName} -> Maybe Text
automationTargetParameterName) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:automationTargetParameterName:CreateAssociation' :: Maybe Text
automationTargetParameterName = Maybe Text
a} :: CreateAssociation)

-- | Specify a descriptive name for the association.
createAssociation_associationName :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_associationName :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_associationName = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
associationName :: Maybe Text
$sel:associationName:CreateAssociation' :: CreateAssociation -> Maybe Text
associationName} -> Maybe Text
associationName) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:associationName:CreateAssociation' :: Maybe Text
associationName = Maybe Text
a} :: CreateAssociation)

-- | The names or Amazon Resource Names (ARNs) of the Change Calendar type
-- documents you want to gate your associations under. The associations
-- only run when that change calendar is open. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-change-calendar Amazon Web Services Systems Manager Change Calendar>.
createAssociation_calendarNames :: Lens.Lens' CreateAssociation (Prelude.Maybe [Prelude.Text])
createAssociation_calendarNames :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateAssociation -> f CreateAssociation
createAssociation_calendarNames = (CreateAssociation -> Maybe [Text])
-> (CreateAssociation -> Maybe [Text] -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe [Text]
calendarNames :: Maybe [Text]
$sel:calendarNames:CreateAssociation' :: CreateAssociation -> Maybe [Text]
calendarNames} -> Maybe [Text]
calendarNames) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe [Text]
a -> CreateAssociation
s {$sel:calendarNames:CreateAssociation' :: Maybe [Text]
calendarNames = Maybe [Text]
a} :: CreateAssociation) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateAssociation -> f CreateAssociation)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateAssociation
-> f CreateAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The severity level to assign to the association.
createAssociation_complianceSeverity :: Lens.Lens' CreateAssociation (Prelude.Maybe AssociationComplianceSeverity)
createAssociation_complianceSeverity :: (Maybe AssociationComplianceSeverity
 -> f (Maybe AssociationComplianceSeverity))
-> CreateAssociation -> f CreateAssociation
createAssociation_complianceSeverity = (CreateAssociation -> Maybe AssociationComplianceSeverity)
-> (CreateAssociation
    -> Maybe AssociationComplianceSeverity -> CreateAssociation)
-> Lens
     CreateAssociation
     CreateAssociation
     (Maybe AssociationComplianceSeverity)
     (Maybe AssociationComplianceSeverity)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe AssociationComplianceSeverity
complianceSeverity :: Maybe AssociationComplianceSeverity
$sel:complianceSeverity:CreateAssociation' :: CreateAssociation -> Maybe AssociationComplianceSeverity
complianceSeverity} -> Maybe AssociationComplianceSeverity
complianceSeverity) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe AssociationComplianceSeverity
a -> CreateAssociation
s {$sel:complianceSeverity:CreateAssociation' :: Maybe AssociationComplianceSeverity
complianceSeverity = Maybe AssociationComplianceSeverity
a} :: CreateAssociation)

-- | The maximum number of targets allowed to run the association at the same
-- time. You can specify a number, for example 10, or a percentage of the
-- target set, for example 10%. The default value is 100%, which means all
-- targets run the association at the same time.
--
-- If a new instance starts and attempts to run an association while
-- Systems Manager is running @MaxConcurrency@ associations, the
-- association is allowed to run. During the next association interval, the
-- new instance will process its association within the limit specified for
-- @MaxConcurrency@.
createAssociation_maxConcurrency :: Lens.Lens' CreateAssociation (Prelude.Maybe Prelude.Text)
createAssociation_maxConcurrency :: (Maybe Text -> f (Maybe Text))
-> CreateAssociation -> f CreateAssociation
createAssociation_maxConcurrency = (CreateAssociation -> Maybe Text)
-> (CreateAssociation -> Maybe Text -> CreateAssociation)
-> Lens
     CreateAssociation CreateAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Maybe Text
maxConcurrency :: Maybe Text
$sel:maxConcurrency:CreateAssociation' :: CreateAssociation -> Maybe Text
maxConcurrency} -> Maybe Text
maxConcurrency) (\s :: CreateAssociation
s@CreateAssociation' {} Maybe Text
a -> CreateAssociation
s {$sel:maxConcurrency:CreateAssociation' :: Maybe Text
maxConcurrency = Maybe Text
a} :: CreateAssociation)

-- | The name of the SSM Command document or Automation runbook that contains
-- the configuration information for the instance.
--
-- You can specify Amazon Web Services-predefined documents, documents you
-- created, or a document that is shared with you from another account.
--
-- For Systems Manager documents (SSM documents) that are shared with you
-- from other Amazon Web Services accounts, you must specify the complete
-- SSM document ARN, in the following format:
--
-- @arn:partition:ssm:region:account-id:document\/document-name @
--
-- For example:
--
-- @arn:aws:ssm:us-east-2:12345678912:document\/My-Shared-Document@
--
-- For Amazon Web Services-predefined documents and SSM documents you
-- created in your account, you only need to specify the document name. For
-- example, @AWS-ApplyPatchBaseline@ or @My-Document@.
createAssociation_name :: Lens.Lens' CreateAssociation Prelude.Text
createAssociation_name :: (Text -> f Text) -> CreateAssociation -> f CreateAssociation
createAssociation_name = (CreateAssociation -> Text)
-> (CreateAssociation -> Text -> CreateAssociation)
-> Lens CreateAssociation CreateAssociation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociation' {Text
name :: Text
$sel:name:CreateAssociation' :: CreateAssociation -> Text
name} -> Text
name) (\s :: CreateAssociation
s@CreateAssociation' {} Text
a -> CreateAssociation
s {$sel:name:CreateAssociation' :: Text
name = Text
a} :: CreateAssociation)

instance Core.AWSRequest CreateAssociation where
  type
    AWSResponse CreateAssociation =
      CreateAssociationResponse
  request :: CreateAssociation -> Request CreateAssociation
request = Service -> CreateAssociation -> Request CreateAssociation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateAssociation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAssociation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateAssociation))
-> Logger
-> Service
-> Proxy CreateAssociation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAssociation)))
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 AssociationDescription -> Int -> CreateAssociationResponse
CreateAssociationResponse'
            (Maybe AssociationDescription -> Int -> CreateAssociationResponse)
-> Either String (Maybe AssociationDescription)
-> Either String (Int -> CreateAssociationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AssociationDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AssociationDescription")
            Either String (Int -> CreateAssociationResponse)
-> Either String Int -> Either String CreateAssociationResponse
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 CreateAssociation

instance Prelude.NFData CreateAssociation

instance Core.ToHeaders CreateAssociation where
  toHeaders :: CreateAssociation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAssociation -> 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.CreateAssociation" ::
                          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 CreateAssociation where
  toJSON :: CreateAssociation -> Value
toJSON CreateAssociation' {Maybe Bool
Maybe [Text]
Maybe [Target]
Maybe (NonEmpty TargetLocation)
Maybe Text
Maybe (HashMap Text [Text])
Maybe AssociationComplianceSeverity
Maybe AssociationSyncCompliance
Maybe InstanceAssociationOutputLocation
Text
name :: Text
maxConcurrency :: Maybe Text
complianceSeverity :: Maybe AssociationComplianceSeverity
calendarNames :: Maybe [Text]
associationName :: Maybe Text
automationTargetParameterName :: Maybe Text
documentVersion :: Maybe Text
parameters :: Maybe (HashMap Text [Text])
targets :: Maybe [Target]
syncCompliance :: Maybe AssociationSyncCompliance
outputLocation :: Maybe InstanceAssociationOutputLocation
scheduleExpression :: Maybe Text
maxErrors :: Maybe Text
applyOnlyAtCronInterval :: Maybe Bool
targetLocations :: Maybe (NonEmpty TargetLocation)
instanceId :: Maybe Text
$sel:name:CreateAssociation' :: CreateAssociation -> Text
$sel:maxConcurrency:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:complianceSeverity:CreateAssociation' :: CreateAssociation -> Maybe AssociationComplianceSeverity
$sel:calendarNames:CreateAssociation' :: CreateAssociation -> Maybe [Text]
$sel:associationName:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:automationTargetParameterName:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:documentVersion:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:parameters:CreateAssociation' :: CreateAssociation -> Maybe (HashMap Text [Text])
$sel:targets:CreateAssociation' :: CreateAssociation -> Maybe [Target]
$sel:syncCompliance:CreateAssociation' :: CreateAssociation -> Maybe AssociationSyncCompliance
$sel:outputLocation:CreateAssociation' :: CreateAssociation -> Maybe InstanceAssociationOutputLocation
$sel:scheduleExpression:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:maxErrors:CreateAssociation' :: CreateAssociation -> Maybe Text
$sel:applyOnlyAtCronInterval:CreateAssociation' :: CreateAssociation -> Maybe Bool
$sel:targetLocations:CreateAssociation' :: CreateAssociation -> Maybe (NonEmpty TargetLocation)
$sel:instanceId:CreateAssociation' :: CreateAssociation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceId" 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
instanceId,
            (Text
"TargetLocations" Text -> NonEmpty TargetLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty TargetLocation -> Pair)
-> Maybe (NonEmpty TargetLocation) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty TargetLocation)
targetLocations,
            (Text
"ApplyOnlyAtCronInterval" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
applyOnlyAtCronInterval,
            (Text
"MaxErrors" 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
maxErrors,
            (Text
"ScheduleExpression" 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
scheduleExpression,
            (Text
"OutputLocation" Text -> InstanceAssociationOutputLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InstanceAssociationOutputLocation -> Pair)
-> Maybe InstanceAssociationOutputLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InstanceAssociationOutputLocation
outputLocation,
            (Text
"SyncCompliance" Text -> AssociationSyncCompliance -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AssociationSyncCompliance -> Pair)
-> Maybe AssociationSyncCompliance -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AssociationSyncCompliance
syncCompliance,
            (Text
"Targets" Text -> [Target] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Target] -> Pair) -> Maybe [Target] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Target]
targets,
            (Text
"Parameters" Text -> HashMap Text [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text [Text] -> Pair)
-> Maybe (HashMap Text [Text]) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text [Text])
parameters,
            (Text
"DocumentVersion" 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
documentVersion,
            (Text
"AutomationTargetParameterName" 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
automationTargetParameterName,
            (Text
"AssociationName" 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
associationName,
            (Text
"CalendarNames" 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]
calendarNames,
            (Text
"ComplianceSeverity" Text -> AssociationComplianceSeverity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AssociationComplianceSeverity -> Pair)
-> Maybe AssociationComplianceSeverity -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AssociationComplianceSeverity
complianceSeverity,
            (Text
"MaxConcurrency" 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
maxConcurrency,
            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 CreateAssociation where
  toPath :: CreateAssociation -> ByteString
toPath = ByteString -> CreateAssociation -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'CreateAssociationResponse' 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:
--
-- 'associationDescription', 'createAssociationResponse_associationDescription' - Information about the association.
--
-- 'httpStatus', 'createAssociationResponse_httpStatus' - The response's http status code.
newCreateAssociationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAssociationResponse
newCreateAssociationResponse :: Int -> CreateAssociationResponse
newCreateAssociationResponse Int
pHttpStatus_ =
  CreateAssociationResponse' :: Maybe AssociationDescription -> Int -> CreateAssociationResponse
CreateAssociationResponse'
    { $sel:associationDescription:CreateAssociationResponse' :: Maybe AssociationDescription
associationDescription =
        Maybe AssociationDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAssociationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the association.
createAssociationResponse_associationDescription :: Lens.Lens' CreateAssociationResponse (Prelude.Maybe AssociationDescription)
createAssociationResponse_associationDescription :: (Maybe AssociationDescription -> f (Maybe AssociationDescription))
-> CreateAssociationResponse -> f CreateAssociationResponse
createAssociationResponse_associationDescription = (CreateAssociationResponse -> Maybe AssociationDescription)
-> (CreateAssociationResponse
    -> Maybe AssociationDescription -> CreateAssociationResponse)
-> Lens
     CreateAssociationResponse
     CreateAssociationResponse
     (Maybe AssociationDescription)
     (Maybe AssociationDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssociationResponse' {Maybe AssociationDescription
associationDescription :: Maybe AssociationDescription
$sel:associationDescription:CreateAssociationResponse' :: CreateAssociationResponse -> Maybe AssociationDescription
associationDescription} -> Maybe AssociationDescription
associationDescription) (\s :: CreateAssociationResponse
s@CreateAssociationResponse' {} Maybe AssociationDescription
a -> CreateAssociationResponse
s {$sel:associationDescription:CreateAssociationResponse' :: Maybe AssociationDescription
associationDescription = Maybe AssociationDescription
a} :: CreateAssociationResponse)

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

instance Prelude.NFData CreateAssociationResponse