{-# 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.GetResourceShares
-- 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)
--
-- Gets the resource shares that you own or the resource shares that are
-- shared with you.
--
-- This operation returns paginated results.
module Amazonka.RAM.GetResourceShares
  ( -- * Creating a Request
    GetResourceShares (..),
    newGetResourceShares,

    -- * Request Lenses
    getResourceShares_tagFilters,
    getResourceShares_nextToken,
    getResourceShares_name,
    getResourceShares_resourceShareStatus,
    getResourceShares_permissionArn,
    getResourceShares_maxResults,
    getResourceShares_resourceShareArns,
    getResourceShares_resourceOwner,

    -- * Destructuring the Response
    GetResourceSharesResponse (..),
    newGetResourceSharesResponse,

    -- * Response Lenses
    getResourceSharesResponse_resourceShares,
    getResourceSharesResponse_nextToken,
    getResourceSharesResponse_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:/ 'newGetResourceShares' smart constructor.
data GetResourceShares = GetResourceShares'
  { -- | One or more tag filters.
    GetResourceShares -> Maybe [TagFilter]
tagFilters :: Prelude.Maybe [TagFilter],
    -- | The token for the next page of results.
    GetResourceShares -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource share.
    GetResourceShares -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The status of the resource share.
    GetResourceShares -> Maybe ResourceShareStatus
resourceShareStatus :: Prelude.Maybe ResourceShareStatus,
    -- | The Amazon Resource Name (ARN) of the RAM permission that is associated
    -- with the resource share.
    GetResourceShares -> Maybe Text
permissionArn :: 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.
    GetResourceShares -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Names (ARNs) of the resource shares.
    GetResourceShares -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | The type of owner.
    GetResourceShares -> ResourceOwner
resourceOwner :: ResourceOwner
  }
  deriving (GetResourceShares -> GetResourceShares -> Bool
(GetResourceShares -> GetResourceShares -> Bool)
-> (GetResourceShares -> GetResourceShares -> Bool)
-> Eq GetResourceShares
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceShares -> GetResourceShares -> Bool
$c/= :: GetResourceShares -> GetResourceShares -> Bool
== :: GetResourceShares -> GetResourceShares -> Bool
$c== :: GetResourceShares -> GetResourceShares -> Bool
Prelude.Eq, ReadPrec [GetResourceShares]
ReadPrec GetResourceShares
Int -> ReadS GetResourceShares
ReadS [GetResourceShares]
(Int -> ReadS GetResourceShares)
-> ReadS [GetResourceShares]
-> ReadPrec GetResourceShares
-> ReadPrec [GetResourceShares]
-> Read GetResourceShares
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceShares]
$creadListPrec :: ReadPrec [GetResourceShares]
readPrec :: ReadPrec GetResourceShares
$creadPrec :: ReadPrec GetResourceShares
readList :: ReadS [GetResourceShares]
$creadList :: ReadS [GetResourceShares]
readsPrec :: Int -> ReadS GetResourceShares
$creadsPrec :: Int -> ReadS GetResourceShares
Prelude.Read, Int -> GetResourceShares -> ShowS
[GetResourceShares] -> ShowS
GetResourceShares -> String
(Int -> GetResourceShares -> ShowS)
-> (GetResourceShares -> String)
-> ([GetResourceShares] -> ShowS)
-> Show GetResourceShares
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceShares] -> ShowS
$cshowList :: [GetResourceShares] -> ShowS
show :: GetResourceShares -> String
$cshow :: GetResourceShares -> String
showsPrec :: Int -> GetResourceShares -> ShowS
$cshowsPrec :: Int -> GetResourceShares -> ShowS
Prelude.Show, (forall x. GetResourceShares -> Rep GetResourceShares x)
-> (forall x. Rep GetResourceShares x -> GetResourceShares)
-> Generic GetResourceShares
forall x. Rep GetResourceShares x -> GetResourceShares
forall x. GetResourceShares -> Rep GetResourceShares x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResourceShares x -> GetResourceShares
$cfrom :: forall x. GetResourceShares -> Rep GetResourceShares x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceShares' 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:
--
-- 'tagFilters', 'getResourceShares_tagFilters' - One or more tag filters.
--
-- 'nextToken', 'getResourceShares_nextToken' - The token for the next page of results.
--
-- 'name', 'getResourceShares_name' - The name of the resource share.
--
-- 'resourceShareStatus', 'getResourceShares_resourceShareStatus' - The status of the resource share.
--
-- 'permissionArn', 'getResourceShares_permissionArn' - The Amazon Resource Name (ARN) of the RAM permission that is associated
-- with the resource share.
--
-- 'maxResults', 'getResourceShares_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', 'getResourceShares_resourceShareArns' - The Amazon Resource Names (ARNs) of the resource shares.
--
-- 'resourceOwner', 'getResourceShares_resourceOwner' - The type of owner.
newGetResourceShares ::
  -- | 'resourceOwner'
  ResourceOwner ->
  GetResourceShares
newGetResourceShares :: ResourceOwner -> GetResourceShares
newGetResourceShares ResourceOwner
pResourceOwner_ =
  GetResourceShares' :: Maybe [TagFilter]
-> Maybe Text
-> Maybe Text
-> Maybe ResourceShareStatus
-> Maybe Text
-> Maybe Natural
-> Maybe [Text]
-> ResourceOwner
-> GetResourceShares
GetResourceShares'
    { $sel:tagFilters:GetResourceShares' :: Maybe [TagFilter]
tagFilters = Maybe [TagFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceShares' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetResourceShares' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareStatus:GetResourceShares' :: Maybe ResourceShareStatus
resourceShareStatus = Maybe ResourceShareStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:permissionArn:GetResourceShares' :: Maybe Text
permissionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetResourceShares' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:GetResourceShares' :: Maybe [Text]
resourceShareArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceOwner:GetResourceShares' :: ResourceOwner
resourceOwner = ResourceOwner
pResourceOwner_
    }

-- | One or more tag filters.
getResourceShares_tagFilters :: Lens.Lens' GetResourceShares (Prelude.Maybe [TagFilter])
getResourceShares_tagFilters :: (Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> GetResourceShares -> f GetResourceShares
getResourceShares_tagFilters = (GetResourceShares -> Maybe [TagFilter])
-> (GetResourceShares -> Maybe [TagFilter] -> GetResourceShares)
-> Lens
     GetResourceShares
     GetResourceShares
     (Maybe [TagFilter])
     (Maybe [TagFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe [TagFilter]
tagFilters :: Maybe [TagFilter]
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
tagFilters} -> Maybe [TagFilter]
tagFilters) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe [TagFilter]
a -> GetResourceShares
s {$sel:tagFilters:GetResourceShares' :: Maybe [TagFilter]
tagFilters = Maybe [TagFilter]
a} :: GetResourceShares) ((Maybe [TagFilter] -> f (Maybe [TagFilter]))
 -> GetResourceShares -> f GetResourceShares)
-> ((Maybe [TagFilter] -> f (Maybe [TagFilter]))
    -> Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> (Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> GetResourceShares
-> f GetResourceShares
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TagFilter] [TagFilter] [TagFilter] [TagFilter]
-> Iso
     (Maybe [TagFilter])
     (Maybe [TagFilter])
     (Maybe [TagFilter])
     (Maybe [TagFilter])
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 [TagFilter] [TagFilter] [TagFilter] [TagFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The name of the resource share.
getResourceShares_name :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Text)
getResourceShares_name :: (Maybe Text -> f (Maybe Text))
-> GetResourceShares -> f GetResourceShares
getResourceShares_name = (GetResourceShares -> Maybe Text)
-> (GetResourceShares -> Maybe Text -> GetResourceShares)
-> Lens
     GetResourceShares GetResourceShares (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Text
name :: Maybe Text
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
name} -> Maybe Text
name) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Text
a -> GetResourceShares
s {$sel:name:GetResourceShares' :: Maybe Text
name = Maybe Text
a} :: GetResourceShares)

-- | The status of the resource share.
getResourceShares_resourceShareStatus :: Lens.Lens' GetResourceShares (Prelude.Maybe ResourceShareStatus)
getResourceShares_resourceShareStatus :: (Maybe ResourceShareStatus -> f (Maybe ResourceShareStatus))
-> GetResourceShares -> f GetResourceShares
getResourceShares_resourceShareStatus = (GetResourceShares -> Maybe ResourceShareStatus)
-> (GetResourceShares
    -> Maybe ResourceShareStatus -> GetResourceShares)
-> Lens
     GetResourceShares
     GetResourceShares
     (Maybe ResourceShareStatus)
     (Maybe ResourceShareStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe ResourceShareStatus
resourceShareStatus :: Maybe ResourceShareStatus
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
resourceShareStatus} -> Maybe ResourceShareStatus
resourceShareStatus) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe ResourceShareStatus
a -> GetResourceShares
s {$sel:resourceShareStatus:GetResourceShares' :: Maybe ResourceShareStatus
resourceShareStatus = Maybe ResourceShareStatus
a} :: GetResourceShares)

-- | The Amazon Resource Name (ARN) of the RAM permission that is associated
-- with the resource share.
getResourceShares_permissionArn :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Text)
getResourceShares_permissionArn :: (Maybe Text -> f (Maybe Text))
-> GetResourceShares -> f GetResourceShares
getResourceShares_permissionArn = (GetResourceShares -> Maybe Text)
-> (GetResourceShares -> Maybe Text -> GetResourceShares)
-> Lens
     GetResourceShares GetResourceShares (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Text
permissionArn :: Maybe Text
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
permissionArn} -> Maybe Text
permissionArn) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Text
a -> GetResourceShares
s {$sel:permissionArn:GetResourceShares' :: Maybe Text
permissionArn = Maybe Text
a} :: GetResourceShares)

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

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

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

instance Prelude.NFData GetResourceShares

instance Core.ToHeaders GetResourceShares where
  toHeaders :: GetResourceShares -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResourceShares -> 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 GetResourceShares where
  toJSON :: GetResourceShares -> Value
