{-# 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.CodeGuruReviewer.ListRepositoryAssociations
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociationSummary.html RepositoryAssociationSummary>
-- objects that contain summary information about a repository association.
-- You can filter the returned list by
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociationSummary.html#reviewer-Type-RepositoryAssociationSummary-ProviderType ProviderType>,
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociationSummary.html#reviewer-Type-RepositoryAssociationSummary-Name Name>,
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociationSummary.html#reviewer-Type-RepositoryAssociationSummary-State State>,
-- and
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_RepositoryAssociationSummary.html#reviewer-Type-RepositoryAssociationSummary-Owner Owner>.
--
-- This operation returns paginated results.
module Amazonka.CodeGuruReviewer.ListRepositoryAssociations
  ( -- * Creating a Request
    ListRepositoryAssociations (..),
    newListRepositoryAssociations,

    -- * Request Lenses
    listRepositoryAssociations_maxResults,
    listRepositoryAssociations_names,
    listRepositoryAssociations_nextToken,
    listRepositoryAssociations_owners,
    listRepositoryAssociations_providerTypes,
    listRepositoryAssociations_states,

    -- * Destructuring the Response
    ListRepositoryAssociationsResponse (..),
    newListRepositoryAssociationsResponse,

    -- * Response Lenses
    listRepositoryAssociationsResponse_nextToken,
    listRepositoryAssociationsResponse_repositoryAssociationSummaries,
    listRepositoryAssociationsResponse_httpStatus,
  )
where

import Amazonka.CodeGuruReviewer.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListRepositoryAssociations' smart constructor.
data ListRepositoryAssociations = ListRepositoryAssociations'
  { -- | The maximum number of repository association results returned by
    -- @ListRepositoryAssociations@ in paginated output. When this parameter is
    -- used, @ListRepositoryAssociations@ only returns @maxResults@ results in
    -- a single page with a @nextToken@ response element. The remaining results
    -- of the initial request can be seen by sending another
    -- @ListRepositoryAssociations@ request with the returned @nextToken@
    -- value. This value can be between 1 and 100. If this parameter is not
    -- used, @ListRepositoryAssociations@ returns up to 100 results and a
    -- @nextToken@ value if applicable.
    ListRepositoryAssociations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | List of repository names to use as a filter.
    ListRepositoryAssociations -> Maybe (NonEmpty Text)
names :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The @nextToken@ value returned from a previous paginated
    -- @ListRepositoryAssociations@ request where @maxResults@ was used and the
    -- results exceeded the value of that parameter. Pagination continues from
    -- the end of the previous results that returned the @nextToken@ value.
    --
    -- Treat this token as an opaque identifier that is only used to retrieve
    -- the next items in a list and not for other programmatic purposes.
    ListRepositoryAssociations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | List of owners to use as a filter. For Amazon Web Services CodeCommit,
    -- it is the name of the CodeCommit account that was used to associate the
    -- repository. For other repository source providers, such as Bitbucket and
    -- GitHub Enterprise Server, this is name of the account that was used to
    -- associate the repository.
    ListRepositoryAssociations -> Maybe (NonEmpty Text)
owners :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | List of provider types to use as a filter.
    ListRepositoryAssociations -> Maybe (NonEmpty ProviderType)
providerTypes :: Prelude.Maybe (Prelude.NonEmpty ProviderType),
    -- | List of repository association states to use as a filter.
    --
    -- The valid repository association states are:
    --
    -- -   __Associated__: The repository association is complete.
    --
    -- -   __Associating__: CodeGuru Reviewer is:
    --
    --     -   Setting up pull request notifications. This is required for pull
    --         requests to trigger a CodeGuru Reviewer review.
    --
    --         If your repository @ProviderType@ is @GitHub@,
    --         @GitHub Enterprise Server@, or @Bitbucket@, CodeGuru Reviewer
    --         creates webhooks in your repository to trigger CodeGuru Reviewer
    --         reviews. If you delete these webhooks, reviews of code in your
    --         repository cannot be triggered.
    --
    --     -   Setting up source code access. This is required for CodeGuru
    --         Reviewer to securely clone code in your repository.
    --
    -- -   __Failed__: The repository failed to associate or disassociate.
    --
    -- -   __Disassociating__: CodeGuru Reviewer is removing the repository\'s
    --     pull request notifications and source code access.
    --
    -- -   __Disassociated__: CodeGuru Reviewer successfully disassociated the
    --     repository. You can create a new association with this repository if
    --     you want to review source code in it later. You can control access
    --     to code reviews created in anassociated repository with tags after
    --     it has been disassociated. For more information, see
    --     <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/auth-and-access-control-using-tags.html Using tags to control access to associated repositories>
    --     in the /Amazon CodeGuru Reviewer User Guide/.
    ListRepositoryAssociations
-> Maybe (NonEmpty RepositoryAssociationState)
states :: Prelude.Maybe (Prelude.NonEmpty RepositoryAssociationState)
  }
  deriving (ListRepositoryAssociations -> ListRepositoryAssociations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRepositoryAssociations -> ListRepositoryAssociations -> Bool
$c/= :: ListRepositoryAssociations -> ListRepositoryAssociations -> Bool
== :: ListRepositoryAssociations -> ListRepositoryAssociations -> Bool
$c== :: ListRepositoryAssociations -> ListRepositoryAssociations -> Bool
Prelude.Eq, ReadPrec [ListRepositoryAssociations]
ReadPrec ListRepositoryAssociations
Int -> ReadS ListRepositoryAssociations
ReadS [ListRepositoryAssociations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRepositoryAssociations]
$creadListPrec :: ReadPrec [ListRepositoryAssociations]
readPrec :: ReadPrec ListRepositoryAssociations
$creadPrec :: ReadPrec ListRepositoryAssociations
readList :: ReadS [ListRepositoryAssociations]
$creadList :: ReadS [ListRepositoryAssociations]
readsPrec :: Int -> ReadS ListRepositoryAssociations
$creadsPrec :: Int -> ReadS ListRepositoryAssociations
Prelude.Read, Int -> ListRepositoryAssociations -> ShowS
[ListRepositoryAssociations] -> ShowS
ListRepositoryAssociations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRepositoryAssociations] -> ShowS
$cshowList :: [ListRepositoryAssociations] -> ShowS
show :: ListRepositoryAssociations -> String
$cshow :: ListRepositoryAssociations -> String
showsPrec :: Int -> ListRepositoryAssociations -> ShowS
$cshowsPrec :: Int -> ListRepositoryAssociations -> ShowS
Prelude.Show, forall x.
Rep ListRepositoryAssociations x -> ListRepositoryAssociations
forall x.
ListRepositoryAssociations -> Rep ListRepositoryAssociations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListRepositoryAssociations x -> ListRepositoryAssociations
$cfrom :: forall x.
ListRepositoryAssociations -> Rep ListRepositoryAssociations x
Prelude.Generic)

-- |
-- Create a value of 'ListRepositoryAssociations' 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', 'listRepositoryAssociations_maxResults' - The maximum number of repository association results returned by
-- @ListRepositoryAssociations@ in paginated output. When this parameter is
-- used, @ListRepositoryAssociations@ only returns @maxResults@ results in
-- a single page with a @nextToken@ response element. The remaining results
-- of the initial request can be seen by sending another
-- @ListRepositoryAssociations@ request with the returned @nextToken@
-- value. This value can be between 1 and 100. If this parameter is not
-- used, @ListRepositoryAssociations@ returns up to 100 results and a
-- @nextToken@ value if applicable.
--
-- 'names', 'listRepositoryAssociations_names' - List of repository names to use as a filter.
--
-- 'nextToken', 'listRepositoryAssociations_nextToken' - The @nextToken@ value returned from a previous paginated
-- @ListRepositoryAssociations@ request where @maxResults@ was used and the
-- results exceeded the value of that parameter. Pagination continues from
-- the end of the previous results that returned the @nextToken@ value.
--
-- Treat this token as an opaque identifier that is only used to retrieve
-- the next items in a list and not for other programmatic purposes.
--
-- 'owners', 'listRepositoryAssociations_owners' - List of owners to use as a filter. For Amazon Web Services CodeCommit,
-- it is the name of the CodeCommit account that was used to associate the
-- repository. For other repository source providers, such as Bitbucket and
-- GitHub Enterprise Server, this is name of the account that was used to
-- associate the repository.
--
-- 'providerTypes', 'listRepositoryAssociations_providerTypes' - List of provider types to use as a filter.
--
-- 'states', 'listRepositoryAssociations_states' - List of repository association states to use as a filter.
--
-- The valid repository association states are:
--
-- -   __Associated__: The repository association is complete.
--
-- -   __Associating__: CodeGuru Reviewer is:
--
--     -   Setting up pull request notifications. This is required for pull
--         requests to trigger a CodeGuru Reviewer review.
--
--         If your repository @ProviderType@ is @GitHub@,
--         @GitHub Enterprise Server@, or @Bitbucket@, CodeGuru Reviewer
--         creates webhooks in your repository to trigger CodeGuru Reviewer
--         reviews. If you delete these webhooks, reviews of code in your
--         repository cannot be triggered.
--
--     -   Setting up source code access. This is required for CodeGuru
--         Reviewer to securely clone code in your repository.
--
-- -   __Failed__: The repository failed to associate or disassociate.
--
-- -   __Disassociating__: CodeGuru Reviewer is removing the repository\'s
--     pull request notifications and source code access.
--
-- -   __Disassociated__: CodeGuru Reviewer successfully disassociated the
--     repository. You can create a new association with this repository if
--     you want to review source code in it later. You can control access
--     to code reviews created in anassociated repository with tags after
--     it has been disassociated. For more information, see
--     <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/auth-and-access-control-using-tags.html Using tags to control access to associated repositories>
--     in the /Amazon CodeGuru Reviewer User Guide/.
newListRepositoryAssociations ::
  ListRepositoryAssociations
newListRepositoryAssociations :: ListRepositoryAssociations
newListRepositoryAssociations =
  ListRepositoryAssociations'
    { $sel:maxResults:ListRepositoryAssociations' :: Maybe Natural
maxResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:names:ListRepositoryAssociations' :: Maybe (NonEmpty Text)
names = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRepositoryAssociations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:owners:ListRepositoryAssociations' :: Maybe (NonEmpty Text)
owners = forall a. Maybe a
Prelude.Nothing,
      $sel:providerTypes:ListRepositoryAssociations' :: Maybe (NonEmpty ProviderType)
providerTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:states:ListRepositoryAssociations' :: Maybe (NonEmpty RepositoryAssociationState)
states = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of repository association results returned by
-- @ListRepositoryAssociations@ in paginated output. When this parameter is
-- used, @ListRepositoryAssociations@ only returns @maxResults@ results in
-- a single page with a @nextToken@ response element. The remaining results
-- of the initial request can be seen by sending another
-- @ListRepositoryAssociations@ request with the returned @nextToken@
-- value. This value can be between 1 and 100. If this parameter is not
-- used, @ListRepositoryAssociations@ returns up to 100 results and a
-- @nextToken@ value if applicable.
listRepositoryAssociations_maxResults :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe Prelude.Natural)
listRepositoryAssociations_maxResults :: Lens' ListRepositoryAssociations (Maybe Natural)
listRepositoryAssociations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe Natural
a -> ListRepositoryAssociations
s {$sel:maxResults:ListRepositoryAssociations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListRepositoryAssociations)

-- | List of repository names to use as a filter.
listRepositoryAssociations_names :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
listRepositoryAssociations_names :: Lens' ListRepositoryAssociations (Maybe (NonEmpty Text))
listRepositoryAssociations_names = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe (NonEmpty Text)
names :: Maybe (NonEmpty Text)
$sel:names:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
names} -> Maybe (NonEmpty Text)
names) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe (NonEmpty Text)
a -> ListRepositoryAssociations
s {$sel:names:ListRepositoryAssociations' :: Maybe (NonEmpty Text)
names = Maybe (NonEmpty Text)
a} :: ListRepositoryAssociations) 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 @nextToken@ value returned from a previous paginated
-- @ListRepositoryAssociations@ request where @maxResults@ was used and the
-- results exceeded the value of that parameter. Pagination continues from
-- the end of the previous results that returned the @nextToken@ value.
--
-- Treat this token as an opaque identifier that is only used to retrieve
-- the next items in a list and not for other programmatic purposes.
listRepositoryAssociations_nextToken :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe Prelude.Text)
listRepositoryAssociations_nextToken :: Lens' ListRepositoryAssociations (Maybe Text)
listRepositoryAssociations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe Text
a -> ListRepositoryAssociations
s {$sel:nextToken:ListRepositoryAssociations' :: Maybe Text
nextToken = Maybe Text
a} :: ListRepositoryAssociations)

-- | List of owners to use as a filter. For Amazon Web Services CodeCommit,
-- it is the name of the CodeCommit account that was used to associate the
-- repository. For other repository source providers, such as Bitbucket and
-- GitHub Enterprise Server, this is name of the account that was used to
-- associate the repository.
listRepositoryAssociations_owners :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
listRepositoryAssociations_owners :: Lens' ListRepositoryAssociations (Maybe (NonEmpty Text))
listRepositoryAssociations_owners = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe (NonEmpty Text)
owners :: Maybe (NonEmpty Text)
$sel:owners:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
owners} -> Maybe (NonEmpty Text)
owners) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe (NonEmpty Text)
a -> ListRepositoryAssociations
s {$sel:owners:ListRepositoryAssociations' :: Maybe (NonEmpty Text)
owners = Maybe (NonEmpty Text)
a} :: ListRepositoryAssociations) 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

-- | List of provider types to use as a filter.
listRepositoryAssociations_providerTypes :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe (Prelude.NonEmpty ProviderType))
listRepositoryAssociations_providerTypes :: Lens' ListRepositoryAssociations (Maybe (NonEmpty ProviderType))
listRepositoryAssociations_providerTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe (NonEmpty ProviderType)
providerTypes :: Maybe (NonEmpty ProviderType)
$sel:providerTypes:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty ProviderType)
providerTypes} -> Maybe (NonEmpty ProviderType)
providerTypes) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe (NonEmpty ProviderType)
a -> ListRepositoryAssociations
s {$sel:providerTypes:ListRepositoryAssociations' :: Maybe (NonEmpty ProviderType)
providerTypes = Maybe (NonEmpty ProviderType)
a} :: ListRepositoryAssociations) 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

-- | List of repository association states to use as a filter.
--
-- The valid repository association states are:
--
-- -   __Associated__: The repository association is complete.
--
-- -   __Associating__: CodeGuru Reviewer is:
--
--     -   Setting up pull request notifications. This is required for pull
--         requests to trigger a CodeGuru Reviewer review.
--
--         If your repository @ProviderType@ is @GitHub@,
--         @GitHub Enterprise Server@, or @Bitbucket@, CodeGuru Reviewer
--         creates webhooks in your repository to trigger CodeGuru Reviewer
--         reviews. If you delete these webhooks, reviews of code in your
--         repository cannot be triggered.
--
--     -   Setting up source code access. This is required for CodeGuru
--         Reviewer to securely clone code in your repository.
--
-- -   __Failed__: The repository failed to associate or disassociate.
--
-- -   __Disassociating__: CodeGuru Reviewer is removing the repository\'s
--     pull request notifications and source code access.
--
-- -   __Disassociated__: CodeGuru Reviewer successfully disassociated the
--     repository. You can create a new association with this repository if
--     you want to review source code in it later. You can control access
--     to code reviews created in anassociated repository with tags after
--     it has been disassociated. For more information, see
--     <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/auth-and-access-control-using-tags.html Using tags to control access to associated repositories>
--     in the /Amazon CodeGuru Reviewer User Guide/.
listRepositoryAssociations_states :: Lens.Lens' ListRepositoryAssociations (Prelude.Maybe (Prelude.NonEmpty RepositoryAssociationState))
listRepositoryAssociations_states :: Lens'
  ListRepositoryAssociations
  (Maybe (NonEmpty RepositoryAssociationState))
listRepositoryAssociations_states = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociations' {Maybe (NonEmpty RepositoryAssociationState)
states :: Maybe (NonEmpty RepositoryAssociationState)
$sel:states:ListRepositoryAssociations' :: ListRepositoryAssociations
-> Maybe (NonEmpty RepositoryAssociationState)
states} -> Maybe (NonEmpty RepositoryAssociationState)
states) (\s :: ListRepositoryAssociations
s@ListRepositoryAssociations' {} Maybe (NonEmpty RepositoryAssociationState)
a -> ListRepositoryAssociations
s {$sel:states:ListRepositoryAssociations' :: Maybe (NonEmpty RepositoryAssociationState)
states = Maybe (NonEmpty RepositoryAssociationState)
a} :: ListRepositoryAssociations) 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

instance Core.AWSPager ListRepositoryAssociations where
  page :: ListRepositoryAssociations
-> AWSResponse ListRepositoryAssociations
-> Maybe ListRepositoryAssociations
page ListRepositoryAssociations
rq AWSResponse ListRepositoryAssociations
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRepositoryAssociations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRepositoryAssociationsResponse (Maybe Text)
listRepositoryAssociationsResponse_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 ListRepositoryAssociations
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  ListRepositoryAssociationsResponse
  (Maybe [RepositoryAssociationSummary])
listRepositoryAssociationsResponse_repositoryAssociationSummaries
            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.$ ListRepositoryAssociations
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRepositoryAssociations (Maybe Text)
listRepositoryAssociations_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRepositoryAssociations
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRepositoryAssociationsResponse (Maybe Text)
listRepositoryAssociationsResponse_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 ListRepositoryAssociations where
  type
    AWSResponse ListRepositoryAssociations =
      ListRepositoryAssociationsResponse
  request :: (Service -> Service)
-> ListRepositoryAssociations -> Request ListRepositoryAssociations
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListRepositoryAssociations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListRepositoryAssociations)))
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 [RepositoryAssociationSummary]
-> Int
-> ListRepositoryAssociationsResponse
ListRepositoryAssociationsResponse'
            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
"RepositoryAssociationSummaries"
                            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 ListRepositoryAssociations where
  hashWithSalt :: Int -> ListRepositoryAssociations -> Int
hashWithSalt Int
_salt ListRepositoryAssociations' {Maybe Natural
Maybe (NonEmpty Text)
Maybe (NonEmpty ProviderType)
Maybe (NonEmpty RepositoryAssociationState)
Maybe Text
states :: Maybe (NonEmpty RepositoryAssociationState)
providerTypes :: Maybe (NonEmpty ProviderType)
owners :: Maybe (NonEmpty Text)
nextToken :: Maybe Text
names :: Maybe (NonEmpty Text)
maxResults :: Maybe Natural
$sel:states:ListRepositoryAssociations' :: ListRepositoryAssociations
-> Maybe (NonEmpty RepositoryAssociationState)
$sel:providerTypes:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty ProviderType)
$sel:owners:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:nextToken:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Text
$sel:names:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:maxResults:ListRepositoryAssociations' :: ListRepositoryAssociations -> 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 (NonEmpty Text)
names
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
owners
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ProviderType)
providerTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty RepositoryAssociationState)
states

instance Prelude.NFData ListRepositoryAssociations where
  rnf :: ListRepositoryAssociations -> ()
rnf ListRepositoryAssociations' {Maybe Natural
Maybe (NonEmpty Text)
Maybe (NonEmpty ProviderType)
Maybe (NonEmpty RepositoryAssociationState)
Maybe Text
states :: Maybe (NonEmpty RepositoryAssociationState)
providerTypes :: Maybe (NonEmpty ProviderType)
owners :: Maybe (NonEmpty Text)
nextToken :: Maybe Text
names :: Maybe (NonEmpty Text)
maxResults :: Maybe Natural
$sel:states:ListRepositoryAssociations' :: ListRepositoryAssociations
-> Maybe (NonEmpty RepositoryAssociationState)
$sel:providerTypes:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty ProviderType)
$sel:owners:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:nextToken:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Text
$sel:names:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:maxResults:ListRepositoryAssociations' :: ListRepositoryAssociations -> 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 (NonEmpty Text)
names
      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 (NonEmpty Text)
owners
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ProviderType)
providerTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty RepositoryAssociationState)
states

instance Data.ToHeaders ListRepositoryAssociations where
  toHeaders :: ListRepositoryAssociations -> 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.ToPath ListRepositoryAssociations where
  toPath :: ListRepositoryAssociations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/associations"

instance Data.ToQuery ListRepositoryAssociations where
  toQuery :: ListRepositoryAssociations -> QueryString
toQuery ListRepositoryAssociations' {Maybe Natural
Maybe (NonEmpty Text)
Maybe (NonEmpty ProviderType)
Maybe (NonEmpty RepositoryAssociationState)
Maybe Text
states :: Maybe (NonEmpty RepositoryAssociationState)
providerTypes :: Maybe (NonEmpty ProviderType)
owners :: Maybe (NonEmpty Text)
nextToken :: Maybe Text
names :: Maybe (NonEmpty Text)
maxResults :: Maybe Natural
$sel:states:ListRepositoryAssociations' :: ListRepositoryAssociations
-> Maybe (NonEmpty RepositoryAssociationState)
$sel:providerTypes:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty ProviderType)
$sel:owners:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:nextToken:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Text
$sel:names:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe (NonEmpty Text)
$sel:maxResults:ListRepositoryAssociations' :: ListRepositoryAssociations -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"MaxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"Name"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
names),
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"Owner"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
owners),
        ByteString
"ProviderType"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ProviderType)
providerTypes
            ),
        ByteString
"State"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty RepositoryAssociationState)
states)
      ]

-- | /See:/ 'newListRepositoryAssociationsResponse' smart constructor.
data ListRepositoryAssociationsResponse = ListRepositoryAssociationsResponse'
  { -- | The @nextToken@ value to include in a future @ListRecommendations@
    -- request. When the results of a @ListRecommendations@ request exceed
    -- @maxResults@, this value can be used to retrieve the next page of
    -- results. This value is @null@ when there are no more results to return.
    ListRepositoryAssociationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of repository associations that meet the criteria of the request.
    ListRepositoryAssociationsResponse
-> Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries :: Prelude.Maybe [RepositoryAssociationSummary],
    -- | The response's http status code.
    ListRepositoryAssociationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListRepositoryAssociationsResponse
-> ListRepositoryAssociationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRepositoryAssociationsResponse
-> ListRepositoryAssociationsResponse -> Bool
$c/= :: ListRepositoryAssociationsResponse
-> ListRepositoryAssociationsResponse -> Bool
== :: ListRepositoryAssociationsResponse
-> ListRepositoryAssociationsResponse -> Bool
$c== :: ListRepositoryAssociationsResponse
-> ListRepositoryAssociationsResponse -> Bool
Prelude.Eq, ReadPrec [ListRepositoryAssociationsResponse]
ReadPrec ListRepositoryAssociationsResponse
Int -> ReadS ListRepositoryAssociationsResponse
ReadS [ListRepositoryAssociationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRepositoryAssociationsResponse]
$creadListPrec :: ReadPrec [ListRepositoryAssociationsResponse]
readPrec :: ReadPrec ListRepositoryAssociationsResponse
$creadPrec :: ReadPrec ListRepositoryAssociationsResponse
readList :: ReadS [ListRepositoryAssociationsResponse]
$creadList :: ReadS [ListRepositoryAssociationsResponse]
readsPrec :: Int -> ReadS ListRepositoryAssociationsResponse
$creadsPrec :: Int -> ReadS ListRepositoryAssociationsResponse
Prelude.Read, Int -> ListRepositoryAssociationsResponse -> ShowS
[ListRepositoryAssociationsResponse] -> ShowS
ListRepositoryAssociationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRepositoryAssociationsResponse] -> ShowS
$cshowList :: [ListRepositoryAssociationsResponse] -> ShowS
show :: ListRepositoryAssociationsResponse -> String
$cshow :: ListRepositoryAssociationsResponse -> String
showsPrec :: Int -> ListRepositoryAssociationsResponse -> ShowS
$cshowsPrec :: Int -> ListRepositoryAssociationsResponse -> ShowS
Prelude.Show, forall x.
Rep ListRepositoryAssociationsResponse x
-> ListRepositoryAssociationsResponse
forall x.
ListRepositoryAssociationsResponse
-> Rep ListRepositoryAssociationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListRepositoryAssociationsResponse x
-> ListRepositoryAssociationsResponse
$cfrom :: forall x.
ListRepositoryAssociationsResponse
-> Rep ListRepositoryAssociationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListRepositoryAssociationsResponse' 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', 'listRepositoryAssociationsResponse_nextToken' - The @nextToken@ value to include in a future @ListRecommendations@
-- request. When the results of a @ListRecommendations@ request exceed
-- @maxResults@, this value can be used to retrieve the next page of
-- results. This value is @null@ when there are no more results to return.
--
-- 'repositoryAssociationSummaries', 'listRepositoryAssociationsResponse_repositoryAssociationSummaries' - A list of repository associations that meet the criteria of the request.
--
-- 'httpStatus', 'listRepositoryAssociationsResponse_httpStatus' - The response's http status code.
newListRepositoryAssociationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRepositoryAssociationsResponse
newListRepositoryAssociationsResponse :: Int -> ListRepositoryAssociationsResponse
newListRepositoryAssociationsResponse Int
pHttpStatus_ =
  ListRepositoryAssociationsResponse'
    { $sel:nextToken:ListRepositoryAssociationsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryAssociationSummaries:ListRepositoryAssociationsResponse' :: Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRepositoryAssociationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @nextToken@ value to include in a future @ListRecommendations@
-- request. When the results of a @ListRecommendations@ request exceed
-- @maxResults@, this value can be used to retrieve the next page of
-- results. This value is @null@ when there are no more results to return.
listRepositoryAssociationsResponse_nextToken :: Lens.Lens' ListRepositoryAssociationsResponse (Prelude.Maybe Prelude.Text)
listRepositoryAssociationsResponse_nextToken :: Lens' ListRepositoryAssociationsResponse (Maybe Text)
listRepositoryAssociationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRepositoryAssociationsResponse' :: ListRepositoryAssociationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRepositoryAssociationsResponse
s@ListRepositoryAssociationsResponse' {} Maybe Text
a -> ListRepositoryAssociationsResponse
s {$sel:nextToken:ListRepositoryAssociationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRepositoryAssociationsResponse)

-- | A list of repository associations that meet the criteria of the request.
listRepositoryAssociationsResponse_repositoryAssociationSummaries :: Lens.Lens' ListRepositoryAssociationsResponse (Prelude.Maybe [RepositoryAssociationSummary])
listRepositoryAssociationsResponse_repositoryAssociationSummaries :: Lens'
  ListRepositoryAssociationsResponse
  (Maybe [RepositoryAssociationSummary])
listRepositoryAssociationsResponse_repositoryAssociationSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociationsResponse' {Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries :: Maybe [RepositoryAssociationSummary]
$sel:repositoryAssociationSummaries:ListRepositoryAssociationsResponse' :: ListRepositoryAssociationsResponse
-> Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries} -> Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries) (\s :: ListRepositoryAssociationsResponse
s@ListRepositoryAssociationsResponse' {} Maybe [RepositoryAssociationSummary]
a -> ListRepositoryAssociationsResponse
s {$sel:repositoryAssociationSummaries:ListRepositoryAssociationsResponse' :: Maybe [RepositoryAssociationSummary]
repositoryAssociationSummaries = Maybe [RepositoryAssociationSummary]
a} :: ListRepositoryAssociationsResponse) 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.
listRepositoryAssociationsResponse_httpStatus :: Lens.Lens' ListRepositoryAssociationsResponse Prelude.Int
listRepositoryAssociationsResponse_httpStatus :: Lens' ListRepositoryAssociationsResponse Int
listRepositoryAssociationsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRepositoryAssociationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListRepositoryAssociationsResponse' :: ListRepositoryAssociationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListRepositoryAssociationsResponse
s@ListRepositoryAssociationsResponse' {} Int
a -> ListRepositoryAssociationsResponse
s {$sel:httpStatus:ListRepositoryAssociationsResponse' :: Int
httpStatus = Int
a} :: ListRepositoryAssociationsResponse)

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