{-# 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.GetEventAction
-- 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 retrieves information about an event action.
module Amazonka.DataExchange.GetEventAction
  ( -- * Creating a Request
    GetEventAction (..),
    newGetEventAction,

    -- * Request Lenses
    getEventAction_eventActionId,

    -- * Destructuring the Response
    GetEventActionResponse (..),
    newGetEventActionResponse,

    -- * Response Lenses
    getEventActionResponse_action,
    getEventActionResponse_arn,
    getEventActionResponse_createdAt,
    getEventActionResponse_event,
    getEventActionResponse_id,
    getEventActionResponse_updatedAt,
    getEventActionResponse_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:/ 'newGetEventAction' smart constructor.
data GetEventAction = GetEventAction'
  { -- | The unique identifier for the event action.
    GetEventAction -> Text
eventActionId :: Prelude.Text
  }
  deriving (GetEventAction -> GetEventAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventAction -> GetEventAction -> Bool
$c/= :: GetEventAction -> GetEventAction -> Bool
== :: GetEventAction -> GetEventAction -> Bool
$c== :: GetEventAction -> GetEventAction -> Bool
Prelude.Eq, ReadPrec [GetEventAction]
ReadPrec GetEventAction
Int -> ReadS GetEventAction
ReadS [GetEventAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventAction]
$creadListPrec :: ReadPrec [GetEventAction]
readPrec :: ReadPrec GetEventAction
$creadPrec :: ReadPrec GetEventAction
readList :: ReadS [GetEventAction]
$creadList :: ReadS [GetEventAction]
readsPrec :: Int -> ReadS GetEventAction
$creadsPrec :: Int -> ReadS GetEventAction
Prelude.Read, Int -> GetEventAction -> ShowS
[GetEventAction] -> ShowS
GetEventAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventAction] -> ShowS
$cshowList :: [GetEventAction] -> ShowS
show :: GetEventAction -> String
$cshow :: GetEventAction -> String
showsPrec :: Int -> GetEventAction -> ShowS
$cshowsPrec :: Int -> GetEventAction -> ShowS
Prelude.Show, forall x. Rep GetEventAction x -> GetEventAction
forall x. GetEventAction -> Rep GetEventAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventAction x -> GetEventAction
$cfrom :: forall x. GetEventAction -> Rep GetEventAction x
Prelude.Generic)

-- |
-- Create a value of 'GetEventAction' 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:
--
-- 'eventActionId', 'getEventAction_eventActionId' - The unique identifier for the event action.
newGetEventAction ::
  -- | 'eventActionId'
  Prelude.Text ->
  GetEventAction
newGetEventAction :: Text -> GetEventAction
newGetEventAction Text
pEventActionId_ =
  GetEventAction' {$sel:eventActionId:GetEventAction' :: Text
eventActionId = Text
pEventActionId_}

-- | The unique identifier for the event action.
getEventAction_eventActionId :: Lens.Lens' GetEventAction Prelude.Text
getEventAction_eventActionId :: Lens' GetEventAction Text
getEventAction_eventActionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventAction' {Text
eventActionId :: Text
$sel:eventActionId:GetEventAction' :: GetEventAction -> Text
eventActionId} -> Text
eventActionId) (\s :: GetEventAction
s@GetEventAction' {} Text
a -> GetEventAction
s {$sel:eventActionId:GetEventAction' :: Text
eventActionId = Text
a} :: GetEventAction)

instance Core.AWSRequest GetEventAction where
  type
    AWSResponse GetEventAction =
      GetEventActionResponse
  request :: (Service -> Service) -> GetEventAction -> Request GetEventAction
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 GetEventAction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEventAction)))
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 Action
-> Maybe Text
-> Maybe ISO8601
-> Maybe Event
-> Maybe Text
-> Maybe ISO8601
-> Int
-> GetEventActionResponse
GetEventActionResponse'
            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
"Action")
            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
"Arn")
            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
"CreatedAt")
            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
"Event")
            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
"Id")
            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
"UpdatedAt")
            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 GetEventAction where
  hashWithSalt :: Int -> GetEventAction -> Int
hashWithSalt Int
_salt GetEventAction' {Text
eventActionId :: Text
$sel:eventActionId:GetEventAction' :: GetEventAction -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
eventActionId

instance Prelude.NFData GetEventAction where
  rnf :: GetEventAction -> ()
rnf GetEventAction' {Text
eventActionId :: Text
$sel:eventActionId:GetEventAction' :: GetEventAction -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
eventActionId

instance Data.ToHeaders GetEventAction where
  toHeaders :: GetEventAction -> 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 GetEventAction where
  toPath :: GetEventAction -> ByteString
toPath GetEventAction' {Text
eventActionId :: Text
$sel:eventActionId:GetEventAction' :: GetEventAction -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/event-actions/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
eventActionId]

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

-- | /See:/ 'newGetEventActionResponse' smart constructor.
data GetEventActionResponse = GetEventActionResponse'
  { -- | What occurs after a certain event.
    GetEventActionResponse -> Maybe Action
action :: Prelude.Maybe Action,
    -- | The ARN for the event action.
    GetEventActionResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the event action was created, in ISO 8601 format.
    GetEventActionResponse -> Maybe ISO8601
createdAt :: Prelude.Maybe Data.ISO8601,
    -- | What occurs to start an action.
    GetEventActionResponse -> Maybe Event
event :: Prelude.Maybe Event,
    -- | The unique identifier for the event action.
    GetEventActionResponse -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the event action was last updated, in ISO 8601
    -- format.
    GetEventActionResponse -> Maybe ISO8601
updatedAt :: Prelude.Maybe Data.ISO8601,
    -- | The response's http status code.
    GetEventActionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetEventActionResponse -> GetEventActionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventActionResponse -> GetEventActionResponse -> Bool
$c/= :: GetEventActionResponse -> GetEventActionResponse -> Bool
== :: GetEventActionResponse -> GetEventActionResponse -> Bool
$c== :: GetEventActionResponse -> GetEventActionResponse -> Bool
Prelude.Eq, ReadPrec [GetEventActionResponse]
ReadPrec GetEventActionResponse
Int -> ReadS GetEventActionResponse
ReadS [GetEventActionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventActionResponse]
$creadListPrec :: ReadPrec [GetEventActionResponse]
readPrec :: ReadPrec GetEventActionResponse
$creadPrec :: ReadPrec GetEventActionResponse
readList :: ReadS [GetEventActionResponse]
$creadList :: ReadS [GetEventActionResponse]
readsPrec :: Int -> ReadS GetEventActionResponse
$creadsPrec :: Int -> ReadS GetEventActionResponse
Prelude.Read, Int -> GetEventActionResponse -> ShowS
[GetEventActionResponse] -> ShowS
GetEventActionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventActionResponse] -> ShowS
$cshowList :: [GetEventActionResponse] -> ShowS
show :: GetEventActionResponse -> String
$cshow :: GetEventActionResponse -> String
showsPrec :: Int -> GetEventActionResponse -> ShowS
$cshowsPrec :: Int -> GetEventActionResponse -> ShowS
Prelude.Show, forall x. Rep GetEventActionResponse x -> GetEventActionResponse
forall x. GetEventActionResponse -> Rep GetEventActionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventActionResponse x -> GetEventActionResponse
$cfrom :: forall x. GetEventActionResponse -> Rep GetEventActionResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEventActionResponse' 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:
--
-- 'action', 'getEventActionResponse_action' - What occurs after a certain event.
--
-- 'arn', 'getEventActionResponse_arn' - The ARN for the event action.
--
-- 'createdAt', 'getEventActionResponse_createdAt' - The date and time that the event action was created, in ISO 8601 format.
--
-- 'event', 'getEventActionResponse_event' - What occurs to start an action.
--
-- 'id', 'getEventActionResponse_id' - The unique identifier for the event action.
--
-- 'updatedAt', 'getEventActionResponse_updatedAt' - The date and time that the event action was last updated, in ISO 8601
-- format.
--
-- 'httpStatus', 'getEventActionResponse_httpStatus' - The response's http status code.
newGetEventActionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetEventActionResponse
newGetEventActionResponse :: Int -> GetEventActionResponse
newGetEventActionResponse Int
pHttpStatus_ =
  GetEventActionResponse'
    { $sel:action:GetEventActionResponse' :: Maybe Action
action = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:GetEventActionResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:GetEventActionResponse' :: Maybe ISO8601
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:event:GetEventActionResponse' :: Maybe Event
event = forall a. Maybe a
Prelude.Nothing,
      $sel:id:GetEventActionResponse' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:updatedAt:GetEventActionResponse' :: Maybe ISO8601
updatedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetEventActionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | What occurs after a certain event.
getEventActionResponse_action :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Action)
getEventActionResponse_action :: Lens' GetEventActionResponse (Maybe Action)
getEventActionResponse_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe Action
action :: Maybe Action
$sel:action:GetEventActionResponse' :: GetEventActionResponse -> Maybe Action
action} -> Maybe Action
action) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe Action
a -> GetEventActionResponse
s {$sel:action:GetEventActionResponse' :: Maybe Action
action = Maybe Action
a} :: GetEventActionResponse)

