{-# 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.DescribeOpsItems
-- 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 a set of OpsItems. You must have permission in Identity and Access
-- Management (IAM) to query a list of OpsItems. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/OpsCenter-getting-started.html Getting started with OpsCenter>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- Operations engineers and IT professionals use Amazon Web Services
-- Systems Manager OpsCenter to view, investigate, and remediate
-- operational issues impacting the performance and health of their Amazon
-- Web Services resources. For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/OpsCenter.html OpsCenter>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- This operation returns paginated results.
module Amazonka.SSM.DescribeOpsItems
  ( -- * Creating a Request
    DescribeOpsItems (..),
    newDescribeOpsItems,

    -- * Request Lenses
    describeOpsItems_opsItemFilters,
    describeOpsItems_nextToken,
    describeOpsItems_maxResults,

    -- * Destructuring the Response
    DescribeOpsItemsResponse (..),
    newDescribeOpsItemsResponse,

    -- * Response Lenses
    describeOpsItemsResponse_nextToken,
    describeOpsItemsResponse_opsItemSummaries,
    describeOpsItemsResponse_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:/ 'newDescribeOpsItems' smart constructor.
data DescribeOpsItems = DescribeOpsItems'
  { -- | One or more filters to limit the response.
    --
    -- -   Key: CreatedTime
    --
    --     Operations: GreaterThan, LessThan
    --
    -- -   Key: LastModifiedBy
    --
    --     Operations: Contains, Equals
    --
    -- -   Key: LastModifiedTime
    --
    --     Operations: GreaterThan, LessThan
    --
    -- -   Key: Priority
    --
    --     Operations: Equals
    --
    -- -   Key: Source
    --
    --     Operations: Contains, Equals
    --
    -- -   Key: Status
    --
    --     Operations: Equals
    --
    -- -   Key: Title*
    --
    --     Operations: Equals,Contains
    --
    -- -   Key: OperationalData**
    --
    --     Operations: Equals
    --
    -- -   Key: OperationalDataKey
    --
    --     Operations: Equals
    --
    -- -   Key: OperationalDataValue
    --
    --     Operations: Equals, Contains
    --
    -- -   Key: OpsItemId
    --
    --     Operations: Equals
    --
    -- -   Key: ResourceId
    --
    --     Operations: Contains
    --
    -- -   Key: AutomationId
    --
    --     Operations: Equals
    --
    -- *The Equals operator for Title matches the first 100 characters. If you
    -- specify more than 100 characters, they system returns an error that the
    -- filter value exceeds the length limit.
    --
    -- **If you filter the response by using the OperationalData operator,
    -- specify a key-value pair by using the following JSON format:
    -- {\"key\":\"key_name\",\"value\":\"a_value\"}
    DescribeOpsItems -> Maybe [OpsItemFilter]
opsItemFilters :: Prelude.Maybe [OpsItemFilter],
    -- | A token to start the list. Use this token to get the next set of
    -- results.
    DescribeOpsItems -> 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.
    DescribeOpsItems -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeOpsItems -> DescribeOpsItems -> Bool
(DescribeOpsItems -> DescribeOpsItems -> Bool)
-> (DescribeOpsItems -> DescribeOpsItems -> Bool)
-> Eq DescribeOpsItems
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeOpsItems -> DescribeOpsItems -> Bool
$c/= :: DescribeOpsItems -> DescribeOpsItems -> Bool
== :: DescribeOpsItems -> DescribeOpsItems -> Bool
$c== :: DescribeOpsItems -> DescribeOpsItems -> Bool
Prelude.Eq, ReadPrec [DescribeOpsItems]
ReadPrec DescribeOpsItems
Int -> ReadS DescribeOpsItems
ReadS [DescribeOpsItems]
(Int -> ReadS DescribeOpsItems)
-> ReadS [DescribeOpsItems]
-> ReadPrec DescribeOpsItems
-> ReadPrec [DescribeOpsItems]
-> Read DescribeOpsItems
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeOpsItems]
$creadListPrec :: ReadPrec [DescribeOpsItems]
readPrec :: ReadPrec DescribeOpsItems
$creadPrec :: ReadPrec DescribeOpsItems
readList :: ReadS [DescribeOpsItems]
$creadList :: ReadS [DescribeOpsItems]
readsPrec :: Int -> ReadS DescribeOpsItems
$creadsPrec :: Int -> ReadS DescribeOpsItems
Prelude.Read, Int -> DescribeOpsItems -> ShowS
[DescribeOpsItems] -> ShowS
DescribeOpsItems -> String
(Int -> DescribeOpsItems -> ShowS)
-> (DescribeOpsItems -> String)
-> ([DescribeOpsItems] -> ShowS)
-> Show DescribeOpsItems
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeOpsItems] -> ShowS
$cshowList :: [DescribeOpsItems] -> ShowS
show :: DescribeOpsItems -> String
$cshow :: DescribeOpsItems -> String
showsPrec :: Int -> DescribeOpsItems -> ShowS
$cshowsPrec :: Int -> DescribeOpsItems -> ShowS
Prelude.Show, (forall x. DescribeOpsItems -> Rep DescribeOpsItems x)
-> (forall x. Rep DescribeOpsItems x -> DescribeOpsItems)
-> Generic DescribeOpsItems
forall x. Rep DescribeOpsItems x -> DescribeOpsItems
forall x. DescribeOpsItems -> Rep DescribeOpsItems x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeOpsItems x -> DescribeOpsItems
$cfrom :: forall x. DescribeOpsItems -> Rep DescribeOpsItems x
Prelude.Generic)

-- |
-- Create a value of 'DescribeOpsItems' 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:
--
-- 'opsItemFilters', 'describeOpsItems_opsItemFilters' - One or more filters to limit the response.
--
-- -   Key: CreatedTime
--
--     Operations: GreaterThan, LessThan
--
-- -   Key: LastModifiedBy
--
--     Operations: Contains, Equals
--
-- -   Key: LastModifiedTime
--
--     Operations: GreaterThan, LessThan
--
-- -   Key: Priority
--
--     Operations: Equals
--
-- -   Key: Source
--
--     Operations: Contains, Equals
--
-- -   Key: Status
--
--     Operations: Equals
--
-- -   Key: Title*
--
--     Operations: Equals,Contains
--
-- -   Key: OperationalData**
--
--     Operations: Equals
--
-- -   Key: OperationalDataKey
--
--     Operations: Equals
--
-- -   Key: OperationalDataValue
--
--     Operations: Equals, Contains
--
-- -   Key: OpsItemId
--
--     Operations: Equals
--
-- -   Key: ResourceId
--
--     Operations: Contains
--
-- -   Key: AutomationId
--
--     Operations: Equals
--
-- *The Equals operator for Title matches the first 100 characters. If you
-- specify more than 100 characters, they system returns an error that the
-- filter value exceeds the length limit.
--
-- **If you filter the response by using the OperationalData operator,
-- specify a key-value pair by using the following JSON format:
-- {\"key\":\"key_name\",\"value\":\"a_value\"}
--
-- 'nextToken', 'describeOpsItems_nextToken' - A token to start the list. Use this token to get the next set of
-- results.
--
-- 'maxResults', 'describeOpsItems_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.
newDescribeOpsItems ::
  DescribeOpsItems
newDescribeOpsItems :: DescribeOpsItems
newDescribeOpsItems =
  DescribeOpsItems' :: Maybe [OpsItemFilter]
-> Maybe Text -> Maybe Natural -> DescribeOpsItems
DescribeOpsItems'
    { $sel:opsItemFilters:DescribeOpsItems' :: Maybe [OpsItemFilter]
opsItemFilters = Maybe [OpsItemFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeOpsItems' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeOpsItems' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more filters to limit the response.
--
-- -   Key: CreatedTime
--
--     Operations: GreaterThan, LessThan
--
-- -   Key: LastModifiedBy
--
--     Operations: Contains, Equals
--
-- -   Key: LastModifiedTime
--
--     Operations: GreaterThan, LessThan
--
-- -   Key: Priority
--
--     Operations: Equals
--
-- -   Key: Source
--
--     Operations: Contains, Equals
--
-- -   Key: Status
--
--     Operations: Equals
--
-- -   Key: Title*
--
--     Operations: Equals,Contains
--
-- -   Key: OperationalData**
--
--     Operations: Equals
--
-- -   Key: OperationalDataKey
--
--     Operations: Equals
--
-- -   Key: OperationalDataValue
--
--     Operations: Equals, Contains
--
-- -   Key: OpsItemId
--
--     Operations: Equals
--
-- -   Key: ResourceId
--
--     Operations: Contains
--
-- -   Key: AutomationId
--
--     Operations: Equals
--
-- *The Equals operator for Title matches the first 100 characters. If you
-- specify more than 100 characters, they system returns an error that the
-- filter value exceeds the length limit.
--
-- **If you filter the response by using the OperationalData operator,
-- specify a key-value pair by using the following JSON format:
-- {\"key\":\"key_name\",\"value\":\"a_value\"}
describeOpsItems_opsItemFilters :: Lens.Lens' DescribeOpsItems (Prelude.Maybe [OpsItemFilter])
describeOpsItems_opsItemFilters :: (Maybe [OpsItemFilter] -> f (Maybe [OpsItemFilter]))
-> DescribeOpsItems -> f DescribeOpsItems
describeOpsItems_opsItemFilters = (DescribeOpsItems -> Maybe [OpsItemFilter])
-> (DescribeOpsItems -> Maybe [OpsItemFilter] -> DescribeOpsItems)
-> Lens
     DescribeOpsItems
     DescribeOpsItems
     (Maybe [OpsItemFilter])
     (Maybe [OpsItemFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOpsItems' {Maybe [OpsItemFilter]
opsItemFilters :: Maybe [OpsItemFilter]
$sel:opsItemFilters:DescribeOpsItems' :: DescribeOpsItems -> Maybe [OpsItemFilter]
opsItemFilters} -> Maybe [OpsItemFilter]
opsItemFilters) (\s :: DescribeOpsItems
s@DescribeOpsItems' {} Maybe [OpsItemFilter]
a -> DescribeOpsItems
s {$sel:opsItemFilters:DescribeOpsItems' :: Maybe [OpsItemFilter]
opsItemFilters = Maybe [OpsItemFilter]
a} :: DescribeOpsItems) ((Maybe [OpsItemFilter] -> f (Maybe [OpsItemFilter]))
 -> DescribeOpsItems -> f DescribeOpsItems)
-> ((Maybe [OpsItemFilter] -> f (Maybe [OpsItemFilter]))
    -> Maybe [OpsItemFilter] -> f (Maybe [OpsItemFilter]))
-> (Maybe [OpsItemFilter] -> f (Maybe [OpsItemFilter]))
-> DescribeOpsItems
-> f DescribeOpsItems
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OpsItemFilter] [OpsItemFilter] [OpsItemFilter] [OpsItemFilter]
-> Iso
     (Maybe [OpsItemFilter])
     (Maybe [OpsItemFilter])
     (Maybe [OpsItemFilter])
     (Maybe [OpsItemFilter])
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
  [OpsItemFilter] [OpsItemFilter] [OpsItemFilter] [OpsItemFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token to start the list. Use this token to get the next set of
-- results.
describeOpsItems_nextToken :: Lens.Lens' DescribeOpsItems (Prelude.Maybe Prelude.Text)
describeOpsItems_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeOpsItems -> f DescribeOpsItems
describeOpsItems_nextToken = (DescribeOpsItems -> Maybe Text)
-> (DescribeOpsItems -> Maybe Text -> DescribeOpsItems)
-> Lens DescribeOpsItems DescribeOpsItems (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOpsItems' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeOpsItems' :: DescribeOpsItems -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeOpsItems
s@DescribeOpsItems' {} Maybe Text
a -> DescribeOpsItems
s {$sel:nextToken:DescribeOpsItems' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeOpsItems)

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

instance Core.AWSPager DescribeOpsItems where
  page :: DescribeOpsItems
-> AWSResponse DescribeOpsItems -> Maybe DescribeOpsItems
page DescribeOpsItems
rq AWSResponse DescribeOpsItems
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeOpsItems
DescribeOpsItemsResponse
rs
            DescribeOpsItemsResponse
-> Getting (First Text) DescribeOpsItemsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeOpsItemsResponse
-> Const (First Text) DescribeOpsItemsResponse
Lens' DescribeOpsItemsResponse (Maybe Text)
describeOpsItemsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeOpsItemsResponse
 -> Const (First Text) DescribeOpsItemsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeOpsItemsResponse 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 DescribeOpsItems
forall a. Maybe a
Prelude.Nothing
    | Maybe [OpsItemSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeOpsItems
DescribeOpsItemsResponse
rs
            DescribeOpsItemsResponse
-> Getting
     (First [OpsItemSummary]) DescribeOpsItemsResponse [OpsItemSummary]
-> Maybe [OpsItemSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [OpsItemSummary]
 -> Const (First [OpsItemSummary]) (Maybe [OpsItemSummary]))
-> DescribeOpsItemsResponse
-> Const (First [OpsItemSummary]) DescribeOpsItemsResponse
Lens' DescribeOpsItemsResponse (Maybe [OpsItemSummary])
describeOpsItemsResponse_opsItemSummaries
              ((Maybe [OpsItemSummary]
  -> Const (First [OpsItemSummary]) (Maybe [OpsItemSummary]))
 -> DescribeOpsItemsResponse
 -> Const (First [OpsItemSummary]) DescribeOpsItemsResponse)
-> (([OpsItemSummary]
     -> Const (First [OpsItemSummary]) [OpsItemSummary])
    -> Maybe [OpsItemSummary]
    -> Const (First [OpsItemSummary]) (Maybe [OpsItemSummary]))
-> Getting
     (First [OpsItemSummary]) DescribeOpsItemsResponse [OpsItemSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([OpsItemSummary]
 -> Const (First [OpsItemSummary]) [OpsItemSummary])
-> Maybe [OpsItemSummary]
-> Const (First [OpsItemSummary]) (Maybe [OpsItemSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeOpsItems
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeOpsItems -> Maybe DescribeOpsItems
forall a. a -> Maybe a
Prelude.Just (DescribeOpsItems -> Maybe DescribeOpsItems)
-> DescribeOpsItems -> Maybe DescribeOpsItems
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeOpsItems
rq
          DescribeOpsItems
-> (DescribeOpsItems -> DescribeOpsItems) -> DescribeOpsItems
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeOpsItems -> Identity DescribeOpsItems
Lens DescribeOpsItems DescribeOpsItems (Maybe Text) (Maybe Text)
describeOpsItems_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeOpsItems -> Identity DescribeOpsItems)
-> Maybe Text -> DescribeOpsItems -> DescribeOpsItems
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeOpsItems
DescribeOpsItemsResponse
rs
          DescribeOpsItemsResponse
-> Getting (First Text) DescribeOpsItemsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeOpsItemsResponse
-> Const (First Text) DescribeOpsItemsResponse
Lens' DescribeOpsItemsResponse (Maybe Text)
describeOpsItemsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeOpsItemsResponse
 -> Const (First Text) DescribeOpsItemsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeOpsItemsResponse 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 DescribeOpsItems where
  type
    AWSResponse DescribeOpsItems =
      DescribeOpsItemsResponse
  request :: DescribeOpsItems -> Request DescribeOpsItems
request = Service -> DescribeOpsItems -> Request DescribeOpsItems
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeOpsItems
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeOpsItems)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeOpsItems))
-> Logger
-> Service
-> Proxy DescribeOpsItems
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeOpsItems)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe [OpsItemSummary] -> Int -> DescribeOpsItemsResponse
DescribeOpsItemsResponse'
            (Maybe Text
 -> Maybe [OpsItemSummary] -> Int -> DescribeOpsItemsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [OpsItemSummary] -> Int -> DescribeOpsItemsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String (Maybe [OpsItemSummary] -> Int -> DescribeOpsItemsResponse)
-> Either String (Maybe [OpsItemSummary])
-> Either String (Int -> DescribeOpsItemsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [OpsItemSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"OpsItemSummaries"
                            Either String (Maybe (Maybe [OpsItemSummary]))
-> Maybe [OpsItemSummary] -> Either String (Maybe [OpsItemSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [OpsItemSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DescribeOpsItemsResponse)
-> Either String Int -> Either String DescribeOpsItemsResponse
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 DescribeOpsItems

instance Prelude.NFData DescribeOpsItems

instance Core.ToHeaders DescribeOpsItems where
  toHeaders :: DescribeOpsItems -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeOpsItems -> 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.DescribeOpsItems" :: 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 DescribeOpsItems where
  toJSON :: DescribeOpsItems -> Value
toJSON DescribeOpsItems' {Maybe Natural
Maybe [OpsItemFilter]
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
opsItemFilters :: Maybe [OpsItemFilter]
$sel:maxResults:DescribeOpsItems' :: DescribeOpsItems -> Maybe Natural
$sel:nextToken:DescribeOpsItems' :: DescribeOpsItems -> Maybe Text
$sel:opsItemFilters:DescribeOpsItems' :: DescribeOpsItems -> Maybe [OpsItemFilter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OpsItemFilters" Text -> [OpsItemFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([OpsItemFilter] -> Pair) -> Maybe [OpsItemFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [OpsItemFilter]
opsItemFilters,
            (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 DescribeOpsItems where
  toPath :: DescribeOpsItems -> ByteString
toPath = ByteString -> DescribeOpsItems -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeOpsItemsResponse' smart constructor.
data DescribeOpsItemsResponse = DescribeOpsItemsResponse'
  { -- | The token for the next set of items to return. Use this token to get the
    -- next set of results.
    DescribeOpsItemsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of OpsItems.
    DescribeOpsItemsResponse -> Maybe [OpsItemSummary]
opsItemSummaries :: Prelude.Maybe [OpsItemSummary],
    -- | The response's http status code.
    DescribeOpsItemsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool
(DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool)
-> (DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool)
-> Eq DescribeOpsItemsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool
$c/= :: DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool
== :: DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool
$c== :: DescribeOpsItemsResponse -> DescribeOpsItemsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeOpsItemsResponse]
ReadPrec DescribeOpsItemsResponse
Int -> ReadS DescribeOpsItemsResponse
ReadS [DescribeOpsItemsResponse]
(Int -> ReadS DescribeOpsItemsResponse)
-> ReadS [DescribeOpsItemsResponse]
-> ReadPrec DescribeOpsItemsResponse
-> ReadPrec [DescribeOpsItemsResponse]
-> Read DescribeOpsItemsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeOpsItemsResponse]
$creadListPrec :: ReadPrec [DescribeOpsItemsResponse]
readPrec :: ReadPrec DescribeOpsItemsResponse
$creadPrec :: ReadPrec DescribeOpsItemsResponse
readList :: ReadS [DescribeOpsItemsResponse]
$creadList :: ReadS [DescribeOpsItemsResponse]
readsPrec :: Int -> ReadS DescribeOpsItemsResponse
$creadsPrec :: Int -> ReadS DescribeOpsItemsResponse
Prelude.Read, Int -> DescribeOpsItemsResponse -> ShowS
[DescribeOpsItemsResponse] -> ShowS
DescribeOpsItemsResponse -> String
(Int -> DescribeOpsItemsResponse -> ShowS)
-> (DescribeOpsItemsResponse -> String)
-> ([DescribeOpsItemsResponse] -> ShowS)
-> Show DescribeOpsItemsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeOpsItemsResponse] -> ShowS
$cshowList :: [DescribeOpsItemsResponse] -> ShowS
show :: DescribeOpsItemsResponse -> String
$cshow :: DescribeOpsItemsResponse -> String
showsPrec :: Int -> DescribeOpsItemsResponse -> ShowS
$cshowsPrec :: Int -> DescribeOpsItemsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeOpsItemsResponse -> Rep DescribeOpsItemsResponse x)
-> (forall x.
    Rep DescribeOpsItemsResponse x -> DescribeOpsItemsResponse)
-> Generic DescribeOpsItemsResponse
forall x.
Rep DescribeOpsItemsResponse x -> DescribeOpsItemsResponse
forall x.
DescribeOpsItemsResponse -> Rep DescribeOpsItemsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeOpsItemsResponse x -> DescribeOpsItemsResponse
$cfrom :: forall x.
DescribeOpsItemsResponse -> Rep DescribeOpsItemsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeOpsItemsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'describeOpsItemsResponse_nextToken' - The token for the next set of items to return. Use this token to get the
-- next set of results.
--
-- 'opsItemSummaries', 'describeOpsItemsResponse_opsItemSummaries' - A list of OpsItems.
--
-- 'httpStatus', 'describeOpsItemsResponse_httpStatus' - The response's http status code.
newDescribeOpsItemsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeOpsItemsResponse
newDescribeOpsItemsResponse :: Int -> DescribeOpsItemsResponse
newDescribeOpsItemsResponse Int
pHttpStatus_ =
  DescribeOpsItemsResponse' :: Maybe Text
-> Maybe [OpsItemSummary] -> Int -> DescribeOpsItemsResponse
DescribeOpsItemsResponse'
    { $sel:nextToken:DescribeOpsItemsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:opsItemSummaries:DescribeOpsItemsResponse' :: Maybe [OpsItemSummary]
opsItemSummaries = Maybe [OpsItemSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeOpsItemsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token for the next set of items to return. Use this token to get the
-- next set of results.
describeOpsItemsResponse_nextToken :: Lens.Lens' DescribeOpsItemsResponse (Prelude.Maybe Prelude.Text)
describeOpsItemsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeOpsItemsResponse -> f DescribeOpsItemsResponse
describeOpsItemsResponse_nextToken = (DescribeOpsItemsResponse -> Maybe Text)
-> (DescribeOpsItemsResponse
    -> Maybe Text -> DescribeOpsItemsResponse)
-> Lens' DescribeOpsItemsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOpsItemsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeOpsItemsResponse' :: DescribeOpsItemsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeOpsItemsResponse
s@DescribeOpsItemsResponse' {} Maybe Text
a -> DescribeOpsItemsResponse
s {$sel:nextToken:DescribeOpsItemsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeOpsItemsResponse)

-- | A list of OpsItems.
describeOpsItemsResponse_opsItemSummaries :: Lens.Lens' DescribeOpsItemsResponse (Prelude.Maybe [OpsItemSummary])
describeOpsItemsResponse_opsItemSummaries :: (Maybe [OpsItemSummary] -> f (Maybe [OpsItemSummary]))
-> DescribeOpsItemsResponse -> f DescribeOpsItemsResponse
describeOpsItemsResponse_opsItemSummaries = (DescribeOpsItemsResponse -> Maybe [OpsItemSummary])
-> (DescribeOpsItemsResponse
    -> Maybe [OpsItemSummary] -> DescribeOpsItemsResponse)
-> Lens' DescribeOpsItemsResponse (Maybe [OpsItemSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOpsItemsResponse' {Maybe [OpsItemSummary]
opsItemSummaries :: Maybe [OpsItemSummary]
$sel:opsItemSummaries:DescribeOpsItemsResponse' :: DescribeOpsItemsResponse -> Maybe [OpsItemSummary]
opsItemSummaries} -> Maybe [OpsItemSummary]
opsItemSummaries) (\s :: DescribeOpsItemsResponse
s@DescribeOpsItemsResponse' {} Maybe [OpsItemSummary]
a -> DescribeOpsItemsResponse
s {$sel:opsItemSummaries:DescribeOpsItemsResponse' :: Maybe [OpsItemSummary]
opsItemSummaries = Maybe [OpsItemSummary]
a} :: DescribeOpsItemsResponse) ((Maybe [OpsItemSummary] -> f (Maybe [OpsItemSummary]))
 -> DescribeOpsItemsResponse -> f DescribeOpsItemsResponse)
-> ((Maybe [OpsItemSummary] -> f (Maybe [OpsItemSummary]))
    -> Maybe [OpsItemSummary] -> f (Maybe [OpsItemSummary]))
-> (Maybe [OpsItemSummary] -> f (Maybe [OpsItemSummary]))
-> DescribeOpsItemsResponse
-> f DescribeOpsItemsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OpsItemSummary] [OpsItemSummary] [OpsItemSummary] [OpsItemSummary]
-> Iso
     (Maybe [OpsItemSummary])
     (Maybe [OpsItemSummary])
     (Maybe [OpsItemSummary])
     (Maybe [OpsItemSummary])
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
  [OpsItemSummary] [OpsItemSummary] [OpsItemSummary] [OpsItemSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeOpsItemsResponse