{-# 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.DescribeMaintenanceWindowsForTarget
-- 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)
--
-- Retrieves information about the maintenance window targets or tasks that
-- an instance is associated with.
--
-- This operation returns paginated results.
module Amazonka.SSM.DescribeMaintenanceWindowsForTarget
  ( -- * Creating a Request
    DescribeMaintenanceWindowsForTarget (..),
    newDescribeMaintenanceWindowsForTarget,

    -- * Request Lenses
    describeMaintenanceWindowsForTarget_nextToken,
    describeMaintenanceWindowsForTarget_maxResults,
    describeMaintenanceWindowsForTarget_targets,
    describeMaintenanceWindowsForTarget_resourceType,

    -- * Destructuring the Response
    DescribeMaintenanceWindowsForTargetResponse (..),
    newDescribeMaintenanceWindowsForTargetResponse,

    -- * Response Lenses
    describeMaintenanceWindowsForTargetResponse_windowIdentities,
    describeMaintenanceWindowsForTargetResponse_nextToken,
    describeMaintenanceWindowsForTargetResponse_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:/ 'newDescribeMaintenanceWindowsForTarget' smart constructor.
data DescribeMaintenanceWindowsForTarget = DescribeMaintenanceWindowsForTarget'
  { -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeMaintenanceWindowsForTarget -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return for this call. The call also
    -- returns a token that you can specify in a subsequent call to get the
    -- next set of results.
    DescribeMaintenanceWindowsForTarget -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The instance ID or key-value pair to retrieve information about.
    DescribeMaintenanceWindowsForTarget -> [Target]
targets :: [Target],
    -- | The type of resource you want to retrieve information about. For
    -- example, @INSTANCE@.
    DescribeMaintenanceWindowsForTarget
-> MaintenanceWindowResourceType
resourceType :: MaintenanceWindowResourceType
  }
  deriving (DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget -> Bool
(DescribeMaintenanceWindowsForTarget
 -> DescribeMaintenanceWindowsForTarget -> Bool)
-> (DescribeMaintenanceWindowsForTarget
    -> DescribeMaintenanceWindowsForTarget -> Bool)
-> Eq DescribeMaintenanceWindowsForTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget -> Bool
$c/= :: DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget -> Bool
== :: DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget -> Bool
$c== :: DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget -> Bool
Prelude.Eq, ReadPrec [DescribeMaintenanceWindowsForTarget]
ReadPrec DescribeMaintenanceWindowsForTarget
Int -> ReadS DescribeMaintenanceWindowsForTarget
ReadS [DescribeMaintenanceWindowsForTarget]
(Int -> ReadS DescribeMaintenanceWindowsForTarget)
-> ReadS [DescribeMaintenanceWindowsForTarget]
-> ReadPrec DescribeMaintenanceWindowsForTarget
-> ReadPrec [DescribeMaintenanceWindowsForTarget]
-> Read DescribeMaintenanceWindowsForTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMaintenanceWindowsForTarget]
$creadListPrec :: ReadPrec [DescribeMaintenanceWindowsForTarget]
readPrec :: ReadPrec DescribeMaintenanceWindowsForTarget
$creadPrec :: ReadPrec DescribeMaintenanceWindowsForTarget
readList :: ReadS [DescribeMaintenanceWindowsForTarget]
$creadList :: ReadS [DescribeMaintenanceWindowsForTarget]
readsPrec :: Int -> ReadS DescribeMaintenanceWindowsForTarget
$creadsPrec :: Int -> ReadS DescribeMaintenanceWindowsForTarget
Prelude.Read, Int -> DescribeMaintenanceWindowsForTarget -> ShowS
[DescribeMaintenanceWindowsForTarget] -> ShowS
DescribeMaintenanceWindowsForTarget -> String
(Int -> DescribeMaintenanceWindowsForTarget -> ShowS)
-> (DescribeMaintenanceWindowsForTarget -> String)
-> ([DescribeMaintenanceWindowsForTarget] -> ShowS)
-> Show DescribeMaintenanceWindowsForTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMaintenanceWindowsForTarget] -> ShowS
$cshowList :: [DescribeMaintenanceWindowsForTarget] -> ShowS
show :: DescribeMaintenanceWindowsForTarget -> String
$cshow :: DescribeMaintenanceWindowsForTarget -> String
showsPrec :: Int -> DescribeMaintenanceWindowsForTarget -> ShowS
$cshowsPrec :: Int -> DescribeMaintenanceWindowsForTarget -> ShowS
Prelude.Show, (forall x.
 DescribeMaintenanceWindowsForTarget
 -> Rep DescribeMaintenanceWindowsForTarget x)
-> (forall x.
    Rep DescribeMaintenanceWindowsForTarget x
    -> DescribeMaintenanceWindowsForTarget)
-> Generic DescribeMaintenanceWindowsForTarget
forall x.
Rep DescribeMaintenanceWindowsForTarget x
-> DescribeMaintenanceWindowsForTarget
forall x.
DescribeMaintenanceWindowsForTarget
-> Rep DescribeMaintenanceWindowsForTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMaintenanceWindowsForTarget x
-> DescribeMaintenanceWindowsForTarget
$cfrom :: forall x.
DescribeMaintenanceWindowsForTarget
-> Rep DescribeMaintenanceWindowsForTarget x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMaintenanceWindowsForTarget' 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:
--
-- 'nextToken', 'describeMaintenanceWindowsForTarget_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxResults', 'describeMaintenanceWindowsForTarget_maxResults' - The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
--
-- 'targets', 'describeMaintenanceWindowsForTarget_targets' - The instance ID or key-value pair to retrieve information about.
--
-- 'resourceType', 'describeMaintenanceWindowsForTarget_resourceType' - The type of resource you want to retrieve information about. For
-- example, @INSTANCE@.
newDescribeMaintenanceWindowsForTarget ::
  -- | 'resourceType'
  MaintenanceWindowResourceType ->
  DescribeMaintenanceWindowsForTarget
newDescribeMaintenanceWindowsForTarget :: MaintenanceWindowResourceType
-> DescribeMaintenanceWindowsForTarget
newDescribeMaintenanceWindowsForTarget MaintenanceWindowResourceType
pResourceType_ =
  DescribeMaintenanceWindowsForTarget' :: Maybe Text
-> Maybe Natural
-> [Target]
-> MaintenanceWindowResourceType
-> DescribeMaintenanceWindowsForTarget
DescribeMaintenanceWindowsForTarget'
    { $sel:nextToken:DescribeMaintenanceWindowsForTarget' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeMaintenanceWindowsForTarget' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:DescribeMaintenanceWindowsForTarget' :: [Target]
targets = [Target]
forall a. Monoid a => a
Prelude.mempty,
      $sel:resourceType:DescribeMaintenanceWindowsForTarget' :: MaintenanceWindowResourceType
resourceType = MaintenanceWindowResourceType
pResourceType_
    }

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
describeMaintenanceWindowsForTarget_nextToken :: Lens.Lens' DescribeMaintenanceWindowsForTarget (Prelude.Maybe Prelude.Text)
describeMaintenanceWindowsForTarget_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeMaintenanceWindowsForTarget
-> f DescribeMaintenanceWindowsForTarget
describeMaintenanceWindowsForTarget_nextToken = (DescribeMaintenanceWindowsForTarget -> Maybe Text)
-> (DescribeMaintenanceWindowsForTarget
    -> Maybe Text -> DescribeMaintenanceWindowsForTarget)
-> Lens
     DescribeMaintenanceWindowsForTarget
     DescribeMaintenanceWindowsForTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTarget' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeMaintenanceWindowsForTarget
s@DescribeMaintenanceWindowsForTarget' {} Maybe Text
a -> DescribeMaintenanceWindowsForTarget
s {$sel:nextToken:DescribeMaintenanceWindowsForTarget' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeMaintenanceWindowsForTarget)

-- | The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
describeMaintenanceWindowsForTarget_maxResults :: Lens.Lens' DescribeMaintenanceWindowsForTarget (Prelude.Maybe Prelude.Natural)
describeMaintenanceWindowsForTarget_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeMaintenanceWindowsForTarget
-> f DescribeMaintenanceWindowsForTarget
describeMaintenanceWindowsForTarget_maxResults = (DescribeMaintenanceWindowsForTarget -> Maybe Natural)
-> (DescribeMaintenanceWindowsForTarget
    -> Maybe Natural -> DescribeMaintenanceWindowsForTarget)
-> Lens
     DescribeMaintenanceWindowsForTarget
     DescribeMaintenanceWindowsForTarget
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTarget' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeMaintenanceWindowsForTarget
s@DescribeMaintenanceWindowsForTarget' {} Maybe Natural
a -> DescribeMaintenanceWindowsForTarget
s {$sel:maxResults:DescribeMaintenanceWindowsForTarget' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeMaintenanceWindowsForTarget)

-- | The instance ID or key-value pair to retrieve information about.
describeMaintenanceWindowsForTarget_targets :: Lens.Lens' DescribeMaintenanceWindowsForTarget [Target]
describeMaintenanceWindowsForTarget_targets :: ([Target] -> f [Target])
-> DescribeMaintenanceWindowsForTarget
-> f DescribeMaintenanceWindowsForTarget
describeMaintenanceWindowsForTarget_targets = (DescribeMaintenanceWindowsForTarget -> [Target])
-> (DescribeMaintenanceWindowsForTarget
    -> [Target] -> DescribeMaintenanceWindowsForTarget)
-> Lens
     DescribeMaintenanceWindowsForTarget
     DescribeMaintenanceWindowsForTarget
     [Target]
     [Target]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTarget' {[Target]
targets :: [Target]
$sel:targets:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> [Target]
targets} -> [Target]
targets) (\s :: DescribeMaintenanceWindowsForTarget
s@DescribeMaintenanceWindowsForTarget' {} [Target]
a -> DescribeMaintenanceWindowsForTarget
s {$sel:targets:DescribeMaintenanceWindowsForTarget' :: [Target]
targets = [Target]
a} :: DescribeMaintenanceWindowsForTarget) (([Target] -> f [Target])
 -> DescribeMaintenanceWindowsForTarget
 -> f DescribeMaintenanceWindowsForTarget)
-> (([Target] -> f [Target]) -> [Target] -> f [Target])
-> ([Target] -> f [Target])
-> DescribeMaintenanceWindowsForTarget
-> f DescribeMaintenanceWindowsForTarget
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

-- | The type of resource you want to retrieve information about. For
-- example, @INSTANCE@.
describeMaintenanceWindowsForTarget_resourceType :: Lens.Lens' DescribeMaintenanceWindowsForTarget MaintenanceWindowResourceType
describeMaintenanceWindowsForTarget_resourceType :: (MaintenanceWindowResourceType -> f MaintenanceWindowResourceType)
-> DescribeMaintenanceWindowsForTarget
-> f DescribeMaintenanceWindowsForTarget
describeMaintenanceWindowsForTarget_resourceType = (DescribeMaintenanceWindowsForTarget
 -> MaintenanceWindowResourceType)
-> (DescribeMaintenanceWindowsForTarget
    -> MaintenanceWindowResourceType
    -> DescribeMaintenanceWindowsForTarget)
-> Lens
     DescribeMaintenanceWindowsForTarget
     DescribeMaintenanceWindowsForTarget
     MaintenanceWindowResourceType
     MaintenanceWindowResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTarget' {MaintenanceWindowResourceType
resourceType :: MaintenanceWindowResourceType
$sel:resourceType:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget
-> MaintenanceWindowResourceType
resourceType} -> MaintenanceWindowResourceType
resourceType) (\s :: DescribeMaintenanceWindowsForTarget
s@DescribeMaintenanceWindowsForTarget' {} MaintenanceWindowResourceType
a -> DescribeMaintenanceWindowsForTarget
s {$sel:resourceType:DescribeMaintenanceWindowsForTarget' :: MaintenanceWindowResourceType
resourceType = MaintenanceWindowResourceType
a} :: DescribeMaintenanceWindowsForTarget)

instance
  Core.AWSPager
    DescribeMaintenanceWindowsForTarget
  where
  page :: DescribeMaintenanceWindowsForTarget
-> AWSResponse DescribeMaintenanceWindowsForTarget
-> Maybe DescribeMaintenanceWindowsForTarget
page DescribeMaintenanceWindowsForTarget
rq AWSResponse DescribeMaintenanceWindowsForTarget
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeMaintenanceWindowsForTarget
DescribeMaintenanceWindowsForTargetResponse
rs
            DescribeMaintenanceWindowsForTargetResponse
-> Getting
     (First Text) DescribeMaintenanceWindowsForTargetResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeMaintenanceWindowsForTargetResponse
-> Const (First Text) DescribeMaintenanceWindowsForTargetResponse
Lens' DescribeMaintenanceWindowsForTargetResponse (Maybe Text)
describeMaintenanceWindowsForTargetResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeMaintenanceWindowsForTargetResponse
 -> Const (First Text) DescribeMaintenanceWindowsForTargetResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeMaintenanceWindowsForTargetResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeMaintenanceWindowsForTarget
forall a. Maybe a
Prelude.Nothing
    | Maybe [MaintenanceWindowIdentityForTarget] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeMaintenanceWindowsForTarget
DescribeMaintenanceWindowsForTargetResponse
rs
            DescribeMaintenanceWindowsForTargetResponse
-> Getting
     (First [MaintenanceWindowIdentityForTarget])
     DescribeMaintenanceWindowsForTargetResponse
     [MaintenanceWindowIdentityForTarget]
-> Maybe [MaintenanceWindowIdentityForTarget]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [MaintenanceWindowIdentityForTarget]
 -> Const
      (First [MaintenanceWindowIdentityForTarget])
      (Maybe [MaintenanceWindowIdentityForTarget]))
-> DescribeMaintenanceWindowsForTargetResponse
-> Const
     (First [MaintenanceWindowIdentityForTarget])
     DescribeMaintenanceWindowsForTargetResponse
Lens'
  DescribeMaintenanceWindowsForTargetResponse
  (Maybe [MaintenanceWindowIdentityForTarget])
describeMaintenanceWindowsForTargetResponse_windowIdentities
              ((Maybe [MaintenanceWindowIdentityForTarget]
  -> Const
       (First [MaintenanceWindowIdentityForTarget])
       (Maybe [MaintenanceWindowIdentityForTarget]))
 -> DescribeMaintenanceWindowsForTargetResponse
 -> Const
      (First [MaintenanceWindowIdentityForTarget])
      DescribeMaintenanceWindowsForTargetResponse)
-> (([MaintenanceWindowIdentityForTarget]
     -> Const
          (First [MaintenanceWindowIdentityForTarget])
          [MaintenanceWindowIdentityForTarget])
    -> Maybe [MaintenanceWindowIdentityForTarget]
    -> Const
         (First [MaintenanceWindowIdentityForTarget])
         (Maybe [MaintenanceWindowIdentityForTarget]))
-> Getting
     (First [MaintenanceWindowIdentityForTarget])
     DescribeMaintenanceWindowsForTargetResponse
     [MaintenanceWindowIdentityForTarget]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MaintenanceWindowIdentityForTarget]
 -> Const
      (First [MaintenanceWindowIdentityForTarget])
      [MaintenanceWindowIdentityForTarget])
-> Maybe [MaintenanceWindowIdentityForTarget]
-> Const
     (First [MaintenanceWindowIdentityForTarget])
     (Maybe [MaintenanceWindowIdentityForTarget])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeMaintenanceWindowsForTarget
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeMaintenanceWindowsForTarget
-> Maybe DescribeMaintenanceWindowsForTarget
forall a. a -> Maybe a
Prelude.Just (DescribeMaintenanceWindowsForTarget
 -> Maybe DescribeMaintenanceWindowsForTarget)
-> DescribeMaintenanceWindowsForTarget
-> Maybe DescribeMaintenanceWindowsForTarget
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeMaintenanceWindowsForTarget
rq
          DescribeMaintenanceWindowsForTarget
-> (DescribeMaintenanceWindowsForTarget
    -> DescribeMaintenanceWindowsForTarget)
-> DescribeMaintenanceWindowsForTarget
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeMaintenanceWindowsForTarget
-> Identity DescribeMaintenanceWindowsForTarget
Lens
  DescribeMaintenanceWindowsForTarget
  DescribeMaintenanceWindowsForTarget
  (Maybe Text)
  (Maybe Text)
describeMaintenanceWindowsForTarget_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeMaintenanceWindowsForTarget
 -> Identity DescribeMaintenanceWindowsForTarget)
-> Maybe Text
-> DescribeMaintenanceWindowsForTarget
-> DescribeMaintenanceWindowsForTarget
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeMaintenanceWindowsForTarget
DescribeMaintenanceWindowsForTargetResponse
rs
          DescribeMaintenanceWindowsForTargetResponse
-> Getting
     (First Text) DescribeMaintenanceWindowsForTargetResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeMaintenanceWindowsForTargetResponse
-> Const (First Text) DescribeMaintenanceWindowsForTargetResponse
Lens' DescribeMaintenanceWindowsForTargetResponse (Maybe Text)
describeMaintenanceWindowsForTargetResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeMaintenanceWindowsForTargetResponse
 -> Const (First Text) DescribeMaintenanceWindowsForTargetResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting
     (First Text) DescribeMaintenanceWindowsForTargetResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    DescribeMaintenanceWindowsForTarget
  where
  type
    AWSResponse DescribeMaintenanceWindowsForTarget =
      DescribeMaintenanceWindowsForTargetResponse
  request :: DescribeMaintenanceWindowsForTarget
-> Request DescribeMaintenanceWindowsForTarget
request = Service
-> DescribeMaintenanceWindowsForTarget
-> Request DescribeMaintenanceWindowsForTarget
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeMaintenanceWindowsForTarget
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeMaintenanceWindowsForTarget)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeMaintenanceWindowsForTarget))
-> Logger
-> Service
-> Proxy DescribeMaintenanceWindowsForTarget
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeMaintenanceWindowsForTarget)))
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 [MaintenanceWindowIdentityForTarget]
-> Maybe Text -> Int -> DescribeMaintenanceWindowsForTargetResponse
DescribeMaintenanceWindowsForTargetResponse'
            (Maybe [MaintenanceWindowIdentityForTarget]
 -> Maybe Text
 -> Int
 -> DescribeMaintenanceWindowsForTargetResponse)
-> Either String (Maybe [MaintenanceWindowIdentityForTarget])
-> Either
     String
     (Maybe Text -> Int -> DescribeMaintenanceWindowsForTargetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either
     String (Maybe (Maybe [MaintenanceWindowIdentityForTarget]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"WindowIdentities"
                            Either String (Maybe (Maybe [MaintenanceWindowIdentityForTarget]))
-> Maybe [MaintenanceWindowIdentityForTarget]
-> Either String (Maybe [MaintenanceWindowIdentityForTarget])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [MaintenanceWindowIdentityForTarget]
forall a. Monoid a => a
Prelude.mempty
                        )
              Either
  String
  (Maybe Text -> Int -> DescribeMaintenanceWindowsForTargetResponse)
-> Either String (Maybe Text)
-> Either
     String (Int -> DescribeMaintenanceWindowsForTargetResponse)
forall (f :: * -> *) a b. Applicative f => 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
"NextToken")
              Either String (Int -> DescribeMaintenanceWindowsForTargetResponse)
-> Either String Int
-> Either String DescribeMaintenanceWindowsForTargetResponse
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
    DescribeMaintenanceWindowsForTarget

instance
  Prelude.NFData
    DescribeMaintenanceWindowsForTarget

instance
  Core.ToHeaders
    DescribeMaintenanceWindowsForTarget
  where
  toHeaders :: DescribeMaintenanceWindowsForTarget -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeMaintenanceWindowsForTarget -> 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.DescribeMaintenanceWindowsForTarget" ::
                          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
    DescribeMaintenanceWindowsForTarget
  where
  toJSON :: DescribeMaintenanceWindowsForTarget -> Value
toJSON DescribeMaintenanceWindowsForTarget' {[Target]
Maybe Natural
Maybe Text
MaintenanceWindowResourceType
resourceType :: MaintenanceWindowResourceType
targets :: [Target]
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:resourceType:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget
-> MaintenanceWindowResourceType
$sel:targets:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> [Target]
$sel:maxResults:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> Maybe Natural
$sel:nextToken:DescribeMaintenanceWindowsForTarget' :: DescribeMaintenanceWindowsForTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            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),
            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)
          ]
      )

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

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

-- | /See:/ 'newDescribeMaintenanceWindowsForTargetResponse' smart constructor.
data DescribeMaintenanceWindowsForTargetResponse = DescribeMaintenanceWindowsForTargetResponse'
  { -- | Information about the maintenance window targets and tasks an instance
    -- is associated with.
    DescribeMaintenanceWindowsForTargetResponse
-> Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities :: Prelude.Maybe [MaintenanceWindowIdentityForTarget],
    -- | The token for the next set of items to return. (You use this token in
    -- the next call.)
    DescribeMaintenanceWindowsForTargetResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeMaintenanceWindowsForTargetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeMaintenanceWindowsForTargetResponse
-> DescribeMaintenanceWindowsForTargetResponse -> Bool
(DescribeMaintenanceWindowsForTargetResponse
 -> DescribeMaintenanceWindowsForTargetResponse -> Bool)
-> (DescribeMaintenanceWindowsForTargetResponse
    -> DescribeMaintenanceWindowsForTargetResponse -> Bool)
-> Eq DescribeMaintenanceWindowsForTargetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMaintenanceWindowsForTargetResponse
-> DescribeMaintenanceWindowsForTargetResponse -> Bool
$c/= :: DescribeMaintenanceWindowsForTargetResponse
-> DescribeMaintenanceWindowsForTargetResponse -> Bool
== :: DescribeMaintenanceWindowsForTargetResponse
-> DescribeMaintenanceWindowsForTargetResponse -> Bool
$c== :: DescribeMaintenanceWindowsForTargetResponse
-> DescribeMaintenanceWindowsForTargetResponse -> Bool
Prelude.Eq, ReadPrec [DescribeMaintenanceWindowsForTargetResponse]
ReadPrec DescribeMaintenanceWindowsForTargetResponse
Int -> ReadS DescribeMaintenanceWindowsForTargetResponse
ReadS [DescribeMaintenanceWindowsForTargetResponse]
(Int -> ReadS DescribeMaintenanceWindowsForTargetResponse)
-> ReadS [DescribeMaintenanceWindowsForTargetResponse]
-> ReadPrec DescribeMaintenanceWindowsForTargetResponse
-> ReadPrec [DescribeMaintenanceWindowsForTargetResponse]
-> Read DescribeMaintenanceWindowsForTargetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMaintenanceWindowsForTargetResponse]
$creadListPrec :: ReadPrec [DescribeMaintenanceWindowsForTargetResponse]
readPrec :: ReadPrec DescribeMaintenanceWindowsForTargetResponse
$creadPrec :: ReadPrec DescribeMaintenanceWindowsForTargetResponse
readList :: ReadS [DescribeMaintenanceWindowsForTargetResponse]
$creadList :: ReadS [DescribeMaintenanceWindowsForTargetResponse]
readsPrec :: Int -> ReadS DescribeMaintenanceWindowsForTargetResponse
$creadsPrec :: Int -> ReadS DescribeMaintenanceWindowsForTargetResponse
Prelude.Read, Int -> DescribeMaintenanceWindowsForTargetResponse -> ShowS
[DescribeMaintenanceWindowsForTargetResponse] -> ShowS
DescribeMaintenanceWindowsForTargetResponse -> String
(Int -> DescribeMaintenanceWindowsForTargetResponse -> ShowS)
-> (DescribeMaintenanceWindowsForTargetResponse -> String)
-> ([DescribeMaintenanceWindowsForTargetResponse] -> ShowS)
-> Show DescribeMaintenanceWindowsForTargetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMaintenanceWindowsForTargetResponse] -> ShowS
$cshowList :: [DescribeMaintenanceWindowsForTargetResponse] -> ShowS
show :: DescribeMaintenanceWindowsForTargetResponse -> String
$cshow :: DescribeMaintenanceWindowsForTargetResponse -> String
showsPrec :: Int -> DescribeMaintenanceWindowsForTargetResponse -> ShowS
$cshowsPrec :: Int -> DescribeMaintenanceWindowsForTargetResponse -> ShowS
Prelude.Show, (forall x.
 DescribeMaintenanceWindowsForTargetResponse
 -> Rep DescribeMaintenanceWindowsForTargetResponse x)
-> (forall x.
    Rep DescribeMaintenanceWindowsForTargetResponse x
    -> DescribeMaintenanceWindowsForTargetResponse)
-> Generic DescribeMaintenanceWindowsForTargetResponse
forall x.
Rep DescribeMaintenanceWindowsForTargetResponse x
-> DescribeMaintenanceWindowsForTargetResponse
forall x.
DescribeMaintenanceWindowsForTargetResponse
-> Rep DescribeMaintenanceWindowsForTargetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMaintenanceWindowsForTargetResponse x
-> DescribeMaintenanceWindowsForTargetResponse
$cfrom :: forall x.
DescribeMaintenanceWindowsForTargetResponse
-> Rep DescribeMaintenanceWindowsForTargetResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMaintenanceWindowsForTargetResponse' 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:
--
-- 'windowIdentities', 'describeMaintenanceWindowsForTargetResponse_windowIdentities' - Information about the maintenance window targets and tasks an instance
-- is associated with.
--
-- 'nextToken', 'describeMaintenanceWindowsForTargetResponse_nextToken' - The token for the next set of items to return. (You use this token in
-- the next call.)
--
-- 'httpStatus', 'describeMaintenanceWindowsForTargetResponse_httpStatus' - The response's http status code.
newDescribeMaintenanceWindowsForTargetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMaintenanceWindowsForTargetResponse
newDescribeMaintenanceWindowsForTargetResponse :: Int -> DescribeMaintenanceWindowsForTargetResponse
newDescribeMaintenanceWindowsForTargetResponse
  Int
pHttpStatus_ =
    DescribeMaintenanceWindowsForTargetResponse' :: Maybe [MaintenanceWindowIdentityForTarget]
-> Maybe Text -> Int -> DescribeMaintenanceWindowsForTargetResponse
DescribeMaintenanceWindowsForTargetResponse'
      { $sel:windowIdentities:DescribeMaintenanceWindowsForTargetResponse' :: Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities =
          Maybe [MaintenanceWindowIdentityForTarget]
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeMaintenanceWindowsForTargetResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeMaintenanceWindowsForTargetResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Information about the maintenance window targets and tasks an instance
-- is associated with.
describeMaintenanceWindowsForTargetResponse_windowIdentities :: Lens.Lens' DescribeMaintenanceWindowsForTargetResponse (Prelude.Maybe [MaintenanceWindowIdentityForTarget])
describeMaintenanceWindowsForTargetResponse_windowIdentities :: (Maybe [MaintenanceWindowIdentityForTarget]
 -> f (Maybe [MaintenanceWindowIdentityForTarget]))
-> DescribeMaintenanceWindowsForTargetResponse
-> f DescribeMaintenanceWindowsForTargetResponse
describeMaintenanceWindowsForTargetResponse_windowIdentities = (DescribeMaintenanceWindowsForTargetResponse
 -> Maybe [MaintenanceWindowIdentityForTarget])
-> (DescribeMaintenanceWindowsForTargetResponse
    -> Maybe [MaintenanceWindowIdentityForTarget]
    -> DescribeMaintenanceWindowsForTargetResponse)
-> Lens'
     DescribeMaintenanceWindowsForTargetResponse
     (Maybe [MaintenanceWindowIdentityForTarget])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTargetResponse' {Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities :: Maybe [MaintenanceWindowIdentityForTarget]
$sel:windowIdentities:DescribeMaintenanceWindowsForTargetResponse' :: DescribeMaintenanceWindowsForTargetResponse
-> Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities} -> Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities) (\s :: DescribeMaintenanceWindowsForTargetResponse
s@DescribeMaintenanceWindowsForTargetResponse' {} Maybe [MaintenanceWindowIdentityForTarget]
a -> DescribeMaintenanceWindowsForTargetResponse
s {$sel:windowIdentities:DescribeMaintenanceWindowsForTargetResponse' :: Maybe [MaintenanceWindowIdentityForTarget]
windowIdentities = Maybe [MaintenanceWindowIdentityForTarget]
a} :: DescribeMaintenanceWindowsForTargetResponse) ((Maybe [MaintenanceWindowIdentityForTarget]
  -> f (Maybe [MaintenanceWindowIdentityForTarget]))
 -> DescribeMaintenanceWindowsForTargetResponse
 -> f DescribeMaintenanceWindowsForTargetResponse)
-> ((Maybe [MaintenanceWindowIdentityForTarget]
     -> f (Maybe [MaintenanceWindowIdentityForTarget]))
    -> Maybe [MaintenanceWindowIdentityForTarget]
    -> f (Maybe [MaintenanceWindowIdentityForTarget]))
-> (Maybe [MaintenanceWindowIdentityForTarget]
    -> f (Maybe [MaintenanceWindowIdentityForTarget]))
-> DescribeMaintenanceWindowsForTargetResponse
-> f DescribeMaintenanceWindowsForTargetResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
-> Iso
     (Maybe [MaintenanceWindowIdentityForTarget])
     (Maybe [MaintenanceWindowIdentityForTarget])
     (Maybe [MaintenanceWindowIdentityForTarget])
     (Maybe [MaintenanceWindowIdentityForTarget])
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
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
  [MaintenanceWindowIdentityForTarget]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of items to return. (You use this token in
-- the next call.)
describeMaintenanceWindowsForTargetResponse_nextToken :: Lens.Lens' DescribeMaintenanceWindowsForTargetResponse (Prelude.Maybe Prelude.Text)
describeMaintenanceWindowsForTargetResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeMaintenanceWindowsForTargetResponse
-> f DescribeMaintenanceWindowsForTargetResponse
describeMaintenanceWindowsForTargetResponse_nextToken = (DescribeMaintenanceWindowsForTargetResponse -> Maybe Text)
-> (DescribeMaintenanceWindowsForTargetResponse
    -> Maybe Text -> DescribeMaintenanceWindowsForTargetResponse)
-> Lens' DescribeMaintenanceWindowsForTargetResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMaintenanceWindowsForTargetResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeMaintenanceWindowsForTargetResponse' :: DescribeMaintenanceWindowsForTargetResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeMaintenanceWindowsForTargetResponse
s@DescribeMaintenanceWindowsForTargetResponse' {} Maybe Text
a -> DescribeMaintenanceWindowsForTargetResponse
s {$sel:nextToken:DescribeMaintenanceWindowsForTargetResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeMaintenanceWindowsForTargetResponse)

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

instance
  Prelude.NFData
    DescribeMaintenanceWindowsForTargetResponse