-- | The ARN for the event action.
getEventActionResponse_arn :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Prelude.Text)
getEventActionResponse_arn :: Lens' GetEventActionResponse (Maybe Text)
getEventActionResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:GetEventActionResponse' :: GetEventActionResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe Text
a -> GetEventActionResponse
s {$sel:arn:GetEventActionResponse' :: Maybe Text
arn = Maybe Text
a} :: GetEventActionResponse)

-- | The date and time that the event action was created, in ISO 8601 format.
getEventActionResponse_createdAt :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Prelude.UTCTime)
getEventActionResponse_createdAt :: Lens' GetEventActionResponse (Maybe UTCTime)
getEventActionResponse_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe ISO8601
createdAt :: Maybe ISO8601
$sel:createdAt:GetEventActionResponse' :: GetEventActionResponse -> Maybe ISO8601
createdAt} -> Maybe ISO8601
createdAt) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe ISO8601
a -> GetEventActionResponse
s {$sel:createdAt:GetEventActionResponse' :: Maybe ISO8601
createdAt = Maybe ISO8601
a} :: GetEventActionResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | What occurs to start an action.
getEventActionResponse_event :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Event)
getEventActionResponse_event :: Lens' GetEventActionResponse (Maybe Event)
getEventActionResponse_event = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe Event
event :: Maybe Event
$sel:event:GetEventActionResponse' :: GetEventActionResponse -> Maybe Event
event} -> Maybe Event
event) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe Event
a -> GetEventActionResponse
s {$sel:event:GetEventActionResponse' :: Maybe Event
event = Maybe Event
a} :: GetEventActionResponse)

-- | The unique identifier for the event action.
getEventActionResponse_id :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Prelude.Text)
getEventActionResponse_id :: Lens' GetEventActionResponse (Maybe Text)
getEventActionResponse_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe Text
id :: Maybe Text
$sel:id:GetEventActionResponse' :: GetEventActionResponse -> Maybe Text
id} -> Maybe Text
id) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe Text
a -> GetEventActionResponse
s {$sel:id:GetEventActionResponse' :: Maybe Text
id = Maybe Text
a} :: GetEventActionResponse)

-- | The date and time that the event action was last updated, in ISO 8601
-- format.
getEventActionResponse_updatedAt :: Lens.Lens' GetEventActionResponse (Prelude.Maybe Prelude.UTCTime)
getEventActionResponse_updatedAt :: Lens' GetEventActionResponse (Maybe UTCTime)
getEventActionResponse_updatedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventActionResponse' {Maybe ISO8601
updatedAt :: Maybe ISO8601
$sel:updatedAt:GetEventActionResponse' :: GetEventActionResponse -> Maybe ISO8601
updatedAt} -> Maybe ISO8601
updatedAt) (\s :: GetEventActionResponse
s@GetEventActionResponse' {} Maybe ISO8601
a -> GetEventActionResponse
s {$sel:updatedAt:GetEventActionResponse' :: Maybe ISO8601
updatedAt = Maybe ISO8601
a} :: GetEventActionResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.NFData GetEventActionResponse where
  rnf :: GetEventActionResponse -> ()
rnf GetEventActionResponse' {Int
Maybe Text
Maybe ISO8601
Maybe Event
Maybe Action
httpStatus :: Int
updatedAt :: Maybe ISO8601
id :: Maybe Text
event :: Maybe Event
createdAt :: Maybe ISO8601
arn :: Maybe Text
action :: Maybe Action
$sel:httpStatus:GetEventActionResponse' :: GetEventActionResponse -> Int
$sel:updatedAt:GetEventActionResponse' :: GetEventActionResponse -> Maybe ISO8601
$sel:id:GetEventActionResponse' :: GetEventActionResponse -> Maybe Text
$sel:event:GetEventActionResponse' :: GetEventActionResponse -> Maybe Event
$sel:createdAt:GetEventActionResponse' :: GetEventActionResponse -> Maybe ISO8601
$sel:arn:GetEventActionResponse' :: GetEventActionResponse -> Maybe Text
$sel:action:GetEventActionResponse' :: GetEventActionResponse -> Maybe Action
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Action
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Event
event
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
updatedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus