{-# 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.GetResourceShareAssociations
-- 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 resources or principals for the resource shares that you own.
--
-- This operation returns paginated results.
module Amazonka.RAM.GetResourceShareAssociations
  ( -- * Creating a Request
    GetResourceShareAssociations (..),
    newGetResourceShareAssociations,

    -- * Request Lenses
    getResourceShareAssociations_nextToken,
    getResourceShareAssociations_resourceArn,
    getResourceShareAssociations_principal,
    getResourceShareAssociations_associationStatus,
    getResourceShareAssociations_maxResults,
    getResourceShareAssociations_resourceShareArns,
    getResourceShareAssociations_associationType,

    -- * Destructuring the Response
    GetResourceShareAssociationsResponse (..),
    newGetResourceShareAssociationsResponse,

    -- * Response Lenses
    getResourceShareAssociationsResponse_resourceShareAssociations,
    getResourceShareAssociationsResponse_nextToken,
    getResourceShareAssociationsResponse_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:/ 'newGetResourceShareAssociations' smart constructor.
data GetResourceShareAssociations = GetResourceShareAssociations'
  { -- | The token for the next page of results.
    GetResourceShareAssociations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the resource. You cannot specify this
    -- parameter if the association type is @PRINCIPAL@.
    GetResourceShareAssociations -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The principal. You cannot specify this parameter if the association type
    -- is @RESOURCE@.
    GetResourceShareAssociations -> Maybe Text
principal :: Prelude.Maybe Prelude.Text,
    -- | The association status.
    GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
associationStatus :: Prelude.Maybe ResourceShareAssociationStatus,
    -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    GetResourceShareAssociations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Names (ARN) of the resource shares.
    GetResourceShareAssociations -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | The association type. Specify @PRINCIPAL@ to list the principals that
    -- are associated with the specified resource share. Specify @RESOURCE@ to
    -- list the resources that are associated with the specified resource
    -- share.
    GetResourceShareAssociations -> ResourceShareAssociationType
associationType :: ResourceShareAssociationType
  }
  deriving (GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
(GetResourceShareAssociations
 -> GetResourceShareAssociations -> Bool)
-> (GetResourceShareAssociations
    -> GetResourceShareAssociations -> Bool)
-> Eq GetResourceShareAssociations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
$c/= :: GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
== :: GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
$c== :: GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
Prelude.Eq, ReadPrec [GetResourceShareAssociations]
ReadPrec GetResourceShareAssociations
Int -> ReadS GetResourceShareAssociations
ReadS [GetResourceShareAssociations]
(Int -> ReadS GetResourceShareAssociations)
-> ReadS [GetResourceShareAssociations]
-> ReadPrec GetResourceShareAssociations
-> ReadPrec [GetResourceShareAssociations]
-> Read GetResourceShareAssociations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceShareAssociations]
$creadListPrec :: ReadPrec [GetResourceShareAssociations]
readPrec :: ReadPrec GetResourceShareAssociations
$creadPrec :: ReadPrec GetResourceShareAssociations
readList :: ReadS [GetResourceShareAssociations]
$creadList :: ReadS [GetResourceShareAssociations]
readsPrec :: Int -> ReadS GetResourceShareAssociations
$creadsPrec :: Int -> ReadS GetResourceShareAssociations
Prelude.Read, Int -> GetResourceShareAssociations -> ShowS
[GetResourceShareAssociations] -> ShowS
GetResourceShareAssociations -> String
(Int -> GetResourceShareAssociations -> ShowS)
-> (GetResourceShareAssociations -> String)
-> ([GetResourceShareAssociations] -> ShowS)
-> Show GetResourceShareAssociations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceShareAssociations] -> ShowS
$cshowList :: [GetResourceShareAssociations] -> ShowS
show :: GetResourceShareAssociations -> String
$cshow :: GetResourceShareAssociations -> String
showsPrec :: Int -> GetResourceShareAssociations -> ShowS
$cshowsPrec :: Int -> GetResourceShareAssociations -> ShowS
Prelude.Show, (forall x.
 GetResourceShareAssociations -> Rep GetResourceShareAssociations x)
-> (forall x.
    Rep GetResourceShareAssociations x -> GetResourceShareAssociations)
-> Generic GetResourceShareAssociations
forall x.
Rep GetResourceShareAssociations x -> GetResourceShareAssociations
forall x.
GetResourceShareAssociations -> Rep GetResourceShareAssociations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResourceShareAssociations x -> GetResourceShareAssociations
$cfrom :: forall x.
GetResourceShareAssociations -> Rep GetResourceShareAssociations x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceShareAssociations' 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', 'getResourceShareAssociations_nextToken' - The token for the next page of results.
--
-- 'resourceArn', 'getResourceShareAssociations_resourceArn' - The Amazon Resource Name (ARN) of the resource. You cannot specify this
-- parameter if the association type is @PRINCIPAL@.
--
-- 'principal', 'getResourceShareAssociations_principal' - The principal. You cannot specify this parameter if the association type
-- is @RESOURCE@.
--
-- 'associationStatus', 'getResourceShareAssociations_associationStatus' - The association status.
--
-- 'maxResults', 'getResourceShareAssociations_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', 'getResourceShareAssociations_resourceShareArns' - The Amazon Resource Names (ARN) of the resource shares.
--
-- 'associationType', 'getResourceShareAssociations_associationType' - The association type. Specify @PRINCIPAL@ to list the principals that
-- are associated with the specified resource share. Specify @RESOURCE@ to
-- list the resources that are associated with the specified resource
-- share.
newGetResourceShareAssociations ::
  -- | 'associationType'
  ResourceShareAssociationType ->
  GetResourceShareAssociations
newGetResourceShareAssociations :: ResourceShareAssociationType -> GetResourceShareAssociations
newGetResourceShareAssociations ResourceShareAssociationType
pAssociationType_ =
  GetResourceShareAssociations' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ResourceShareAssociationStatus
-> Maybe Natural
-> Maybe [Text]
-> ResourceShareAssociationType
-> GetResourceShareAssociations
GetResourceShareAssociations'
    { $sel:nextToken:GetResourceShareAssociations' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:GetResourceShareAssociations' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:principal:GetResourceShareAssociations' :: Maybe Text
principal = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associationStatus:GetResourceShareAssociations' :: Maybe ResourceShareAssociationStatus
associationStatus = Maybe ResourceShareAssociationStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetResourceShareAssociations' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:GetResourceShareAssociations' :: Maybe [Text]
resourceShareArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:associationType:GetResourceShareAssociations' :: ResourceShareAssociationType
associationType = ResourceShareAssociationType
pAssociationType_
    }

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

-- | The Amazon Resource Name (ARN) of the resource. You cannot specify this
-- parameter if the association type is @PRINCIPAL@.
getResourceShareAssociations_resourceArn :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Text)
getResourceShareAssociations_resourceArn :: (Maybe Text -> f (Maybe Text))
-> GetResourceShareAssociations -> f GetResourceShareAssociations
getResourceShareAssociations_resourceArn = (GetResourceShareAssociations -> Maybe Text)
-> (GetResourceShareAssociations
    -> Maybe Text -> GetResourceShareAssociations)
-> Lens
     GetResourceShareAssociations
     GetResourceShareAssociations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociations' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: GetResourceShareAssociations
s@GetResourceShareAssociations' {} Maybe Text
a -> GetResourceShareAssociations
s {$sel:resourceArn:GetResourceShareAssociations' :: Maybe Text
resourceArn = Maybe Text
a} :: GetResourceShareAssociations)

-- | The principal. You cannot specify this parameter if the association type
-- is @RESOURCE@.
getResourceShareAssociations_principal :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Text)
getResourceShareAssociations_principal :: (Maybe Text -> f (Maybe Text))
-> GetResourceShareAssociations -> f GetResourceShareAssociations
getResourceShareAssociations_principal = (GetResourceShareAssociations -> Maybe Text)
-> (GetResourceShareAssociations
    -> Maybe Text -> GetResourceShareAssociations)
-> Lens
     GetResourceShareAssociations
     GetResourceShareAssociations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociations' {Maybe Text
principal :: Maybe Text
$sel:principal:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
principal} -> Maybe Text
principal) (\s :: GetResourceShareAssociations
s@GetResourceShareAssociations' {} Maybe Text
a -> GetResourceShareAssociations
s {$sel:principal:GetResourceShareAssociations' :: Maybe Text
principal = Maybe Text
a} :: GetResourceShareAssociations)

-- | The association status.
getResourceShareAssociations_associationStatus :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe ResourceShareAssociationStatus)
getResourceShareAssociations_associationStatus :: (Maybe ResourceShareAssociationStatus
 -> f (Maybe ResourceShareAssociationStatus))
-> GetResourceShareAssociations -> f GetResourceShareAssociations
getResourceShareAssociations_associationStatus = (GetResourceShareAssociations
 -> Maybe ResourceShareAssociationStatus)
-> (GetResourceShareAssociations
    -> Maybe ResourceShareAssociationStatus
    -> GetResourceShareAssociations)
-> Lens
     GetResourceShareAssociations
     GetResourceShareAssociations
     (Maybe ResourceShareAssociationStatus)
     (Maybe ResourceShareAssociationStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociations' {Maybe ResourceShareAssociationStatus
associationStatus :: Maybe ResourceShareAssociationStatus
$sel:associationStatus:GetResourceShareAssociations' :: GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
associationStatus} -> Maybe ResourceShareAssociationStatus
associationStatus) (\s :: GetResourceShareAssociations
s@GetResourceShareAssociations' {} Maybe ResourceShareAssociationStatus
a -> GetResourceShareAssociations
s {$sel:associationStatus:GetResourceShareAssociations' :: Maybe ResourceShareAssociationStatus
associationStatus = Maybe ResourceShareAssociationStatus
a} :: GetResourceShareAssociations)

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

-- | The Amazon Resource Names (ARN) of the resource shares.
getResourceShareAssociations_resourceShareArns :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe [Prelude.Text])
getResourceShareAssociations_resourceShareArns :: (Maybe [Text] -> f (Maybe [Text]))
-> GetResourceShareAssociations -> f GetResourceShareAssociations
getResourceShareAssociations_resourceShareArns = (GetResourceShareAssociations -> Maybe [Text])
-> (GetResourceShareAssociations
    -> Maybe [Text] -> GetResourceShareAssociations)
-> Lens
     GetResourceShareAssociations
     GetResourceShareAssociations
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociations' {Maybe [Text]
resourceShareArns :: Maybe [Text]
$sel:resourceShareArns:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe [Text]
resourceShareArns} -> Maybe [Text]
resourceShareArns) (\s :: GetResourceShareAssociations
s@GetResourceShareAssociations' {} Maybe [Text]
a -> GetResourceShareAssociations
s {$sel:resourceShareArns:GetResourceShareAssociations' :: Maybe [Text]
resourceShareArns = Maybe [Text]
a} :: GetResourceShareAssociations) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetResourceShareAssociations -> f GetResourceShareAssociations)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetResourceShareAssociations
-> f GetResourceShareAssociations
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 association type. Specify @PRINCIPAL@ to list the principals that
-- are associated with the specified resource share. Specify @RESOURCE@ to
-- list the resources that are associated with the specified resource
-- share.
getResourceShareAssociations_associationType :: Lens.Lens' GetResourceShareAssociations ResourceShareAssociationType
getResourceShareAssociations_associationType :: (ResourceShareAssociationType -> f ResourceShareAssociationType)
-> GetResourceShareAssociations -> f GetResourceShareAssociations
getResourceShareAssociations_associationType = (GetResourceShareAssociations -> ResourceShareAssociationType)
-> (GetResourceShareAssociations
    -> ResourceShareAssociationType -> GetResourceShareAssociations)
-> Lens
     GetResourceShareAssociations
     GetResourceShareAssociations
     ResourceShareAssociationType
     ResourceShareAssociationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociations' {ResourceShareAssociationType
associationType :: ResourceShareAssociationType
$sel:associationType:GetResourceShareAssociations' :: GetResourceShareAssociations -> ResourceShareAssociationType
associationType} -> ResourceShareAssociationType
associationType) (\s :: GetResourceShareAssociations
s@GetResourceShareAssociations' {} ResourceShareAssociationType
a -> GetResourceShareAssociations
s {$sel:associationType:GetResourceShareAssociations' :: ResourceShareAssociationType
associationType = ResourceShareAssociationType
a} :: GetResourceShareAssociations)

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

instance Prelude.NFData GetResourceShareAssociations

instance Core.ToHeaders GetResourceShareAssociations where
  toHeaders :: GetResourceShareAssociations -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetResourceShareAssociations -> 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 GetResourceShareAssociations where
  toJSON :: GetResourceShareAssociations -> Value
toJSON GetResourceShareAssociations' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe ResourceShareAssociationStatus
ResourceShareAssociationType
associationType :: ResourceShareAssociationType
resourceShareArns :: Maybe [Text]
maxResults :: Maybe Natural
associationStatus :: Maybe ResourceShareAssociationStatus
principal :: Maybe Text
resourceArn :: Maybe Text
nextToken :: Maybe Text
$sel:associationType:GetResourceShareAssociations' :: GetResourceShareAssociations -> ResourceShareAssociationType
$sel:resourceShareArns:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe [Text]
$sel:maxResults:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Natural
$sel:associationStatus:GetResourceShareAssociations' :: GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
$sel:principal:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:resourceArn:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:nextToken:GetResourceShareAssociations' :: GetResourceShareAssociations -> 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
"resourceArn" 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
resourceArn,
            (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
"associationStatus" Text -> ResourceShareAssociationStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ResourceShareAssociationStatus -> Pair)
-> Maybe ResourceShareAssociationStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceShareAssociationStatus
associationStatus,
            (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
"associationType" Text -> ResourceShareAssociationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceShareAssociationType
associationType)
          ]
      )

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

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

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

-- |
-- Create a value of 'GetResourceShareAssociationsResponse' 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:
--
-- 'resourceShareAssociations', 'getResourceShareAssociationsResponse_resourceShareAssociations' - Information about the associations.
--
-- 'nextToken', 'getResourceShareAssociationsResponse_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', 'getResourceShareAssociationsResponse_httpStatus' - The response's http status code.
newGetResourceShareAssociationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceShareAssociationsResponse
newGetResourceShareAssociationsResponse :: Int -> GetResourceShareAssociationsResponse
newGetResourceShareAssociationsResponse Int
pHttpStatus_ =
  GetResourceShareAssociationsResponse' :: Maybe [ResourceShareAssociation]
-> Maybe Text -> Int -> GetResourceShareAssociationsResponse
GetResourceShareAssociationsResponse'
    { $sel:resourceShareAssociations:GetResourceShareAssociationsResponse' :: Maybe [ResourceShareAssociation]
resourceShareAssociations =
        Maybe [ResourceShareAssociation]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceShareAssociationsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceShareAssociationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the associations.
getResourceShareAssociationsResponse_resourceShareAssociations :: Lens.Lens' GetResourceShareAssociationsResponse (Prelude.Maybe [ResourceShareAssociation])
getResourceShareAssociationsResponse_resourceShareAssociations :: (Maybe [ResourceShareAssociation]
 -> f (Maybe [ResourceShareAssociation]))
-> GetResourceShareAssociationsResponse
-> f GetResourceShareAssociationsResponse
getResourceShareAssociationsResponse_resourceShareAssociations = (GetResourceShareAssociationsResponse
 -> Maybe [ResourceShareAssociation])
-> (GetResourceShareAssociationsResponse
    -> Maybe [ResourceShareAssociation]
    -> GetResourceShareAssociationsResponse)
-> Lens'
     GetResourceShareAssociationsResponse
     (Maybe [ResourceShareAssociation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociationsResponse' {Maybe [ResourceShareAssociation]
resourceShareAssociations :: Maybe [ResourceShareAssociation]
$sel:resourceShareAssociations:GetResourceShareAssociationsResponse' :: GetResourceShareAssociationsResponse
-> Maybe [ResourceShareAssociation]
resourceShareAssociations} -> Maybe [ResourceShareAssociation]
resourceShareAssociations) (\s :: GetResourceShareAssociationsResponse
s@GetResourceShareAssociationsResponse' {} Maybe [ResourceShareAssociation]
a -> GetResourceShareAssociationsResponse
s {$sel:resourceShareAssociations:GetResourceShareAssociationsResponse' :: Maybe [ResourceShareAssociation]
resourceShareAssociations = Maybe [ResourceShareAssociation]
a} :: GetResourceShareAssociationsResponse) ((Maybe [ResourceShareAssociation]
  -> f (Maybe [ResourceShareAssociation]))
 -> GetResourceShareAssociationsResponse
 -> f GetResourceShareAssociationsResponse)
-> ((Maybe [ResourceShareAssociation]
     -> f (Maybe [ResourceShareAssociation]))
    -> Maybe [ResourceShareAssociation]
    -> f (Maybe [ResourceShareAssociation]))
-> (Maybe [ResourceShareAssociation]
    -> f (Maybe [ResourceShareAssociation]))
-> GetResourceShareAssociationsResponse
-> f GetResourceShareAssociationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourceShareAssociation]
  [ResourceShareAssociation]
  [ResourceShareAssociation]
  [ResourceShareAssociation]
-> Iso
     (Maybe [ResourceShareAssociation])
     (Maybe [ResourceShareAssociation])
     (Maybe [ResourceShareAssociation])
     (Maybe [ResourceShareAssociation])
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
  [ResourceShareAssociation]
  [ResourceShareAssociation]
  [ResourceShareAssociation]
  [ResourceShareAssociation]
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.
getResourceShareAssociationsResponse_nextToken :: Lens.Lens' GetResourceShareAssociationsResponse (Prelude.Maybe Prelude.Text)
getResourceShareAssociationsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetResourceShareAssociationsResponse
-> f GetResourceShareAssociationsResponse
getResourceShareAssociationsResponse_nextToken = (GetResourceShareAssociationsResponse -> Maybe Text)
-> (GetResourceShareAssociationsResponse
    -> Maybe Text -> GetResourceShareAssociationsResponse)
-> Lens' GetResourceShareAssociationsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShareAssociationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceShareAssociationsResponse' :: GetResourceShareAssociationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceShareAssociationsResponse
s@GetResourceShareAssociationsResponse' {} Maybe Text
a -> GetResourceShareAssociationsResponse
s {$sel:nextToken:GetResourceShareAssociationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceShareAssociationsResponse)

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

instance
  Prelude.NFData
    GetResourceShareAssociationsResponse