{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.RAM.GetResourceShares
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves details about the resource shares that you own or that are
-- shared with you.
--
-- This operation returns paginated results.
module Amazonka.RAM.GetResourceShares
  ( -- * Creating a Request
    GetResourceShares (..),
    newGetResourceShares,

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

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

    -- * Response Lenses
    getResourceSharesResponse_nextToken,
    getResourceSharesResponse_resourceShares,
    getResourceSharesResponse_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:/ 'newGetResourceShares' smart constructor.
data GetResourceShares = GetResourceShares'
  { -- | 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.
    GetResourceShares -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Specifies the name of an individual resource share that you want to
    -- retrieve details about.
    GetResourceShares -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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.
    GetResourceShares -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specifies that you want to retrieve details of only those resource
    -- shares that use the RAM permission with this
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>.
    GetResourceShares -> Maybe Text
permissionArn :: Prelude.Maybe Prelude.Text,
    -- | Specifies the
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- of individual resource shares that you want information about.
    GetResourceShares -> Maybe [Text]
resourceShareArns :: Prelude.Maybe [Prelude.Text],
    -- | Specifies that you want to retrieve details of only those resource
    -- shares that have this status.
    GetResourceShares -> Maybe ResourceShareStatus
resourceShareStatus :: Prelude.Maybe ResourceShareStatus,
    -- | Specifies that you want to retrieve details of only those resource
    -- shares that match the specified tag keys and values.
    GetResourceShares -> Maybe [TagFilter]
tagFilters :: Prelude.Maybe [TagFilter],
    -- | Specifies that you want to retrieve details of only those resource
    -- shares that match the following:
    --
    -- -   __@SELF@__ – resource shares that your account shares with other
    --     accounts
    --
    -- -   __@OTHER-ACCOUNTS@__ – resource shares that other accounts share
    --     with your account
    GetResourceShares -> ResourceOwner
resourceOwner :: ResourceOwner
  }
  deriving (GetResourceShares -> GetResourceShares -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceShares -> GetResourceShares -> Bool
$c/= :: GetResourceShares -> GetResourceShares -> Bool
== :: GetResourceShares -> GetResourceShares -> Bool
$c== :: GetResourceShares -> GetResourceShares -> Bool
Prelude.Eq, ReadPrec [GetResourceShares]
ReadPrec GetResourceShares
Int -> ReadS GetResourceShares
ReadS [GetResourceShares]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceShares]
$creadListPrec :: ReadPrec [GetResourceShares]
readPrec :: ReadPrec GetResourceShares
$creadPrec :: ReadPrec GetResourceShares
readList :: ReadS [GetResourceShares]
$creadList :: ReadS [GetResourceShares]
readsPrec :: Int -> ReadS GetResourceShares
$creadsPrec :: Int -> ReadS GetResourceShares
Prelude.Read, Int -> GetResourceShares -> ShowS
[GetResourceShares] -> ShowS
GetResourceShares -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceShares] -> ShowS
$cshowList :: [GetResourceShares] -> ShowS
show :: GetResourceShares -> String
$cshow :: GetResourceShares -> String
showsPrec :: Int -> GetResourceShares -> ShowS
$cshowsPrec :: Int -> GetResourceShares -> ShowS
Prelude.Show, forall x. Rep GetResourceShares x -> GetResourceShares
forall x. GetResourceShares -> Rep GetResourceShares x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResourceShares x -> GetResourceShares
$cfrom :: forall x. GetResourceShares -> Rep GetResourceShares x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceShares' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxResults', 'getResourceShares_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.
--
-- 'name', 'getResourceShares_name' - Specifies the name of an individual resource share that you want to
-- retrieve details about.
--
-- 'nextToken', 'getResourceShares_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.
--
-- 'permissionArn', 'getResourceShares_permissionArn' - Specifies that you want to retrieve details of only those resource
-- shares that use the RAM permission with this
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>.
--
-- 'resourceShareArns', 'getResourceShares_resourceShareArns' - Specifies the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- of individual resource shares that you want information about.
--
-- 'resourceShareStatus', 'getResourceShares_resourceShareStatus' - Specifies that you want to retrieve details of only those resource
-- shares that have this status.
--
-- 'tagFilters', 'getResourceShares_tagFilters' - Specifies that you want to retrieve details of only those resource
-- shares that match the specified tag keys and values.
--
-- 'resourceOwner', 'getResourceShares_resourceOwner' - Specifies that you want to retrieve details of only those resource
-- shares that match the following:
--
-- -   __@SELF@__ – resource shares that your account shares with other
--     accounts
--
-- -   __@OTHER-ACCOUNTS@__ – resource shares that other accounts share
--     with your account
newGetResourceShares ::
  -- | 'resourceOwner'
  ResourceOwner ->
  GetResourceShares
newGetResourceShares :: ResourceOwner -> GetResourceShares
newGetResourceShares ResourceOwner
pResourceOwner_ =
  GetResourceShares'
    { $sel:maxResults:GetResourceShares' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetResourceShares' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetResourceShares' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:permissionArn:GetResourceShares' :: Maybe Text
permissionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArns:GetResourceShares' :: Maybe [Text]
resourceShareArns = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareStatus:GetResourceShares' :: Maybe ResourceShareStatus
resourceShareStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:tagFilters:GetResourceShares' :: Maybe [TagFilter]
tagFilters = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceOwner:GetResourceShares' :: ResourceOwner
resourceOwner = ResourceOwner
pResourceOwner_
    }

-- | 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.
getResourceShares_maxResults :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Natural)
getResourceShares_maxResults :: Lens' GetResourceShares (Maybe Natural)
getResourceShares_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:GetResourceShares' :: GetResourceShares -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Natural
a -> GetResourceShares
s {$sel:maxResults:GetResourceShares' :: Maybe Natural
maxResults = Maybe Natural
a} :: GetResourceShares)

