{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.KafkaConnect.Types.Plugin
-- 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)
module Amazonka.KafkaConnect.Types.Plugin where

import qualified Amazonka.Core as Core
import Amazonka.KafkaConnect.Types.CustomPlugin
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A plugin is an AWS resource that contains the code that defines your
-- connector logic.
--
-- /See:/ 'newPlugin' smart constructor.
data Plugin = Plugin'
  { -- | Details about a custom plugin.
    Plugin -> CustomPlugin
customPlugin :: CustomPlugin
  }
  deriving (Plugin -> Plugin -> Bool
(Plugin -> Plugin -> Bool)
-> (Plugin -> Plugin -> Bool) -> Eq Plugin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Plugin -> Plugin -> Bool
$c/= :: Plugin -> Plugin -> Bool
== :: Plugin -> Plugin -> Bool
$c== :: Plugin -> Plugin -> Bool
Prelude.Eq, ReadPrec [Plugin]
ReadPrec Plugin
Int -> ReadS Plugin
ReadS [Plugin]
(Int -> ReadS Plugin)
-> ReadS [Plugin]
-> ReadPrec Plugin
-> ReadPrec [Plugin]
-> Read Plugin
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Plugin]
$creadListPrec :: ReadPrec [Plugin]
readPrec :: ReadPrec Plugin
$creadPrec :: ReadPrec Plugin
readList :: ReadS [Plugin]
$creadList :: ReadS [Plugin]
readsPrec :: Int -> ReadS Plugin
$creadsPrec :: Int -> ReadS Plugin
Prelude.Read, Int -> Plugin -> ShowS
[Plugin] -> ShowS
Plugin -> String
(Int -> Plugin -> ShowS)
-> (Plugin -> String) -> ([Plugin] -> ShowS) -> Show Plugin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Plugin] -> ShowS
$cshowList :: [Plugin] -> ShowS
show :: Plugin -> String
$cshow :: Plugin -> String
showsPrec :: Int -> Plugin -> ShowS
$cshowsPrec :: Int -> Plugin -> ShowS
Prelude.Show, (forall x. Plugin -> Rep Plugin x)
-> (forall x. Rep Plugin x -> Plugin) -> Generic Plugin
forall x. Rep Plugin x -> Plugin
forall x. Plugin -> Rep Plugin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Plugin x -> Plugin
$cfrom :: forall x. Plugin -> Rep Plugin x
Prelude.Generic)

-- |
-- Create a value of 'Plugin' 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:
--
-- 'customPlugin', 'plugin_customPlugin' - Details about a custom plugin.
newPlugin ::
  -- | 'customPlugin'
  CustomPlugin ->
  Plugin
newPlugin :: CustomPlugin -> Plugin
newPlugin CustomPlugin
pCustomPlugin_ =
  Plugin' :: CustomPlugin -> Plugin
Plugin' {$sel:customPlugin:Plugin' :: CustomPlugin
customPlugin = CustomPlugin
pCustomPlugin_}

-- | Details about a custom plugin.
plugin_customPlugin :: Lens.Lens' Plugin CustomPlugin
plugin_customPlugin :: (CustomPlugin -> f CustomPlugin) -> Plugin -> f Plugin
plugin_customPlugin = (Plugin -> CustomPlugin)
-> (Plugin -> CustomPlugin -> Plugin)
-> Lens Plugin Plugin CustomPlugin CustomPlugin
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Plugin' {CustomPlugin
customPlugin :: CustomPlugin
$sel:customPlugin:Plugin' :: Plugin -> CustomPlugin
customPlugin} -> CustomPlugin
customPlugin) (\s :: Plugin
s@Plugin' {} CustomPlugin
a -> Plugin
s {$sel:customPlugin:Plugin' :: CustomPlugin
customPlugin = CustomPlugin
a} :: Plugin)

instance Prelude.Hashable Plugin

instance Prelude.NFData Plugin

instance Core.ToJSON Plugin where
  toJSON :: Plugin -> Value
toJSON Plugin' {CustomPlugin
customPlugin :: CustomPlugin
$sel:customPlugin:Plugin' :: Plugin -> CustomPlugin
..} =
    [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
"customPlugin" Text -> CustomPlugin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CustomPlugin
customPlugin)]
      )