{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the resource and principal associations for resource shares
-- that you own.
--
-- This operation returns paginated results.
module Amazonka.RAM.GetResourceShareAssociations
  ( -- * Creating a Request
    GetResourceShareAssociations (..),
    newGetResourceShareAssociations,

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

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

    -- * Response Lenses
    getResourceShareAssociationsResponse_nextToken,
    getResourceShareAssociationsResponse_resourceShareAssociations,
    getResourceShareAssociationsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | Specifies that you want to retrieve only associations with this status.
    GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
associationStatus :: Prelude.Maybe ResourceShareAssociationStatus,
    -- | Specifies the total number of results that you want included on each
    -- page of the response. If you do not include this parameter, it defaults
    -- to a value that is specific to the operation. If additional items exist
    -- beyond the number you specify, the @NextToken@ response element is
    -- returned with a value (not null). Include the specified value as the
    -- @NextToken@ request parameter in the next call to the operation to get
    -- the next part of the results. Note that the service might return fewer
    -- results than the maximum even when there are more results available. You
    -- should check @NextToken@ after every operation to ensure that you
    -- receive all of the results.
    GetResourceShareAssociations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Specifies that you want to receive the next page of results. Valid only
    -- if you received a @NextToken@ response in the previous request. If you
    -- did, it indicates that more output is available. Set this parameter to
    -- the value provided by the previous call\'s @NextToken@ response to
    -- request the next page of results.
    GetResourceShareAssociations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies the ID of the principal whose resource shares you want to
    -- retrieve. This can be an Amazon Web Services account ID, an organization
    -- ID, an organizational unit ID, or the
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
    -- of an individual IAM user or role.
    --
    -- You cannot specify this parameter if the association type is @RESOURCE@.
    GetResourceShareAssociations -> Maybe Text
principal :: Prelude.Maybe Prelude.Text,
    -- | Specifies the
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
    -- of the resource whose resource shares you want to retrieve.
    --
    -- You cannot specify this parameter if the association type is
    -- @PRINCIPAL@.
    GetResourceShareAssociations -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | Specifies a list of
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- of the resource share whose associations you want to retrieve.
    GetResourceShareAssociations -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | Specifies whether you want to retrieve the associations that involve a
    -- specified resource or principal.
    --
    -- -   @PRINCIPAL@ – list the principals that are associated with the
    --     specified resource share.
    --
    -- -   @RESOURCE@ – list the resources that are associated with the
    --     specified resource share.
    GetResourceShareAssociations -> ResourceShareAssociationType
associationType :: ResourceShareAssociationType
  }
  deriving (GetResourceShareAssociations
-> GetResourceShareAssociations -> Bool
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]
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
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.
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:
--
-- 'associationStatus', 'getResourceShareAssociations_associationStatus' - Specifies that you want to retrieve only associations with this status.
--
-- 'maxResults', 'getResourceShareAssociations_maxResults' - Specifies the total number of results that you want included on each
-- page of the response. If you do not include this parameter, it defaults
-- to a value that is specific to the operation. If additional items exist
-- beyond the number you specify, the @NextToken@ response element is
-- returned with a value (not null). Include the specified value as the
-- @NextToken@ request parameter in the next call to the operation to get
-- the next part of the results. Note that the service might return fewer
-- results than the maximum even when there are more results available. You
-- should check @NextToken@ after every operation to ensure that you
-- receive all of the results.
--
-- 'nextToken', 'getResourceShareAssociations_nextToken' - Specifies that you want to receive the next page of results. Valid only
-- if you received a @NextToken@ response in the previous request. If you
-- did, it indicates that more output is available. Set this parameter to
-- the value provided by the previous call\'s @NextToken@ response to
-- request the next page of results.
--
-- 'principal', 'getResourceShareAssociations_principal' - Specifies the ID of the principal whose resource shares you want to
-- retrieve. This can be an Amazon Web Services account ID, an organization
-- ID, an organizational unit ID, or the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of an individual IAM user or role.
--
-- You cannot specify this parameter if the association type is @RESOURCE@.
--
-- 'resourceArn', 'getResourceShareAssociations_resourceArn' - Specifies the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of the resource whose resource shares you want to retrieve.
--
-- You cannot specify this parameter if the association type is
-- @PRINCIPAL@.
--
-- 'resourceShareArns', 'getResourceShareAssociations_resourceShareArns' - Specifies a list of
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- of the resource share whose associations you want to retrieve.
--
-- 'associationType', 'getResourceShareAssociations_associationType' - Specifies whether you want to retrieve the associations that involve a
-- specified resource or principal.
--
-- -   @PRINCIPAL@ – list the principals that are associated with the
--     specified resource share.
--
-- -   @RESOURCE@ – list the resources that are associated with the
--     specified resource share.
newGetResourceShareAssociations ::
  -- | 'associationType'
  ResourceShareAssociationType ->
  GetResourceShareAssociations
newGetResourceShareAssociations :: ResourceShareAssociationType -> GetResourceShareAssociations
newGetResourceShareAssociations ResourceShareAssociationType
pAssociationType_ =
  GetResourceShareAssociations'
    { $sel:associationStatus:GetResourceShareAssociations' :: Maybe ResourceShareAssociationStatus
associationStatus =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetResourceShareAssociations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceShareAssociations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:principal:GetResourceShareAssociations' :: Maybe Text
principal = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:GetResourceShareAssociations' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:GetResourceShareAssociations' :: Maybe [Text]
resourceShareArns = forall a. Maybe a
Prelude.Nothing,
      $sel:associationType:GetResourceShareAssociations' :: ResourceShareAssociationType
associationType = ResourceShareAssociationType
pAssociationType_
    }

-- | Specifies that you want to retrieve only associations with this status.
getResourceShareAssociations_associationStatus :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe ResourceShareAssociationStatus)
getResourceShareAssociations_associationStatus :: Lens'
  GetResourceShareAssociations (Maybe ResourceShareAssociationStatus)
getResourceShareAssociations_associationStatus = 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)

-- | Specifies the total number of results that you want included on each
-- page of the response. If you do not include this parameter, it defaults
-- to a value that is specific to the operation. If additional items exist
-- beyond the number you specify, the @NextToken@ response element is
-- returned with a value (not null). Include the specified value as the
-- @NextToken@ request parameter in the next call to the operation to get
-- the next part of the results. Note that the service might return fewer
-- results than the maximum even when there are more results available. You
-- should check @NextToken@ after every operation to ensure that you
-- receive all of the results.
getResourceShareAssociations_maxResults :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Natural)
getResourceShareAssociations_maxResults :: Lens' GetResourceShareAssociations (Maybe Natural)
getResourceShareAssociations_maxResults = 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)

-- | Specifies that you want to receive the next page of results. Valid only
-- if you received a @NextToken@ response in the previous request. If you
-- did, it indicates that more output is available. Set this parameter to
-- the value provided by the previous call\'s @NextToken@ response to
-- request the next page of results.
getResourceShareAssociations_nextToken :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Text)
getResourceShareAssociations_nextToken :: Lens' GetResourceShareAssociations (Maybe Text)
getResourceShareAssociations_nextToken = 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)

-- | Specifies the ID of the principal whose resource shares you want to
-- retrieve. This can be an Amazon Web Services account ID, an organization
-- ID, an organizational unit ID, or the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of an individual IAM user or role.
--
-- You cannot specify this parameter if the association type is @RESOURCE@.
getResourceShareAssociations_principal :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Text)
getResourceShareAssociations_principal :: Lens' GetResourceShareAssociations (Maybe Text)
getResourceShareAssociations_principal = 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)

-- | Specifies the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of the resource whose resource shares you want to retrieve.
--
-- You cannot specify this parameter if the association type is
-- @PRINCIPAL@.
getResourceShareAssociations_resourceArn :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe Prelude.Text)
getResourceShareAssociations_resourceArn :: Lens' GetResourceShareAssociations (Maybe Text)
getResourceShareAssociations_resourceArn = 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)

-- | Specifies a list of
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- of the resource share whose associations you want to retrieve.
getResourceShareAssociations_resourceShareArns :: Lens.Lens' GetResourceShareAssociations (Prelude.Maybe [Prelude.Text])
getResourceShareAssociations_resourceShareArns :: Lens' GetResourceShareAssociations (Maybe [Text])
getResourceShareAssociations_resourceShareArns = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies whether you want to retrieve the associations that involve a
-- specified resource or principal.
--
-- -   @PRINCIPAL@ – list the principals that are associated with the
--     specified resource share.
--
-- -   @RESOURCE@ – list the resources that are associated with the
--     specified resource share.
getResourceShareAssociations_associationType :: Lens.Lens' GetResourceShareAssociations ResourceShareAssociationType
getResourceShareAssociations_associationType :: Lens' GetResourceShareAssociations ResourceShareAssociationType
getResourceShareAssociations_associationType = 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
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetResourceShareAssociations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetResourceShareAssociationsResponse (Maybe Text)
getResourceShareAssociationsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetResourceShareAssociations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  GetResourceShareAssociationsResponse
  (Maybe [ResourceShareAssociation])
getResourceShareAssociationsResponse_resourceShareAssociations
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ GetResourceShareAssociations
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetResourceShareAssociations (Maybe Text)
getResourceShareAssociations_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetResourceShareAssociations
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetResourceShareAssociationsResponse (Maybe Text)
getResourceShareAssociationsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetResourceShareAssociations where
  type
    AWSResponse GetResourceShareAssociations =
      GetResourceShareAssociationsResponse
  request :: (Service -> Service)
-> GetResourceShareAssociations
-> Request GetResourceShareAssociations
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetResourceShareAssociations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResourceShareAssociations)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe [ResourceShareAssociation]
-> Int
-> GetResourceShareAssociationsResponse
GetResourceShareAssociationsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"resourceShareAssociations"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    GetResourceShareAssociations
  where
  hashWithSalt :: Int -> GetResourceShareAssociations -> Int
hashWithSalt Int
_salt GetResourceShareAssociations' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe ResourceShareAssociationStatus
ResourceShareAssociationType
associationType :: ResourceShareAssociationType
resourceShareArns :: Maybe [Text]
resourceArn :: Maybe Text
principal :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
associationStatus :: Maybe ResourceShareAssociationStatus
$sel:associationType:GetResourceShareAssociations' :: GetResourceShareAssociations -> ResourceShareAssociationType
$sel:resourceShareArns:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe [Text]
$sel:resourceArn:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:principal:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:nextToken:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:maxResults:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Natural
$sel:associationStatus:GetResourceShareAssociations' :: GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceShareAssociationStatus
associationStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
principal
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resourceShareArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceShareAssociationType
associationType

instance Prelude.NFData GetResourceShareAssociations where
  rnf :: GetResourceShareAssociations -> ()
rnf GetResourceShareAssociations' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe ResourceShareAssociationStatus
ResourceShareAssociationType
associationType :: ResourceShareAssociationType
resourceShareArns :: Maybe [Text]
resourceArn :: Maybe Text
principal :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
associationStatus :: Maybe ResourceShareAssociationStatus
$sel:associationType:GetResourceShareAssociations' :: GetResourceShareAssociations -> ResourceShareAssociationType
$sel:resourceShareArns:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe [Text]
$sel:resourceArn:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:principal:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:nextToken:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:maxResults:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Natural
$sel:associationStatus:GetResourceShareAssociations' :: GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceShareAssociationStatus
associationStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
principal
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
resourceShareArns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceShareAssociationType
associationType

instance Data.ToHeaders GetResourceShareAssociations where
  toHeaders :: GetResourceShareAssociations -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetResourceShareAssociations where
  toJSON :: GetResourceShareAssociations -> Value
toJSON GetResourceShareAssociations' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe ResourceShareAssociationStatus
ResourceShareAssociationType
associationType :: ResourceShareAssociationType
resourceShareArns :: Maybe [Text]
resourceArn :: Maybe Text
principal :: Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
associationStatus :: Maybe ResourceShareAssociationStatus
$sel:associationType:GetResourceShareAssociations' :: GetResourceShareAssociations -> ResourceShareAssociationType
$sel:resourceShareArns:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe [Text]
$sel:resourceArn:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:principal:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:nextToken:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Text
$sel:maxResults:GetResourceShareAssociations' :: GetResourceShareAssociations -> Maybe Natural
$sel:associationStatus:GetResourceShareAssociations' :: GetResourceShareAssociations
-> Maybe ResourceShareAssociationStatus
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"associationStatus" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceShareAssociationStatus
associationStatus,
            (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Key
"principal" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
principal,
            (Key
"resourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceArn,
            (Key
"resourceShareArns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
resourceShareArns,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"associationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceShareAssociationType
associationType)
          ]
      )

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

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

-- | /See:/ 'newGetResourceShareAssociationsResponse' smart constructor.
data GetResourceShareAssociationsResponse = GetResourceShareAssociationsResponse'
  { -- | If present, this value indicates that more output is available than is
    -- included in the current response. Use this value in the @NextToken@
    -- request parameter in a subsequent call to the operation to get the next
    -- part of the output. You should repeat this until the @NextToken@
    -- response element comes back as @null@. This indicates that this is the
    -- last page of results.
    GetResourceShareAssociationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that contain the details about the associations.
    GetResourceShareAssociationsResponse
-> Maybe [ResourceShareAssociation]
resourceShareAssociations :: Prelude.Maybe [ResourceShareAssociation],
    -- | The response's http status code.
    GetResourceShareAssociationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetResourceShareAssociationsResponse
-> GetResourceShareAssociationsResponse -> Bool
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]
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
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.
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:
--
-- 'nextToken', 'getResourceShareAssociationsResponse_nextToken' - If present, this value indicates that more output is available than is
-- included in the current response. Use this value in the @NextToken@
-- request parameter in a subsequent call to the operation to get the next
-- part of the output. You should repeat this until the @NextToken@
-- response element comes back as @null@. This indicates that this is the
-- last page of results.
--
-- 'resourceShareAssociations', 'getResourceShareAssociationsResponse_resourceShareAssociations' - An array of objects that contain the details about the associations.
--
-- 'httpStatus', 'getResourceShareAssociationsResponse_httpStatus' - The response's http status code.
newGetResourceShareAssociationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceShareAssociationsResponse
newGetResourceShareAssociationsResponse :: Int -> GetResourceShareAssociationsResponse
newGetResourceShareAssociationsResponse Int
pHttpStatus_ =
  GetResourceShareAssociationsResponse'
    { $sel:nextToken:GetResourceShareAssociationsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareAssociations:GetResourceShareAssociationsResponse' :: Maybe [ResourceShareAssociation]
resourceShareAssociations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceShareAssociationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If present, this value indicates that more output is available than is
-- included in the current response. Use this value in the @NextToken@
-- request parameter in a subsequent call to the operation to get the next
-- part of the output. You should repeat this until the @NextToken@
-- response element comes back as @null@. This indicates that this is the
-- last page of results.
getResourceShareAssociationsResponse_nextToken :: Lens.Lens' GetResourceShareAssociationsResponse (Prelude.Maybe Prelude.Text)
getResourceShareAssociationsResponse_nextToken :: Lens' GetResourceShareAssociationsResponse (Maybe Text)
getResourceShareAssociationsResponse_nextToken = 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)

-- | An array of objects that contain the details about the associations.
getResourceShareAssociationsResponse_resourceShareAssociations :: Lens.Lens' GetResourceShareAssociationsResponse (Prelude.Maybe [ResourceShareAssociation])
getResourceShareAssociationsResponse_resourceShareAssociations :: Lens'
  GetResourceShareAssociationsResponse
  (Maybe [ResourceShareAssociation])
getResourceShareAssociationsResponse_resourceShareAssociations = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getResourceShareAssociationsResponse_httpStatus :: Lens.Lens' GetResourceShareAssociationsResponse Prelude.Int
getResourceShareAssociationsResponse_httpStatus :: Lens' GetResourceShareAssociationsResponse Int
getResourceShareAssociationsResponse_httpStatus = 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
  where
  rnf :: GetResourceShareAssociationsResponse -> ()
rnf GetResourceShareAssociationsResponse' {Int
Maybe [ResourceShareAssociation]
Maybe Text
httpStatus :: Int
resourceShareAssociations :: Maybe [ResourceShareAssociation]
nextToken :: Maybe Text
$sel:httpStatus:GetResourceShareAssociationsResponse' :: GetResourceShareAssociationsResponse -> Int
$sel:resourceShareAssociations:GetResourceShareAssociationsResponse' :: GetResourceShareAssociationsResponse
-> Maybe [ResourceShareAssociation]
$sel:nextToken:GetResourceShareAssociationsResponse' :: GetResourceShareAssociationsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResourceShareAssociation]
resourceShareAssociations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus