{-# 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.DescribeInstancePatches
-- 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 patches on the specified instance and
-- their state relative to the patch baseline being used for the instance.
--
-- This operation returns paginated results.
module Amazonka.SSM.DescribeInstancePatches
  ( -- * Creating a Request
    DescribeInstancePatches (..),
    newDescribeInstancePatches,

    -- * Request Lenses
    describeInstancePatches_filters,
    describeInstancePatches_nextToken,
    describeInstancePatches_maxResults,
    describeInstancePatches_instanceId,

    -- * Destructuring the Response
    DescribeInstancePatchesResponse (..),
    newDescribeInstancePatchesResponse,

    -- * Response Lenses
    describeInstancePatchesResponse_patches,
    describeInstancePatchesResponse_nextToken,
    describeInstancePatchesResponse_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:/ 'newDescribeInstancePatches' smart constructor.
data DescribeInstancePatches = DescribeInstancePatches'
  { -- | Each element in the array is a structure containing a key-value pair.
    --
    -- Supported keys for @DescribeInstancePatches@include the following:
    --
    -- -   __@Classification@__
    --
    --     Sample values: @Security@ | @SecurityUpdates@
    --
    -- -   __@KBId@__
    --
    --     Sample values: @KB4480056@ | @java-1.7.0-openjdk.x86_64@
    --
    -- -   __@Severity@__
    --
    --     Sample values: @Important@ | @Medium@ | @Low@
    --
    -- -   __@State@__
    --
    --     Sample values: @Installed@ | @InstalledOther@ |
    --     @InstalledPendingReboot@
    DescribeInstancePatches -> Maybe [PatchOrchestratorFilter]
filters :: Prelude.Maybe [PatchOrchestratorFilter],
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeInstancePatches -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of patches to return (per page).
    DescribeInstancePatches -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the instance whose patch state information should be
    -- retrieved.
    DescribeInstancePatches -> Text
instanceId :: Prelude.Text
  }
  deriving (DescribeInstancePatches -> DescribeInstancePatches -> Bool
(DescribeInstancePatches -> DescribeInstancePatches -> Bool)
-> (DescribeInstancePatches -> DescribeInstancePatches -> Bool)
-> Eq DescribeInstancePatches
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInstancePatches -> DescribeInstancePatches -> Bool
$c/= :: DescribeInstancePatches -> DescribeInstancePatches -> Bool
== :: DescribeInstancePatches -> DescribeInstancePatches -> Bool
$c== :: DescribeInstancePatches -> DescribeInstancePatches -> Bool
Prelude.Eq, ReadPrec [DescribeInstancePatches]
ReadPrec DescribeInstancePatches
Int -> ReadS DescribeInstancePatches
ReadS [DescribeInstancePatches]
(Int -> ReadS DescribeInstancePatches)
-> ReadS [DescribeInstancePatches]
-> ReadPrec DescribeInstancePatches
-> ReadPrec [DescribeInstancePatches]
-> Read DescribeInstancePatches
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInstancePatches]
$creadListPrec :: ReadPrec [DescribeInstancePatches]
readPrec :: ReadPrec DescribeInstancePatches
$creadPrec :: ReadPrec DescribeInstancePatches
readList :: ReadS [DescribeInstancePatches]
$creadList :: ReadS [DescribeInstancePatches]
readsPrec :: Int -> ReadS DescribeInstancePatches
$creadsPrec :: Int -> ReadS DescribeInstancePatches
Prelude.Read, Int -> DescribeInstancePatches -> ShowS
[DescribeInstancePatches] -> ShowS
DescribeInstancePatches -> String
(Int -> DescribeInstancePatches -> ShowS)
-> (DescribeInstancePatches -> String)
-> ([DescribeInstancePatches] -> ShowS)
-> Show DescribeInstancePatches
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInstancePatches] -> ShowS
$cshowList :: [DescribeInstancePatches] -> ShowS
show :: DescribeInstancePatches -> String
$cshow :: DescribeInstancePatches -> String
showsPrec :: Int -> DescribeInstancePatches -> ShowS
$cshowsPrec :: Int -> DescribeInstancePatches -> ShowS
Prelude.Show, (forall x.
 DescribeInstancePatches -> Rep DescribeInstancePatches x)
-> (forall x.
    Rep DescribeInstancePatches x -> DescribeInstancePatches)
-> Generic DescribeInstancePatches
forall x. Rep DescribeInstancePatches x -> DescribeInstancePatches
forall x. DescribeInstancePatches -> Rep DescribeInstancePatches x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeInstancePatches x -> DescribeInstancePatches
$cfrom :: forall x. DescribeInstancePatches -> Rep DescribeInstancePatches x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInstancePatches' 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:
--
-- 'filters', 'describeInstancePatches_filters' - Each element in the array is a structure containing a key-value pair.
--
-- Supported keys for @DescribeInstancePatches@include the following:
--
-- -   __@Classification@__
--
--     Sample values: @Security@ | @SecurityUpdates@
--
-- -   __@KBId@__
--
--     Sample values: @KB4480056@ | @java-1.7.0-openjdk.x86_64@
--
-- -   __@Severity@__
--
--     Sample values: @Important@ | @Medium@ | @Low@
--
-- -   __@State@__
--
--     Sample values: @Installed@ | @InstalledOther@ |
--     @InstalledPendingReboot@
--
-- 'nextToken', 'describeInstancePatches_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxResults', 'describeInstancePatches_maxResults' - The maximum number of patches to return (per page).
--
-- 'instanceId', 'describeInstancePatches_instanceId' - The ID of the instance whose patch state information should be
-- retrieved.
newDescribeInstancePatches ::
  -- | 'instanceId'
  Prelude.Text ->
  DescribeInstancePatches
newDescribeInstancePatches :: Text -> DescribeInstancePatches
newDescribeInstancePatches Text
pInstanceId_ =
  DescribeInstancePatches' :: Maybe [PatchOrchestratorFilter]
-> Maybe Text -> Maybe Natural -> Text -> DescribeInstancePatches
DescribeInstancePatches'
    { $sel:filters:DescribeInstancePatches' :: Maybe [PatchOrchestratorFilter]
filters = Maybe [PatchOrchestratorFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeInstancePatches' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeInstancePatches' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:DescribeInstancePatches' :: Text
instanceId = Text
pInstanceId_
    }

-- | Each element in the array is a structure containing a key-value pair.
--
-- Supported keys for @DescribeInstancePatches@include the following:
--
-- -   __@Classification@__
--
--     Sample values: @Security@ | @SecurityUpdates@
--
-- -   __@KBId@__
--
--     Sample values: @KB4480056@ | @java-1.7.0-openjdk.x86_64@
--
-- -   __@Severity@__
--
--     Sample values: @Important@ | @Medium@ | @Low@
--
-- -   __@State@__
--
--     Sample values: @Installed@ | @InstalledOther@ |
--     @InstalledPendingReboot@
describeInstancePatches_filters :: Lens.Lens' DescribeInstancePatches (Prelude.Maybe [PatchOrchestratorFilter])
describeInstancePatches_filters :: (Maybe [PatchOrchestratorFilter]
 -> f (Maybe [PatchOrchestratorFilter]))
-> DescribeInstancePatches -> f DescribeInstancePatches
describeInstancePatches_filters = (DescribeInstancePatches -> Maybe [PatchOrchestratorFilter])
-> (DescribeInstancePatches
    -> Maybe [PatchOrchestratorFilter] -> DescribeInstancePatches)
-> Lens
     DescribeInstancePatches
     DescribeInstancePatches
     (Maybe [PatchOrchestratorFilter])
     (Maybe [PatchOrchestratorFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatches' {Maybe [PatchOrchestratorFilter]
filters :: Maybe [PatchOrchestratorFilter]
$sel:filters:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe [PatchOrchestratorFilter]
filters} -> Maybe [PatchOrchestratorFilter]
filters) (\s :: DescribeInstancePatches
s@DescribeInstancePatches' {} Maybe [PatchOrchestratorFilter]
a -> DescribeInstancePatches
s {$sel:filters:DescribeInstancePatches' :: Maybe [PatchOrchestratorFilter]
filters = Maybe [PatchOrchestratorFilter]
a} :: DescribeInstancePatches) ((Maybe [PatchOrchestratorFilter]
  -> f (Maybe [PatchOrchestratorFilter]))
 -> DescribeInstancePatches -> f DescribeInstancePatches)
-> ((Maybe [PatchOrchestratorFilter]
     -> f (Maybe [PatchOrchestratorFilter]))
    -> Maybe [PatchOrchestratorFilter]
    -> f (Maybe [PatchOrchestratorFilter]))
-> (Maybe [PatchOrchestratorFilter]
    -> f (Maybe [PatchOrchestratorFilter]))
-> DescribeInstancePatches
-> f DescribeInstancePatches
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
-> Iso
     (Maybe [PatchOrchestratorFilter])
     (Maybe [PatchOrchestratorFilter])
     (Maybe [PatchOrchestratorFilter])
     (Maybe [PatchOrchestratorFilter])
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
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
  [PatchOrchestratorFilter]
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 received this token
-- from a previous call.)
describeInstancePatches_nextToken :: Lens.Lens' DescribeInstancePatches (Prelude.Maybe Prelude.Text)
describeInstancePatches_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeInstancePatches -> f DescribeInstancePatches
describeInstancePatches_nextToken = (DescribeInstancePatches -> Maybe Text)
-> (DescribeInstancePatches
    -> Maybe Text -> DescribeInstancePatches)
-> Lens
     DescribeInstancePatches
     DescribeInstancePatches
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatches' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeInstancePatches
s@DescribeInstancePatches' {} Maybe Text
a -> DescribeInstancePatches
s {$sel:nextToken:DescribeInstancePatches' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeInstancePatches)

-- | The maximum number of patches to return (per page).
describeInstancePatches_maxResults :: Lens.Lens' DescribeInstancePatches (Prelude.Maybe Prelude.Natural)
describeInstancePatches_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeInstancePatches -> f DescribeInstancePatches
describeInstancePatches_maxResults = (DescribeInstancePatches -> Maybe Natural)
-> (DescribeInstancePatches
    -> Maybe Natural -> DescribeInstancePatches)
-> Lens
     DescribeInstancePatches
     DescribeInstancePatches
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatches' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeInstancePatches
s@DescribeInstancePatches' {} Maybe Natural
a -> DescribeInstancePatches
s {$sel:maxResults:DescribeInstancePatches' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeInstancePatches)

-- | The ID of the instance whose patch state information should be
-- retrieved.
describeInstancePatches_instanceId :: Lens.Lens' DescribeInstancePatches Prelude.Text
describeInstancePatches_instanceId :: (Text -> f Text)
-> DescribeInstancePatches -> f DescribeInstancePatches
describeInstancePatches_instanceId = (DescribeInstancePatches -> Text)
-> (DescribeInstancePatches -> Text -> DescribeInstancePatches)
-> Lens DescribeInstancePatches DescribeInstancePatches Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatches' {Text
instanceId :: Text
$sel:instanceId:DescribeInstancePatches' :: DescribeInstancePatches -> Text
instanceId} -> Text
instanceId) (\s :: DescribeInstancePatches
s@DescribeInstancePatches' {} Text
a -> DescribeInstancePatches
s {$sel:instanceId:DescribeInstancePatches' :: Text
instanceId = Text
a} :: DescribeInstancePatches)

instance Core.AWSPager DescribeInstancePatches where
  page :: DescribeInstancePatches
-> AWSResponse DescribeInstancePatches
-> Maybe DescribeInstancePatches
page DescribeInstancePatches
rq AWSResponse DescribeInstancePatches
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeInstancePatches
DescribeInstancePatchesResponse
rs
            DescribeInstancePatchesResponse
-> Getting (First Text) DescribeInstancePatchesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeInstancePatchesResponse
-> Const (First Text) DescribeInstancePatchesResponse
Lens' DescribeInstancePatchesResponse (Maybe Text)
describeInstancePatchesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeInstancePatchesResponse
 -> Const (First Text) DescribeInstancePatchesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeInstancePatchesResponse 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 DescribeInstancePatches
forall a. Maybe a
Prelude.Nothing
    | Maybe [PatchComplianceData] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeInstancePatches
DescribeInstancePatchesResponse
rs
            DescribeInstancePatchesResponse
-> Getting
     (First [PatchComplianceData])
     DescribeInstancePatchesResponse
     [PatchComplianceData]
-> Maybe [PatchComplianceData]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [PatchComplianceData]
 -> Const
      (First [PatchComplianceData]) (Maybe [PatchComplianceData]))
-> DescribeInstancePatchesResponse
-> Const
     (First [PatchComplianceData]) DescribeInstancePatchesResponse
Lens' DescribeInstancePatchesResponse (Maybe [PatchComplianceData])
describeInstancePatchesResponse_patches
              ((Maybe [PatchComplianceData]
  -> Const
       (First [PatchComplianceData]) (Maybe [PatchComplianceData]))
 -> DescribeInstancePatchesResponse
 -> Const
      (First [PatchComplianceData]) DescribeInstancePatchesResponse)
-> (([PatchComplianceData]
     -> Const (First [PatchComplianceData]) [PatchComplianceData])
    -> Maybe [PatchComplianceData]
    -> Const
         (First [PatchComplianceData]) (Maybe [PatchComplianceData]))
-> Getting
     (First [PatchComplianceData])
     DescribeInstancePatchesResponse
     [PatchComplianceData]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PatchComplianceData]
 -> Const (First [PatchComplianceData]) [PatchComplianceData])
-> Maybe [PatchComplianceData]
-> Const
     (First [PatchComplianceData]) (Maybe [PatchComplianceData])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeInstancePatches
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeInstancePatches -> Maybe DescribeInstancePatches
forall a. a -> Maybe a
Prelude.Just (DescribeInstancePatches -> Maybe DescribeInstancePatches)
-> DescribeInstancePatches -> Maybe DescribeInstancePatches
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeInstancePatches
rq
          DescribeInstancePatches
-> (DescribeInstancePatches -> DescribeInstancePatches)
-> DescribeInstancePatches
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeInstancePatches -> Identity DescribeInstancePatches
Lens
  DescribeInstancePatches
  DescribeInstancePatches
  (Maybe Text)
  (Maybe Text)
describeInstancePatches_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeInstancePatches -> Identity DescribeInstancePatches)
-> Maybe Text -> DescribeInstancePatches -> DescribeInstancePatches
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeInstancePatches
DescribeInstancePatchesResponse
rs
          DescribeInstancePatchesResponse
-> Getting (First Text) DescribeInstancePatchesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeInstancePatchesResponse
-> Const (First Text) DescribeInstancePatchesResponse
Lens' DescribeInstancePatchesResponse (Maybe Text)
describeInstancePatchesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeInstancePatchesResponse
 -> Const (First Text) DescribeInstancePatchesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeInstancePatchesResponse 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 DescribeInstancePatches where
  type
    AWSResponse DescribeInstancePatches =
      DescribeInstancePatchesResponse
  request :: DescribeInstancePatches -> Request DescribeInstancePatches
request = Service
-> DescribeInstancePatches -> Request DescribeInstancePatches
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeInstancePatches
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeInstancePatches)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeInstancePatches))
-> Logger
-> Service
-> Proxy DescribeInstancePatches
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeInstancePatches)))
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 [PatchComplianceData]
-> Maybe Text -> Int -> DescribeInstancePatchesResponse
DescribeInstancePatchesResponse'
            (Maybe [PatchComplianceData]
 -> Maybe Text -> Int -> DescribeInstancePatchesResponse)
-> Either String (Maybe [PatchComplianceData])
-> Either
     String (Maybe Text -> Int -> DescribeInstancePatchesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe (Maybe [PatchComplianceData]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Patches" Either String (Maybe (Maybe [PatchComplianceData]))
-> Maybe [PatchComplianceData]
-> Either String (Maybe [PatchComplianceData])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PatchComplianceData]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Text -> Int -> DescribeInstancePatchesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeInstancePatchesResponse)
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 -> DescribeInstancePatchesResponse)
-> Either String Int
-> Either String DescribeInstancePatchesResponse
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 DescribeInstancePatches

instance Prelude.NFData DescribeInstancePatches

instance Core.ToHeaders DescribeInstancePatches where
  toHeaders :: DescribeInstancePatches -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeInstancePatches -> 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.DescribeInstancePatches" ::
                          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 DescribeInstancePatches where
  toJSON :: DescribeInstancePatches -> Value
toJSON DescribeInstancePatches' {Maybe Natural
Maybe [PatchOrchestratorFilter]
Maybe Text
Text
instanceId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
filters :: Maybe [PatchOrchestratorFilter]
$sel:instanceId:DescribeInstancePatches' :: DescribeInstancePatches -> Text
$sel:maxResults:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe Natural
$sel:nextToken:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe Text
$sel:filters:DescribeInstancePatches' :: DescribeInstancePatches -> Maybe [PatchOrchestratorFilter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Filters" Text -> [PatchOrchestratorFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([PatchOrchestratorFilter] -> Pair)
-> Maybe [PatchOrchestratorFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOrchestratorFilter]
filters,
            (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
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)
          ]
      )

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

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

-- | /See:/ 'newDescribeInstancePatchesResponse' smart constructor.
data DescribeInstancePatchesResponse = DescribeInstancePatchesResponse'
  { -- | Each entry in the array is a structure containing:
    --
    -- -   Title (string)
    --
    -- -   KBId (string)
    --
    -- -   Classification (string)
    --
    -- -   Severity (string)
    --
    -- -   State (string, such as \"INSTALLED\" or \"FAILED\")
    --
    -- -   InstalledTime (DateTime)
    --
    -- -   InstalledBy (string)
    DescribeInstancePatchesResponse -> Maybe [PatchComplianceData]
patches :: Prelude.Maybe [PatchComplianceData],
    -- | The token to use when requesting the next set of items. If there are no
    -- additional items to return, the string is empty.
    DescribeInstancePatchesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeInstancePatchesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeInstancePatchesResponse
-> DescribeInstancePatchesResponse -> Bool
(DescribeInstancePatchesResponse
 -> DescribeInstancePatchesResponse -> Bool)
-> (DescribeInstancePatchesResponse
    -> DescribeInstancePatchesResponse -> Bool)
-> Eq DescribeInstancePatchesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInstancePatchesResponse
-> DescribeInstancePatchesResponse -> Bool
$c/= :: DescribeInstancePatchesResponse
-> DescribeInstancePatchesResponse -> Bool
== :: DescribeInstancePatchesResponse
-> DescribeInstancePatchesResponse -> Bool
$c== :: DescribeInstancePatchesResponse
-> DescribeInstancePatchesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeInstancePatchesResponse]
ReadPrec DescribeInstancePatchesResponse
Int -> ReadS DescribeInstancePatchesResponse
ReadS [DescribeInstancePatchesResponse]
(Int -> ReadS DescribeInstancePatchesResponse)
-> ReadS [DescribeInstancePatchesResponse]
-> ReadPrec DescribeInstancePatchesResponse
-> ReadPrec [DescribeInstancePatchesResponse]
-> Read DescribeInstancePatchesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInstancePatchesResponse]
$creadListPrec :: ReadPrec [DescribeInstancePatchesResponse]
readPrec :: ReadPrec DescribeInstancePatchesResponse
$creadPrec :: ReadPrec DescribeInstancePatchesResponse
readList :: ReadS [DescribeInstancePatchesResponse]
$creadList :: ReadS [DescribeInstancePatchesResponse]
readsPrec :: Int -> ReadS DescribeInstancePatchesResponse
$creadsPrec :: Int -> ReadS DescribeInstancePatchesResponse
Prelude.Read, Int -> DescribeInstancePatchesResponse -> ShowS
[DescribeInstancePatchesResponse] -> ShowS
DescribeInstancePatchesResponse -> String
(Int -> DescribeInstancePatchesResponse -> ShowS)
-> (DescribeInstancePatchesResponse -> String)
-> ([DescribeInstancePatchesResponse] -> ShowS)
-> Show DescribeInstancePatchesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInstancePatchesResponse] -> ShowS
$cshowList :: [DescribeInstancePatchesResponse] -> ShowS
show :: DescribeInstancePatchesResponse -> String
$cshow :: DescribeInstancePatchesResponse -> String
showsPrec :: Int -> DescribeInstancePatchesResponse -> ShowS
$cshowsPrec :: Int -> DescribeInstancePatchesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeInstancePatchesResponse
 -> Rep DescribeInstancePatchesResponse x)
-> (forall x.
    Rep DescribeInstancePatchesResponse x
    -> DescribeInstancePatchesResponse)
-> Generic DescribeInstancePatchesResponse
forall x.
Rep DescribeInstancePatchesResponse x
-> DescribeInstancePatchesResponse
forall x.
DescribeInstancePatchesResponse
-> Rep DescribeInstancePatchesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeInstancePatchesResponse x
-> DescribeInstancePatchesResponse
$cfrom :: forall x.
DescribeInstancePatchesResponse
-> Rep DescribeInstancePatchesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInstancePatchesResponse' 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:
--
-- 'patches', 'describeInstancePatchesResponse_patches' - Each entry in the array is a structure containing:
--
-- -   Title (string)
--
-- -   KBId (string)
--
-- -   Classification (string)
--
-- -   Severity (string)
--
-- -   State (string, such as \"INSTALLED\" or \"FAILED\")
--
-- -   InstalledTime (DateTime)
--
-- -   InstalledBy (string)
--
-- 'nextToken', 'describeInstancePatchesResponse_nextToken' - The token to use when requesting the next set of items. If there are no
-- additional items to return, the string is empty.
--
-- 'httpStatus', 'describeInstancePatchesResponse_httpStatus' - The response's http status code.
newDescribeInstancePatchesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeInstancePatchesResponse
newDescribeInstancePatchesResponse :: Int -> DescribeInstancePatchesResponse
newDescribeInstancePatchesResponse Int
pHttpStatus_ =
  DescribeInstancePatchesResponse' :: Maybe [PatchComplianceData]
-> Maybe Text -> Int -> DescribeInstancePatchesResponse
DescribeInstancePatchesResponse'
    { $sel:patches:DescribeInstancePatchesResponse' :: Maybe [PatchComplianceData]
patches =
        Maybe [PatchComplianceData]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeInstancePatchesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeInstancePatchesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Each entry in the array is a structure containing:
--
-- -   Title (string)
--
-- -   KBId (string)
--
-- -   Classification (string)
--
-- -   Severity (string)
--
-- -   State (string, such as \"INSTALLED\" or \"FAILED\")
--
-- -   InstalledTime (DateTime)
--
-- -   InstalledBy (string)
describeInstancePatchesResponse_patches :: Lens.Lens' DescribeInstancePatchesResponse (Prelude.Maybe [PatchComplianceData])
describeInstancePatchesResponse_patches :: (Maybe [PatchComplianceData] -> f (Maybe [PatchComplianceData]))
-> DescribeInstancePatchesResponse
-> f DescribeInstancePatchesResponse
describeInstancePatchesResponse_patches = (DescribeInstancePatchesResponse -> Maybe [PatchComplianceData])
-> (DescribeInstancePatchesResponse
    -> Maybe [PatchComplianceData] -> DescribeInstancePatchesResponse)
-> Lens'
     DescribeInstancePatchesResponse (Maybe [PatchComplianceData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatchesResponse' {Maybe [PatchComplianceData]
patches :: Maybe [PatchComplianceData]
$sel:patches:DescribeInstancePatchesResponse' :: DescribeInstancePatchesResponse -> Maybe [PatchComplianceData]
patches} -> Maybe [PatchComplianceData]
patches) (\s :: DescribeInstancePatchesResponse
s@DescribeInstancePatchesResponse' {} Maybe [PatchComplianceData]
a -> DescribeInstancePatchesResponse
s {$sel:patches:DescribeInstancePatchesResponse' :: Maybe [PatchComplianceData]
patches = Maybe [PatchComplianceData]
a} :: DescribeInstancePatchesResponse) ((Maybe [PatchComplianceData] -> f (Maybe [PatchComplianceData]))
 -> DescribeInstancePatchesResponse
 -> f DescribeInstancePatchesResponse)
-> ((Maybe [PatchComplianceData]
     -> f (Maybe [PatchComplianceData]))
    -> Maybe [PatchComplianceData] -> f (Maybe [PatchComplianceData]))
-> (Maybe [PatchComplianceData] -> f (Maybe [PatchComplianceData]))
-> DescribeInstancePatchesResponse
-> f DescribeInstancePatchesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchComplianceData]
  [PatchComplianceData]
  [PatchComplianceData]
  [PatchComplianceData]
-> Iso
     (Maybe [PatchComplianceData])
     (Maybe [PatchComplianceData])
     (Maybe [PatchComplianceData])
     (Maybe [PatchComplianceData])
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
  [PatchComplianceData]
  [PatchComplianceData]
  [PatchComplianceData]
  [PatchComplianceData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use when requesting the next set of items. If there are no
-- additional items to return, the string is empty.
describeInstancePatchesResponse_nextToken :: Lens.Lens' DescribeInstancePatchesResponse (Prelude.Maybe Prelude.Text)
describeInstancePatchesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeInstancePatchesResponse
-> f DescribeInstancePatchesResponse
describeInstancePatchesResponse_nextToken = (DescribeInstancePatchesResponse -> Maybe Text)
-> (DescribeInstancePatchesResponse
    -> Maybe Text -> DescribeInstancePatchesResponse)
-> Lens' DescribeInstancePatchesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInstancePatchesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeInstancePatchesResponse' :: DescribeInstancePatchesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeInstancePatchesResponse
s@DescribeInstancePatchesResponse' {} Maybe Text
a -> DescribeInstancePatchesResponse
s {$sel:nextToken:DescribeInstancePatchesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeInstancePatchesResponse)

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

instance
  Prelude.NFData
    DescribeInstancePatchesResponse