{-# 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.CloudWatchEvents.DescribePartnerEventSource
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- An SaaS partner can use this operation to list details about a partner
-- event source that they have created. Amazon Web Services customers do
-- not use this operation. Instead, Amazon Web Services customers can use
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_DescribeEventSource.html DescribeEventSource>
-- to see details about a partner event source that is shared with them.
module Amazonka.CloudWatchEvents.DescribePartnerEventSource
  ( -- * Creating a Request
    DescribePartnerEventSource (..),
    newDescribePartnerEventSource,

    -- * Request Lenses
    describePartnerEventSource_name,

    -- * Destructuring the Response
    DescribePartnerEventSourceResponse (..),
    newDescribePartnerEventSourceResponse,

    -- * Response Lenses
    describePartnerEventSourceResponse_arn,
    describePartnerEventSourceResponse_name,
    describePartnerEventSourceResponse_httpStatus,
  )
where

import Amazonka.CloudWatchEvents.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribePartnerEventSource' smart constructor.
data DescribePartnerEventSource = DescribePartnerEventSource'
  { -- | The name of the event source to display.
    DescribePartnerEventSource -> Text
name :: Prelude.Text
  }
  deriving (DescribePartnerEventSource -> DescribePartnerEventSource -> Bool
(DescribePartnerEventSource -> DescribePartnerEventSource -> Bool)
-> (DescribePartnerEventSource
    -> DescribePartnerEventSource -> Bool)
-> Eq DescribePartnerEventSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePartnerEventSource -> DescribePartnerEventSource -> Bool
$c/= :: DescribePartnerEventSource -> DescribePartnerEventSource -> Bool
== :: DescribePartnerEventSource -> DescribePartnerEventSource -> Bool
$c== :: DescribePartnerEventSource -> DescribePartnerEventSource -> Bool
Prelude.Eq, ReadPrec [DescribePartnerEventSource]
ReadPrec DescribePartnerEventSource
Int -> ReadS DescribePartnerEventSource
ReadS [DescribePartnerEventSource]
(Int -> ReadS DescribePartnerEventSource)
-> ReadS [DescribePartnerEventSource]
-> ReadPrec DescribePartnerEventSource
-> ReadPrec [DescribePartnerEventSource]
-> Read DescribePartnerEventSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePartnerEventSource]
$creadListPrec :: ReadPrec [DescribePartnerEventSource]
readPrec :: ReadPrec DescribePartnerEventSource
$creadPrec :: ReadPrec DescribePartnerEventSource
readList :: ReadS [DescribePartnerEventSource]
$creadList :: ReadS [DescribePartnerEventSource]
readsPrec :: Int -> ReadS DescribePartnerEventSource
$creadsPrec :: Int -> ReadS DescribePartnerEventSource
Prelude.Read, Int -> DescribePartnerEventSource -> ShowS
[DescribePartnerEventSource] -> ShowS
DescribePartnerEventSource -> String
(Int -> DescribePartnerEventSource -> ShowS)
-> (DescribePartnerEventSource -> String)
-> ([DescribePartnerEventSource] -> ShowS)
-> Show DescribePartnerEventSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePartnerEventSource] -> ShowS
$cshowList :: [DescribePartnerEventSource] -> ShowS
show :: DescribePartnerEventSource -> String
$cshow :: DescribePartnerEventSource -> String
showsPrec :: Int -> DescribePartnerEventSource -> ShowS
$cshowsPrec :: Int -> DescribePartnerEventSource -> ShowS
Prelude.Show, (forall x.
 DescribePartnerEventSource -> Rep DescribePartnerEventSource x)
-> (forall x.
    Rep DescribePartnerEventSource x -> DescribePartnerEventSource)
-> Generic DescribePartnerEventSource
forall x.
Rep DescribePartnerEventSource x -> DescribePartnerEventSource
forall x.
DescribePartnerEventSource -> Rep DescribePartnerEventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribePartnerEventSource x -> DescribePartnerEventSource
$cfrom :: forall x.
DescribePartnerEventSource -> Rep DescribePartnerEventSource x
Prelude.Generic)

-- |
-- Create a value of 'DescribePartnerEventSource' 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:
--
-- 'name', 'describePartnerEventSource_name' - The name of the event source to display.
newDescribePartnerEventSource ::
  -- | 'name'
  Prelude.Text ->
  DescribePartnerEventSource
newDescribePartnerEventSource :: Text -> DescribePartnerEventSource
newDescribePartnerEventSource Text
pName_ =
  DescribePartnerEventSource' :: Text -> DescribePartnerEventSource
DescribePartnerEventSource' {$sel:name:DescribePartnerEventSource' :: Text
name = Text
pName_}

-- | The name of the event source to display.
describePartnerEventSource_name :: Lens.Lens' DescribePartnerEventSource Prelude.Text
describePartnerEventSource_name :: (Text -> f Text)
-> DescribePartnerEventSource -> f DescribePartnerEventSource
describePartnerEventSource_name = (DescribePartnerEventSource -> Text)
-> (DescribePartnerEventSource
    -> Text -> DescribePartnerEventSource)
-> Lens
     DescribePartnerEventSource DescribePartnerEventSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePartnerEventSource' {Text
name :: Text
$sel:name:DescribePartnerEventSource' :: DescribePartnerEventSource -> Text
name} -> Text
name) (\s :: DescribePartnerEventSource
s@DescribePartnerEventSource' {} Text
a -> DescribePartnerEventSource
s {$sel:name:DescribePartnerEventSource' :: Text
name = Text
a} :: DescribePartnerEventSource)

instance Core.AWSRequest DescribePartnerEventSource where
  type
    AWSResponse DescribePartnerEventSource =
      DescribePartnerEventSourceResponse
  request :: DescribePartnerEventSource -> Request DescribePartnerEventSource
request = Service
-> DescribePartnerEventSource -> Request DescribePartnerEventSource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribePartnerEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribePartnerEventSource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribePartnerEventSource))
-> Logger
-> Service
-> Proxy DescribePartnerEventSource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribePartnerEventSource)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text -> Int -> DescribePartnerEventSourceResponse
DescribePartnerEventSourceResponse'
            (Maybe Text
 -> Maybe Text -> Int -> DescribePartnerEventSourceResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> DescribePartnerEventSourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Arn")
            Either
  String (Maybe Text -> Int -> DescribePartnerEventSourceResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribePartnerEventSourceResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Name")
            Either String (Int -> DescribePartnerEventSourceResponse)
-> Either String Int
-> Either String DescribePartnerEventSourceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribePartnerEventSource

instance Prelude.NFData DescribePartnerEventSource

instance Core.ToHeaders DescribePartnerEventSource where
  toHeaders :: DescribePartnerEventSource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribePartnerEventSource -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSEvents.DescribePartnerEventSource" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribePartnerEventSource where
  toJSON :: DescribePartnerEventSource -> Value
toJSON DescribePartnerEventSource' {Text
name :: Text
$sel:name:DescribePartnerEventSource' :: DescribePartnerEventSource -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

instance Core.ToPath DescribePartnerEventSource where
  toPath :: DescribePartnerEventSource -> ByteString
toPath = ByteString -> DescribePartnerEventSource -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribePartnerEventSourceResponse' smart constructor.
data DescribePartnerEventSourceResponse = DescribePartnerEventSourceResponse'
  { -- | The ARN of the event source.
    DescribePartnerEventSourceResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the event source.
    DescribePartnerEventSourceResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribePartnerEventSourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribePartnerEventSourceResponse
-> DescribePartnerEventSourceResponse -> Bool
(DescribePartnerEventSourceResponse
 -> DescribePartnerEventSourceResponse -> Bool)
-> (DescribePartnerEventSourceResponse
    -> DescribePartnerEventSourceResponse -> Bool)
-> Eq DescribePartnerEventSourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePartnerEventSourceResponse
-> DescribePartnerEventSourceResponse -> Bool
$c/= :: DescribePartnerEventSourceResponse
-> DescribePartnerEventSourceResponse -> Bool
== :: DescribePartnerEventSourceResponse
-> DescribePartnerEventSourceResponse -> Bool
$c== :: DescribePartnerEventSourceResponse
-> DescribePartnerEventSourceResponse -> Bool
Prelude.Eq, ReadPrec [DescribePartnerEventSourceResponse]
ReadPrec DescribePartnerEventSourceResponse
Int -> ReadS DescribePartnerEventSourceResponse
ReadS [DescribePartnerEventSourceResponse]
(Int -> ReadS DescribePartnerEventSourceResponse)
-> ReadS [DescribePartnerEventSourceResponse]
-> ReadPrec DescribePartnerEventSourceResponse
-> ReadPrec [DescribePartnerEventSourceResponse]
-> Read DescribePartnerEventSourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePartnerEventSourceResponse]
$creadListPrec :: ReadPrec [DescribePartnerEventSourceResponse]
readPrec :: ReadPrec DescribePartnerEventSourceResponse
$creadPrec :: ReadPrec DescribePartnerEventSourceResponse
readList :: ReadS [DescribePartnerEventSourceResponse]
$creadList :: ReadS [DescribePartnerEventSourceResponse]
readsPrec :: Int -> ReadS DescribePartnerEventSourceResponse
$creadsPrec :: Int -> ReadS DescribePartnerEventSourceResponse
Prelude.Read, Int -> DescribePartnerEventSourceResponse -> ShowS
[DescribePartnerEventSourceResponse] -> ShowS
DescribePartnerEventSourceResponse -> String
(Int -> DescribePartnerEventSourceResponse -> ShowS)
-> (DescribePartnerEventSourceResponse -> String)
-> ([DescribePartnerEventSourceResponse] -> ShowS)
-> Show DescribePartnerEventSourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePartnerEventSourceResponse] -> ShowS
$cshowList :: [DescribePartnerEventSourceResponse] -> ShowS
show :: DescribePartnerEventSourceResponse -> String
$cshow :: DescribePartnerEventSourceResponse -> String
showsPrec :: Int -> DescribePartnerEventSourceResponse -> ShowS
$cshowsPrec :: Int -> DescribePartnerEventSourceResponse -> ShowS
Prelude.Show, (forall x.
 DescribePartnerEventSourceResponse
 -> Rep DescribePartnerEventSourceResponse x)
-> (forall x.
    Rep DescribePartnerEventSourceResponse x
    -> DescribePartnerEventSourceResponse)
-> Generic DescribePartnerEventSourceResponse
forall x.
Rep DescribePartnerEventSourceResponse x
-> DescribePartnerEventSourceResponse
forall x.
DescribePartnerEventSourceResponse
-> Rep DescribePartnerEventSourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribePartnerEventSourceResponse x
-> DescribePartnerEventSourceResponse
$cfrom :: forall x.
DescribePartnerEventSourceResponse
-> Rep DescribePartnerEventSourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribePartnerEventSourceResponse' 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:
--
-- 'arn', 'describePartnerEventSourceResponse_arn' - The ARN of the event source.
--
-- 'name', 'describePartnerEventSourceResponse_name' - The name of the event source.
--
-- 'httpStatus', 'describePartnerEventSourceResponse_httpStatus' - The response's http status code.
newDescribePartnerEventSourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribePartnerEventSourceResponse
newDescribePartnerEventSourceResponse :: Int -> DescribePartnerEventSourceResponse
newDescribePartnerEventSourceResponse Int
pHttpStatus_ =
  DescribePartnerEventSourceResponse' :: Maybe Text
-> Maybe Text -> Int -> DescribePartnerEventSourceResponse
DescribePartnerEventSourceResponse'
    { $sel:arn:DescribePartnerEventSourceResponse' :: Maybe Text
arn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DescribePartnerEventSourceResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribePartnerEventSourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the event source.
describePartnerEventSourceResponse_arn :: Lens.Lens' DescribePartnerEventSourceResponse (Prelude.Maybe Prelude.Text)
describePartnerEventSourceResponse_arn :: (Maybe Text -> f (Maybe Text))
-> DescribePartnerEventSourceResponse
-> f DescribePartnerEventSourceResponse
describePartnerEventSourceResponse_arn = (DescribePartnerEventSourceResponse -> Maybe Text)
-> (DescribePartnerEventSourceResponse
    -> Maybe Text -> DescribePartnerEventSourceResponse)
-> Lens
     DescribePartnerEventSourceResponse
     DescribePartnerEventSourceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePartnerEventSourceResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:DescribePartnerEventSourceResponse' :: DescribePartnerEventSourceResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DescribePartnerEventSourceResponse
s@DescribePartnerEventSourceResponse' {} Maybe Text
a -> DescribePartnerEventSourceResponse
s {$sel:arn:DescribePartnerEventSourceResponse' :: Maybe Text
arn = Maybe Text
a} :: DescribePartnerEventSourceResponse)

-- | The name of the event source.
describePartnerEventSourceResponse_name :: Lens.Lens' DescribePartnerEventSourceResponse (Prelude.Maybe Prelude.Text)
describePartnerEventSourceResponse_name :: (Maybe Text -> f (Maybe Text))
-> DescribePartnerEventSourceResponse
-> f DescribePartnerEventSourceResponse
describePartnerEventSourceResponse_name = (DescribePartnerEventSourceResponse -> Maybe Text)
-> (DescribePartnerEventSourceResponse
    -> Maybe Text -> DescribePartnerEventSourceResponse)
-> Lens
     DescribePartnerEventSourceResponse
     DescribePartnerEventSourceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePartnerEventSourceResponse' {Maybe Text
name :: Maybe Text
$sel:name:DescribePartnerEventSourceResponse' :: DescribePartnerEventSourceResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: DescribePartnerEventSourceResponse
s@DescribePartnerEventSourceResponse' {} Maybe Text
a -> DescribePartnerEventSourceResponse
s {$sel:name:DescribePartnerEventSourceResponse' :: Maybe Text
name = Maybe Text
a} :: DescribePartnerEventSourceResponse)

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

instance
  Prelude.NFData
    DescribePartnerEventSourceResponse