-- | Specifies the name of an individual resource share that you want to
-- retrieve details about.
getResourceShares_name :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Text)
getResourceShares_name :: Lens' GetResourceShares (Maybe Text)
getResourceShares_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Text
name :: Maybe Text
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
name} -> Maybe Text
name) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Text
a -> GetResourceShares
s {$sel:name:GetResourceShares' :: Maybe Text
name = Maybe Text
a} :: GetResourceShares)

-- | 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.
getResourceShares_nextToken :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Text)
getResourceShares_nextToken :: Lens' GetResourceShares (Maybe Text)
getResourceShares_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceShares' :: GetResourceShares -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Text
a -> GetResourceShares
s {$sel:nextToken:GetResourceShares' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceShares)

-- | Specifies that you want to retrieve details of only those resource
-- shares that use the RAM permission with this
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>.
getResourceShares_permissionArn :: Lens.Lens' GetResourceShares (Prelude.Maybe Prelude.Text)
getResourceShares_permissionArn :: Lens' GetResourceShares (Maybe Text)
getResourceShares_permissionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe Text
permissionArn :: Maybe Text
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
permissionArn} -> Maybe Text
permissionArn) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe Text
a -> GetResourceShares
s {$sel:permissionArn:GetResourceShares' :: Maybe Text
permissionArn = Maybe Text
a} :: GetResourceShares)

-- | Specifies the
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- of individual resource shares that you want information about.
getResourceShares_resourceShareArns :: Lens.Lens' GetResourceShares (Prelude.Maybe [Prelude.Text])
getResourceShares_resourceShareArns :: Lens' GetResourceShares (Maybe [Text])
getResourceShares_resourceShareArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe [Text]
resourceShareArns :: Maybe [Text]
$sel:resourceShareArns:GetResourceShares' :: GetResourceShares -> Maybe [Text]
resourceShareArns} -> Maybe [Text]
resourceShareArns) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe [Text]
a -> GetResourceShares
s {$sel:resourceShareArns:GetResourceShares' :: Maybe [Text]
resourceShareArns = Maybe [Text]
a} :: GetResourceShares) 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 that you want to retrieve details of only those resource
-- shares that have this status.
getResourceShares_resourceShareStatus :: Lens.Lens' GetResourceShares (Prelude.Maybe ResourceShareStatus)
getResourceShares_resourceShareStatus :: Lens' GetResourceShares (Maybe ResourceShareStatus)
getResourceShares_resourceShareStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe ResourceShareStatus
resourceShareStatus :: Maybe ResourceShareStatus
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
resourceShareStatus} -> Maybe ResourceShareStatus
resourceShareStatus) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe ResourceShareStatus
a -> GetResourceShares
s {$sel:resourceShareStatus:GetResourceShares' :: Maybe ResourceShareStatus
resourceShareStatus = Maybe ResourceShareStatus
a} :: GetResourceShares)

-- | Specifies that you want to retrieve details of only those resource
-- shares that match the specified tag keys and values.
getResourceShares_tagFilters :: Lens.Lens' GetResourceShares (Prelude.Maybe [TagFilter])
getResourceShares_tagFilters :: Lens' GetResourceShares (Maybe [TagFilter])
getResourceShares_tagFilters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {Maybe [TagFilter]
tagFilters :: Maybe [TagFilter]
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
tagFilters} -> Maybe [TagFilter]
tagFilters) (\s :: GetResourceShares
s@GetResourceShares' {} Maybe [TagFilter]
a -> GetResourceShares
s {$sel:tagFilters:GetResourceShares' :: Maybe [TagFilter]
tagFilters = Maybe [TagFilter]
a} :: GetResourceShares) 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 that you want to retrieve details of only those resource
-- shares that match the following:
--
-- -   __@SELF@__ – resource shares that your account shares with other
--     accounts
--
-- -   __@OTHER-ACCOUNTS@__ – resource shares that other accounts share
--     with your account
getResourceShares_resourceOwner :: Lens.Lens' GetResourceShares ResourceOwner
getResourceShares_resourceOwner :: Lens' GetResourceShares ResourceOwner
getResourceShares_resourceOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceShares' {ResourceOwner
resourceOwner :: ResourceOwner
$sel:resourceOwner:GetResourceShares' :: GetResourceShares -> ResourceOwner
resourceOwner} -> ResourceOwner
resourceOwner) (\s :: GetResourceShares
s@GetResourceShares' {} ResourceOwner
a -> GetResourceShares
s {$sel:resourceOwner:GetResourceShares' :: ResourceOwner
resourceOwner = ResourceOwner
a} :: GetResourceShares)

instance Core.AWSPager GetResourceShares where
  page :: GetResourceShares
-> AWSResponse GetResourceShares -> Maybe GetResourceShares
page GetResourceShares
rq AWSResponse GetResourceShares
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetResourceShares
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetResourceSharesResponse (Maybe Text)
getResourceSharesResponse_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 GetResourceShares
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetResourceSharesResponse (Maybe [ResourceShare])
getResourceSharesResponse_resourceShares
            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.$ GetResourceShares
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetResourceShares (Maybe Text)
getResourceShares_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetResourceShares
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetResourceSharesResponse (Maybe Text)
getResourceSharesResponse_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 GetResourceShares where
  type
    AWSResponse GetResourceShares =
      GetResourceSharesResponse
  request :: (Service -> Service)
-> GetResourceShares -> Request GetResourceShares
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 GetResourceShares
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetResourceShares)))
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 [ResourceShare] -> Int -> GetResourceSharesResponse
GetResourceSharesResponse'
            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
"resourceShares" 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 GetResourceShares where
  hashWithSalt :: Int -> GetResourceShares -> Int
hashWithSalt Int
_salt GetResourceShares' {Maybe Natural
Maybe [Text]
Maybe [TagFilter]
Maybe Text
Maybe ResourceShareStatus
ResourceOwner
resourceOwner :: ResourceOwner
tagFilters :: Maybe [TagFilter]
resourceShareStatus :: Maybe ResourceShareStatus
resourceShareArns :: Maybe [Text]
permissionArn :: Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:resourceOwner:GetResourceShares' :: GetResourceShares -> ResourceOwner
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
$sel:resourceShareArns:GetResourceShares' :: GetResourceShares -> Maybe [Text]
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:nextToken:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:maxResults:GetResourceShares' :: GetResourceShares -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
permissionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resourceShareArns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceShareStatus
resourceShareStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagFilter]
tagFilters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ResourceOwner
resourceOwner

instance Prelude.NFData GetResourceShares where
  rnf :: GetResourceShares -> ()
rnf GetResourceShares' {Maybe Natural
Maybe [Text]
Maybe [TagFilter]
Maybe Text
Maybe ResourceShareStatus
ResourceOwner
resourceOwner :: ResourceOwner
tagFilters :: Maybe [TagFilter]
resourceShareStatus :: Maybe ResourceShareStatus
resourceShareArns :: Maybe [Text]
permissionArn :: Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:resourceOwner:GetResourceShares' :: GetResourceShares -> ResourceOwner
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
$sel:resourceShareArns:GetResourceShares' :: GetResourceShares -> Maybe [Text]
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:nextToken:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:maxResults:GetResourceShares' :: GetResourceShares -> Maybe Natural
..} =
    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
name
      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
permissionArn
      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 Maybe ResourceShareStatus
resourceShareStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagFilter]
tagFilters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ResourceOwner
resourceOwner

instance Data.ToHeaders GetResourceShares where
  toHeaders :: GetResourceShares -> 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 GetResourceShares where
  toJSON :: GetResourceShares -> Value
toJSON GetResourceShares' {Maybe Natural
Maybe [Text]
Maybe [TagFilter]
Maybe Text
Maybe ResourceShareStatus
ResourceOwner
resourceOwner :: ResourceOwner
tagFilters :: Maybe [TagFilter]
resourceShareStatus :: Maybe ResourceShareStatus
resourceShareArns :: Maybe [Text]
permissionArn :: Maybe Text
nextToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:resourceOwner:GetResourceShares' :: GetResourceShares -> ResourceOwner
$sel:tagFilters:GetResourceShares' :: GetResourceShares -> Maybe [TagFilter]
$sel:resourceShareStatus:GetResourceShares' :: GetResourceShares -> Maybe ResourceShareStatus
$sel:resourceShareArns:GetResourceShares' :: GetResourceShares -> Maybe [Text]
$sel:permissionArn:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:nextToken:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:name:GetResourceShares' :: GetResourceShares -> Maybe Text
$sel:maxResults:GetResourceShares' :: GetResourceShares -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"name" 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
name,
            (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
"permissionArn" 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
permissionArn,
            (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,
            (Key
"resourceShareStatus" 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 ResourceShareStatus
resourceShareStatus,
            (Key
"tagFilters" 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 [TagFilter]
tagFilters,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"resourceOwner" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ResourceOwner
resourceOwner)
          ]
      )

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

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

-- | /See:/ 'newGetResourceSharesResponse' smart constructor.
data GetResourceSharesResponse = GetResourceSharesResponse'
  { -- | 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.
    GetResourceSharesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that contain the information about the resource
    -- shares.
    GetResourceSharesResponse -> Maybe [ResourceShare]
resourceShares :: Prelude.Maybe [ResourceShare],
    -- | The response's http status code.
    GetResourceSharesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetResourceSharesResponse -> GetResourceSharesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceSharesResponse -> GetResourceSharesResponse -> Bool
$c/= :: GetResourceSharesResponse -> GetResourceSharesResponse -> Bool
== :: GetResourceSharesResponse -> GetResourceSharesResponse -> Bool
$c== :: GetResourceSharesResponse -> GetResourceSharesResponse -> Bool
Prelude.Eq, ReadPrec [GetResourceSharesResponse]
ReadPrec GetResourceSharesResponse
Int -> ReadS GetResourceSharesResponse
ReadS [GetResourceSharesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceSharesResponse]
$creadListPrec :: ReadPrec [GetResourceSharesResponse]
readPrec :: ReadPrec GetResourceSharesResponse
$creadPrec :: ReadPrec GetResourceSharesResponse
readList :: ReadS [GetResourceSharesResponse]
$creadList :: ReadS [GetResourceSharesResponse]
readsPrec :: Int -> ReadS GetResourceSharesResponse
$creadsPrec :: Int -> ReadS GetResourceSharesResponse
Prelude.Read, Int -> GetResourceSharesResponse -> ShowS
[GetResourceSharesResponse] -> ShowS
GetResourceSharesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceSharesResponse] -> ShowS
$cshowList :: [GetResourceSharesResponse] -> ShowS
show :: GetResourceSharesResponse -> String
$cshow :: GetResourceSharesResponse -> String
showsPrec :: Int -> GetResourceSharesResponse -> ShowS
$cshowsPrec :: Int -> GetResourceSharesResponse -> ShowS
Prelude.Show, forall x.
Rep GetResourceSharesResponse x -> GetResourceSharesResponse
forall x.
GetResourceSharesResponse -> Rep GetResourceSharesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetResourceSharesResponse x -> GetResourceSharesResponse
$cfrom :: forall x.
GetResourceSharesResponse -> Rep GetResourceSharesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceSharesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'nextToken', 'getResourceSharesResponse_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.
--
-- 'resourceShares', 'getResourceSharesResponse_resourceShares' - An array of objects that contain the information about the resource
-- shares.
--
-- 'httpStatus', 'getResourceSharesResponse_httpStatus' - The response's http status code.
newGetResourceSharesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceSharesResponse
newGetResourceSharesResponse :: Int -> GetResourceSharesResponse
newGetResourceSharesResponse Int
pHttpStatus_ =
  GetResourceSharesResponse'
    { $sel:nextToken:GetResourceSharesResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShares:GetResourceSharesResponse' :: Maybe [ResourceShare]
resourceShares = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceSharesResponse' :: 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.
getResourceSharesResponse_nextToken :: Lens.Lens' GetResourceSharesResponse (Prelude.Maybe Prelude.Text)
getResourceSharesResponse_nextToken :: Lens' GetResourceSharesResponse (Maybe Text)
getResourceSharesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceSharesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetResourceSharesResponse' :: GetResourceSharesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetResourceSharesResponse
s@GetResourceSharesResponse' {} Maybe Text
a -> GetResourceSharesResponse
s {$sel:nextToken:GetResourceSharesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetResourceSharesResponse)

-- | An array of objects that contain the information about the resource
-- shares.
getResourceSharesResponse_resourceShares :: Lens.Lens' GetResourceSharesResponse (Prelude.Maybe [ResourceShare])
getResourceSharesResponse_resourceShares :: Lens' GetResourceSharesResponse (Maybe [ResourceShare])
getResourceSharesResponse_resourceShares = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceSharesResponse' {Maybe [ResourceShare]
resourceShares :: Maybe [ResourceShare]
$sel:resourceShares:GetResourceSharesResponse' :: GetResourceSharesResponse -> Maybe [ResourceShare]
resourceShares} -> Maybe [ResourceShare]
resourceShares) (\s :: GetResourceSharesResponse
s@GetResourceSharesResponse' {} Maybe [ResourceShare]
a -> GetResourceSharesResponse
s {$sel:resourceShares:GetResourceSharesResponse' :: Maybe [ResourceShare]
resourceShares = Maybe [ResourceShare]
a} :: GetResourceSharesResponse) 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.
getResourceSharesResponse_httpStatus :: Lens.Lens' GetResourceSharesResponse Prelude.Int
getResourceSharesResponse_httpStatus :: Lens' GetResourceSharesResponse Int
getResourceSharesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceSharesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetResourceSharesResponse' :: GetResourceSharesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetResourceSharesResponse
s@GetResourceSharesResponse' {} Int
a -> GetResourceSharesResponse
s {$sel:httpStatus:GetResourceSharesResponse' :: Int
httpStatus = Int
a} :: GetResourceSharesResponse)

instance Prelude.NFData GetResourceSharesResponse where
  rnf :: GetResourceSharesResponse -> ()
rnf GetResourceSharesResponse' {Int
Maybe [ResourceShare]
Maybe Text
httpStatus :: Int
resourceShares :: Maybe [ResourceShare]
nextToken :: Maybe Text
$sel:httpStatus:GetResourceSharesResponse' :: GetResourceSharesResponse -> Int
$sel:resourceShares:GetResourceSharesResponse' :: GetResourceSharesResponse -> Maybe [ResourceShare]
$sel:nextToken:GetResourceSharesResponse' :: GetResourceSharesResponse -> 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 [ResourceShare]
resourceShares
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus