{-# 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.GetResourceShareInvitations
-- 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 invitations that you have received for resource shares.
--
-- This operation returns paginated results.
module Amazonka.RAM.GetResourceShareInvitations
  ( -- * Creating a Request
    GetResourceShareInvitations (..),
    newGetResourceShareInvitations,

    -- * Request Lenses
    getResourceShareInvitations_nextToken,
    getResourceShareInvitations_resourceShareInvitationArns,
    getResourceShareInvitations_maxResults,
    getResourceShareInvitations_resourceShareArns,

    -- * Destructuring the Response
    GetResourceShareInvitationsResponse (..),
    newGetResourceShareInvitationsResponse,

    -- * Response Lenses
    getResourceShareInvitationsResponse_resourceShareInvitations,
    getResourceShareInvitationsResponse_nextToken,
    getResourceShareInvitationsResponse_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:/ 'newGetResourceShareInvitations' smart constructor.
data GetResourceShareInvitations = GetResourceShareInvitations'
  { -- | The token for the next page of results.
    GetResourceShareInvitations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Names (ARN) of the invitations.
    GetResourceShareInvitations -> Maybe [Text]
resourceShareInvitationArns :: 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.
    GetResourceShareInvitations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Names (ARN) of the resource shares.
    GetResourceShareInvitations -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text]
  }
  deriving (GetResourceShareInvitations -> GetResourceShareInvitations -> Bool
(GetResourceShareInvitations
 -> GetResourceShareInvitations -> Bool)
-> (GetResourceShareInvitations
    -> GetResourceShareInvitations -> Bool)
-> Eq GetResourceShareInvitations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceShareInvitations -> GetResourceShareInvitations -> Bool
$c/= :: GetResourceShareInvitations -> GetResourceShareInvitations -> Bool
== :: GetResourceShareInvitations -> GetResourceShareInvitations -> Bool
$c== :: GetResourceShareInvitations -> GetResourceShareInvitations -> Bool
Prelude.Eq, ReadPrec [GetResourceShareInvitations]
ReadPrec GetResourceShareInvitations
Int -> ReadS GetResourceShareInvitations
ReadS [GetResourceShareInvitations]
(Int -> ReadS GetResourceShareInvitations)
-> ReadS [GetResourceShareInvitations]
-> ReadPrec GetResourceShareInvitations
-> ReadPrec [GetResourceShareInvitations]
-> Read GetResourceShareInvitations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceShareInvitations]
$creadListPrec :: ReadPrec [GetResourceShareInvitations]
readPrec :: ReadPrec GetResourceShareInvitations
$creadPrec :: ReadPrec GetResourceShareInvitations
readList :: ReadS [GetResourceShareInvitations]
$creadList :: ReadS [GetResourceShareInvitations]
readsPrec :: Int -> ReadS GetResourceShareInvitations
$creadsPrec :: Int -> ReadS GetResourceShareInvitations
Prelude.Read, Int -> GetResourceShareInvitations -> ShowS
[GetResourceShareInvitations] -> ShowS
GetResourceShareInvitations -> String
(Int -> GetResourceShareInvitations -> ShowS)
-> (GetResourceShareInvitations -> String)
-> ([GetResourceShareInvitations] -> ShowS)
-> Show GetResourceShareInvitations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceShareInvitations] -> ShowS
$cshowList :: [GetResourceShareInvitations] -> ShowS
show :: GetResourceShareInvitations -> String
$cshow :: GetResourceShareInvitations -> String
showsPrec :: Int -> GetResourceShareInvitations -> ShowS
$cshowsPrec :: Int -> GetResourceShareInvitations -> ShowS
Prelude.Show, (forall x.
 GetResourceShareInvitations -> Rep GetResourceShareInvitations x)
-> (forall x.
    Rep GetResourceShareInvitations x -> GetResourceShareInvitations)
-> Generic GetResourceShareInvitations
forall x.
Rep GetResourceShareInvitations x -> GetResourceShareInvitations
forall x.
GetResourceShareInvitations -> Rep GetResourceShareInvitations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResourceShareInvitations x -> GetResourceShareInvitations
$cfrom :: forall x.
GetResourceShareInvitations -> Rep GetResourceShareInvitations x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceShareInvitations' 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', 'getResourceShareInvitations_nextToken' - The token for the next page of results.
--
-- 'resourceShareInvitationArns', 'getResourceShareInvitations_resourceShareInvitationArns' - The Amazon Resource Names (ARN) of the invitations.
--
-- 'maxResults', 'getResourceShareInvitations_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', 'getResourceShareInvitations_resourceShareArns' - The Amazon Resource Names (ARN) of the resource shares.
newGetResourceShareInvitations ::
  GetResourceShareInvitations
newGetResourceShareInvitations :: GetResourceShareInvitations
newGetResourceShareInvitations =
  GetResourceShareInvitations' :: Maybe Text
-> Maybe [Text]
-> Maybe Natural
-> Maybe [Text]
-> GetResourceShareInvitations
GetResourceShareInvitations'
    { $sel:nextToken:GetResourceShareInvitations' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareInvitationArns:GetResourceShareInvitations' :: Maybe [Text]
resourceShareInvitationArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetResourceShareInvitations' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:GetResourceShareInvitations' :: Maybe [Text]
resourceShareArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The Amazon Resource Names (ARN) of the invitations.
getResourceShareInvitations_resourceShareInvitationArns :: Lens.Lens' GetResourceShareInvitations (Prelude.Maybe [Prelude.Text])
getResourceShareInvitations_resourceShareInvitationArns :: (Maybe [Text] -> f (Maybe [Text]))
-> GetResourceShareInvitations -> f GetResourceShareInvitations
getResourceShareInvitations_resourceShareInvitationArns = (GetResourceShareInvitations -> Maybe [Text])
-> (GetResourceShareInvitations
    -> Maybe [Text] -> GetResourceShareInvitations)
-> Lens
     GetResourceShareInvitations
     GetResourceShareInvitations
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareInvitations' {Maybe [Text]
resourceShareInvitationArns :: Maybe [Text]
$sel:resourceShareInvitationArns:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe [Text]
resourceShareInvitationArns} -> Maybe [Text]
resourceShareInvitationArns) (\s :: GetResourceShareInvitations
s@GetResourceShareInvitations' {} Maybe [Text]
a -> GetResourceShareInvitations
s {$sel:resourceShareInvitationArns:GetResourceShareInvitations' :: Maybe [Text]
resourceShareInvitationArns = Maybe [Text]
a} :: GetResourceShareInvitations) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetResourceShareInvitations -> f GetResourceShareInvitations)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetResourceShareInvitations
-> f GetResourceShareInvitations
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 maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
getResourceShareInvitations_maxResults :: Lens.Lens' GetResourceShareInvitations (Prelude.Maybe Prelude.Natural)
getResourceShareInvitations_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> GetResourceShareInvitations -> f GetResourceShareInvitations
getResourceShareInvitations_maxResults = (GetResourceShareInvitations -> Maybe Natural)
-> (GetResourceShareInvitations
    -> Maybe Natural -> GetResourceShareInvitations)
-> Lens
     GetResourceShareInvitations
     GetResourceShareInvitations
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareInvitations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetResourceShareInvitations
s@GetResourceShareInvitations' {} Maybe Natural
a -> GetResourceShareInvitations
s {$sel:maxResults:GetResourceShareInvitations' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetResourceShareInvitations)

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

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

instance Prelude.NFData GetResourceShareInvitations

instance Core.ToHeaders GetResourceShareInvitations where
  toHeaders :: GetResourceShareInvitations -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResourceShareInvitations -> 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 GetResourceShareInvitations where
  toJSON :: GetResourceShareInvitations -> Value
toJSON GetResourceShareInvitations' {Maybe Natural
Maybe [Text]
Maybe Text
resourceShareArns :: Maybe [Text]
maxResults :: Maybe Natural
resourceShareInvitationArns :: Maybe [Text]
nextToken :: Maybe Text
$sel:resourceShareArns:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe [Text]
$sel:maxResults:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe Natural
$sel:resourceShareInvitationArns:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe [Text]
$sel:nextToken:GetResourceShareInvitations' :: GetResourceShareInvitations -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"resourceShareInvitationArns" 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]
resourceShareInvitationArns,
            (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
          ]
      )

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

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

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

-- |
-- Create a value of 'GetResourceShareInvitationsResponse' 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:
--
-- 'resourceShareInvitations', 'getResourceShareInvitationsResponse_resourceShareInvitations' - Information about the invitations.
--
-- 'nextToken', 'getResourceShareInvitationsResponse_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', 'getResourceShareInvitationsResponse_httpStatus' - The response's http status code.
newGetResourceShareInvitationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceShareInvitationsResponse
newGetResourceShareInvitationsResponse :: Int -> GetResourceShareInvitationsResponse
newGetResourceShareInvitationsResponse Int
pHttpStatus_ =
  GetResourceShareInvitationsResponse' :: Maybe [ResourceShareInvitation]
-> Maybe Text -> Int -> GetResourceShareInvitationsResponse
GetResourceShareInvitationsResponse'
    { $sel:resourceShareInvitations:GetResourceShareInvitationsResponse' :: Maybe [ResourceShareInvitation]
resourceShareInvitations =
        Maybe [ResourceShareInvitation]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceShareInvitationsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceShareInvitationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the invitations.
getResourceShareInvitationsResponse_resourceShareInvitations :: Lens.Lens' GetResourceShareInvitationsResponse (Prelude.Maybe [ResourceShareInvitation])
getResourceShareInvitationsResponse_resourceShareInvitations :: (Maybe [ResourceShareInvitation]
 -> f (Maybe [ResourceShareInvitation]))
-> GetResourceShareInvitationsResponse
-> f GetResourceShareInvitationsResponse
getResourceShareInvitationsResponse_resourceShareInvitations = (GetResourceShareInvitationsResponse
 -> Maybe [ResourceShareInvitation])
-> (GetResourceShareInvitationsResponse
    -> Maybe [ResourceShareInvitation]
    -> GetResourceShareInvitationsResponse)
-> Lens'
     GetResourceShareInvitationsResponse
     (Maybe [ResourceShareInvitation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareInvitationsResponse' {Maybe [ResourceShareInvitation]
resourceShareInvitations :: Maybe [ResourceShareInvitation]
$sel:resourceShareInvitations:GetResourceShareInvitationsResponse' :: GetResourceShareInvitationsResponse
-> Maybe [ResourceShareInvitation]
resourceShareInvitations} -> Maybe [ResourceShareInvitation]
resourceShareInvitations) (\s :: GetResourceShareInvitationsResponse
s@GetResourceShareInvitationsResponse' {} Maybe [ResourceShareInvitation]
a -> GetResourceShareInvitationsResponse
s {$sel:resourceShareInvitations:GetResourceShareInvitationsResponse' :: Maybe [ResourceShareInvitation]
resourceShareInvitations = Maybe [ResourceShareInvitation]
a} :: GetResourceShareInvitationsResponse) ((Maybe [ResourceShareInvitation]
  -> f (Maybe [ResourceShareInvitation]))
 -> GetResourceShareInvitationsResponse
 -> f GetResourceShareInvitationsResponse)
-> ((Maybe [ResourceShareInvitation]
     -> f (Maybe [ResourceShareInvitation]))
    -> Maybe [ResourceShareInvitation]
    -> f (Maybe [ResourceShareInvitation]))
-> (Maybe [ResourceShareInvitation]
    -> f (Maybe [ResourceShareInvitation]))
-> GetResourceShareInvitationsResponse
-> f GetResourceShareInvitationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceShareInvitation]
  [ResourceShareInvitation]
  [ResourceShareInvitation]
  [ResourceShareInvitation]
-> Iso
     (Maybe [ResourceShareInvitation])
     (Maybe [ResourceShareInvitation])
     (Maybe [ResourceShareInvitation])
     (Maybe [ResourceShareInvitation])
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
  [ResourceShareInvitation]
  [ResourceShareInvitation]
  [ResourceShareInvitation]
  [ResourceShareInvitation]
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.
getResourceShareInvitationsResponse_nextToken :: Lens.Lens' GetResourceShareInvitationsResponse (Prelude.Maybe Prelude.Text)
getResourceShareInvitationsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetResourceShareInvitationsResponse
-> f GetResourceShareInvitationsResponse
getResourceShareInvitationsResponse_nextToken = (GetResourceShareInvitationsResponse -> Maybe Text)
-> (GetResourceShareInvitationsResponse
    -> Maybe Text -> GetResourceShareInvitationsResponse)
-> Lens' GetResourceShareInvitationsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareInvitationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceShareInvitationsResponse' :: GetResourceShareInvitationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceShareInvitationsResponse
s@GetResourceShareInvitationsResponse' {} Maybe Text
a -> GetResourceShareInvitationsResponse
s {$sel:nextToken:GetResourceShareInvitationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceShareInvitationsResponse)

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

instance
  Prelude.NFData
    GetResourceShareInvitationsResponse