{-# 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.IoTAnalytics.Types.DatastoreActivity
-- 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.IoTAnalytics.Types.DatastoreActivity where

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

-- | The datastore activity that specifies where to store the processed data.
--
-- /See:/ 'newDatastoreActivity' smart constructor.
data DatastoreActivity = DatastoreActivity'
  { -- | The name of the datastore activity.
    DatastoreActivity -> Text
name :: Prelude.Text,
    -- | The name of the data store where processed messages are stored.
    DatastoreActivity -> Text
datastoreName :: Prelude.Text
  }
  deriving (DatastoreActivity -> DatastoreActivity -> Bool
(DatastoreActivity -> DatastoreActivity -> Bool)
-> (DatastoreActivity -> DatastoreActivity -> Bool)
-> Eq DatastoreActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatastoreActivity -> DatastoreActivity -> Bool
$c/= :: DatastoreActivity -> DatastoreActivity -> Bool
== :: DatastoreActivity -> DatastoreActivity -> Bool
$c== :: DatastoreActivity -> DatastoreActivity -> Bool
Prelude.Eq, ReadPrec [DatastoreActivity]
ReadPrec DatastoreActivity
Int -> ReadS DatastoreActivity
ReadS [DatastoreActivity]
(Int -> ReadS DatastoreActivity)
-> ReadS [DatastoreActivity]
-> ReadPrec DatastoreActivity
-> ReadPrec [DatastoreActivity]
-> Read DatastoreActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatastoreActivity]
$creadListPrec :: ReadPrec [DatastoreActivity]
readPrec :: ReadPrec DatastoreActivity
$creadPrec :: ReadPrec DatastoreActivity
readList :: ReadS [DatastoreActivity]
$creadList :: ReadS [DatastoreActivity]
readsPrec :: Int -> ReadS DatastoreActivity
$creadsPrec :: Int -> ReadS DatastoreActivity
Prelude.Read, Int -> DatastoreActivity -> ShowS
[DatastoreActivity] -> ShowS
DatastoreActivity -> String
(Int -> DatastoreActivity -> ShowS)
-> (DatastoreActivity -> String)
-> ([DatastoreActivity] -> ShowS)
-> Show DatastoreActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatastoreActivity] -> ShowS
$cshowList :: [DatastoreActivity] -> ShowS
show :: DatastoreActivity -> String
$cshow :: DatastoreActivity -> String
showsPrec :: Int -> DatastoreActivity -> ShowS
$cshowsPrec :: Int -> DatastoreActivity -> ShowS
Prelude.Show, (forall x. DatastoreActivity -> Rep DatastoreActivity x)
-> (forall x. Rep DatastoreActivity x -> DatastoreActivity)
-> Generic DatastoreActivity
forall x. Rep DatastoreActivity x -> DatastoreActivity
forall x. DatastoreActivity -> Rep DatastoreActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatastoreActivity x -> DatastoreActivity
$cfrom :: forall x. DatastoreActivity -> Rep DatastoreActivity x
Prelude.Generic)

-- |
-- Create a value of 'DatastoreActivity' 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', 'datastoreActivity_name' - The name of the datastore activity.
--
-- 'datastoreName', 'datastoreActivity_datastoreName' - The name of the data store where processed messages are stored.
newDatastoreActivity ::
  -- | 'name'
  Prelude.Text ->
  -- | 'datastoreName'
  Prelude.Text ->
  DatastoreActivity
newDatastoreActivity :: Text -> Text -> DatastoreActivity
newDatastoreActivity Text
pName_ Text
pDatastoreName_ =
  DatastoreActivity' :: Text -> Text -> DatastoreActivity
DatastoreActivity'
    { $sel:name:DatastoreActivity' :: Text
name = Text
pName_,
      $sel:datastoreName:DatastoreActivity' :: Text
datastoreName = Text
pDatastoreName_
    }

-- | The name of the datastore activity.
datastoreActivity_name :: Lens.Lens' DatastoreActivity Prelude.Text
datastoreActivity_name :: (Text -> f Text) -> DatastoreActivity -> f DatastoreActivity
datastoreActivity_name = (DatastoreActivity -> Text)
-> (DatastoreActivity -> Text -> DatastoreActivity)
-> Lens DatastoreActivity DatastoreActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastoreActivity' {Text
name :: Text
$sel:name:DatastoreActivity' :: DatastoreActivity -> Text
name} -> Text
name) (\s :: DatastoreActivity
s@DatastoreActivity' {} Text
a -> DatastoreActivity
s {$sel:name:DatastoreActivity' :: Text
name = Text
a} :: DatastoreActivity)

-- | The name of the data store where processed messages are stored.
datastoreActivity_datastoreName :: Lens.Lens' DatastoreActivity Prelude.Text
datastoreActivity_datastoreName :: (Text -> f Text) -> DatastoreActivity -> f DatastoreActivity
datastoreActivity_datastoreName = (DatastoreActivity -> Text)
-> (DatastoreActivity -> Text -> DatastoreActivity)
-> Lens DatastoreActivity DatastoreActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastoreActivity' {Text
datastoreName :: Text
$sel:datastoreName:DatastoreActivity' :: DatastoreActivity -> Text
datastoreName} -> Text
datastoreName) (\s :: DatastoreActivity
s@DatastoreActivity' {} Text
a -> DatastoreActivity
s {$sel:datastoreName:DatastoreActivity' :: Text
datastoreName = Text
a} :: DatastoreActivity)

instance Core.FromJSON DatastoreActivity where
  parseJSON :: Value -> Parser DatastoreActivity
parseJSON =
    String
-> (Object -> Parser DatastoreActivity)
-> Value
-> Parser DatastoreActivity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DatastoreActivity"
      ( \Object
x ->
          Text -> Text -> DatastoreActivity
DatastoreActivity'
            (Text -> Text -> DatastoreActivity)
-> Parser Text -> Parser (Text -> DatastoreActivity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
            Parser (Text -> DatastoreActivity)
-> Parser Text -> Parser DatastoreActivity
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
"datastoreName")
      )

instance Prelude.Hashable DatastoreActivity

instance Prelude.NFData DatastoreActivity

instance Core.ToJSON DatastoreActivity where
  toJSON :: DatastoreActivity -> Value
toJSON DatastoreActivity' {Text
datastoreName :: Text
name :: Text
$sel:datastoreName:DatastoreActivity' :: DatastoreActivity -> Text
$sel:name:DatastoreActivity' :: DatastoreActivity -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"datastoreName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
datastoreName)
          ]
      )