{-# 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.Greengrass.Types.Connector
-- 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.Greengrass.Types.Connector where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a connector. Connectors run on the Greengrass core and
-- contain built-in integration with local infrastructure, device
-- protocols, AWS, and other cloud services.
--
-- /See:/ 'newConnector' smart constructor.
data Connector = Connector'
  { -- | The parameters or configuration that the connector uses.
    Connector -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The ARN of the connector.
    Connector -> Text
connectorArn :: Prelude.Text,
    -- | A descriptive or arbitrary ID for the connector. This value must be
    -- unique within the connector definition version. Max length is 128
    -- characters with pattern [a-zA-Z0-9:_-]+.
    Connector -> Text
id :: Prelude.Text
  }
  deriving (Connector -> Connector -> Bool
(Connector -> Connector -> Bool)
-> (Connector -> Connector -> Bool) -> Eq Connector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Connector -> Connector -> Bool
$c/= :: Connector -> Connector -> Bool
== :: Connector -> Connector -> Bool
$c== :: Connector -> Connector -> Bool
Prelude.Eq, ReadPrec [Connector]
ReadPrec Connector
Int -> ReadS Connector
ReadS [Connector]
(Int -> ReadS Connector)
-> ReadS [Connector]
-> ReadPrec Connector
-> ReadPrec [Connector]
-> Read Connector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Connector]
$creadListPrec :: ReadPrec [Connector]
readPrec :: ReadPrec Connector
$creadPrec :: ReadPrec Connector
readList :: ReadS [Connector]
$creadList :: ReadS [Connector]
readsPrec :: Int -> ReadS Connector
$creadsPrec :: Int -> ReadS Connector
Prelude.Read, Int -> Connector -> ShowS
[Connector] -> ShowS
Connector -> String
(Int -> Connector -> ShowS)
-> (Connector -> String)
-> ([Connector] -> ShowS)
-> Show Connector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Connector] -> ShowS
$cshowList :: [Connector] -> ShowS
show :: Connector -> String
$cshow :: Connector -> String
showsPrec :: Int -> Connector -> ShowS
$cshowsPrec :: Int -> Connector -> ShowS
Prelude.Show, (forall x. Connector -> Rep Connector x)
-> (forall x. Rep Connector x -> Connector) -> Generic Connector
forall x. Rep Connector x -> Connector
forall x. Connector -> Rep Connector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Connector x -> Connector
$cfrom :: forall x. Connector -> Rep Connector x
Prelude.Generic)

-- |
-- Create a value of 'Connector' 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:
--
-- 'parameters', 'connector_parameters' - The parameters or configuration that the connector uses.
--
-- 'connectorArn', 'connector_connectorArn' - The ARN of the connector.
--
-- 'id', 'connector_id' - A descriptive or arbitrary ID for the connector. This value must be
-- unique within the connector definition version. Max length is 128
-- characters with pattern [a-zA-Z0-9:_-]+.
newConnector ::
  -- | 'connectorArn'
  Prelude.Text ->
  -- | 'id'
  Prelude.Text ->
  Connector
newConnector :: Text -> Text -> Connector
newConnector Text
pConnectorArn_ Text
pId_ =
  Connector' :: Maybe (HashMap Text Text) -> Text -> Text -> Connector
Connector'
    { $sel:parameters:Connector' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:connectorArn:Connector' :: Text
connectorArn = Text
pConnectorArn_,
      $sel:id:Connector' :: Text
id = Text
pId_
    }

-- | The parameters or configuration that the connector uses.
connector_parameters :: Lens.Lens' Connector (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
connector_parameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Connector -> f Connector
connector_parameters = (Connector -> Maybe (HashMap Text Text))
-> (Connector -> Maybe (HashMap Text Text) -> Connector)
-> Lens
     Connector
     Connector
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connector' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:Connector' :: Connector -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: Connector
s@Connector' {} Maybe (HashMap Text Text)
a -> Connector
s {$sel:parameters:Connector' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: Connector) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> Connector -> f Connector)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Connector
-> f Connector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the connector.
connector_connectorArn :: Lens.Lens' Connector Prelude.Text
connector_connectorArn :: (Text -> f Text) -> Connector -> f Connector
connector_connectorArn = (Connector -> Text)
-> (Connector -> Text -> Connector)
-> Lens Connector Connector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connector' {Text
connectorArn :: Text
$sel:connectorArn:Connector' :: Connector -> Text
connectorArn} -> Text
connectorArn) (\s :: Connector
s@Connector' {} Text
a -> Connector
s {$sel:connectorArn:Connector' :: Text
connectorArn = Text
a} :: Connector)

-- | A descriptive or arbitrary ID for the connector. This value must be
-- unique within the connector definition version. Max length is 128
-- characters with pattern [a-zA-Z0-9:_-]+.
connector_id :: Lens.Lens' Connector Prelude.Text
connector_id :: (Text -> f Text) -> Connector -> f Connector
connector_id = (Connector -> Text)
-> (Connector -> Text -> Connector)
-> Lens Connector Connector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connector' {Text
id :: Text
$sel:id:Connector' :: Connector -> Text
id} -> Text
id) (\s :: Connector
s@Connector' {} Text
a -> Connector
s {$sel:id:Connector' :: Text
id = Text
a} :: Connector)

instance Core.FromJSON Connector where
  parseJSON :: Value -> Parser Connector
parseJSON =
    String -> (Object -> Parser Connector) -> Value -> Parser Connector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Connector"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Text -> Text -> Connector
Connector'
            (Maybe (HashMap Text Text) -> Text -> Text -> Connector)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Text -> Text -> Connector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Text -> Connector)
-> Parser Text -> Parser (Text -> Connector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConnectorArn")
            Parser (Text -> Connector) -> Parser Text -> Parser Connector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
      )

instance Prelude.Hashable Connector

instance Prelude.NFData Connector

instance Core.ToJSON Connector where
  toJSON :: Connector -> Value
toJSON Connector' {Maybe (HashMap Text Text)
Text
id :: Text
connectorArn :: Text
parameters :: Maybe (HashMap Text Text)
$sel:id:Connector' :: Connector -> Text
$sel:connectorArn:Connector' :: Connector -> Text
$sel:parameters:Connector' :: Connector -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Parameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ConnectorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
connectorArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )