{-# 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.DescribeAvailablePatches
-- 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)
--
-- Lists all patches eligible to be included in a patch baseline.
--
-- This operation returns paginated results.
module Amazonka.SSM.DescribeAvailablePatches
  ( -- * Creating a Request
    DescribeAvailablePatches (..),
    newDescribeAvailablePatches,

    -- * Request Lenses
    describeAvailablePatches_filters,
    describeAvailablePatches_nextToken,
    describeAvailablePatches_maxResults,

    -- * Destructuring the Response
    DescribeAvailablePatchesResponse (..),
    newDescribeAvailablePatchesResponse,

    -- * Response Lenses
    describeAvailablePatchesResponse_patches,
    describeAvailablePatchesResponse_nextToken,
    describeAvailablePatchesResponse_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:/ 'newDescribeAvailablePatches' smart constructor.
data DescribeAvailablePatches = DescribeAvailablePatches'
  { -- | Each element in the array is a structure containing a key-value pair.
    --
    -- __Windows Server__
    --
    -- Supported keys for Windows Server instance patches include the
    -- following:
    --
    -- -   __@PATCH_SET@__
    --
    --     Sample values: @OS@ | @APPLICATION@
    --
    -- -   __@PRODUCT@__
    --
    --     Sample values: @WindowsServer2012@ | @Office 2010@ |
    --     @MicrosoftDefenderAntivirus@
    --
    -- -   __@PRODUCT_FAMILY@__
    --
    --     Sample values: @Windows@ | @Office@
    --
    -- -   __@MSRC_SEVERITY@__
    --
    --     Sample values: @ServicePacks@ | @Important@ | @Moderate@
    --
    -- -   __@CLASSIFICATION@__
    --
    --     Sample values: @ServicePacks@ | @SecurityUpdates@ |
    --     @DefinitionUpdates@
    --
    -- -   __@PATCH_ID@__
    --
    --     Sample values: @KB123456@ | @KB4516046@
    --
    -- __Linux__
    --
    -- When specifying filters for Linux patches, you must specify a key-pair
    -- for @PRODUCT@. For example, using the Command Line Interface (CLI), the
    -- following command fails:
    --
    -- @aws ssm describe-available-patches --filters Key=CVE_ID,Values=CVE-2018-3615@
    --
    -- However, the following command succeeds:
    --
    -- @aws ssm describe-available-patches --filters Key=PRODUCT,Values=AmazonLinux2018.03 Key=CVE_ID,Values=CVE-2018-3615@
    --
    -- Supported keys for Linux instance patches include the following:
    --
    -- -   __@PRODUCT@__
    --
    --     Sample values: @AmazonLinux2018.03@ | @AmazonLinux2.0@
    --
    -- -   __@NAME@__
    --
    --     Sample values: @kernel-headers@ | @samba-python@ | @php@
    --
    -- -   __@SEVERITY@__
    --
    --     Sample values: @Critical@ | @Important@ | @Medium@ | @Low@
    --
    -- -   __@EPOCH@__
    --
    --     Sample values: @0@ | @1@
    --
    -- -   __@VERSION@__
    --
    --     Sample values: @78.6.1@ | @4.10.16@
    --
    -- -   __@RELEASE@__
    --
    --     Sample values: @9.56.amzn1@ | @1.amzn2@
    --
    -- -   __@ARCH@__
    --
    --     Sample values: @i686@ | @x86_64@
    --
    -- -   __@REPOSITORY@__
    --
    --     Sample values: @Core@ | @Updates@
    --
    -- -   __@ADVISORY_ID@__
    --
    --     Sample values: @ALAS-2018-1058@ | @ALAS2-2021-1594@
    --
    -- -   __@CVE_ID@__
    --
    --     Sample values: @CVE-2018-3615@ | @CVE-2020-1472@
    --
    -- -   __@BUGZILLA_ID@__
    --
    --     Sample values: @1463241@
    DescribeAvailablePatches -> Maybe [PatchOrchestratorFilter]
filters :: Prelude.Maybe [PatchOrchestratorFilter],
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeAvailablePatches -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of patches to return (per page).
    DescribeAvailablePatches -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeAvailablePatches -> DescribeAvailablePatches -> Bool
(DescribeAvailablePatches -> DescribeAvailablePatches -> Bool)
-> (DescribeAvailablePatches -> DescribeAvailablePatches -> Bool)
-> Eq DescribeAvailablePatches
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAvailablePatches -> DescribeAvailablePatches -> Bool
$c/= :: DescribeAvailablePatches -> DescribeAvailablePatches -> Bool
== :: DescribeAvailablePatches -> DescribeAvailablePatches -> Bool
$c== :: DescribeAvailablePatches -> DescribeAvailablePatches -> Bool
Prelude.Eq, ReadPrec [DescribeAvailablePatches]
ReadPrec DescribeAvailablePatches
Int -> ReadS DescribeAvailablePatches
ReadS [DescribeAvailablePatches]
(Int -> ReadS DescribeAvailablePatches)
-> ReadS [DescribeAvailablePatches]
-> ReadPrec DescribeAvailablePatches
-> ReadPrec [DescribeAvailablePatches]
-> Read DescribeAvailablePatches
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAvailablePatches]
$creadListPrec :: ReadPrec [DescribeAvailablePatches]
readPrec :: ReadPrec DescribeAvailablePatches
$creadPrec :: ReadPrec DescribeAvailablePatches
readList :: ReadS [DescribeAvailablePatches]
$creadList :: ReadS [DescribeAvailablePatches]
readsPrec :: Int -> ReadS DescribeAvailablePatches
$creadsPrec :: Int -> ReadS DescribeAvailablePatches
Prelude.Read, Int -> DescribeAvailablePatches -> ShowS
[DescribeAvailablePatches] -> ShowS
DescribeAvailablePatches -> String
(Int -> DescribeAvailablePatches -> ShowS)
-> (DescribeAvailablePatches -> String)
-> ([DescribeAvailablePatches] -> ShowS)
-> Show DescribeAvailablePatches
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAvailablePatches] -> ShowS
$cshowList :: [DescribeAvailablePatches] -> ShowS
show :: DescribeAvailablePatches -> String
$cshow :: DescribeAvailablePatches -> String
showsPrec :: Int -> DescribeAvailablePatches -> ShowS
$cshowsPrec :: Int -> DescribeAvailablePatches -> ShowS
Prelude.Show, (forall x.
 DescribeAvailablePatches -> Rep DescribeAvailablePatches x)
-> (forall x.
    Rep DescribeAvailablePatches x -> DescribeAvailablePatches)
-> Generic DescribeAvailablePatches
forall x.
Rep DescribeAvailablePatches x -> DescribeAvailablePatches
forall x.
DescribeAvailablePatches -> Rep DescribeAvailablePatches x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAvailablePatches x -> DescribeAvailablePatches
$cfrom :: forall x.
DescribeAvailablePatches -> Rep DescribeAvailablePatches x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAvailablePatches' 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', 'describeAvailablePatches_filters' - Each element in the array is a structure containing a key-value pair.
--
-- __Windows Server__
--
-- Supported keys for Windows Server instance patches include the
-- following:
--
-- -   __@PATCH_SET@__
--
--     Sample values: @OS@ | @APPLICATION@
--
-- -   __@PRODUCT@__
--
--     Sample values: @WindowsServer2012@ | @Office 2010@ |
--     @MicrosoftDefenderAntivirus@
--
-- -   __@PRODUCT_FAMILY@__
--
--     Sample values: @Windows@ | @Office@
--
-- -   __@MSRC_SEVERITY@__
--
--     Sample values: @ServicePacks@ | @Important@ | @Moderate@
--
-- -   __@CLASSIFICATION@__
--
--     Sample values: @ServicePacks@ | @SecurityUpdates@ |
--     @DefinitionUpdates@
--
-- -   __@PATCH_ID@__
--
--     Sample values: @KB123456@ | @KB4516046@
--
-- __Linux__
--
-- When specifying filters for Linux patches, you must specify a key-pair
-- for @PRODUCT@. For example, using the Command Line Interface (CLI), the
-- following command fails:
--
-- @aws ssm describe-available-patches --filters Key=CVE_ID,Values=CVE-2018-3615@
--
-- However, the following command succeeds:
--
-- @aws ssm describe-available-patches --filters Key=PRODUCT,Values=AmazonLinux2018.03 Key=CVE_ID,Values=CVE-2018-3615@
--
-- Supported keys for Linux instance patches include the following:
--
-- -   __@PRODUCT@__
--
--     Sample values: @AmazonLinux2018.03@ | @AmazonLinux2.0@
--
-- -   __@NAME@__
--
--     Sample values: @kernel-headers@ | @samba-python@ | @php@
--
-- -   __@SEVERITY@__
--
--     Sample values: @Critical@ | @Important@ | @Medium@ | @Low@
--
-- -   __@EPOCH@__
--
--     Sample values: @0@ | @1@
--
-- -   __@VERSION@__
--
--     Sample values: @78.6.1@ | @4.10.16@
--
-- -   __@RELEASE@__
--
--     Sample values: @9.56.amzn1@ | @1.amzn2@
--
-- -   __@ARCH@__
--
--     Sample values: @i686@ | @x86_64@
--
-- -   __@REPOSITORY@__
--
--     Sample values: @Core@ | @Updates@
--
-- -   __@ADVISORY_ID@__
--
--     Sample values: @ALAS-2018-1058@ | @ALAS2-2021-1594@
--
-- -   __@CVE_ID@__
--
--     Sample values: @CVE-2018-3615@ | @CVE-2020-1472@
--
-- -   __@BUGZILLA_ID@__
--
--     Sample values: @1463241@
--
-- 'nextToken', 'describeAvailablePatches_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxResults', 'describeAvailablePatches_maxResults' - The maximum number of patches to return (per page).
newDescribeAvailablePatches ::
  DescribeAvailablePatches
newDescribeAvailablePatches :: DescribeAvailablePatches
newDescribeAvailablePatches =
  DescribeAvailablePatches' :: Maybe [PatchOrchestratorFilter]
-> Maybe Text -> Maybe Natural -> DescribeAvailablePatches
DescribeAvailablePatches'
    { $sel:filters:DescribeAvailablePatches' :: Maybe [PatchOrchestratorFilter]
filters =
        Maybe [PatchOrchestratorFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAvailablePatches' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeAvailablePatches' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Each element in the array is a structure containing a key-value pair.
--
-- __Windows Server__
--
-- Supported keys for Windows Server instance patches include the
-- following:
--
-- -   __@PATCH_SET@__
--
--     Sample values: @OS@ | @APPLICATION@
--
-- -   __@PRODUCT@__
--
--     Sample values: @WindowsServer2012@ | @Office 2010@ |
--     @MicrosoftDefenderAntivirus@
--
-- -   __@PRODUCT_FAMILY@__
--
--     Sample values: @Windows@ | @Office@
--
-- -   __@MSRC_SEVERITY@__
--
--     Sample values: @ServicePacks@ | @Important@ | @Moderate@
--
-- -   __@CLASSIFICATION@__
--
--     Sample values: @ServicePacks@ | @SecurityUpdates@ |
--     @DefinitionUpdates@
--
-- -   __@PATCH_ID@__
--
--     Sample values: @KB123456@ | @KB4516046@
--
-- __Linux__
--
-- When specifying filters for Linux patches, you must specify a key-pair
-- for @PRODUCT@. For example, using the Command Line Interface (CLI), the
-- following command fails:
--
-- @aws ssm describe-available-patches --filters Key=CVE_ID,Values=CVE-2018-3615@
--
-- However, the following command succeeds:
--
-- @aws ssm describe-available-patches --filters Key=PRODUCT,Values=AmazonLinux2018.03 Key=CVE_ID,Values=CVE-2018-3615@
--
-- Supported keys for Linux instance patches include the following:
--
-- -   __@PRODUCT@__
--
--     Sample values: @AmazonLinux2018.03@ | @AmazonLinux2.0@
--
-- -   __@NAME@__
--
--     Sample values: @kernel-headers@ | @samba-python@ | @php@
--
-- -   __@SEVERITY@__
--
--     Sample values: @Critical@ | @Important@ | @Medium@ | @Low@
--
-- -   __@EPOCH@__
--
--     Sample values: @0@ | @1@
--
-- -   __@VERSION@__
--
--     Sample values: @78.6.1@ | @4.10.16@
--
-- -   __@RELEASE@__
--
--     Sample values: @9.56.amzn1@ | @1.amzn2@
--
-- -   __@ARCH@__
--
--     Sample values: @i686@ | @x86_64@
--
-- -   __@REPOSITORY@__
--
--     Sample values: @Core@ | @Updates@
--
-- -   __@ADVISORY_ID@__
--
--     Sample values: @ALAS-2018-1058@ | @ALAS2-2021-1594@
--
-- -   __@CVE_ID@__
--
--     Sample values: @CVE-2018-3615@ | @CVE-2020-1472@
--
-- -   __@BUGZILLA_ID@__
--
--     Sample values: @1463241@
describeAvailablePatches_filters :: Lens.Lens' DescribeAvailablePatches (Prelude.Maybe [PatchOrchestratorFilter])
describeAvailablePatches_filters :: (Maybe [PatchOrchestratorFilter]
 -> f (Maybe [PatchOrchestratorFilter]))
-> DescribeAvailablePatches -> f DescribeAvailablePatches
describeAvailablePatches_filters = (DescribeAvailablePatches -> Maybe [PatchOrchestratorFilter])
-> (DescribeAvailablePatches
    -> Maybe [PatchOrchestratorFilter] -> DescribeAvailablePatches)
-> Lens
     DescribeAvailablePatches
     DescribeAvailablePatches
     (Maybe [PatchOrchestratorFilter])
     (Maybe [PatchOrchestratorFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAvailablePatches' {Maybe [PatchOrchestratorFilter]
filters :: Maybe [PatchOrchestratorFilter]
$sel:filters:DescribeAvailablePatches' :: DescribeAvailablePatches -> Maybe [PatchOrchestratorFilter]
filters} -> Maybe [PatchOrchestratorFilter]
filters) (\s :: DescribeAvailablePatches
s@DescribeAvailablePatches' {} Maybe [PatchOrchestratorFilter]
a -> DescribeAvailablePatches
s {$sel:filters:DescribeAvailablePatches' :: Maybe [PatchOrchestratorFilter]
filters = Maybe [PatchOrchestratorFilter]
a} :: DescribeAvailablePatches) ((Maybe [PatchOrchestratorFilter]
  -> f (Maybe [PatchOrchestratorFilter]))
 -> DescribeAvailablePatches -> f DescribeAvailablePatches)
-> ((Maybe [PatchOrchestratorFilter]
     -> f (Maybe [PatchOrchestratorFilter]))
    -> Maybe [PatchOrchestratorFilter]
    -> f (Maybe [PatchOrchestratorFilter]))
-> (Maybe [PatchOrchestratorFilter]
    -> f (Maybe [PatchOrchestratorFilter]))
-> DescribeAvailablePatches
-> f DescribeAvailablePatches
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.)
describeAvailablePatches_nextToken :: Lens.Lens' DescribeAvailablePatches (Prelude.Maybe Prelude.Text)
describeAvailablePatches_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeAvailablePatches -> f DescribeAvailablePatches
describeAvailablePatches_nextToken = (DescribeAvailablePatches -> Maybe Text)
-> (DescribeAvailablePatches
    -> Maybe Text -> DescribeAvailablePatches)
-> Lens
     DescribeAvailablePatches
     DescribeAvailablePatches
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAvailablePatches' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAvailablePatches' :: DescribeAvailablePatches -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAvailablePatches
s@DescribeAvailablePatches' {} Maybe Text
a -> DescribeAvailablePatches
s {$sel:nextToken:DescribeAvailablePatches' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAvailablePatches)

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

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

instance Prelude.NFData DescribeAvailablePatches

instance Core.ToHeaders DescribeAvailablePatches where
  toHeaders :: DescribeAvailablePatches -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeAvailablePatches -> 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.DescribeAvailablePatches" ::
                          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 DescribeAvailablePatches where
  toJSON :: DescribeAvailablePatches -> Value
toJSON DescribeAvailablePatches' {Maybe Natural
Maybe [PatchOrchestratorFilter]
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
filters :: Maybe [PatchOrchestratorFilter]
$sel:maxResults:DescribeAvailablePatches' :: DescribeAvailablePatches -> Maybe Natural
$sel:nextToken:DescribeAvailablePatches' :: DescribeAvailablePatches -> Maybe Text
$sel:filters:DescribeAvailablePatches' :: DescribeAvailablePatches -> 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
          ]
      )

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

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

-- | /See:/ 'newDescribeAvailablePatchesResponse' smart constructor.
data DescribeAvailablePatchesResponse = DescribeAvailablePatchesResponse'
  { -- | An array of patches. Each entry in the array is a patch structure.
    DescribeAvailablePatchesResponse -> Maybe [Patch]
patches :: Prelude.Maybe [Patch],
    -- | The token to use when requesting the next set of items. If there are no
    -- additional items to return, the string is empty.
    DescribeAvailablePatchesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAvailablePatchesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAvailablePatchesResponse
-> DescribeAvailablePatchesResponse -> Bool
(DescribeAvailablePatchesResponse
 -> DescribeAvailablePatchesResponse -> Bool)
-> (DescribeAvailablePatchesResponse
    -> DescribeAvailablePatchesResponse -> Bool)
-> Eq DescribeAvailablePatchesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAvailablePatchesResponse
-> DescribeAvailablePatchesResponse -> Bool
$c/= :: DescribeAvailablePatchesResponse
-> DescribeAvailablePatchesResponse -> Bool
== :: DescribeAvailablePatchesResponse
-> DescribeAvailablePatchesResponse -> Bool
$c== :: DescribeAvailablePatchesResponse
-> DescribeAvailablePatchesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAvailablePatchesResponse]
ReadPrec DescribeAvailablePatchesResponse
Int -> ReadS DescribeAvailablePatchesResponse
ReadS [DescribeAvailablePatchesResponse]
(Int -> ReadS DescribeAvailablePatchesResponse)
-> ReadS [DescribeAvailablePatchesResponse]
-> ReadPrec DescribeAvailablePatchesResponse
-> ReadPrec [DescribeAvailablePatchesResponse]
-> Read DescribeAvailablePatchesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAvailablePatchesResponse]
$creadListPrec :: ReadPrec [DescribeAvailablePatchesResponse]
readPrec :: ReadPrec DescribeAvailablePatchesResponse
$creadPrec :: ReadPrec DescribeAvailablePatchesResponse
readList :: ReadS [DescribeAvailablePatchesResponse]
$creadList :: ReadS [DescribeAvailablePatchesResponse]
readsPrec :: Int -> ReadS DescribeAvailablePatchesResponse
$creadsPrec :: Int -> ReadS DescribeAvailablePatchesResponse
Prelude.Read, Int -> DescribeAvailablePatchesResponse -> ShowS
[DescribeAvailablePatchesResponse] -> ShowS
DescribeAvailablePatchesResponse -> String
(Int -> DescribeAvailablePatchesResponse -> ShowS)
-> (DescribeAvailablePatchesResponse -> String)
-> ([DescribeAvailablePatchesResponse] -> ShowS)
-> Show DescribeAvailablePatchesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAvailablePatchesResponse] -> ShowS
$cshowList :: [DescribeAvailablePatchesResponse] -> ShowS
show :: DescribeAvailablePatchesResponse -> String
$cshow :: DescribeAvailablePatchesResponse -> String
showsPrec :: Int -> DescribeAvailablePatchesResponse -> ShowS
$cshowsPrec :: Int -> DescribeAvailablePatchesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAvailablePatchesResponse
 -> Rep DescribeAvailablePatchesResponse x)
-> (forall x.
    Rep DescribeAvailablePatchesResponse x
    -> DescribeAvailablePatchesResponse)
-> Generic DescribeAvailablePatchesResponse
forall x.
Rep DescribeAvailablePatchesResponse x
-> DescribeAvailablePatchesResponse
forall x.
DescribeAvailablePatchesResponse
-> Rep DescribeAvailablePatchesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAvailablePatchesResponse x
-> DescribeAvailablePatchesResponse
$cfrom :: forall x.
DescribeAvailablePatchesResponse
-> Rep DescribeAvailablePatchesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAvailablePatchesResponse' 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', 'describeAvailablePatchesResponse_patches' - An array of patches. Each entry in the array is a patch structure.
--
-- 'nextToken', 'describeAvailablePatchesResponse_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', 'describeAvailablePatchesResponse_httpStatus' - The response's http status code.
newDescribeAvailablePatchesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAvailablePatchesResponse
newDescribeAvailablePatchesResponse :: Int -> DescribeAvailablePatchesResponse
newDescribeAvailablePatchesResponse Int
pHttpStatus_ =
  DescribeAvailablePatchesResponse' :: Maybe [Patch]
-> Maybe Text -> Int -> DescribeAvailablePatchesResponse
DescribeAvailablePatchesResponse'
    { $sel:patches:DescribeAvailablePatchesResponse' :: Maybe [Patch]
patches =
        Maybe [Patch]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAvailablePatchesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAvailablePatchesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of patches. Each entry in the array is a patch structure.
describeAvailablePatchesResponse_patches :: Lens.Lens' DescribeAvailablePatchesResponse (Prelude.Maybe [Patch])
describeAvailablePatchesResponse_patches :: (Maybe [Patch] -> f (Maybe [Patch]))
-> DescribeAvailablePatchesResponse
-> f DescribeAvailablePatchesResponse
describeAvailablePatchesResponse_patches = (DescribeAvailablePatchesResponse -> Maybe [Patch])
-> (DescribeAvailablePatchesResponse
    -> Maybe [Patch] -> DescribeAvailablePatchesResponse)
-> Lens' DescribeAvailablePatchesResponse (Maybe [Patch])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAvailablePatchesResponse' {Maybe [Patch]
patches :: Maybe [Patch]
$sel:patches:DescribeAvailablePatchesResponse' :: DescribeAvailablePatchesResponse -> Maybe [Patch]
patches} -> Maybe [Patch]
patches) (\s :: DescribeAvailablePatchesResponse
s@DescribeAvailablePatchesResponse' {} Maybe [Patch]
a -> DescribeAvailablePatchesResponse
s {$sel:patches:DescribeAvailablePatchesResponse' :: Maybe [Patch]
patches = Maybe [Patch]
a} :: DescribeAvailablePatchesResponse) ((Maybe [Patch] -> f (Maybe [Patch]))
 -> DescribeAvailablePatchesResponse
 -> f DescribeAvailablePatchesResponse)
-> ((Maybe [Patch] -> f (Maybe [Patch]))
    -> Maybe [Patch] -> f (Maybe [Patch]))
-> (Maybe [Patch] -> f (Maybe [Patch]))
-> DescribeAvailablePatchesResponse
-> f DescribeAvailablePatchesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Patch] [Patch] [Patch] [Patch]
-> Iso
     (Maybe [Patch]) (Maybe [Patch]) (Maybe [Patch]) (Maybe [Patch])
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 [Patch] [Patch] [Patch] [Patch]
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.
describeAvailablePatchesResponse_nextToken :: Lens.Lens' DescribeAvailablePatchesResponse (Prelude.Maybe Prelude.Text)
describeAvailablePatchesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeAvailablePatchesResponse
-> f DescribeAvailablePatchesResponse
describeAvailablePatchesResponse_nextToken = (DescribeAvailablePatchesResponse -> Maybe Text)
-> (DescribeAvailablePatchesResponse
    -> Maybe Text -> DescribeAvailablePatchesResponse)
-> Lens' DescribeAvailablePatchesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAvailablePatchesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAvailablePatchesResponse' :: DescribeAvailablePatchesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAvailablePatchesResponse
s@DescribeAvailablePatchesResponse' {} Maybe Text
a -> DescribeAvailablePatchesResponse
s {$sel:nextToken:DescribeAvailablePatchesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAvailablePatchesResponse)

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

instance
  Prelude.NFData
    DescribeAvailablePatchesResponse