{-# 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.ManagedBlockChain.ListAccessors
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The token based access feature is in preview release for Ethereum on
-- Amazon Managed Blockchain and is subject to change. We recommend that
-- you use this feature only with test scenarios, and not in production
-- environments.
--
-- Returns a list of the accessors and their properties. Accessor objects
-- are containers that have the information required for token based access
-- to your Ethereum nodes.
--
-- This operation returns paginated results.
module Amazonka.ManagedBlockChain.ListAccessors
  ( -- * Creating a Request
    ListAccessors (..),
    newListAccessors,

    -- * Request Lenses
    listAccessors_maxResults,
    listAccessors_nextToken,

    -- * Destructuring the Response
    ListAccessorsResponse (..),
    newListAccessorsResponse,

    -- * Response Lenses
    listAccessorsResponse_accessors,
    listAccessorsResponse_nextToken,
    listAccessorsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ManagedBlockChain.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListAccessors' smart constructor.
data ListAccessors = ListAccessors'
  { -- | The maximum number of accessors to list.
    ListAccessors -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token that indicates the next set of results to retrieve.
    ListAccessors -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListAccessors -> ListAccessors -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessors -> ListAccessors -> Bool
$c/= :: ListAccessors -> ListAccessors -> Bool
== :: ListAccessors -> ListAccessors -> Bool
$c== :: ListAccessors -> ListAccessors -> Bool
Prelude.Eq, ReadPrec [ListAccessors]
ReadPrec ListAccessors
Int -> ReadS ListAccessors
ReadS [ListAccessors]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessors]
$creadListPrec :: ReadPrec [ListAccessors]
readPrec :: ReadPrec ListAccessors
$creadPrec :: ReadPrec ListAccessors
readList :: ReadS [ListAccessors]
$creadList :: ReadS [ListAccessors]
readsPrec :: Int -> ReadS ListAccessors
$creadsPrec :: Int -> ReadS ListAccessors
Prelude.Read, Int -> ListAccessors -> ShowS
[ListAccessors] -> ShowS
ListAccessors -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessors] -> ShowS
$cshowList :: [ListAccessors] -> ShowS
show :: ListAccessors -> String
$cshow :: ListAccessors -> String
showsPrec :: Int -> ListAccessors -> ShowS
$cshowsPrec :: Int -> ListAccessors -> ShowS
Prelude.Show, forall x. Rep ListAccessors x -> ListAccessors
forall x. ListAccessors -> Rep ListAccessors x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccessors x -> ListAccessors
$cfrom :: forall x. ListAccessors -> Rep ListAccessors x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessors' 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', 'listAccessors_maxResults' - The maximum number of accessors to list.
--
-- 'nextToken', 'listAccessors_nextToken' - The pagination token that indicates the next set of results to retrieve.
newListAccessors ::
  ListAccessors
newListAccessors :: ListAccessors
newListAccessors =
  ListAccessors'
    { $sel:maxResults:ListAccessors' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAccessors' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of accessors to list.
listAccessors_maxResults :: Lens.Lens' ListAccessors (Prelude.Maybe Prelude.Natural)
listAccessors_maxResults :: Lens' ListAccessors (Maybe Natural)
listAccessors_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessors' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAccessors' :: ListAccessors -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAccessors
s@ListAccessors' {} Maybe Natural
a -> ListAccessors
s {$sel:maxResults:ListAccessors' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAccessors)

-- | The pagination token that indicates the next set of results to retrieve.
listAccessors_nextToken :: Lens.Lens' ListAccessors (Prelude.Maybe Prelude.Text)
listAccessors_nextToken :: Lens' ListAccessors (Maybe Text)
listAccessors_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessors' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessors' :: ListAccessors -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessors
s@ListAccessors' {} Maybe Text
a -> ListAccessors
s {$sel:nextToken:ListAccessors' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessors)

instance Core.AWSPager ListAccessors where
  page :: ListAccessors -> AWSResponse ListAccessors -> Maybe ListAccessors
page ListAccessors
rq AWSResponse ListAccessors
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAccessors
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccessorsResponse (Maybe Text)
listAccessorsResponse_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 ListAccessors
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccessorsResponse (Maybe [AccessorSummary])
listAccessorsResponse_accessors
            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.$ ListAccessors
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListAccessors (Maybe Text)
listAccessors_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAccessors
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAccessorsResponse (Maybe Text)
listAccessorsResponse_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 ListAccessors where
  type
    AWSResponse ListAccessors =
      ListAccessorsResponse
  request :: (Service -> Service) -> ListAccessors -> Request ListAccessors
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 ListAccessors
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAccessors)))
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 [AccessorSummary]
-> Maybe Text -> Int -> ListAccessorsResponse
ListAccessorsResponse'
            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
"Accessors" 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.<*> (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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListAccessors where
  hashWithSalt :: Int -> ListAccessors -> Int
hashWithSalt Int
_salt ListAccessors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAccessors' :: ListAccessors -> Maybe Text
$sel:maxResults:ListAccessors' :: ListAccessors -> 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
nextToken

instance Prelude.NFData ListAccessors where
  rnf :: ListAccessors -> ()
rnf ListAccessors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAccessors' :: ListAccessors -> Maybe Text
$sel:maxResults:ListAccessors' :: ListAccessors -> 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
nextToken

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

instance Data.ToQuery ListAccessors where
  toQuery :: ListAccessors -> QueryString
toQuery ListAccessors' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAccessors' :: ListAccessors -> Maybe Text
$sel:maxResults:ListAccessors' :: ListAccessors -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListAccessorsResponse' smart constructor.
data ListAccessorsResponse = ListAccessorsResponse'
  { -- | An array of AccessorSummary objects that contain configuration
    -- properties for each accessor.
    ListAccessorsResponse -> Maybe [AccessorSummary]
accessors :: Prelude.Maybe [AccessorSummary],
    -- | The pagination token that indicates the next set of results to retrieve.
    ListAccessorsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAccessorsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAccessorsResponse -> ListAccessorsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessorsResponse -> ListAccessorsResponse -> Bool
$c/= :: ListAccessorsResponse -> ListAccessorsResponse -> Bool
== :: ListAccessorsResponse -> ListAccessorsResponse -> Bool
$c== :: ListAccessorsResponse -> ListAccessorsResponse -> Bool
Prelude.Eq, ReadPrec [ListAccessorsResponse]
ReadPrec ListAccessorsResponse
Int -> ReadS ListAccessorsResponse
ReadS [ListAccessorsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAccessorsResponse]
$creadListPrec :: ReadPrec [ListAccessorsResponse]
readPrec :: ReadPrec ListAccessorsResponse
$creadPrec :: ReadPrec ListAccessorsResponse
readList :: ReadS [ListAccessorsResponse]
$creadList :: ReadS [ListAccessorsResponse]
readsPrec :: Int -> ReadS ListAccessorsResponse
$creadsPrec :: Int -> ReadS ListAccessorsResponse
Prelude.Read, Int -> ListAccessorsResponse -> ShowS
[ListAccessorsResponse] -> ShowS
ListAccessorsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessorsResponse] -> ShowS
$cshowList :: [ListAccessorsResponse] -> ShowS
show :: ListAccessorsResponse -> String
$cshow :: ListAccessorsResponse -> String
showsPrec :: Int -> ListAccessorsResponse -> ShowS
$cshowsPrec :: Int -> ListAccessorsResponse -> ShowS
Prelude.Show, forall x. Rep ListAccessorsResponse x -> ListAccessorsResponse
forall x. ListAccessorsResponse -> Rep ListAccessorsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAccessorsResponse x -> ListAccessorsResponse
$cfrom :: forall x. ListAccessorsResponse -> Rep ListAccessorsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAccessorsResponse' 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:
--
-- 'accessors', 'listAccessorsResponse_accessors' - An array of AccessorSummary objects that contain configuration
-- properties for each accessor.
--
-- 'nextToken', 'listAccessorsResponse_nextToken' - The pagination token that indicates the next set of results to retrieve.
--
-- 'httpStatus', 'listAccessorsResponse_httpStatus' - The response's http status code.
newListAccessorsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAccessorsResponse
newListAccessorsResponse :: Int -> ListAccessorsResponse
newListAccessorsResponse Int
pHttpStatus_ =
  ListAccessorsResponse'
    { $sel:accessors:ListAccessorsResponse' :: Maybe [AccessorSummary]
accessors = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAccessorsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAccessorsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of AccessorSummary objects that contain configuration
-- properties for each accessor.
listAccessorsResponse_accessors :: Lens.Lens' ListAccessorsResponse (Prelude.Maybe [AccessorSummary])
listAccessorsResponse_accessors :: Lens' ListAccessorsResponse (Maybe [AccessorSummary])
listAccessorsResponse_accessors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessorsResponse' {Maybe [AccessorSummary]
accessors :: Maybe [AccessorSummary]
$sel:accessors:ListAccessorsResponse' :: ListAccessorsResponse -> Maybe [AccessorSummary]
accessors} -> Maybe [AccessorSummary]
accessors) (\s :: ListAccessorsResponse
s@ListAccessorsResponse' {} Maybe [AccessorSummary]
a -> ListAccessorsResponse
s {$sel:accessors:ListAccessorsResponse' :: Maybe [AccessorSummary]
accessors = Maybe [AccessorSummary]
a} :: ListAccessorsResponse) 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 pagination token that indicates the next set of results to retrieve.
listAccessorsResponse_nextToken :: Lens.Lens' ListAccessorsResponse (Prelude.Maybe Prelude.Text)
listAccessorsResponse_nextToken :: Lens' ListAccessorsResponse (Maybe Text)
listAccessorsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAccessorsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAccessorsResponse' :: ListAccessorsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAccessorsResponse
s@ListAccessorsResponse' {} Maybe Text
a -> ListAccessorsResponse
s {$sel:nextToken:ListAccessorsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAccessorsResponse)

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

instance Prelude.NFData ListAccessorsResponse where
  rnf :: ListAccessorsResponse -> ()
rnf ListAccessorsResponse' {Int
Maybe [AccessorSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
accessors :: Maybe [AccessorSummary]
$sel:httpStatus:ListAccessorsResponse' :: ListAccessorsResponse -> Int
$sel:nextToken:ListAccessorsResponse' :: ListAccessorsResponse -> Maybe Text
$sel:accessors:ListAccessorsResponse' :: ListAccessorsResponse -> Maybe [AccessorSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AccessorSummary]
accessors
      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 Int
httpStatus