{-# 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.DatastoreStorage
-- 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.DatastoreStorage where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.CustomerManagedDatastoreS3Storage
import Amazonka.IoTAnalytics.Types.DatastoreIotSiteWiseMultiLayerStorage
import Amazonka.IoTAnalytics.Types.ServiceManagedDatastoreS3Storage
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Where data in a data store is stored.. You can choose @serviceManagedS3@
-- storage, @customerManagedS3@ storage, or @iotSiteWiseMultiLayerStorage@
-- storage. The default is @serviceManagedS3@. You can\'t change the choice
-- of Amazon S3 storage after your data store is created.
--
-- /See:/ 'newDatastoreStorage' smart constructor.
data DatastoreStorage = DatastoreStorage'
  { -- | Used to store data in an Amazon S3 bucket managed by IoT Analytics. You
    -- can\'t change the choice of Amazon S3 storage after your data store is
    -- created.
    DatastoreStorage -> Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3 :: Prelude.Maybe ServiceManagedDatastoreS3Storage,
    -- | S3-customer-managed; When you choose customer-managed storage, the
    -- @retentionPeriod@ parameter is ignored. You can\'t change the choice of
    -- Amazon S3 storage after your data store is created.
    DatastoreStorage -> Maybe CustomerManagedDatastoreS3Storage
customerManagedS3 :: Prelude.Maybe CustomerManagedDatastoreS3Storage,
    -- | Used to store data used by IoT SiteWise in an Amazon S3 bucket that you
    -- manage. You can\'t change the choice of Amazon S3 storage after your
    -- data store is created.
    DatastoreStorage -> Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage :: Prelude.Maybe DatastoreIotSiteWiseMultiLayerStorage
  }
  deriving (DatastoreStorage -> DatastoreStorage -> Bool
(DatastoreStorage -> DatastoreStorage -> Bool)
-> (DatastoreStorage -> DatastoreStorage -> Bool)
-> Eq DatastoreStorage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatastoreStorage -> DatastoreStorage -> Bool
$c/= :: DatastoreStorage -> DatastoreStorage -> Bool
== :: DatastoreStorage -> DatastoreStorage -> Bool
$c== :: DatastoreStorage -> DatastoreStorage -> Bool
Prelude.Eq, ReadPrec [DatastoreStorage]
ReadPrec DatastoreStorage
Int -> ReadS DatastoreStorage
ReadS [DatastoreStorage]
(Int -> ReadS DatastoreStorage)
-> ReadS [DatastoreStorage]
-> ReadPrec DatastoreStorage
-> ReadPrec [DatastoreStorage]
-> Read DatastoreStorage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatastoreStorage]
$creadListPrec :: ReadPrec [DatastoreStorage]
readPrec :: ReadPrec DatastoreStorage
$creadPrec :: ReadPrec DatastoreStorage
readList :: ReadS [DatastoreStorage]
$creadList :: ReadS [DatastoreStorage]
readsPrec :: Int -> ReadS DatastoreStorage
$creadsPrec :: Int -> ReadS DatastoreStorage
Prelude.Read, Int -> DatastoreStorage -> ShowS
[DatastoreStorage] -> ShowS
DatastoreStorage -> String
(Int -> DatastoreStorage -> ShowS)
-> (DatastoreStorage -> String)
-> ([DatastoreStorage] -> ShowS)
-> Show DatastoreStorage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatastoreStorage] -> ShowS
$cshowList :: [DatastoreStorage] -> ShowS
show :: DatastoreStorage -> String
$cshow :: DatastoreStorage -> String
showsPrec :: Int -> DatastoreStorage -> ShowS
$cshowsPrec :: Int -> DatastoreStorage -> ShowS
Prelude.Show, (forall x. DatastoreStorage -> Rep DatastoreStorage x)
-> (forall x. Rep DatastoreStorage x -> DatastoreStorage)
-> Generic DatastoreStorage
forall x. Rep DatastoreStorage x -> DatastoreStorage
forall x. DatastoreStorage -> Rep DatastoreStorage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatastoreStorage x -> DatastoreStorage
$cfrom :: forall x. DatastoreStorage -> Rep DatastoreStorage x
Prelude.Generic)

-- |
-- Create a value of 'DatastoreStorage' 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:
--
-- 'serviceManagedS3', 'datastoreStorage_serviceManagedS3' - Used to store data in an Amazon S3 bucket managed by IoT Analytics. You
-- can\'t change the choice of Amazon S3 storage after your data store is
-- created.
--
-- 'customerManagedS3', 'datastoreStorage_customerManagedS3' - S3-customer-managed; When you choose customer-managed storage, the
-- @retentionPeriod@ parameter is ignored. You can\'t change the choice of
-- Amazon S3 storage after your data store is created.
--
-- 'iotSiteWiseMultiLayerStorage', 'datastoreStorage_iotSiteWiseMultiLayerStorage' - Used to store data used by IoT SiteWise in an Amazon S3 bucket that you
-- manage. You can\'t change the choice of Amazon S3 storage after your
-- data store is created.
newDatastoreStorage ::
  DatastoreStorage
newDatastoreStorage :: DatastoreStorage
newDatastoreStorage =
  DatastoreStorage' :: Maybe ServiceManagedDatastoreS3Storage
-> Maybe CustomerManagedDatastoreS3Storage
-> Maybe DatastoreIotSiteWiseMultiLayerStorage
-> DatastoreStorage
DatastoreStorage'
    { $sel:serviceManagedS3:DatastoreStorage' :: Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3 =
        Maybe ServiceManagedDatastoreS3Storage
forall a. Maybe a
Prelude.Nothing,
      $sel:customerManagedS3:DatastoreStorage' :: Maybe CustomerManagedDatastoreS3Storage
customerManagedS3 = Maybe CustomerManagedDatastoreS3Storage
forall a. Maybe a
Prelude.Nothing,
      $sel:iotSiteWiseMultiLayerStorage:DatastoreStorage' :: Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage = Maybe DatastoreIotSiteWiseMultiLayerStorage
forall a. Maybe a
Prelude.Nothing
    }

-- | Used to store data in an Amazon S3 bucket managed by IoT Analytics. You
-- can\'t change the choice of Amazon S3 storage after your data store is
-- created.
datastoreStorage_serviceManagedS3 :: Lens.Lens' DatastoreStorage (Prelude.Maybe ServiceManagedDatastoreS3Storage)
datastoreStorage_serviceManagedS3 :: (Maybe ServiceManagedDatastoreS3Storage
 -> f (Maybe ServiceManagedDatastoreS3Storage))
-> DatastoreStorage -> f DatastoreStorage
datastoreStorage_serviceManagedS3 = (DatastoreStorage -> Maybe ServiceManagedDatastoreS3Storage)
-> (DatastoreStorage
    -> Maybe ServiceManagedDatastoreS3Storage -> DatastoreStorage)
-> Lens
     DatastoreStorage
     DatastoreStorage
     (Maybe ServiceManagedDatastoreS3Storage)
     (Maybe ServiceManagedDatastoreS3Storage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastoreStorage' {Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3 :: Maybe ServiceManagedDatastoreS3Storage
$sel:serviceManagedS3:DatastoreStorage' :: DatastoreStorage -> Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3} -> Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3) (\s :: DatastoreStorage
s@DatastoreStorage' {} Maybe ServiceManagedDatastoreS3Storage
a -> DatastoreStorage
s {$sel:serviceManagedS3:DatastoreStorage' :: Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3 = Maybe ServiceManagedDatastoreS3Storage
a} :: DatastoreStorage)

-- | S3-customer-managed; When you choose customer-managed storage, the
-- @retentionPeriod@ parameter is ignored. You can\'t change the choice of
-- Amazon S3 storage after your data store is created.
datastoreStorage_customerManagedS3 :: Lens.Lens' DatastoreStorage (Prelude.Maybe CustomerManagedDatastoreS3Storage)
datastoreStorage_customerManagedS3 :: (Maybe CustomerManagedDatastoreS3Storage
 -> f (Maybe CustomerManagedDatastoreS3Storage))
-> DatastoreStorage -> f DatastoreStorage
datastoreStorage_customerManagedS3 = (DatastoreStorage -> Maybe CustomerManagedDatastoreS3Storage)
-> (DatastoreStorage
    -> Maybe CustomerManagedDatastoreS3Storage -> DatastoreStorage)
-> Lens
     DatastoreStorage
     DatastoreStorage
     (Maybe CustomerManagedDatastoreS3Storage)
     (Maybe CustomerManagedDatastoreS3Storage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastoreStorage' {Maybe CustomerManagedDatastoreS3Storage
customerManagedS3 :: Maybe CustomerManagedDatastoreS3Storage
$sel:customerManagedS3:DatastoreStorage' :: DatastoreStorage -> Maybe CustomerManagedDatastoreS3Storage
customerManagedS3} -> Maybe CustomerManagedDatastoreS3Storage
customerManagedS3) (\s :: DatastoreStorage
s@DatastoreStorage' {} Maybe CustomerManagedDatastoreS3Storage
a -> DatastoreStorage
s {$sel:customerManagedS3:DatastoreStorage' :: Maybe CustomerManagedDatastoreS3Storage
customerManagedS3 = Maybe CustomerManagedDatastoreS3Storage
a} :: DatastoreStorage)

-- | Used to store data used by IoT SiteWise in an Amazon S3 bucket that you
-- manage. You can\'t change the choice of Amazon S3 storage after your
-- data store is created.
datastoreStorage_iotSiteWiseMultiLayerStorage :: Lens.Lens' DatastoreStorage (Prelude.Maybe DatastoreIotSiteWiseMultiLayerStorage)
datastoreStorage_iotSiteWiseMultiLayerStorage :: (Maybe DatastoreIotSiteWiseMultiLayerStorage
 -> f (Maybe DatastoreIotSiteWiseMultiLayerStorage))
-> DatastoreStorage -> f DatastoreStorage
datastoreStorage_iotSiteWiseMultiLayerStorage = (DatastoreStorage -> Maybe DatastoreIotSiteWiseMultiLayerStorage)
-> (DatastoreStorage
    -> Maybe DatastoreIotSiteWiseMultiLayerStorage -> DatastoreStorage)
-> Lens
     DatastoreStorage
     DatastoreStorage
     (Maybe DatastoreIotSiteWiseMultiLayerStorage)
     (Maybe DatastoreIotSiteWiseMultiLayerStorage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastoreStorage' {Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage :: Maybe DatastoreIotSiteWiseMultiLayerStorage
$sel:iotSiteWiseMultiLayerStorage:DatastoreStorage' :: DatastoreStorage -> Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage} -> Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage) (\s :: DatastoreStorage
s@DatastoreStorage' {} Maybe DatastoreIotSiteWiseMultiLayerStorage
a -> DatastoreStorage
s {$sel:iotSiteWiseMultiLayerStorage:DatastoreStorage' :: Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage = Maybe DatastoreIotSiteWiseMultiLayerStorage
a} :: DatastoreStorage)

instance Core.FromJSON DatastoreStorage where
  parseJSON :: Value -> Parser DatastoreStorage
parseJSON =
    String
-> (Object -> Parser DatastoreStorage)
-> Value
-> Parser DatastoreStorage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DatastoreStorage"
      ( \Object
x ->
          Maybe ServiceManagedDatastoreS3Storage
-> Maybe CustomerManagedDatastoreS3Storage
-> Maybe DatastoreIotSiteWiseMultiLayerStorage
-> DatastoreStorage
DatastoreStorage'
            (Maybe ServiceManagedDatastoreS3Storage
 -> Maybe CustomerManagedDatastoreS3Storage
 -> Maybe DatastoreIotSiteWiseMultiLayerStorage
 -> DatastoreStorage)
-> Parser (Maybe ServiceManagedDatastoreS3Storage)
-> Parser
     (Maybe CustomerManagedDatastoreS3Storage
      -> Maybe DatastoreIotSiteWiseMultiLayerStorage -> DatastoreStorage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ServiceManagedDatastoreS3Storage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serviceManagedS3")
            Parser
  (Maybe CustomerManagedDatastoreS3Storage
   -> Maybe DatastoreIotSiteWiseMultiLayerStorage -> DatastoreStorage)
-> Parser (Maybe CustomerManagedDatastoreS3Storage)
-> Parser
     (Maybe DatastoreIotSiteWiseMultiLayerStorage -> DatastoreStorage)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CustomerManagedDatastoreS3Storage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"customerManagedS3")
            Parser
  (Maybe DatastoreIotSiteWiseMultiLayerStorage -> DatastoreStorage)
-> Parser (Maybe DatastoreIotSiteWiseMultiLayerStorage)
-> Parser DatastoreStorage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe DatastoreIotSiteWiseMultiLayerStorage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iotSiteWiseMultiLayerStorage")
      )

instance Prelude.Hashable DatastoreStorage

instance Prelude.NFData DatastoreStorage

instance Core.ToJSON DatastoreStorage where
  toJSON :: DatastoreStorage -> Value
toJSON DatastoreStorage' {Maybe CustomerManagedDatastoreS3Storage
Maybe DatastoreIotSiteWiseMultiLayerStorage
Maybe ServiceManagedDatastoreS3Storage
iotSiteWiseMultiLayerStorage :: Maybe DatastoreIotSiteWiseMultiLayerStorage
customerManagedS3 :: Maybe CustomerManagedDatastoreS3Storage
serviceManagedS3 :: Maybe ServiceManagedDatastoreS3Storage
$sel:iotSiteWiseMultiLayerStorage:DatastoreStorage' :: DatastoreStorage -> Maybe DatastoreIotSiteWiseMultiLayerStorage
$sel:customerManagedS3:DatastoreStorage' :: DatastoreStorage -> Maybe CustomerManagedDatastoreS3Storage
$sel:serviceManagedS3:DatastoreStorage' :: DatastoreStorage -> Maybe ServiceManagedDatastoreS3Storage
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serviceManagedS3" Text -> ServiceManagedDatastoreS3Storage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ServiceManagedDatastoreS3Storage -> Pair)
-> Maybe ServiceManagedDatastoreS3Storage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServiceManagedDatastoreS3Storage
serviceManagedS3,
            (Text
"customerManagedS3" Text -> CustomerManagedDatastoreS3Storage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CustomerManagedDatastoreS3Storage -> Pair)
-> Maybe CustomerManagedDatastoreS3Storage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CustomerManagedDatastoreS3Storage
customerManagedS3,
            (Text
"iotSiteWiseMultiLayerStorage" Text -> DatastoreIotSiteWiseMultiLayerStorage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DatastoreIotSiteWiseMultiLayerStorage -> Pair)
-> Maybe DatastoreIotSiteWiseMultiLayerStorage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatastoreIotSiteWiseMultiLayerStorage
iotSiteWiseMultiLayerStorage
          ]
      )