toJSON GetResourceShares' {Maybe Natural
Maybe [Text]
Maybe [TagFilter]
Maybe Text
Maybe ResourceShareStatus
ResourceOwner
resourceOwner :: ResourceOwner
resourceShareArns :: Maybe [Text]
maxResults :: Maybe Natural
permissionArn :: Maybe Text
resourceShareStatus :: Maybe ResourceShareStatus
name :: Maybe Text
nextToken :: Maybe Text
tagFilters :: Maybe [TagFilter]
$sel:resourceOwner:GetResourceShares' :: GetResourceShares -> ResourceOwner
$sel:resourceShareArns:GetResourceShares' :: GetResourceShares -> Maybe [Text]
$sel:maxResults:GetResourceShares' :: GetResourceShares -> Maybe Natural
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:nextToken:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"tagFilters" Text -> [TagFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([TagFilter] -> Pair) -> Maybe [TagFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagFilter]
tagFilters,
            (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
"name" 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
name,
            (Text
"resourceShareStatus" Text -> ResourceShareStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ResourceShareStatus -> Pair)
-> Maybe ResourceShareStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceShareStatus
resourceShareStatus,
            (Text
"permissionArn" 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
permissionArn,
            (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 GetResourceShares where
  toPath :: GetResourceShares -> ByteString
toPath = ByteString -> GetResourceShares -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/getresourceshares"

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

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

-- |
-- Create a value of 'GetResourceSharesResponse' 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:
--
-- 'resourceShares', 'getResourceSharesResponse_resourceShares' - Information about the resource shares.
--
-- 'nextToken', 'getResourceSharesResponse_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', 'getResourceSharesResponse_httpStatus' - The response's http status code.
newGetResourceSharesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceSharesResponse
newGetResourceSharesResponse :: Int -> GetResourceSharesResponse
newGetResourceSharesResponse Int
pHttpStatus_ =
  GetResourceSharesResponse' :: Maybe [ResourceShare]
-> Maybe Text -> Int -> GetResourceSharesResponse
GetResourceSharesResponse'
    { $sel:resourceShares:GetResourceSharesResponse' :: Maybe [ResourceShare]
resourceShares =
        Maybe [ResourceShare]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceSharesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceSharesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the resource shares.
getResourceSharesResponse_resourceShares :: Lens.Lens' GetResourceSharesResponse (Prelude.Maybe [ResourceShare])
getResourceSharesResponse_resourceShares :: (Maybe [ResourceShare] -> f (Maybe [ResourceShare]))
-> GetResourceSharesResponse -> f GetResourceSharesResponse
getResourceSharesResponse_resourceShares = (GetResourceSharesResponse -> Maybe [ResourceShare])
-> (GetResourceSharesResponse
    -> Maybe [ResourceShare] -> GetResourceSharesResponse)
-> Lens' GetResourceSharesResponse (Maybe [ResourceShare])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceSharesResponse' {Maybe [ResourceShare]
resourceShares :: Maybe [ResourceShare]
$sel:resourceShares:GetResourceSharesResponse' :: GetResourceSharesResponse -> Maybe [ResourceShare]
resourceShares} -> Maybe [ResourceShare]
resourceShares) (\s :: GetResourceSharesResponse
s@GetResourceSharesResponse' {} Maybe [ResourceShare]
a -> GetResourceSharesResponse
s {$sel:resourceShares:GetResourceSharesResponse' :: Maybe [ResourceShare]
resourceShares = Maybe [ResourceShare]
a} :: GetResourceSharesResponse) ((Maybe [ResourceShare] -> f (Maybe [ResourceShare]))
 -> GetResourceSharesResponse -> f GetResourceSharesResponse)
-> ((Maybe [ResourceShare] -> f (Maybe [ResourceShare]))
    -> Maybe [ResourceShare] -> f (Maybe [ResourceShare]))
-> (Maybe [ResourceShare] -> f (Maybe [ResourceShare]))
-> GetResourceSharesResponse
-> f GetResourceSharesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceShare] [ResourceShare] [ResourceShare] [ResourceShare]
-> Iso
     (Maybe [ResourceShare])
     (Maybe [ResourceShare])
     (Maybe [ResourceShare])
     (Maybe [ResourceShare])
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
  [ResourceShare] [ResourceShare] [ResourceShare] [ResourceShare]
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.
getResourceSharesResponse_nextToken :: Lens.Lens' GetResourceSharesResponse (Prelude.Maybe Prelude.Text)
getResourceSharesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetResourceSharesResponse -> f GetResourceSharesResponse
getResourceSharesResponse_nextToken = (GetResourceSharesResponse -> Maybe Text)
-> (GetResourceSharesResponse
    -> Maybe Text -> GetResourceSharesResponse)
-> Lens' GetResourceSharesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceSharesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceSharesResponse' :: GetResourceSharesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceSharesResponse
s@GetResourceSharesResponse' {} Maybe Text
a -> GetResourceSharesResponse
s {$sel:nextToken:GetResourceSharesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceSharesResponse)

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

instance Prelude.NFData GetResourceSharesResponse