{-# 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.RAM.ListResources
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the resources that you added to a resource shares or the resources
-- that are shared with you.
--
-- This operation returns paginated results.
module Amazonka.RAM.ListResources
  ( -- * Creating a Request
    ListResources (..),
    newListResources,

    -- * Request Lenses
    listResources_resourceType,
    listResources_nextToken,
    listResources_resourceArns,
    listResources_principal,
    listResources_maxResults,
    listResources_resourceShareArns,
    listResources_resourceOwner,

    -- * Destructuring the Response
    ListResourcesResponse (..),
    newListResourcesResponse,

    -- * Response Lenses
    listResourcesResponse_resources,
    listResourcesResponse_nextToken,
    listResourcesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RAM.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListResources' smart constructor.
data ListResources = ListResources'
  { -- | The resource type.
    --
    -- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
    -- @codebuild:Project@ | @codebuild:ReportGroup@ |
    -- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
    -- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
    -- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
    -- @imagebuilder:Component@ | @imagebuilder:Image@ |
    -- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
    -- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
    -- @license-manager:LicenseConfiguration@ I
    -- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
    -- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
    -- @resource-groups:Group@ | @rds:Cluster@ |
    -- @route53resolver:FirewallRuleGroup@
    -- |@route53resolver:ResolverQueryLogConfig@ |
    -- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
    -- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
    ListResources -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The token for the next page of results.
    ListResources -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Names (ARNs) of the resources.
    ListResources -> Maybe [Text]
resourceArns :: Prelude.Maybe [Prelude.Text],
    -- | The principal.
    ListResources -> Maybe Text
principal :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    ListResources -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Names (ARN) of the resource shares.
    ListResources -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | The type of owner.
    ListResources -> ResourceOwner
resourceOwner :: ResourceOwner
  }
  deriving (ListResources -> ListResources -> Bool
(ListResources -> ListResources -> Bool)
-> (ListResources -> ListResources -> Bool) -> Eq ListResources
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResources -> ListResources -> Bool
$c/= :: ListResources -> ListResources -> Bool
== :: ListResources -> ListResources -> Bool
$c== :: ListResources -> ListResources -> Bool
Prelude.Eq, ReadPrec [ListResources]
ReadPrec ListResources
Int -> ReadS ListResources
ReadS [ListResources]
(Int -> ReadS ListResources)
-> ReadS [ListResources]
-> ReadPrec ListResources
-> ReadPrec [ListResources]
-> Read ListResources
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResources]
$creadListPrec :: ReadPrec [ListResources]
readPrec :: ReadPrec ListResources
$creadPrec :: ReadPrec ListResources
readList :: ReadS [ListResources]
$creadList :: ReadS [ListResources]
readsPrec :: Int -> ReadS ListResources
$creadsPrec :: Int -> ReadS ListResources
Prelude.Read, Int -> ListResources -> ShowS
[ListResources] -> ShowS
ListResources -> String
(Int -> ListResources -> ShowS)
-> (ListResources -> String)
-> ([ListResources] -> ShowS)
-> Show ListResources
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResources] -> ShowS
$cshowList :: [ListResources] -> ShowS
show :: ListResources -> String
$cshow :: ListResources -> String
showsPrec :: Int -> ListResources -> ShowS
$cshowsPrec :: Int -> ListResources -> ShowS
Prelude.Show, (forall x. ListResources -> Rep ListResources x)
-> (forall x. Rep ListResources x -> ListResources)
-> Generic ListResources
forall x. Rep ListResources x -> ListResources
forall x. ListResources -> Rep ListResources x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResources x -> ListResources
$cfrom :: forall x. ListResources -> Rep ListResources x
Prelude.Generic)

-- |
-- Create a value of 'ListResources' 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:
--
-- 'resourceType', 'listResources_resourceType' - The resource type.
--
-- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
-- @codebuild:Project@ | @codebuild:ReportGroup@ |
-- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
-- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
-- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
-- @imagebuilder:Component@ | @imagebuilder:Image@ |
-- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
-- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
-- @license-manager:LicenseConfiguration@ I
-- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
-- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
-- @resource-groups:Group@ | @rds:Cluster@ |
-- @route53resolver:FirewallRuleGroup@
-- |@route53resolver:ResolverQueryLogConfig@ |
-- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
-- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
--
-- 'nextToken', 'listResources_nextToken' - The token for the next page of results.
--
-- 'resourceArns', 'listResources_resourceArns' - The Amazon Resource Names (ARNs) of the resources.
--
-- 'principal', 'listResources_principal' - The principal.
--
-- 'maxResults', 'listResources_maxResults' - The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
--
-- 'resourceShareArns', 'listResources_resourceShareArns' - The Amazon Resource Names (ARN) of the resource shares.
--
-- 'resourceOwner', 'listResources_resourceOwner' - The type of owner.
newListResources ::
  -- | 'resourceOwner'
  ResourceOwner ->
  ListResources
newListResources :: ResourceOwner -> ListResources
newListResources ResourceOwner
pResourceOwner_ =
  ListResources' :: Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Natural
-> Maybe [Text]
-> ResourceOwner
-> ListResources
ListResources'
    { $sel:resourceType:ListResources' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListResources' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArns:ListResources' :: Maybe [Text]
resourceArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:principal:ListResources' :: Maybe Text
principal = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListResources' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:ListResources' :: Maybe [Text]
resourceShareArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceOwner:ListResources' :: ResourceOwner
resourceOwner = ResourceOwner
pResourceOwner_
    }

-- | The resource type.
--
-- Valid values: @acm-pca:CertificateAuthority@ | @appmesh:Mesh@ |
-- @codebuild:Project@ | @codebuild:ReportGroup@ |
-- @ec2:CapacityReservation@ | @ec2:DedicatedHost@ |
-- @ec2:LocalGatewayRouteTable@ | @ec2:PrefixList@ | @ec2:Subnet@ |
-- @ec2:TrafficMirrorTarget@ | @ec2:TransitGateway@ |
-- @imagebuilder:Component@ | @imagebuilder:Image@ |
-- @imagebuilder:ImageRecipe@ | @imagebuilder:ContainerRecipe@ |
-- @glue:Catalog@ | @glue:Database@ | @glue:Table@ |
-- @license-manager:LicenseConfiguration@ I
-- @network-firewall:FirewallPolicy@ | @network-firewall:StatefulRuleGroup@
-- | @network-firewall:StatelessRuleGroup@ | @outposts:Outpost@ |
-- @resource-groups:Group@ | @rds:Cluster@ |
-- @route53resolver:FirewallRuleGroup@
-- |@route53resolver:ResolverQueryLogConfig@ |
-- @route53resolver:ResolverRule@ | @s3-outposts:Outpost@ |
-- @ssm-contacts:Contact@ | @ssm-incidents:ResponsePlan@
listResources_resourceType :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Text)
listResources_resourceType :: (Maybe Text -> f (Maybe Text)) -> ListResources -> f ListResources
listResources_resourceType = (ListResources -> Maybe Text)
-> (ListResources -> Maybe Text -> ListResources)
-> Lens ListResources ListResources (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ListResources' :: ListResources -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ListResources
s@ListResources' {} Maybe Text
a -> ListResources
s {$sel:resourceType:ListResources' :: Maybe Text
resourceType = Maybe Text
a} :: ListResources)

-- | The token for the next page of results.
listResources_nextToken :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Text)
listResources_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListResources -> f ListResources
listResources_nextToken = (ListResources -> Maybe Text)
-> (ListResources -> Maybe Text -> ListResources)
-> Lens ListResources ListResources (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResources
s@ListResources' {} Maybe Text
a -> ListResources
s {$sel:nextToken:ListResources' :: Maybe Text
nextToken = Maybe Text
a} :: ListResources)

-- | The Amazon Resource Names (ARNs) of the resources.
listResources_resourceArns :: Lens.Lens' ListResources (Prelude.Maybe [Prelude.Text])
listResources_resourceArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ListResources -> f ListResources
listResources_resourceArns = (ListResources -> Maybe [Text])
-> (ListResources -> Maybe [Text] -> ListResources)
-> Lens ListResources ListResources (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe [Text]
resourceArns :: Maybe [Text]
$sel:resourceArns:ListResources' :: ListResources -> Maybe [Text]
resourceArns} -> Maybe [Text]
resourceArns) (\s :: ListResources
s@ListResources' {} Maybe [Text]
a -> ListResources
s {$sel:resourceArns:ListResources' :: Maybe [Text]
resourceArns = Maybe [Text]
a} :: ListResources) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListResources -> f ListResources)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListResources
-> f ListResources
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 principal.
listResources_principal :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Text)
listResources_principal :: (Maybe Text -> f (Maybe Text)) -> ListResources -> f ListResources
listResources_principal = (ListResources -> Maybe Text)
-> (ListResources -> Maybe Text -> ListResources)
-> Lens ListResources ListResources (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Text
principal :: Maybe Text
$sel:principal:ListResources' :: ListResources -> Maybe Text
principal} -> Maybe Text
principal) (\s :: ListResources
s@ListResources' {} Maybe Text
a -> ListResources
s {$sel:principal:ListResources' :: Maybe Text
principal = Maybe Text
a} :: ListResources)

-- | The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
listResources_maxResults :: Lens.Lens' ListResources (Prelude.Maybe Prelude.Natural)
listResources_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListResources -> f ListResources
listResources_maxResults = (ListResources -> Maybe Natural)
-> (ListResources -> Maybe Natural -> ListResources)
-> Lens ListResources ListResources (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListResources
s@ListResources' {} Maybe Natural
a -> ListResources
s {$sel:maxResults:ListResources' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListResources)

-- | The Amazon Resource Names (ARN) of the resource shares.
listResources_resourceShareArns :: Lens.Lens' ListResources (Prelude.Maybe [Prelude.Text])
listResources_resourceShareArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ListResources -> f ListResources
listResources_resourceShareArns = (ListResources -> Maybe [Text])
-> (ListResources -> Maybe [Text] -> ListResources)
-> Lens ListResources ListResources (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {Maybe [Text]
resourceShareArns :: Maybe [Text]
$sel:resourceShareArns:ListResources' :: ListResources -> Maybe [Text]
resourceShareArns} -> Maybe [Text]
resourceShareArns) (\s :: ListResources
s@ListResources' {} Maybe [Text]
a -> ListResources
s {$sel:resourceShareArns:ListResources' :: Maybe [Text]
resourceShareArns = Maybe [Text]
a} :: ListResources) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListResources -> f ListResources)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListResources
-> f ListResources
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 type of owner.
listResources_resourceOwner :: Lens.Lens' ListResources ResourceOwner
listResources_resourceOwner :: (ResourceOwner -> f ResourceOwner)
-> ListResources -> f ListResources
listResources_resourceOwner = (ListResources -> ResourceOwner)
-> (ListResources -> ResourceOwner -> ListResources)
-> Lens ListResources ListResources ResourceOwner ResourceOwner
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResources' {ResourceOwner
resourceOwner :: ResourceOwner
$sel:resourceOwner:ListResources' :: ListResources -> ResourceOwner
resourceOwner} -> ResourceOwner
resourceOwner) (\s :: ListResources
s@ListResources' {} ResourceOwner
a -> ListResources
s {$sel:resourceOwner:ListResources' :: ResourceOwner
resourceOwner = ResourceOwner
a} :: ListResources)

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

instance Prelude.NFData ListResources

instance Core.ToHeaders ListResources where
  toHeaders :: ListResources -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListResources -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 ListResources where
  toJSON :: ListResources -> Value
toJSON ListResources' {Maybe Natural
Maybe [Text]
Maybe Text
ResourceOwner
resourceOwner :: ResourceOwner
resourceShareArns :: Maybe [Text]
maxResults :: Maybe Natural
principal :: Maybe Text
resourceArns :: Maybe [Text]
nextToken :: Maybe Text
resourceType :: Maybe Text
$sel:resourceOwner:ListResources' :: ListResources -> ResourceOwner
$sel:resourceShareArns:ListResources' :: ListResources -> Maybe [Text]
$sel:maxResults:ListResources' :: ListResources -> Maybe Natural
$sel:principal:ListResources' :: ListResources -> Maybe Text
$sel:resourceArns:ListResources' :: ListResources -> Maybe [Text]
$sel:nextToken:ListResources' :: ListResources -> Maybe Text
$sel:resourceType:ListResources' :: ListResources -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"resourceType" 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
resourceType,
            (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
"resourceArns" 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]
resourceArns,
            (Text
"principal" 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
principal,
            (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,
            (Text
"resourceShareArns" 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]
resourceShareArns,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"resourceOwner" Text -> ResourceOwner -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceOwner
resourceOwner)
          ]
      )

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

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

-- | /See:/ 'newListResourcesResponse' smart constructor.
data ListResourcesResponse = ListResourcesResponse'
  { -- | Information about the resources.
    ListResourcesResponse -> Maybe [Resource]
resources :: Prelude.Maybe [Resource],
    -- | The token to use to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    ListResourcesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListResourcesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListResourcesResponse -> ListResourcesResponse -> Bool
(ListResourcesResponse -> ListResourcesResponse -> Bool)
-> (ListResourcesResponse -> ListResourcesResponse -> Bool)
-> Eq ListResourcesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourcesResponse -> ListResourcesResponse -> Bool
$c/= :: ListResourcesResponse -> ListResourcesResponse -> Bool
== :: ListResourcesResponse -> ListResourcesResponse -> Bool
$c== :: ListResourcesResponse -> ListResourcesResponse -> Bool
Prelude.Eq, ReadPrec [ListResourcesResponse]
ReadPrec ListResourcesResponse
Int -> ReadS ListResourcesResponse
ReadS [ListResourcesResponse]
(Int -> ReadS ListResourcesResponse)
-> ReadS [ListResourcesResponse]
-> ReadPrec ListResourcesResponse
-> ReadPrec [ListResourcesResponse]
-> Read ListResourcesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourcesResponse]
$creadListPrec :: ReadPrec [ListResourcesResponse]
readPrec :: ReadPrec ListResourcesResponse
$creadPrec :: ReadPrec ListResourcesResponse
readList :: ReadS [ListResourcesResponse]
$creadList :: ReadS [ListResourcesResponse]
readsPrec :: Int -> ReadS ListResourcesResponse
$creadsPrec :: Int -> ReadS ListResourcesResponse
Prelude.Read, Int -> ListResourcesResponse -> ShowS
[ListResourcesResponse] -> ShowS
ListResourcesResponse -> String
(Int -> ListResourcesResponse -> ShowS)
-> (ListResourcesResponse -> String)
-> ([ListResourcesResponse] -> ShowS)
-> Show ListResourcesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourcesResponse] -> ShowS
$cshowList :: [ListResourcesResponse] -> ShowS
show :: ListResourcesResponse -> String
$cshow :: ListResourcesResponse -> String
showsPrec :: Int -> ListResourcesResponse -> ShowS
$cshowsPrec :: Int -> ListResourcesResponse -> ShowS
Prelude.Show, (forall x. ListResourcesResponse -> Rep ListResourcesResponse x)
-> (forall x. Rep ListResourcesResponse x -> ListResourcesResponse)
-> Generic ListResourcesResponse
forall x. Rep ListResourcesResponse x -> ListResourcesResponse
forall x. ListResourcesResponse -> Rep ListResourcesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResourcesResponse x -> ListResourcesResponse
$cfrom :: forall x. ListResourcesResponse -> Rep ListResourcesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListResourcesResponse' 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:
--
-- 'resources', 'listResourcesResponse_resources' - Information about the resources.
--
-- 'nextToken', 'listResourcesResponse_nextToken' - The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
--
-- 'httpStatus', 'listResourcesResponse_httpStatus' - The response's http status code.
newListResourcesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListResourcesResponse
newListResourcesResponse :: Int -> ListResourcesResponse
newListResourcesResponse Int
pHttpStatus_ =
  ListResourcesResponse' :: Maybe [Resource] -> Maybe Text -> Int -> ListResourcesResponse
ListResourcesResponse'
    { $sel:resources:ListResourcesResponse' :: Maybe [Resource]
resources = Maybe [Resource]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListResourcesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListResourcesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the resources.
listResourcesResponse_resources :: Lens.Lens' ListResourcesResponse (Prelude.Maybe [Resource])
listResourcesResponse_resources :: (Maybe [Resource] -> f (Maybe [Resource]))
-> ListResourcesResponse -> f ListResourcesResponse
listResourcesResponse_resources = (ListResourcesResponse -> Maybe [Resource])
-> (ListResourcesResponse
    -> Maybe [Resource] -> ListResourcesResponse)
-> Lens' ListResourcesResponse (Maybe [Resource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesResponse' {Maybe [Resource]
resources :: Maybe [Resource]
$sel:resources:ListResourcesResponse' :: ListResourcesResponse -> Maybe [Resource]
resources} -> Maybe [Resource]
resources) (\s :: ListResourcesResponse
s@ListResourcesResponse' {} Maybe [Resource]
a -> ListResourcesResponse
s {$sel:resources:ListResourcesResponse' :: Maybe [Resource]
resources = Maybe [Resource]
a} :: ListResourcesResponse) ((Maybe [Resource] -> f (Maybe [Resource]))
 -> ListResourcesResponse -> f ListResourcesResponse)
-> ((Maybe [Resource] -> f (Maybe [Resource]))
    -> Maybe [Resource] -> f (Maybe [Resource]))
-> (Maybe [Resource] -> f (Maybe [Resource]))
-> ListResourcesResponse
-> f ListResourcesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Resource] [Resource] [Resource] [Resource]
-> Iso
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
     (Maybe [Resource])
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 [Resource] [Resource] [Resource] [Resource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
listResourcesResponse_nextToken :: Lens.Lens' ListResourcesResponse (Prelude.Maybe Prelude.Text)
listResourcesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListResourcesResponse -> f ListResourcesResponse
listResourcesResponse_nextToken = (ListResourcesResponse -> Maybe Text)
-> (ListResourcesResponse -> Maybe Text -> ListResourcesResponse)
-> Lens' ListResourcesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourcesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResourcesResponse' :: ListResourcesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResourcesResponse
s@ListResourcesResponse' {} Maybe Text
a -> ListResourcesResponse
s {$sel:nextToken:ListResourcesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListResourcesResponse)

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

instance Prelude.NFData ListResourcesResponse