{-# 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.RegisterTargetWithMaintenanceWindow
-- 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)
--
-- Registers a target with a maintenance window.
module Amazonka.SSM.RegisterTargetWithMaintenanceWindow
  ( -- * Creating a Request
    RegisterTargetWithMaintenanceWindow (..),
    newRegisterTargetWithMaintenanceWindow,

    -- * Request Lenses
    registerTargetWithMaintenanceWindow_clientToken,
    registerTargetWithMaintenanceWindow_ownerInformation,
    registerTargetWithMaintenanceWindow_name,
    registerTargetWithMaintenanceWindow_description,
    registerTargetWithMaintenanceWindow_windowId,
    registerTargetWithMaintenanceWindow_resourceType,
    registerTargetWithMaintenanceWindow_targets,

    -- * Destructuring the Response
    RegisterTargetWithMaintenanceWindowResponse (..),
    newRegisterTargetWithMaintenanceWindowResponse,

    -- * Response Lenses
    registerTargetWithMaintenanceWindowResponse_windowTargetId,
    registerTargetWithMaintenanceWindowResponse_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:/ 'newRegisterTargetWithMaintenanceWindow' smart constructor.
data RegisterTargetWithMaintenanceWindow = RegisterTargetWithMaintenanceWindow'
  { -- | User-provided idempotency token.
    RegisterTargetWithMaintenanceWindow -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | User-provided value that will be included in any Amazon CloudWatch
    -- Events events raised while running tasks for these targets in this
    -- maintenance window.
    RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
ownerInformation :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | An optional name for the target.
    RegisterTargetWithMaintenanceWindow -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | An optional description for the target.
    RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
description :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ID of the maintenance window the target should be registered with.
    RegisterTargetWithMaintenanceWindow -> Text
windowId :: Prelude.Text,
    -- | The type of target being registered with the maintenance window.
    RegisterTargetWithMaintenanceWindow
-> MaintenanceWindowResourceType
resourceType :: MaintenanceWindowResourceType,
    -- | The targets to register with the maintenance window. In other words, the
    -- instances to run commands on when the maintenance window runs.
    --
    -- If a single maintenance window task is registered with multiple targets,
    -- its task invocations occur sequentially and not in parallel. If your
    -- task must run on multiple targets at the same time, register a task for
    -- each target individually and assign each task the same priority level.
    --
    -- You can specify targets using instance IDs, resource group names, or
    -- tags that have been applied to instances.
    --
    -- __Example 1__: Specify instance IDs
    --
    -- @Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3 @
    --
    -- __Example 2__: Use tag key-pairs applied to instances
    --
    -- @Key=tag:my-tag-key,Values=my-tag-value-1,my-tag-value-2 @
    --
    -- __Example 3__: Use tag-keys applied to instances
    --
    -- @Key=tag-key,Values=my-tag-key-1,my-tag-key-2 @
    --
    -- __Example 4__: Use resource group names
    --
    -- @Key=resource-groups:Name,Values=resource-group-name @
    --
    -- __Example 5__: Use filters for resource group types
    --
    -- @Key=resource-groups:ResourceTypeFilters,Values=resource-type-1,resource-type-2 @
    --
    -- For @Key=resource-groups:ResourceTypeFilters@, specify resource types in
    -- the following format
    --
    -- @Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC @
    --
    -- For more information about these examples formats, including the best
    -- use case for each one, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/mw-cli-tutorial-targets-examples.html Examples: Register targets with a maintenance window>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    RegisterTargetWithMaintenanceWindow -> [Target]
targets :: [Target]
  }
  deriving (RegisterTargetWithMaintenanceWindow
-> RegisterTargetWithMaintenanceWindow -> Bool
(RegisterTargetWithMaintenanceWindow
 -> RegisterTargetWithMaintenanceWindow -> Bool)
-> (RegisterTargetWithMaintenanceWindow
    -> RegisterTargetWithMaintenanceWindow -> Bool)
-> Eq RegisterTargetWithMaintenanceWindow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterTargetWithMaintenanceWindow
-> RegisterTargetWithMaintenanceWindow -> Bool
$c/= :: RegisterTargetWithMaintenanceWindow
-> RegisterTargetWithMaintenanceWindow -> Bool
== :: RegisterTargetWithMaintenanceWindow
-> RegisterTargetWithMaintenanceWindow -> Bool
$c== :: RegisterTargetWithMaintenanceWindow
-> RegisterTargetWithMaintenanceWindow -> Bool
Prelude.Eq, Int -> RegisterTargetWithMaintenanceWindow -> ShowS
[RegisterTargetWithMaintenanceWindow] -> ShowS
RegisterTargetWithMaintenanceWindow -> String
(Int -> RegisterTargetWithMaintenanceWindow -> ShowS)
-> (RegisterTargetWithMaintenanceWindow -> String)
-> ([RegisterTargetWithMaintenanceWindow] -> ShowS)
-> Show RegisterTargetWithMaintenanceWindow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterTargetWithMaintenanceWindow] -> ShowS
$cshowList :: [RegisterTargetWithMaintenanceWindow] -> ShowS
show :: RegisterTargetWithMaintenanceWindow -> String
$cshow :: RegisterTargetWithMaintenanceWindow -> String
showsPrec :: Int -> RegisterTargetWithMaintenanceWindow -> ShowS
$cshowsPrec :: Int -> RegisterTargetWithMaintenanceWindow -> ShowS
Prelude.Show, (forall x.
 RegisterTargetWithMaintenanceWindow
 -> Rep RegisterTargetWithMaintenanceWindow x)
-> (forall x.
    Rep RegisterTargetWithMaintenanceWindow x
    -> RegisterTargetWithMaintenanceWindow)
-> Generic RegisterTargetWithMaintenanceWindow
forall x.
Rep RegisterTargetWithMaintenanceWindow x
-> RegisterTargetWithMaintenanceWindow
forall x.
RegisterTargetWithMaintenanceWindow
-> Rep RegisterTargetWithMaintenanceWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterTargetWithMaintenanceWindow x
-> RegisterTargetWithMaintenanceWindow
$cfrom :: forall x.
RegisterTargetWithMaintenanceWindow
-> Rep RegisterTargetWithMaintenanceWindow x
Prelude.Generic)

-- |
-- Create a value of 'RegisterTargetWithMaintenanceWindow' 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:
--
-- 'clientToken', 'registerTargetWithMaintenanceWindow_clientToken' - User-provided idempotency token.
--
-- 'ownerInformation', 'registerTargetWithMaintenanceWindow_ownerInformation' - User-provided value that will be included in any Amazon CloudWatch
-- Events events raised while running tasks for these targets in this
-- maintenance window.
--
-- 'name', 'registerTargetWithMaintenanceWindow_name' - An optional name for the target.
--
-- 'description', 'registerTargetWithMaintenanceWindow_description' - An optional description for the target.
--
-- 'windowId', 'registerTargetWithMaintenanceWindow_windowId' - The ID of the maintenance window the target should be registered with.
--
-- 'resourceType', 'registerTargetWithMaintenanceWindow_resourceType' - The type of target being registered with the maintenance window.
--
-- 'targets', 'registerTargetWithMaintenanceWindow_targets' - The targets to register with the maintenance window. In other words, the
-- instances to run commands on when the maintenance window runs.
--
-- If a single maintenance window task is registered with multiple targets,
-- its task invocations occur sequentially and not in parallel. If your
-- task must run on multiple targets at the same time, register a task for
-- each target individually and assign each task the same priority level.
--
-- You can specify targets using instance IDs, resource group names, or
-- tags that have been applied to instances.
--
-- __Example 1__: Specify instance IDs
--
-- @Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3 @
--
-- __Example 2__: Use tag key-pairs applied to instances
--
-- @Key=tag:my-tag-key,Values=my-tag-value-1,my-tag-value-2 @
--
-- __Example 3__: Use tag-keys applied to instances
--
-- @Key=tag-key,Values=my-tag-key-1,my-tag-key-2 @
--
-- __Example 4__: Use resource group names
--
-- @Key=resource-groups:Name,Values=resource-group-name @
--
-- __Example 5__: Use filters for resource group types
--
-- @Key=resource-groups:ResourceTypeFilters,Values=resource-type-1,resource-type-2 @
--
-- For @Key=resource-groups:ResourceTypeFilters@, specify resource types in
-- the following format
--
-- @Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC @
--
-- For more information about these examples formats, including the best
-- use case for each one, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/mw-cli-tutorial-targets-examples.html Examples: Register targets with a maintenance window>
-- in the /Amazon Web Services Systems Manager User Guide/.
newRegisterTargetWithMaintenanceWindow ::
  -- | 'windowId'
  Prelude.Text ->
  -- | 'resourceType'
  MaintenanceWindowResourceType ->
  RegisterTargetWithMaintenanceWindow
newRegisterTargetWithMaintenanceWindow :: Text
-> MaintenanceWindowResourceType
-> RegisterTargetWithMaintenanceWindow
newRegisterTargetWithMaintenanceWindow
  Text
pWindowId_
  MaintenanceWindowResourceType
pResourceType_ =
    RegisterTargetWithMaintenanceWindow' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe (Sensitive Text)
-> Text
-> MaintenanceWindowResourceType
-> [Target]
-> RegisterTargetWithMaintenanceWindow
RegisterTargetWithMaintenanceWindow'
      { $sel:clientToken:RegisterTargetWithMaintenanceWindow' :: Maybe Text
clientToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:ownerInformation:RegisterTargetWithMaintenanceWindow' :: Maybe (Sensitive Text)
ownerInformation = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:name:RegisterTargetWithMaintenanceWindow' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:description:RegisterTargetWithMaintenanceWindow' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:windowId:RegisterTargetWithMaintenanceWindow' :: Text
windowId = Text
pWindowId_,
        $sel:resourceType:RegisterTargetWithMaintenanceWindow' :: MaintenanceWindowResourceType
resourceType = MaintenanceWindowResourceType
pResourceType_,
        $sel:targets:RegisterTargetWithMaintenanceWindow' :: [Target]
targets = [Target]
forall a. Monoid a => a
Prelude.mempty
      }

-- | User-provided idempotency token.
registerTargetWithMaintenanceWindow_clientToken :: Lens.Lens' RegisterTargetWithMaintenanceWindow (Prelude.Maybe Prelude.Text)
registerTargetWithMaintenanceWindow_clientToken :: (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_clientToken = (RegisterTargetWithMaintenanceWindow -> Maybe Text)
-> (RegisterTargetWithMaintenanceWindow
    -> Maybe Text -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} Maybe Text
a -> RegisterTargetWithMaintenanceWindow
s {$sel:clientToken:RegisterTargetWithMaintenanceWindow' :: Maybe Text
clientToken = Maybe Text
a} :: RegisterTargetWithMaintenanceWindow)

-- | User-provided value that will be included in any Amazon CloudWatch
-- Events events raised while running tasks for these targets in this
-- maintenance window.
registerTargetWithMaintenanceWindow_ownerInformation :: Lens.Lens' RegisterTargetWithMaintenanceWindow (Prelude.Maybe Prelude.Text)
registerTargetWithMaintenanceWindow_ownerInformation :: (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_ownerInformation = (RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text))
-> (RegisterTargetWithMaintenanceWindow
    -> Maybe (Sensitive Text) -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {Maybe (Sensitive Text)
ownerInformation :: Maybe (Sensitive Text)
$sel:ownerInformation:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
ownerInformation} -> Maybe (Sensitive Text)
ownerInformation) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} Maybe (Sensitive Text)
a -> RegisterTargetWithMaintenanceWindow
s {$sel:ownerInformation:RegisterTargetWithMaintenanceWindow' :: Maybe (Sensitive Text)
ownerInformation = Maybe (Sensitive Text)
a} :: RegisterTargetWithMaintenanceWindow) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> RegisterTargetWithMaintenanceWindow
 -> f RegisterTargetWithMaintenanceWindow)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | An optional name for the target.
registerTargetWithMaintenanceWindow_name :: Lens.Lens' RegisterTargetWithMaintenanceWindow (Prelude.Maybe Prelude.Text)
registerTargetWithMaintenanceWindow_name :: (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_name = (RegisterTargetWithMaintenanceWindow -> Maybe Text)
-> (RegisterTargetWithMaintenanceWindow
    -> Maybe Text -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {Maybe Text
name :: Maybe Text
$sel:name:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe Text
name} -> Maybe Text
name) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} Maybe Text
a -> RegisterTargetWithMaintenanceWindow
s {$sel:name:RegisterTargetWithMaintenanceWindow' :: Maybe Text
name = Maybe Text
a} :: RegisterTargetWithMaintenanceWindow)

-- | An optional description for the target.
registerTargetWithMaintenanceWindow_description :: Lens.Lens' RegisterTargetWithMaintenanceWindow (Prelude.Maybe Prelude.Text)
registerTargetWithMaintenanceWindow_description :: (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_description = (RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text))
-> (RegisterTargetWithMaintenanceWindow
    -> Maybe (Sensitive Text) -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:description:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
description} -> Maybe (Sensitive Text)
description) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} Maybe (Sensitive Text)
a -> RegisterTargetWithMaintenanceWindow
s {$sel:description:RegisterTargetWithMaintenanceWindow' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
a} :: RegisterTargetWithMaintenanceWindow) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> RegisterTargetWithMaintenanceWindow
 -> f RegisterTargetWithMaintenanceWindow)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ID of the maintenance window the target should be registered with.
registerTargetWithMaintenanceWindow_windowId :: Lens.Lens' RegisterTargetWithMaintenanceWindow Prelude.Text
registerTargetWithMaintenanceWindow_windowId :: (Text -> f Text)
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_windowId = (RegisterTargetWithMaintenanceWindow -> Text)
-> (RegisterTargetWithMaintenanceWindow
    -> Text -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {Text
windowId :: Text
$sel:windowId:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Text
windowId} -> Text
windowId) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} Text
a -> RegisterTargetWithMaintenanceWindow
s {$sel:windowId:RegisterTargetWithMaintenanceWindow' :: Text
windowId = Text
a} :: RegisterTargetWithMaintenanceWindow)

-- | The type of target being registered with the maintenance window.
registerTargetWithMaintenanceWindow_resourceType :: Lens.Lens' RegisterTargetWithMaintenanceWindow MaintenanceWindowResourceType
registerTargetWithMaintenanceWindow_resourceType :: (MaintenanceWindowResourceType -> f MaintenanceWindowResourceType)
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_resourceType = (RegisterTargetWithMaintenanceWindow
 -> MaintenanceWindowResourceType)
-> (RegisterTargetWithMaintenanceWindow
    -> MaintenanceWindowResourceType
    -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     MaintenanceWindowResourceType
     MaintenanceWindowResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {MaintenanceWindowResourceType
resourceType :: MaintenanceWindowResourceType
$sel:resourceType:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow
-> MaintenanceWindowResourceType
resourceType} -> MaintenanceWindowResourceType
resourceType) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} MaintenanceWindowResourceType
a -> RegisterTargetWithMaintenanceWindow
s {$sel:resourceType:RegisterTargetWithMaintenanceWindow' :: MaintenanceWindowResourceType
resourceType = MaintenanceWindowResourceType
a} :: RegisterTargetWithMaintenanceWindow)

-- | The targets to register with the maintenance window. In other words, the
-- instances to run commands on when the maintenance window runs.
--
-- If a single maintenance window task is registered with multiple targets,
-- its task invocations occur sequentially and not in parallel. If your
-- task must run on multiple targets at the same time, register a task for
-- each target individually and assign each task the same priority level.
--
-- You can specify targets using instance IDs, resource group names, or
-- tags that have been applied to instances.
--
-- __Example 1__: Specify instance IDs
--
-- @Key=InstanceIds,Values=instance-id-1,instance-id-2,instance-id-3 @
--
-- __Example 2__: Use tag key-pairs applied to instances
--
-- @Key=tag:my-tag-key,Values=my-tag-value-1,my-tag-value-2 @
--
-- __Example 3__: Use tag-keys applied to instances
--
-- @Key=tag-key,Values=my-tag-key-1,my-tag-key-2 @
--
-- __Example 4__: Use resource group names
--
-- @Key=resource-groups:Name,Values=resource-group-name @
--
-- __Example 5__: Use filters for resource group types
--
-- @Key=resource-groups:ResourceTypeFilters,Values=resource-type-1,resource-type-2 @
--
-- For @Key=resource-groups:ResourceTypeFilters@, specify resource types in
-- the following format
--
-- @Key=resource-groups:ResourceTypeFilters,Values=AWS::EC2::INSTANCE,AWS::EC2::VPC @
--
-- For more information about these examples formats, including the best
-- use case for each one, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/mw-cli-tutorial-targets-examples.html Examples: Register targets with a maintenance window>
-- in the /Amazon Web Services Systems Manager User Guide/.
registerTargetWithMaintenanceWindow_targets :: Lens.Lens' RegisterTargetWithMaintenanceWindow [Target]
registerTargetWithMaintenanceWindow_targets :: ([Target] -> f [Target])
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
registerTargetWithMaintenanceWindow_targets = (RegisterTargetWithMaintenanceWindow -> [Target])
-> (RegisterTargetWithMaintenanceWindow
    -> [Target] -> RegisterTargetWithMaintenanceWindow)
-> Lens
     RegisterTargetWithMaintenanceWindow
     RegisterTargetWithMaintenanceWindow
     [Target]
     [Target]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindow' {[Target]
targets :: [Target]
$sel:targets:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> [Target]
targets} -> [Target]
targets) (\s :: RegisterTargetWithMaintenanceWindow
s@RegisterTargetWithMaintenanceWindow' {} [Target]
a -> RegisterTargetWithMaintenanceWindow
s {$sel:targets:RegisterTargetWithMaintenanceWindow' :: [Target]
targets = [Target]
a} :: RegisterTargetWithMaintenanceWindow) (([Target] -> f [Target])
 -> RegisterTargetWithMaintenanceWindow
 -> f RegisterTargetWithMaintenanceWindow)
-> (([Target] -> f [Target]) -> [Target] -> f [Target])
-> ([Target] -> f [Target])
-> RegisterTargetWithMaintenanceWindow
-> f RegisterTargetWithMaintenanceWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Target] -> f [Target]) -> [Target] -> f [Target]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    RegisterTargetWithMaintenanceWindow

instance
  Core.ToHeaders
    RegisterTargetWithMaintenanceWindow
  where
  toHeaders :: RegisterTargetWithMaintenanceWindow -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> RegisterTargetWithMaintenanceWindow -> 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.RegisterTargetWithMaintenanceWindow" ::
                          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
    RegisterTargetWithMaintenanceWindow
  where
  toJSON :: RegisterTargetWithMaintenanceWindow -> Value
toJSON RegisterTargetWithMaintenanceWindow' {[Target]
Maybe Text
Maybe (Sensitive Text)
Text
MaintenanceWindowResourceType
targets :: [Target]
resourceType :: MaintenanceWindowResourceType
windowId :: Text
description :: Maybe (Sensitive Text)
name :: Maybe Text
ownerInformation :: Maybe (Sensitive Text)
clientToken :: Maybe Text
$sel:targets:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> [Target]
$sel:resourceType:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow
-> MaintenanceWindowResourceType
$sel:windowId:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Text
$sel:description:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
$sel:name:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe Text
$sel:ownerInformation:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe (Sensitive Text)
$sel:clientToken:RegisterTargetWithMaintenanceWindow' :: RegisterTargetWithMaintenanceWindow -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientToken" 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
clientToken,
            (Text
"OwnerInformation" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
ownerInformation,
            (Text
"Name" 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
name,
            (Text
"Description" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WindowId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
windowId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ResourceType" Text -> MaintenanceWindowResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MaintenanceWindowResourceType
resourceType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Targets" Text -> [Target] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Target]
targets)
          ]
      )

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

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

-- | /See:/ 'newRegisterTargetWithMaintenanceWindowResponse' smart constructor.
data RegisterTargetWithMaintenanceWindowResponse = RegisterTargetWithMaintenanceWindowResponse'
  { -- | The ID of the target definition in this maintenance window.
    RegisterTargetWithMaintenanceWindowResponse -> Maybe Text
windowTargetId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    RegisterTargetWithMaintenanceWindowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RegisterTargetWithMaintenanceWindowResponse
-> RegisterTargetWithMaintenanceWindowResponse -> Bool
(RegisterTargetWithMaintenanceWindowResponse
 -> RegisterTargetWithMaintenanceWindowResponse -> Bool)
-> (RegisterTargetWithMaintenanceWindowResponse
    -> RegisterTargetWithMaintenanceWindowResponse -> Bool)
-> Eq RegisterTargetWithMaintenanceWindowResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterTargetWithMaintenanceWindowResponse
-> RegisterTargetWithMaintenanceWindowResponse -> Bool
$c/= :: RegisterTargetWithMaintenanceWindowResponse
-> RegisterTargetWithMaintenanceWindowResponse -> Bool
== :: RegisterTargetWithMaintenanceWindowResponse
-> RegisterTargetWithMaintenanceWindowResponse -> Bool
$c== :: RegisterTargetWithMaintenanceWindowResponse
-> RegisterTargetWithMaintenanceWindowResponse -> Bool
Prelude.Eq, ReadPrec [RegisterTargetWithMaintenanceWindowResponse]
ReadPrec RegisterTargetWithMaintenanceWindowResponse
Int -> ReadS RegisterTargetWithMaintenanceWindowResponse
ReadS [RegisterTargetWithMaintenanceWindowResponse]
(Int -> ReadS RegisterTargetWithMaintenanceWindowResponse)
-> ReadS [RegisterTargetWithMaintenanceWindowResponse]
-> ReadPrec RegisterTargetWithMaintenanceWindowResponse
-> ReadPrec [RegisterTargetWithMaintenanceWindowResponse]
-> Read RegisterTargetWithMaintenanceWindowResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterTargetWithMaintenanceWindowResponse]
$creadListPrec :: ReadPrec [RegisterTargetWithMaintenanceWindowResponse]
readPrec :: ReadPrec RegisterTargetWithMaintenanceWindowResponse
$creadPrec :: ReadPrec RegisterTargetWithMaintenanceWindowResponse
readList :: ReadS [RegisterTargetWithMaintenanceWindowResponse]
$creadList :: ReadS [RegisterTargetWithMaintenanceWindowResponse]
readsPrec :: Int -> ReadS RegisterTargetWithMaintenanceWindowResponse
$creadsPrec :: Int -> ReadS RegisterTargetWithMaintenanceWindowResponse
Prelude.Read, Int -> RegisterTargetWithMaintenanceWindowResponse -> ShowS
[RegisterTargetWithMaintenanceWindowResponse] -> ShowS
RegisterTargetWithMaintenanceWindowResponse -> String
(Int -> RegisterTargetWithMaintenanceWindowResponse -> ShowS)
-> (RegisterTargetWithMaintenanceWindowResponse -> String)
-> ([RegisterTargetWithMaintenanceWindowResponse] -> ShowS)
-> Show RegisterTargetWithMaintenanceWindowResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterTargetWithMaintenanceWindowResponse] -> ShowS
$cshowList :: [RegisterTargetWithMaintenanceWindowResponse] -> ShowS
show :: RegisterTargetWithMaintenanceWindowResponse -> String
$cshow :: RegisterTargetWithMaintenanceWindowResponse -> String
showsPrec :: Int -> RegisterTargetWithMaintenanceWindowResponse -> ShowS
$cshowsPrec :: Int -> RegisterTargetWithMaintenanceWindowResponse -> ShowS
Prelude.Show, (forall x.
 RegisterTargetWithMaintenanceWindowResponse
 -> Rep RegisterTargetWithMaintenanceWindowResponse x)
-> (forall x.
    Rep RegisterTargetWithMaintenanceWindowResponse x
    -> RegisterTargetWithMaintenanceWindowResponse)
-> Generic RegisterTargetWithMaintenanceWindowResponse
forall x.
Rep RegisterTargetWithMaintenanceWindowResponse x
-> RegisterTargetWithMaintenanceWindowResponse
forall x.
RegisterTargetWithMaintenanceWindowResponse
-> Rep RegisterTargetWithMaintenanceWindowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterTargetWithMaintenanceWindowResponse x
-> RegisterTargetWithMaintenanceWindowResponse
$cfrom :: forall x.
RegisterTargetWithMaintenanceWindowResponse
-> Rep RegisterTargetWithMaintenanceWindowResponse x
Prelude.Generic)

-- |
-- Create a value of 'RegisterTargetWithMaintenanceWindowResponse' 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:
--
-- 'windowTargetId', 'registerTargetWithMaintenanceWindowResponse_windowTargetId' - The ID of the target definition in this maintenance window.
--
-- 'httpStatus', 'registerTargetWithMaintenanceWindowResponse_httpStatus' - The response's http status code.
newRegisterTargetWithMaintenanceWindowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterTargetWithMaintenanceWindowResponse
newRegisterTargetWithMaintenanceWindowResponse :: Int -> RegisterTargetWithMaintenanceWindowResponse
newRegisterTargetWithMaintenanceWindowResponse
  Int
pHttpStatus_ =
    RegisterTargetWithMaintenanceWindowResponse' :: Maybe Text -> Int -> RegisterTargetWithMaintenanceWindowResponse
RegisterTargetWithMaintenanceWindowResponse'
      { $sel:windowTargetId:RegisterTargetWithMaintenanceWindowResponse' :: Maybe Text
windowTargetId =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:RegisterTargetWithMaintenanceWindowResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The ID of the target definition in this maintenance window.
registerTargetWithMaintenanceWindowResponse_windowTargetId :: Lens.Lens' RegisterTargetWithMaintenanceWindowResponse (Prelude.Maybe Prelude.Text)
registerTargetWithMaintenanceWindowResponse_windowTargetId :: (Maybe Text -> f (Maybe Text))
-> RegisterTargetWithMaintenanceWindowResponse
-> f RegisterTargetWithMaintenanceWindowResponse
registerTargetWithMaintenanceWindowResponse_windowTargetId = (RegisterTargetWithMaintenanceWindowResponse -> Maybe Text)
-> (RegisterTargetWithMaintenanceWindowResponse
    -> Maybe Text -> RegisterTargetWithMaintenanceWindowResponse)
-> Lens
     RegisterTargetWithMaintenanceWindowResponse
     RegisterTargetWithMaintenanceWindowResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterTargetWithMaintenanceWindowResponse' {Maybe Text
windowTargetId :: Maybe Text
$sel:windowTargetId:RegisterTargetWithMaintenanceWindowResponse' :: RegisterTargetWithMaintenanceWindowResponse -> Maybe Text
windowTargetId} -> Maybe Text
windowTargetId) (\s :: RegisterTargetWithMaintenanceWindowResponse
s@RegisterTargetWithMaintenanceWindowResponse' {} Maybe Text
a -> RegisterTargetWithMaintenanceWindowResponse
s {$sel:windowTargetId:RegisterTargetWithMaintenanceWindowResponse' :: Maybe Text
windowTargetId = Maybe Text
a} :: RegisterTargetWithMaintenanceWindowResponse)

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

instance
  Prelude.NFData
    RegisterTargetWithMaintenanceWindowResponse