{-# 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.Config.ListDiscoveredResources
-- 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)
--
-- Accepts a resource type and returns a list of resource identifiers for
-- the resources of that type. A resource identifier includes the resource
-- type, ID, and (if available) the custom resource name. The results
-- consist of resources that Config has discovered, including those that
-- Config is not currently recording. You can narrow the results to include
-- only resources that have specific resource IDs or a resource name.
--
-- You can specify either resource IDs or a resource name, but not both, in
-- the same request.
--
-- The response is paginated. By default, Config lists 100 resource
-- identifiers on each page. You can customize this number with the @limit@
-- parameter. The response includes a @nextToken@ string. To get the next
-- page of results, run the request again and specify the string for the
-- @nextToken@ parameter.
--
-- This operation returns paginated results.
module Amazonka.Config.ListDiscoveredResources
  ( -- * Creating a Request
    ListDiscoveredResources (..),
    newListDiscoveredResources,

    -- * Request Lenses
    listDiscoveredResources_resourceIds,
    listDiscoveredResources_resourceName,
    listDiscoveredResources_includeDeletedResources,
    listDiscoveredResources_nextToken,
    listDiscoveredResources_limit,
    listDiscoveredResources_resourceType,

    -- * Destructuring the Response
    ListDiscoveredResourcesResponse (..),
    newListDiscoveredResourcesResponse,

    -- * Response Lenses
    listDiscoveredResourcesResponse_nextToken,
    listDiscoveredResourcesResponse_resourceIdentifiers,
    listDiscoveredResourcesResponse_httpStatus,
  )
where

import Amazonka.Config.Types
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

-- |
--
-- /See:/ 'newListDiscoveredResources' smart constructor.
data ListDiscoveredResources = ListDiscoveredResources'
  { -- | The IDs of only those resources that you want Config to list in the
    -- response. If you do not specify this parameter, Config lists all
    -- resources of the specified type that it has discovered.
    ListDiscoveredResources -> Maybe [Text]
resourceIds :: Prelude.Maybe [Prelude.Text],
    -- | The custom name of only those resources that you want Config to list in
    -- the response. If you do not specify this parameter, Config lists all
    -- resources of the specified type that it has discovered.
    ListDiscoveredResources -> Maybe Text
resourceName :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether Config includes deleted resources in the results. By
    -- default, deleted resources are not included.
    ListDiscoveredResources -> Maybe Bool
includeDeletedResources :: Prelude.Maybe Prelude.Bool,
    -- | The @nextToken@ string returned on a previous page that you use to get
    -- the next page of results in a paginated response.
    ListDiscoveredResources -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of resource identifiers returned on each page. The
    -- default is 100. You cannot specify a number greater than 100. If you
    -- specify 0, Config uses the default.
    ListDiscoveredResources -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The type of resources that you want Config to list in the response.
    ListDiscoveredResources -> ResourceType
resourceType :: ResourceType
  }
  deriving (ListDiscoveredResources -> ListDiscoveredResources -> Bool
(ListDiscoveredResources -> ListDiscoveredResources -> Bool)
-> (ListDiscoveredResources -> ListDiscoveredResources -> Bool)
-> Eq ListDiscoveredResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDiscoveredResources -> ListDiscoveredResources -> Bool
$c/= :: ListDiscoveredResources -> ListDiscoveredResources -> Bool
== :: ListDiscoveredResources -> ListDiscoveredResources -> Bool
$c== :: ListDiscoveredResources -> ListDiscoveredResources -> Bool
Prelude.Eq, ReadPrec [ListDiscoveredResources]
ReadPrec ListDiscoveredResources
Int -> ReadS ListDiscoveredResources
ReadS [ListDiscoveredResources]
(Int -> ReadS ListDiscoveredResources)
-> ReadS [ListDiscoveredResources]
-> ReadPrec ListDiscoveredResources
-> ReadPrec [ListDiscoveredResources]
-> Read ListDiscoveredResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDiscoveredResources]
$creadListPrec :: ReadPrec [ListDiscoveredResources]
readPrec :: ReadPrec ListDiscoveredResources
$creadPrec :: ReadPrec ListDiscoveredResources
readList :: ReadS [ListDiscoveredResources]
$creadList :: ReadS [ListDiscoveredResources]
readsPrec :: Int -> ReadS ListDiscoveredResources
$creadsPrec :: Int -> ReadS ListDiscoveredResources
Prelude.Read, Int -> ListDiscoveredResources -> ShowS
[ListDiscoveredResources] -> ShowS
ListDiscoveredResources -> String
(Int -> ListDiscoveredResources -> ShowS)
-> (ListDiscoveredResources -> String)
-> ([ListDiscoveredResources] -> ShowS)
-> Show ListDiscoveredResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDiscoveredResources] -> ShowS
$cshowList :: [ListDiscoveredResources] -> ShowS
show :: ListDiscoveredResources -> String
$cshow :: ListDiscoveredResources -> String
showsPrec :: Int -> ListDiscoveredResources -> ShowS
$cshowsPrec :: Int -> ListDiscoveredResources -> ShowS
Prelude.Show, (forall x.
 ListDiscoveredResources -> Rep ListDiscoveredResources x)
-> (forall x.
    Rep ListDiscoveredResources x -> ListDiscoveredResources)
-> Generic ListDiscoveredResources
forall x. Rep ListDiscoveredResources x -> ListDiscoveredResources
forall x. ListDiscoveredResources -> Rep ListDiscoveredResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDiscoveredResources x -> ListDiscoveredResources
$cfrom :: forall x. ListDiscoveredResources -> Rep ListDiscoveredResources x
Prelude.Generic)

-- |
-- Create a value of 'ListDiscoveredResources' 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:
--
-- 'resourceIds', 'listDiscoveredResources_resourceIds' - The IDs of only those resources that you want Config to list in the
-- response. If you do not specify this parameter, Config lists all
-- resources of the specified type that it has discovered.
--
-- 'resourceName', 'listDiscoveredResources_resourceName' - The custom name of only those resources that you want Config to list in
-- the response. If you do not specify this parameter, Config lists all
-- resources of the specified type that it has discovered.
--
-- 'includeDeletedResources', 'listDiscoveredResources_includeDeletedResources' - Specifies whether Config includes deleted resources in the results. By
-- default, deleted resources are not included.
--
-- 'nextToken', 'listDiscoveredResources_nextToken' - The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
--
-- 'limit', 'listDiscoveredResources_limit' - The maximum number of resource identifiers returned on each page. The
-- default is 100. You cannot specify a number greater than 100. If you
-- specify 0, Config uses the default.
--
-- 'resourceType', 'listDiscoveredResources_resourceType' - The type of resources that you want Config to list in the response.
newListDiscoveredResources ::
  -- | 'resourceType'
  ResourceType ->
  ListDiscoveredResources
newListDiscoveredResources :: ResourceType -> ListDiscoveredResources
newListDiscoveredResources ResourceType
pResourceType_ =
  ListDiscoveredResources' :: Maybe [Text]
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Natural
-> ResourceType
-> ListDiscoveredResources
ListDiscoveredResources'
    { $sel:resourceIds:ListDiscoveredResources' :: Maybe [Text]
resourceIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceName:ListDiscoveredResources' :: Maybe Text
resourceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:includeDeletedResources:ListDiscoveredResources' :: Maybe Bool
includeDeletedResources = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDiscoveredResources' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListDiscoveredResources' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ListDiscoveredResources' :: ResourceType
resourceType = ResourceType
pResourceType_
    }

-- | The IDs of only those resources that you want Config to list in the
-- response. If you do not specify this parameter, Config lists all
-- resources of the specified type that it has discovered.
listDiscoveredResources_resourceIds :: Lens.Lens' ListDiscoveredResources (Prelude.Maybe [Prelude.Text])
listDiscoveredResources_resourceIds :: (Maybe [Text] -> f (Maybe [Text]))
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_resourceIds = (ListDiscoveredResources -> Maybe [Text])
-> (ListDiscoveredResources
    -> Maybe [Text] -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {Maybe [Text]
resourceIds :: Maybe [Text]
$sel:resourceIds:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe [Text]
resourceIds} -> Maybe [Text]
resourceIds) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} Maybe [Text]
a -> ListDiscoveredResources
s {$sel:resourceIds:ListDiscoveredResources' :: Maybe [Text]
resourceIds = Maybe [Text]
a} :: ListDiscoveredResources) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListDiscoveredResources -> f ListDiscoveredResources)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListDiscoveredResources
-> f ListDiscoveredResources
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The custom name of only those resources that you want Config to list in
-- the response. If you do not specify this parameter, Config lists all
-- resources of the specified type that it has discovered.
listDiscoveredResources_resourceName :: Lens.Lens' ListDiscoveredResources (Prelude.Maybe Prelude.Text)
listDiscoveredResources_resourceName :: (Maybe Text -> f (Maybe Text))
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_resourceName = (ListDiscoveredResources -> Maybe Text)
-> (ListDiscoveredResources
    -> Maybe Text -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {Maybe Text
resourceName :: Maybe Text
$sel:resourceName:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Text
resourceName} -> Maybe Text
resourceName) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} Maybe Text
a -> ListDiscoveredResources
s {$sel:resourceName:ListDiscoveredResources' :: Maybe Text
resourceName = Maybe Text
a} :: ListDiscoveredResources)

-- | Specifies whether Config includes deleted resources in the results. By
-- default, deleted resources are not included.
listDiscoveredResources_includeDeletedResources :: Lens.Lens' ListDiscoveredResources (Prelude.Maybe Prelude.Bool)
listDiscoveredResources_includeDeletedResources :: (Maybe Bool -> f (Maybe Bool))
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_includeDeletedResources = (ListDiscoveredResources -> Maybe Bool)
-> (ListDiscoveredResources
    -> Maybe Bool -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {Maybe Bool
includeDeletedResources :: Maybe Bool
$sel:includeDeletedResources:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Bool
includeDeletedResources} -> Maybe Bool
includeDeletedResources) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} Maybe Bool
a -> ListDiscoveredResources
s {$sel:includeDeletedResources:ListDiscoveredResources' :: Maybe Bool
includeDeletedResources = Maybe Bool
a} :: ListDiscoveredResources)

-- | The @nextToken@ string returned on a previous page that you use to get
-- the next page of results in a paginated response.
listDiscoveredResources_nextToken :: Lens.Lens' ListDiscoveredResources (Prelude.Maybe Prelude.Text)
listDiscoveredResources_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_nextToken = (ListDiscoveredResources -> Maybe Text)
-> (ListDiscoveredResources
    -> Maybe Text -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} Maybe Text
a -> ListDiscoveredResources
s {$sel:nextToken:ListDiscoveredResources' :: Maybe Text
nextToken = Maybe Text
a} :: ListDiscoveredResources)

-- | The maximum number of resource identifiers returned on each page. The
-- default is 100. You cannot specify a number greater than 100. If you
-- specify 0, Config uses the default.
listDiscoveredResources_limit :: Lens.Lens' ListDiscoveredResources (Prelude.Maybe Prelude.Natural)
listDiscoveredResources_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_limit = (ListDiscoveredResources -> Maybe Natural)
-> (ListDiscoveredResources
    -> Maybe Natural -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} Maybe Natural
a -> ListDiscoveredResources
s {$sel:limit:ListDiscoveredResources' :: Maybe Natural
limit = Maybe Natural
a} :: ListDiscoveredResources)

-- | The type of resources that you want Config to list in the response.
listDiscoveredResources_resourceType :: Lens.Lens' ListDiscoveredResources ResourceType
listDiscoveredResources_resourceType :: (ResourceType -> f ResourceType)
-> ListDiscoveredResources -> f ListDiscoveredResources
listDiscoveredResources_resourceType = (ListDiscoveredResources -> ResourceType)
-> (ListDiscoveredResources
    -> ResourceType -> ListDiscoveredResources)
-> Lens
     ListDiscoveredResources
     ListDiscoveredResources
     ResourceType
     ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResources' {ResourceType
resourceType :: ResourceType
$sel:resourceType:ListDiscoveredResources' :: ListDiscoveredResources -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: ListDiscoveredResources
s@ListDiscoveredResources' {} ResourceType
a -> ListDiscoveredResources
s {$sel:resourceType:ListDiscoveredResources' :: ResourceType
resourceType = ResourceType
a} :: ListDiscoveredResources)

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

instance Prelude.NFData ListDiscoveredResources

instance Core.ToHeaders ListDiscoveredResources where
  toHeaders :: ListDiscoveredResources -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListDiscoveredResources -> 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
"StarlingDoveService.ListDiscoveredResources" ::
                          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 ListDiscoveredResources where
  toJSON :: ListDiscoveredResources -> Value
toJSON ListDiscoveredResources' {Maybe Bool
Maybe Natural
Maybe [Text]
Maybe Text
ResourceType
resourceType :: ResourceType
limit :: Maybe Natural
nextToken :: Maybe Text
includeDeletedResources :: Maybe Bool
resourceName :: Maybe Text
resourceIds :: Maybe [Text]
$sel:resourceType:ListDiscoveredResources' :: ListDiscoveredResources -> ResourceType
$sel:limit:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Natural
$sel:nextToken:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Text
$sel:includeDeletedResources:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Bool
$sel:resourceName:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe Text
$sel:resourceIds:ListDiscoveredResources' :: ListDiscoveredResources -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"resourceIds" 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]
resourceIds,
            (Text
"resourceName" 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
resourceName,
            (Text
"includeDeletedResources" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeDeletedResources,
            (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
"limit" 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
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"resourceType" Text -> ResourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceType
resourceType)
          ]
      )

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

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

-- |
--
-- /See:/ 'newListDiscoveredResourcesResponse' smart constructor.
data ListDiscoveredResourcesResponse = ListDiscoveredResourcesResponse'
  { -- | The string that you use in a subsequent request to get the next page of
    -- results in a paginated response.
    ListDiscoveredResourcesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The details that identify a resource that is discovered by Config,
    -- including the resource type, ID, and (if available) the custom resource
    -- name.
    ListDiscoveredResourcesResponse -> Maybe [ResourceIdentifier]
resourceIdentifiers :: Prelude.Maybe [ResourceIdentifier],
    -- | The response's http status code.
    ListDiscoveredResourcesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDiscoveredResourcesResponse
-> ListDiscoveredResourcesResponse -> Bool
(ListDiscoveredResourcesResponse
 -> ListDiscoveredResourcesResponse -> Bool)
-> (ListDiscoveredResourcesResponse
    -> ListDiscoveredResourcesResponse -> Bool)
-> Eq ListDiscoveredResourcesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDiscoveredResourcesResponse
-> ListDiscoveredResourcesResponse -> Bool
$c/= :: ListDiscoveredResourcesResponse
-> ListDiscoveredResourcesResponse -> Bool
== :: ListDiscoveredResourcesResponse
-> ListDiscoveredResourcesResponse -> Bool
$c== :: ListDiscoveredResourcesResponse
-> ListDiscoveredResourcesResponse -> Bool
Prelude.Eq, ReadPrec [ListDiscoveredResourcesResponse]
ReadPrec ListDiscoveredResourcesResponse
Int -> ReadS ListDiscoveredResourcesResponse
ReadS [ListDiscoveredResourcesResponse]
(Int -> ReadS ListDiscoveredResourcesResponse)
-> ReadS [ListDiscoveredResourcesResponse]
-> ReadPrec ListDiscoveredResourcesResponse
-> ReadPrec [ListDiscoveredResourcesResponse]
-> Read ListDiscoveredResourcesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDiscoveredResourcesResponse]
$creadListPrec :: ReadPrec [ListDiscoveredResourcesResponse]
readPrec :: ReadPrec ListDiscoveredResourcesResponse
$creadPrec :: ReadPrec ListDiscoveredResourcesResponse
readList :: ReadS [ListDiscoveredResourcesResponse]
$creadList :: ReadS [ListDiscoveredResourcesResponse]
readsPrec :: Int -> ReadS ListDiscoveredResourcesResponse
$creadsPrec :: Int -> ReadS ListDiscoveredResourcesResponse
Prelude.Read, Int -> ListDiscoveredResourcesResponse -> ShowS
[ListDiscoveredResourcesResponse] -> ShowS
ListDiscoveredResourcesResponse -> String
(Int -> ListDiscoveredResourcesResponse -> ShowS)
-> (ListDiscoveredResourcesResponse -> String)
-> ([ListDiscoveredResourcesResponse] -> ShowS)
-> Show ListDiscoveredResourcesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDiscoveredResourcesResponse] -> ShowS
$cshowList :: [ListDiscoveredResourcesResponse] -> ShowS
show :: ListDiscoveredResourcesResponse -> String
$cshow :: ListDiscoveredResourcesResponse -> String
showsPrec :: Int -> ListDiscoveredResourcesResponse -> ShowS
$cshowsPrec :: Int -> ListDiscoveredResourcesResponse -> ShowS
Prelude.Show, (forall x.
 ListDiscoveredResourcesResponse
 -> Rep ListDiscoveredResourcesResponse x)
-> (forall x.
    Rep ListDiscoveredResourcesResponse x
    -> ListDiscoveredResourcesResponse)
-> Generic ListDiscoveredResourcesResponse
forall x.
Rep ListDiscoveredResourcesResponse x
-> ListDiscoveredResourcesResponse
forall x.
ListDiscoveredResourcesResponse
-> Rep ListDiscoveredResourcesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDiscoveredResourcesResponse x
-> ListDiscoveredResourcesResponse
$cfrom :: forall x.
ListDiscoveredResourcesResponse
-> Rep ListDiscoveredResourcesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDiscoveredResourcesResponse' 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', 'listDiscoveredResourcesResponse_nextToken' - The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
--
-- 'resourceIdentifiers', 'listDiscoveredResourcesResponse_resourceIdentifiers' - The details that identify a resource that is discovered by Config,
-- including the resource type, ID, and (if available) the custom resource
-- name.
--
-- 'httpStatus', 'listDiscoveredResourcesResponse_httpStatus' - The response's http status code.
newListDiscoveredResourcesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDiscoveredResourcesResponse
newListDiscoveredResourcesResponse :: Int -> ListDiscoveredResourcesResponse
newListDiscoveredResourcesResponse Int
pHttpStatus_ =
  ListDiscoveredResourcesResponse' :: Maybe Text
-> Maybe [ResourceIdentifier]
-> Int
-> ListDiscoveredResourcesResponse
ListDiscoveredResourcesResponse'
    { $sel:nextToken:ListDiscoveredResourcesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifiers:ListDiscoveredResourcesResponse' :: Maybe [ResourceIdentifier]
resourceIdentifiers = Maybe [ResourceIdentifier]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDiscoveredResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The string that you use in a subsequent request to get the next page of
-- results in a paginated response.
listDiscoveredResourcesResponse_nextToken :: Lens.Lens' ListDiscoveredResourcesResponse (Prelude.Maybe Prelude.Text)
listDiscoveredResourcesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDiscoveredResourcesResponse
-> f ListDiscoveredResourcesResponse
listDiscoveredResourcesResponse_nextToken = (ListDiscoveredResourcesResponse -> Maybe Text)
-> (ListDiscoveredResourcesResponse
    -> Maybe Text -> ListDiscoveredResourcesResponse)
-> Lens' ListDiscoveredResourcesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResourcesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDiscoveredResourcesResponse' :: ListDiscoveredResourcesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDiscoveredResourcesResponse
s@ListDiscoveredResourcesResponse' {} Maybe Text
a -> ListDiscoveredResourcesResponse
s {$sel:nextToken:ListDiscoveredResourcesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDiscoveredResourcesResponse)

-- | The details that identify a resource that is discovered by Config,
-- including the resource type, ID, and (if available) the custom resource
-- name.
listDiscoveredResourcesResponse_resourceIdentifiers :: Lens.Lens' ListDiscoveredResourcesResponse (Prelude.Maybe [ResourceIdentifier])
listDiscoveredResourcesResponse_resourceIdentifiers :: (Maybe [ResourceIdentifier] -> f (Maybe [ResourceIdentifier]))
-> ListDiscoveredResourcesResponse
-> f ListDiscoveredResourcesResponse
listDiscoveredResourcesResponse_resourceIdentifiers = (ListDiscoveredResourcesResponse -> Maybe [ResourceIdentifier])
-> (ListDiscoveredResourcesResponse
    -> Maybe [ResourceIdentifier] -> ListDiscoveredResourcesResponse)
-> Lens'
     ListDiscoveredResourcesResponse (Maybe [ResourceIdentifier])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDiscoveredResourcesResponse' {Maybe [ResourceIdentifier]
resourceIdentifiers :: Maybe [ResourceIdentifier]
$sel:resourceIdentifiers:ListDiscoveredResourcesResponse' :: ListDiscoveredResourcesResponse -> Maybe [ResourceIdentifier]
resourceIdentifiers} -> Maybe [ResourceIdentifier]
resourceIdentifiers) (\s :: ListDiscoveredResourcesResponse
s@ListDiscoveredResourcesResponse' {} Maybe [ResourceIdentifier]
a -> ListDiscoveredResourcesResponse
s {$sel:resourceIdentifiers:ListDiscoveredResourcesResponse' :: Maybe [ResourceIdentifier]
resourceIdentifiers = Maybe [ResourceIdentifier]
a} :: ListDiscoveredResourcesResponse) ((Maybe [ResourceIdentifier] -> f (Maybe [ResourceIdentifier]))
 -> ListDiscoveredResourcesResponse
 -> f ListDiscoveredResourcesResponse)
-> ((Maybe [ResourceIdentifier] -> f (Maybe [ResourceIdentifier]))
    -> Maybe [ResourceIdentifier] -> f (Maybe [ResourceIdentifier]))
-> (Maybe [ResourceIdentifier] -> f (Maybe [ResourceIdentifier]))
-> ListDiscoveredResourcesResponse
-> f ListDiscoveredResourcesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceIdentifier]
  [ResourceIdentifier]
  [ResourceIdentifier]
  [ResourceIdentifier]
-> Iso
     (Maybe [ResourceIdentifier])
     (Maybe [ResourceIdentifier])
     (Maybe [ResourceIdentifier])
     (Maybe [ResourceIdentifier])
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
  [ResourceIdentifier]
  [ResourceIdentifier]
  [ResourceIdentifier]
  [ResourceIdentifier]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListDiscoveredResourcesResponse