{-# 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.GetInventory
-- 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)
--
-- Query inventory information. This includes instance status, such as
-- @Stopped@ or @Terminated@.
--
-- This operation returns paginated results.
module Amazonka.SSM.GetInventory
  ( -- * Creating a Request
    GetInventory (..),
    newGetInventory,

    -- * Request Lenses
    getInventory_aggregators,
    getInventory_filters,
    getInventory_resultAttributes,
    getInventory_nextToken,
    getInventory_maxResults,

    -- * Destructuring the Response
    GetInventoryResponse (..),
    newGetInventoryResponse,

    -- * Response Lenses
    getInventoryResponse_entities,
    getInventoryResponse_nextToken,
    getInventoryResponse_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:/ 'newGetInventory' smart constructor.
data GetInventory = GetInventory'
  { -- | Returns counts of inventory types based on one or more expressions. For
    -- example, if you aggregate by using an expression that uses the
    -- @AWS:InstanceInformation.PlatformType@ type, you can see a count of how
    -- many Windows and Linux instances exist in your inventoried fleet.
    GetInventory -> Maybe (NonEmpty InventoryAggregator)
aggregators :: Prelude.Maybe (Prelude.NonEmpty InventoryAggregator),
    -- | One or more filters. Use a filter to return a more specific list of
    -- results.
    GetInventory -> Maybe (NonEmpty InventoryFilter)
filters :: Prelude.Maybe (Prelude.NonEmpty InventoryFilter),
    -- | The list of inventory item types to return.
    GetInventory -> Maybe (NonEmpty ResultAttribute)
resultAttributes :: Prelude.Maybe (Prelude.NonEmpty ResultAttribute),
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    GetInventory -> 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.
    GetInventory -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (GetInventory -> GetInventory -> Bool
(GetInventory -> GetInventory -> Bool)
-> (GetInventory -> GetInventory -> Bool) -> Eq GetInventory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInventory -> GetInventory -> Bool
$c/= :: GetInventory -> GetInventory -> Bool
== :: GetInventory -> GetInventory -> Bool
$c== :: GetInventory -> GetInventory -> Bool
Prelude.Eq, ReadPrec [GetInventory]
ReadPrec GetInventory
Int -> ReadS GetInventory
ReadS [GetInventory]
(Int -> ReadS GetInventory)
-> ReadS [GetInventory]
-> ReadPrec GetInventory
-> ReadPrec [GetInventory]
-> Read GetInventory
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInventory]
$creadListPrec :: ReadPrec [GetInventory]
readPrec :: ReadPrec GetInventory
$creadPrec :: ReadPrec GetInventory
readList :: ReadS [GetInventory]
$creadList :: ReadS [GetInventory]
readsPrec :: Int -> ReadS GetInventory
$creadsPrec :: Int -> ReadS GetInventory
Prelude.Read, Int -> GetInventory -> ShowS
[GetInventory] -> ShowS
GetInventory -> String
(Int -> GetInventory -> ShowS)
-> (GetInventory -> String)
-> ([GetInventory] -> ShowS)
-> Show GetInventory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInventory] -> ShowS
$cshowList :: [GetInventory] -> ShowS
show :: GetInventory -> String
$cshow :: GetInventory -> String
showsPrec :: Int -> GetInventory -> ShowS
$cshowsPrec :: Int -> GetInventory -> ShowS
Prelude.Show, (forall x. GetInventory -> Rep GetInventory x)
-> (forall x. Rep GetInventory x -> GetInventory)
-> Generic GetInventory
forall x. Rep GetInventory x -> GetInventory
forall x. GetInventory -> Rep GetInventory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInventory x -> GetInventory
$cfrom :: forall x. GetInventory -> Rep GetInventory x
Prelude.Generic)

-- |
-- Create a value of 'GetInventory' 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:
--
-- 'aggregators', 'getInventory_aggregators' - Returns counts of inventory types based on one or more expressions. For
-- example, if you aggregate by using an expression that uses the
-- @AWS:InstanceInformation.PlatformType@ type, you can see a count of how
-- many Windows and Linux instances exist in your inventoried fleet.
--
-- 'filters', 'getInventory_filters' - One or more filters. Use a filter to return a more specific list of
-- results.
--
-- 'resultAttributes', 'getInventory_resultAttributes' - The list of inventory item types to return.
--
-- 'nextToken', 'getInventory_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxResults', 'getInventory_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.
newGetInventory ::
  GetInventory
newGetInventory :: GetInventory
newGetInventory =
  GetInventory' :: Maybe (NonEmpty InventoryAggregator)
-> Maybe (NonEmpty InventoryFilter)
-> Maybe (NonEmpty ResultAttribute)
-> Maybe Text
-> Maybe Natural
-> GetInventory
GetInventory'
    { $sel:aggregators:GetInventory' :: Maybe (NonEmpty InventoryAggregator)
aggregators = Maybe (NonEmpty InventoryAggregator)
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:GetInventory' :: Maybe (NonEmpty InventoryFilter)
filters = Maybe (NonEmpty InventoryFilter)
forall a. Maybe a
Prelude.Nothing,
      $sel:resultAttributes:GetInventory' :: Maybe (NonEmpty ResultAttribute)
resultAttributes = Maybe (NonEmpty ResultAttribute)
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetInventory' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetInventory' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Returns counts of inventory types based on one or more expressions. For
-- example, if you aggregate by using an expression that uses the
-- @AWS:InstanceInformation.PlatformType@ type, you can see a count of how
-- many Windows and Linux instances exist in your inventoried fleet.
getInventory_aggregators :: Lens.Lens' GetInventory (Prelude.Maybe (Prelude.NonEmpty InventoryAggregator))
getInventory_aggregators :: (Maybe (NonEmpty InventoryAggregator)
 -> f (Maybe (NonEmpty InventoryAggregator)))
-> GetInventory -> f GetInventory
getInventory_aggregators = (GetInventory -> Maybe (NonEmpty InventoryAggregator))
-> (GetInventory
    -> Maybe (NonEmpty InventoryAggregator) -> GetInventory)
-> Lens
     GetInventory
     GetInventory
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventory' {Maybe (NonEmpty InventoryAggregator)
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:aggregators:GetInventory' :: GetInventory -> Maybe (NonEmpty InventoryAggregator)
aggregators} -> Maybe (NonEmpty InventoryAggregator)
aggregators) (\s :: GetInventory
s@GetInventory' {} Maybe (NonEmpty InventoryAggregator)
a -> GetInventory
s {$sel:aggregators:GetInventory' :: Maybe (NonEmpty InventoryAggregator)
aggregators = Maybe (NonEmpty InventoryAggregator)
a} :: GetInventory) ((Maybe (NonEmpty InventoryAggregator)
  -> f (Maybe (NonEmpty InventoryAggregator)))
 -> GetInventory -> f GetInventory)
-> ((Maybe (NonEmpty InventoryAggregator)
     -> f (Maybe (NonEmpty InventoryAggregator)))
    -> Maybe (NonEmpty InventoryAggregator)
    -> f (Maybe (NonEmpty InventoryAggregator)))
-> (Maybe (NonEmpty InventoryAggregator)
    -> f (Maybe (NonEmpty InventoryAggregator)))
-> GetInventory
-> f GetInventory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
-> Iso
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
     (Maybe (NonEmpty InventoryAggregator))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
  (NonEmpty InventoryAggregator)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more filters. Use a filter to return a more specific list of
-- results.
getInventory_filters :: Lens.Lens' GetInventory (Prelude.Maybe (Prelude.NonEmpty InventoryFilter))
getInventory_filters :: (Maybe (NonEmpty InventoryFilter)
 -> f (Maybe (NonEmpty InventoryFilter)))
-> GetInventory -> f GetInventory
getInventory_filters = (GetInventory -> Maybe (NonEmpty InventoryFilter))
-> (GetInventory
    -> Maybe (NonEmpty InventoryFilter) -> GetInventory)
-> Lens
     GetInventory
     GetInventory
     (Maybe (NonEmpty InventoryFilter))
     (Maybe (NonEmpty InventoryFilter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventory' {Maybe (NonEmpty InventoryFilter)
filters :: Maybe (NonEmpty InventoryFilter)
$sel:filters:GetInventory' :: GetInventory -> Maybe (NonEmpty InventoryFilter)
filters} -> Maybe (NonEmpty InventoryFilter)
filters) (\s :: GetInventory
s@GetInventory' {} Maybe (NonEmpty InventoryFilter)
a -> GetInventory
s {$sel:filters:GetInventory' :: Maybe (NonEmpty InventoryFilter)
filters = Maybe (NonEmpty InventoryFilter)
a} :: GetInventory) ((Maybe (NonEmpty InventoryFilter)
  -> f (Maybe (NonEmpty InventoryFilter)))
 -> GetInventory -> f GetInventory)
-> ((Maybe (NonEmpty InventoryFilter)
     -> f (Maybe (NonEmpty InventoryFilter)))
    -> Maybe (NonEmpty InventoryFilter)
    -> f (Maybe (NonEmpty InventoryFilter)))
-> (Maybe (NonEmpty InventoryFilter)
    -> f (Maybe (NonEmpty InventoryFilter)))
-> GetInventory
-> f GetInventory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
-> Iso
     (Maybe (NonEmpty InventoryFilter))
     (Maybe (NonEmpty InventoryFilter))
     (Maybe (NonEmpty InventoryFilter))
     (Maybe (NonEmpty InventoryFilter))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
  (NonEmpty InventoryFilter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of inventory item types to return.
getInventory_resultAttributes :: Lens.Lens' GetInventory (Prelude.Maybe (Prelude.NonEmpty ResultAttribute))
getInventory_resultAttributes :: (Maybe (NonEmpty ResultAttribute)
 -> f (Maybe (NonEmpty ResultAttribute)))
-> GetInventory -> f GetInventory
getInventory_resultAttributes = (GetInventory -> Maybe (NonEmpty ResultAttribute))
-> (GetInventory
    -> Maybe (NonEmpty ResultAttribute) -> GetInventory)
-> Lens
     GetInventory
     GetInventory
     (Maybe (NonEmpty ResultAttribute))
     (Maybe (NonEmpty ResultAttribute))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventory' {Maybe (NonEmpty ResultAttribute)
resultAttributes :: Maybe (NonEmpty ResultAttribute)
$sel:resultAttributes:GetInventory' :: GetInventory -> Maybe (NonEmpty ResultAttribute)
resultAttributes} -> Maybe (NonEmpty ResultAttribute)
resultAttributes) (\s :: GetInventory
s@GetInventory' {} Maybe (NonEmpty ResultAttribute)
a -> GetInventory
s {$sel:resultAttributes:GetInventory' :: Maybe (NonEmpty ResultAttribute)
resultAttributes = Maybe (NonEmpty ResultAttribute)
a} :: GetInventory) ((Maybe (NonEmpty ResultAttribute)
  -> f (Maybe (NonEmpty ResultAttribute)))
 -> GetInventory -> f GetInventory)
-> ((Maybe (NonEmpty ResultAttribute)
     -> f (Maybe (NonEmpty ResultAttribute)))
    -> Maybe (NonEmpty ResultAttribute)
    -> f (Maybe (NonEmpty ResultAttribute)))
-> (Maybe (NonEmpty ResultAttribute)
    -> f (Maybe (NonEmpty ResultAttribute)))
-> GetInventory
-> f GetInventory
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
-> Iso
     (Maybe (NonEmpty ResultAttribute))
     (Maybe (NonEmpty ResultAttribute))
     (Maybe (NonEmpty ResultAttribute))
     (Maybe (NonEmpty ResultAttribute))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
  (NonEmpty ResultAttribute)
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.)
getInventory_nextToken :: Lens.Lens' GetInventory (Prelude.Maybe Prelude.Text)
getInventory_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetInventory -> f GetInventory
getInventory_nextToken = (GetInventory -> Maybe Text)
-> (GetInventory -> Maybe Text -> GetInventory)
-> Lens GetInventory GetInventory (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetInventory' :: GetInventory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetInventory
s@GetInventory' {} Maybe Text
a -> GetInventory
s {$sel:nextToken:GetInventory' :: Maybe Text
nextToken = Maybe Text
a} :: GetInventory)

-- | 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.
getInventory_maxResults :: Lens.Lens' GetInventory (Prelude.Maybe Prelude.Natural)
getInventory_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetInventory -> f GetInventory
getInventory_maxResults = (GetInventory -> Maybe Natural)
-> (GetInventory -> Maybe Natural -> GetInventory)
-> Lens GetInventory GetInventory (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventory' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetInventory' :: GetInventory -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetInventory
s@GetInventory' {} Maybe Natural
a -> GetInventory
s {$sel:maxResults:GetInventory' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetInventory)

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

instance Prelude.NFData GetInventory

instance Core.ToHeaders GetInventory where
  toHeaders :: GetInventory -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetInventory -> 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.GetInventory" :: 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 GetInventory where
  toJSON :: GetInventory -> Value
toJSON GetInventory' {Maybe Natural
Maybe (NonEmpty InventoryFilter)
Maybe (NonEmpty InventoryAggregator)
Maybe (NonEmpty ResultAttribute)
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
resultAttributes :: Maybe (NonEmpty ResultAttribute)
filters :: Maybe (NonEmpty InventoryFilter)
aggregators :: Maybe (NonEmpty InventoryAggregator)
$sel:maxResults:GetInventory' :: GetInventory -> Maybe Natural
$sel:nextToken:GetInventory' :: GetInventory -> Maybe Text
$sel:resultAttributes:GetInventory' :: GetInventory -> Maybe (NonEmpty ResultAttribute)
$sel:filters:GetInventory' :: GetInventory -> Maybe (NonEmpty InventoryFilter)
$sel:aggregators:GetInventory' :: GetInventory -> Maybe (NonEmpty InventoryAggregator)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Aggregators" Text -> NonEmpty InventoryAggregator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty InventoryAggregator -> Pair)
-> Maybe (NonEmpty InventoryAggregator) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty InventoryAggregator)
aggregators,
            (Text
"Filters" Text -> NonEmpty InventoryFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty InventoryFilter -> Pair)
-> Maybe (NonEmpty InventoryFilter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty InventoryFilter)
filters,
            (Text
"ResultAttributes" Text -> NonEmpty ResultAttribute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ResultAttribute -> Pair)
-> Maybe (NonEmpty ResultAttribute) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ResultAttribute)
resultAttributes,
            (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 GetInventory where
  toPath :: GetInventory -> ByteString
toPath = ByteString -> GetInventory -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetInventoryResponse' smart constructor.
data GetInventoryResponse = GetInventoryResponse'
  { -- | Collection of inventory entities such as a collection of instance
    -- inventory.
    GetInventoryResponse -> Maybe [InventoryResultEntity]
entities :: Prelude.Maybe [InventoryResultEntity],
    -- | The token to use when requesting the next set of items. If there are no
    -- additional items to return, the string is empty.
    GetInventoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetInventoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetInventoryResponse -> GetInventoryResponse -> Bool
(GetInventoryResponse -> GetInventoryResponse -> Bool)
-> (GetInventoryResponse -> GetInventoryResponse -> Bool)
-> Eq GetInventoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInventoryResponse -> GetInventoryResponse -> Bool
$c/= :: GetInventoryResponse -> GetInventoryResponse -> Bool
== :: GetInventoryResponse -> GetInventoryResponse -> Bool
$c== :: GetInventoryResponse -> GetInventoryResponse -> Bool
Prelude.Eq, ReadPrec [GetInventoryResponse]
ReadPrec GetInventoryResponse
Int -> ReadS GetInventoryResponse
ReadS [GetInventoryResponse]
(Int -> ReadS GetInventoryResponse)
-> ReadS [GetInventoryResponse]
-> ReadPrec GetInventoryResponse
-> ReadPrec [GetInventoryResponse]
-> Read GetInventoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInventoryResponse]
$creadListPrec :: ReadPrec [GetInventoryResponse]
readPrec :: ReadPrec GetInventoryResponse
$creadPrec :: ReadPrec GetInventoryResponse
readList :: ReadS [GetInventoryResponse]
$creadList :: ReadS [GetInventoryResponse]
readsPrec :: Int -> ReadS GetInventoryResponse
$creadsPrec :: Int -> ReadS GetInventoryResponse
Prelude.Read, Int -> GetInventoryResponse -> ShowS
[GetInventoryResponse] -> ShowS
GetInventoryResponse -> String
(Int -> GetInventoryResponse -> ShowS)
-> (GetInventoryResponse -> String)
-> ([GetInventoryResponse] -> ShowS)
-> Show GetInventoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInventoryResponse] -> ShowS
$cshowList :: [GetInventoryResponse] -> ShowS
show :: GetInventoryResponse -> String
$cshow :: GetInventoryResponse -> String
showsPrec :: Int -> GetInventoryResponse -> ShowS
$cshowsPrec :: Int -> GetInventoryResponse -> ShowS
Prelude.Show, (forall x. GetInventoryResponse -> Rep GetInventoryResponse x)
-> (forall x. Rep GetInventoryResponse x -> GetInventoryResponse)
-> Generic GetInventoryResponse
forall x. Rep GetInventoryResponse x -> GetInventoryResponse
forall x. GetInventoryResponse -> Rep GetInventoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInventoryResponse x -> GetInventoryResponse
$cfrom :: forall x. GetInventoryResponse -> Rep GetInventoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetInventoryResponse' 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:
--
-- 'entities', 'getInventoryResponse_entities' - Collection of inventory entities such as a collection of instance
-- inventory.
--
-- 'nextToken', 'getInventoryResponse_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', 'getInventoryResponse_httpStatus' - The response's http status code.
newGetInventoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetInventoryResponse
newGetInventoryResponse :: Int -> GetInventoryResponse
newGetInventoryResponse Int
pHttpStatus_ =
  GetInventoryResponse' :: Maybe [InventoryResultEntity]
-> Maybe Text -> Int -> GetInventoryResponse
GetInventoryResponse'
    { $sel:entities:GetInventoryResponse' :: Maybe [InventoryResultEntity]
entities = Maybe [InventoryResultEntity]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetInventoryResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetInventoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Collection of inventory entities such as a collection of instance
-- inventory.
getInventoryResponse_entities :: Lens.Lens' GetInventoryResponse (Prelude.Maybe [InventoryResultEntity])
getInventoryResponse_entities :: (Maybe [InventoryResultEntity]
 -> f (Maybe [InventoryResultEntity]))
-> GetInventoryResponse -> f GetInventoryResponse
getInventoryResponse_entities = (GetInventoryResponse -> Maybe [InventoryResultEntity])
-> (GetInventoryResponse
    -> Maybe [InventoryResultEntity] -> GetInventoryResponse)
-> Lens' GetInventoryResponse (Maybe [InventoryResultEntity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventoryResponse' {Maybe [InventoryResultEntity]
entities :: Maybe [InventoryResultEntity]
$sel:entities:GetInventoryResponse' :: GetInventoryResponse -> Maybe [InventoryResultEntity]
entities} -> Maybe [InventoryResultEntity]
entities) (\s :: GetInventoryResponse
s@GetInventoryResponse' {} Maybe [InventoryResultEntity]
a -> GetInventoryResponse
s {$sel:entities:GetInventoryResponse' :: Maybe [InventoryResultEntity]
entities = Maybe [InventoryResultEntity]
a} :: GetInventoryResponse) ((Maybe [InventoryResultEntity]
  -> f (Maybe [InventoryResultEntity]))
 -> GetInventoryResponse -> f GetInventoryResponse)
-> ((Maybe [InventoryResultEntity]
     -> f (Maybe [InventoryResultEntity]))
    -> Maybe [InventoryResultEntity]
    -> f (Maybe [InventoryResultEntity]))
-> (Maybe [InventoryResultEntity]
    -> f (Maybe [InventoryResultEntity]))
-> GetInventoryResponse
-> f GetInventoryResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [InventoryResultEntity]
  [InventoryResultEntity]
  [InventoryResultEntity]
  [InventoryResultEntity]
-> Iso
     (Maybe [InventoryResultEntity])
     (Maybe [InventoryResultEntity])
     (Maybe [InventoryResultEntity])
     (Maybe [InventoryResultEntity])
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
  [InventoryResultEntity]
  [InventoryResultEntity]
  [InventoryResultEntity]
  [InventoryResultEntity]
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.
getInventoryResponse_nextToken :: Lens.Lens' GetInventoryResponse (Prelude.Maybe Prelude.Text)
getInventoryResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetInventoryResponse -> f GetInventoryResponse
getInventoryResponse_nextToken = (GetInventoryResponse -> Maybe Text)
-> (GetInventoryResponse -> Maybe Text -> GetInventoryResponse)
-> Lens' GetInventoryResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInventoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetInventoryResponse' :: GetInventoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetInventoryResponse
s@GetInventoryResponse' {} Maybe Text
a -> GetInventoryResponse
s {$sel:nextToken:GetInventoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetInventoryResponse)

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

instance Prelude.NFData GetInventoryResponse