{-# 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.DataExchange.ListEventActions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation lists your event actions.
--
-- This operation returns paginated results.
module Amazonka.DataExchange.ListEventActions
  ( -- * Creating a Request
    ListEventActions (..),
    newListEventActions,

    -- * Request Lenses
    listEventActions_eventSourceId,
    listEventActions_maxResults,
    listEventActions_nextToken,

    -- * Destructuring the Response
    ListEventActionsResponse (..),
    newListEventActionsResponse,

    -- * Response Lenses
    listEventActionsResponse_eventActions,
    listEventActionsResponse_nextToken,
    listEventActionsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListEventActions' smart constructor.
data ListEventActions = ListEventActions'
  { -- | The unique identifier for the event source.
    ListEventActions -> Maybe Text
eventSourceId :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results returned by a single call.
    ListEventActions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token value retrieved from a previous call to access the next page
    -- of results.
    ListEventActions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListEventActions -> ListEventActions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListEventActions -> ListEventActions -> Bool
$c/= :: ListEventActions -> ListEventActions -> Bool
== :: ListEventActions -> ListEventActions -> Bool
$c== :: ListEventActions -> ListEventActions -> Bool
Prelude.Eq, ReadPrec [ListEventActions]
ReadPrec ListEventActions
Int -> ReadS ListEventActions
ReadS [ListEventActions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListEventActions]
$creadListPrec :: ReadPrec [ListEventActions]
readPrec :: ReadPrec ListEventActions
$creadPrec :: ReadPrec ListEventActions
readList :: ReadS [ListEventActions]
$creadList :: ReadS [ListEventActions]
readsPrec :: Int -> ReadS ListEventActions
$creadsPrec :: Int -> ReadS ListEventActions
Prelude.Read, Int -> ListEventActions -> ShowS
[ListEventActions] -> ShowS
ListEventActions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListEventActions] -> ShowS
$cshowList :: [ListEventActions] -> ShowS
show :: ListEventActions -> String
$cshow :: ListEventActions -> String
showsPrec :: Int -> ListEventActions -> ShowS
$cshowsPrec :: Int -> ListEventActions -> ShowS
Prelude.Show, forall x. Rep ListEventActions x -> ListEventActions
forall x. ListEventActions -> Rep ListEventActions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListEventActions x -> ListEventActions
$cfrom :: forall x. ListEventActions -> Rep ListEventActions x
Prelude.Generic)

-- |
-- Create a value of 'ListEventActions' 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:
--
-- 'eventSourceId', 'listEventActions_eventSourceId' - The unique identifier for the event source.
--
-- 'maxResults', 'listEventActions_maxResults' - The maximum number of results returned by a single call.
--
-- 'nextToken', 'listEventActions_nextToken' - The token value retrieved from a previous call to access the next page
-- of results.
newListEventActions ::
  ListEventActions
newListEventActions :: ListEventActions
newListEventActions =
  ListEventActions'
    { $sel:eventSourceId:ListEventActions' :: Maybe Text
eventSourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListEventActions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListEventActions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the event source.
listEventActions_eventSourceId :: Lens.Lens' ListEventActions (Prelude.Maybe Prelude.Text)
listEventActions_eventSourceId :: Lens' ListEventActions (Maybe Text)
listEventActions_eventSourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEventActions' {Maybe Text
eventSourceId :: Maybe Text
$sel:eventSourceId:ListEventActions' :: ListEventActions -> Maybe Text
eventSourceId} -> Maybe Text
eventSourceId) (\s :: ListEventActions
s@ListEventActions' {} Maybe Text
a -> ListEventActions
s {$sel:eventSourceId:ListEventActions' :: Maybe Text
eventSourceId = Maybe Text
a} :: ListEventActions)

-- | The maximum number of results returned by a single call.
listEventActions_maxResults :: Lens.Lens' ListEventActions (Prelude.Maybe Prelude.Natural)
listEventActions_maxResults :: Lens' ListEventActions (Maybe Natural)
listEventActions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEventActions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListEventActions' :: ListEventActions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListEventActions
s@ListEventActions' {} Maybe Natural
a -> ListEventActions
s {$sel:maxResults:ListEventActions' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListEventActions)

-- | The token value retrieved from a previous call to access the next page
-- of results.
listEventActions_nextToken :: Lens.Lens' ListEventActions (Prelude.Maybe Prelude.Text)
listEventActions_nextToken :: Lens' ListEventActions (Maybe Text)
listEventActions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEventActions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEventActions' :: ListEventActions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEventActions
s@ListEventActions' {} Maybe Text
a -> ListEventActions
s {$sel:nextToken:ListEventActions' :: Maybe Text
nextToken = Maybe Text
a} :: ListEventActions)

instance Core.AWSPager ListEventActions where
  page :: ListEventActions
-> AWSResponse ListEventActions -> Maybe ListEventActions
page ListEventActions
rq AWSResponse ListEventActions
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListEventActions
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEventActionsResponse (Maybe Text)
listEventActionsResponse_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 ListEventActions
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEventActionsResponse (Maybe [EventActionEntry])
listEventActionsResponse_eventActions
            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.$ ListEventActions
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListEventActions (Maybe Text)
listEventActions_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListEventActions
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListEventActionsResponse (Maybe Text)
listEventActionsResponse_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 ListEventActions where
  type
    AWSResponse ListEventActions =
      ListEventActionsResponse
  request :: (Service -> Service)
-> ListEventActions -> Request ListEventActions
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 ListEventActions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListEventActions)))
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 [EventActionEntry]
-> Maybe Text -> Int -> ListEventActionsResponse
ListEventActionsResponse'
            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
"EventActions" 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 ListEventActions where
  hashWithSalt :: Int -> ListEventActions -> Int
hashWithSalt Int
_salt ListEventActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
eventSourceId :: Maybe Text
$sel:nextToken:ListEventActions' :: ListEventActions -> Maybe Text
$sel:maxResults:ListEventActions' :: ListEventActions -> Maybe Natural
$sel:eventSourceId:ListEventActions' :: ListEventActions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventSourceId
      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 ListEventActions where
  rnf :: ListEventActions -> ()
rnf ListEventActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
eventSourceId :: Maybe Text
$sel:nextToken:ListEventActions' :: ListEventActions -> Maybe Text
$sel:maxResults:ListEventActions' :: ListEventActions -> Maybe Natural
$sel:eventSourceId:ListEventActions' :: ListEventActions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventSourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToQuery ListEventActions where
  toQuery :: ListEventActions -> QueryString
toQuery ListEventActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
eventSourceId :: Maybe Text
$sel:nextToken:ListEventActions' :: ListEventActions -> Maybe Text
$sel:maxResults:ListEventActions' :: ListEventActions -> Maybe Natural
$sel:eventSourceId:ListEventActions' :: ListEventActions -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"eventSourceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
eventSourceId,
        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:/ 'newListEventActionsResponse' smart constructor.
data ListEventActionsResponse = ListEventActionsResponse'
  { -- | The event action objects listed by the request.
    ListEventActionsResponse -> Maybe [EventActionEntry]
eventActions :: Prelude.Maybe [EventActionEntry],
    -- | The token value retrieved from a previous call to access the next page
    -- of results.
    ListEventActionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListEventActionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListEventActionsResponse -> ListEventActionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListEventActionsResponse -> ListEventActionsResponse -> Bool
$c/= :: ListEventActionsResponse -> ListEventActionsResponse -> Bool
== :: ListEventActionsResponse -> ListEventActionsResponse -> Bool
$c== :: ListEventActionsResponse -> ListEventActionsResponse -> Bool
Prelude.Eq, ReadPrec [ListEventActionsResponse]
ReadPrec ListEventActionsResponse
Int -> ReadS ListEventActionsResponse
ReadS [ListEventActionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListEventActionsResponse]
$creadListPrec :: ReadPrec [ListEventActionsResponse]
readPrec :: ReadPrec ListEventActionsResponse
$creadPrec :: ReadPrec ListEventActionsResponse
readList :: ReadS [ListEventActionsResponse]
$creadList :: ReadS [ListEventActionsResponse]
readsPrec :: Int -> ReadS ListEventActionsResponse
$creadsPrec :: Int -> ReadS ListEventActionsResponse
Prelude.Read, Int -> ListEventActionsResponse -> ShowS
[ListEventActionsResponse] -> ShowS
ListEventActionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListEventActionsResponse] -> ShowS
$cshowList :: [ListEventActionsResponse] -> ShowS
show :: ListEventActionsResponse -> String
$cshow :: ListEventActionsResponse -> String
showsPrec :: Int -> ListEventActionsResponse -> ShowS
$cshowsPrec :: Int -> ListEventActionsResponse -> ShowS
Prelude.Show, forall x.
Rep ListEventActionsResponse x -> ListEventActionsResponse
forall x.
ListEventActionsResponse -> Rep ListEventActionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListEventActionsResponse x -> ListEventActionsResponse
$cfrom :: forall x.
ListEventActionsResponse -> Rep ListEventActionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListEventActionsResponse' 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:
--
-- 'eventActions', 'listEventActionsResponse_eventActions' - The event action objects listed by the request.
--
-- 'nextToken', 'listEventActionsResponse_nextToken' - The token value retrieved from a previous call to access the next page
-- of results.
--
-- 'httpStatus', 'listEventActionsResponse_httpStatus' - The response's http status code.
newListEventActionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListEventActionsResponse
newListEventActionsResponse :: Int -> ListEventActionsResponse
newListEventActionsResponse Int
pHttpStatus_ =
  ListEventActionsResponse'
    { $sel:eventActions:ListEventActionsResponse' :: Maybe [EventActionEntry]
eventActions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListEventActionsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListEventActionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The event action objects listed by the request.
listEventActionsResponse_eventActions :: Lens.Lens' ListEventActionsResponse (Prelude.Maybe [EventActionEntry])
listEventActionsResponse_eventActions :: Lens' ListEventActionsResponse (Maybe [EventActionEntry])
listEventActionsResponse_eventActions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEventActionsResponse' {Maybe [EventActionEntry]
eventActions :: Maybe [EventActionEntry]
$sel:eventActions:ListEventActionsResponse' :: ListEventActionsResponse -> Maybe [EventActionEntry]
eventActions} -> Maybe [EventActionEntry]
eventActions) (\s :: ListEventActionsResponse
s@ListEventActionsResponse' {} Maybe [EventActionEntry]
a -> ListEventActionsResponse
s {$sel:eventActions:ListEventActionsResponse' :: Maybe [EventActionEntry]
eventActions = Maybe [EventActionEntry]
a} :: ListEventActionsResponse) 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 token value retrieved from a previous call to access the next page
-- of results.
listEventActionsResponse_nextToken :: Lens.Lens' ListEventActionsResponse (Prelude.Maybe Prelude.Text)
listEventActionsResponse_nextToken :: Lens' ListEventActionsResponse (Maybe Text)
listEventActionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListEventActionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListEventActionsResponse' :: ListEventActionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListEventActionsResponse
s@ListEventActionsResponse' {} Maybe Text
a -> ListEventActionsResponse
s {$sel:nextToken:ListEventActionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListEventActionsResponse)

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

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