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

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.CustomerManagedChannelS3Storage
import Amazonka.IoTAnalytics.Types.ServiceManagedChannelS3Storage
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Where channel data is stored. You may choose one of @serviceManagedS3@,
-- @customerManagedS3@ storage. If not specified, the default is
-- @serviceManagedS3@. This can\'t be changed after creation of the
-- channel.
--
-- /See:/ 'newChannelStorage' smart constructor.
data ChannelStorage = ChannelStorage'
  { -- | Used to store channel data in an S3 bucket managed by IoT Analytics. You
    -- can\'t change the choice of S3 storage after the data store is created.
    ChannelStorage -> Maybe ServiceManagedChannelS3Storage
serviceManagedS3 :: Prelude.Maybe ServiceManagedChannelS3Storage,
    -- | Used to store channel data in an S3 bucket that you manage. If customer
    -- managed storage is selected, the @retentionPeriod@ parameter is ignored.
    -- You can\'t change the choice of S3 storage after the data store is
    -- created.
    ChannelStorage -> Maybe CustomerManagedChannelS3Storage
customerManagedS3 :: Prelude.Maybe CustomerManagedChannelS3Storage
  }
  deriving (ChannelStorage -> ChannelStorage -> Bool
(ChannelStorage -> ChannelStorage -> Bool)
-> (ChannelStorage -> ChannelStorage -> Bool) -> Eq ChannelStorage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelStorage -> ChannelStorage -> Bool
$c/= :: ChannelStorage -> ChannelStorage -> Bool
== :: ChannelStorage -> ChannelStorage -> Bool
$c== :: ChannelStorage -> ChannelStorage -> Bool
Prelude.Eq, ReadPrec [ChannelStorage]
ReadPrec ChannelStorage
Int -> ReadS ChannelStorage
ReadS [ChannelStorage]
(Int -> ReadS ChannelStorage)
-> ReadS [ChannelStorage]
-> ReadPrec ChannelStorage
-> ReadPrec [ChannelStorage]
-> Read ChannelStorage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelStorage]
$creadListPrec :: ReadPrec [ChannelStorage]
readPrec :: ReadPrec ChannelStorage
$creadPrec :: ReadPrec ChannelStorage
readList :: ReadS [ChannelStorage]
$creadList :: ReadS [ChannelStorage]
readsPrec :: Int -> ReadS ChannelStorage
$creadsPrec :: Int -> ReadS ChannelStorage
Prelude.Read, Int -> ChannelStorage -> ShowS
[ChannelStorage] -> ShowS
ChannelStorage -> String
(Int -> ChannelStorage -> ShowS)
-> (ChannelStorage -> String)
-> ([ChannelStorage] -> ShowS)
-> Show ChannelStorage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelStorage] -> ShowS
$cshowList :: [ChannelStorage] -> ShowS
show :: ChannelStorage -> String
$cshow :: ChannelStorage -> String
showsPrec :: Int -> ChannelStorage -> ShowS
$cshowsPrec :: Int -> ChannelStorage -> ShowS
Prelude.Show, (forall x. ChannelStorage -> Rep ChannelStorage x)
-> (forall x. Rep ChannelStorage x -> ChannelStorage)
-> Generic ChannelStorage
forall x. Rep ChannelStorage x -> ChannelStorage
forall x. ChannelStorage -> Rep ChannelStorage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelStorage x -> ChannelStorage
$cfrom :: forall x. ChannelStorage -> Rep ChannelStorage x
Prelude.Generic)

-- |
-- Create a value of 'ChannelStorage' 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', 'channelStorage_serviceManagedS3' - Used to store channel data in an S3 bucket managed by IoT Analytics. You
-- can\'t change the choice of S3 storage after the data store is created.
--
-- 'customerManagedS3', 'channelStorage_customerManagedS3' - Used to store channel data in an S3 bucket that you manage. If customer
-- managed storage is selected, the @retentionPeriod@ parameter is ignored.
-- You can\'t change the choice of S3 storage after the data store is
-- created.
newChannelStorage ::
  ChannelStorage
newChannelStorage :: ChannelStorage
newChannelStorage =
  ChannelStorage' :: Maybe ServiceManagedChannelS3Storage
-> Maybe CustomerManagedChannelS3Storage -> ChannelStorage
ChannelStorage'
    { $sel:serviceManagedS3:ChannelStorage' :: Maybe ServiceManagedChannelS3Storage
serviceManagedS3 = Maybe ServiceManagedChannelS3Storage
forall a. Maybe a
Prelude.Nothing,
      $sel:customerManagedS3:ChannelStorage' :: Maybe CustomerManagedChannelS3Storage
customerManagedS3 = Maybe CustomerManagedChannelS3Storage
forall a. Maybe a
Prelude.Nothing
    }

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

-- | Used to store channel data in an S3 bucket that you manage. If customer
-- managed storage is selected, the @retentionPeriod@ parameter is ignored.
-- You can\'t change the choice of S3 storage after the data store is
-- created.
channelStorage_customerManagedS3 :: Lens.Lens' ChannelStorage (Prelude.Maybe CustomerManagedChannelS3Storage)
channelStorage_customerManagedS3 :: (Maybe CustomerManagedChannelS3Storage
 -> f (Maybe CustomerManagedChannelS3Storage))
-> ChannelStorage -> f ChannelStorage
channelStorage_customerManagedS3 = (ChannelStorage -> Maybe CustomerManagedChannelS3Storage)
-> (ChannelStorage
    -> Maybe CustomerManagedChannelS3Storage -> ChannelStorage)
-> Lens
     ChannelStorage
     ChannelStorage
     (Maybe CustomerManagedChannelS3Storage)
     (Maybe CustomerManagedChannelS3Storage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelStorage' {Maybe CustomerManagedChannelS3Storage
customerManagedS3 :: Maybe CustomerManagedChannelS3Storage
$sel:customerManagedS3:ChannelStorage' :: ChannelStorage -> Maybe CustomerManagedChannelS3Storage
customerManagedS3} -> Maybe CustomerManagedChannelS3Storage
customerManagedS3) (\s :: ChannelStorage
s@ChannelStorage' {} Maybe CustomerManagedChannelS3Storage
a -> ChannelStorage
s {$sel:customerManagedS3:ChannelStorage' :: Maybe CustomerManagedChannelS3Storage
customerManagedS3 = Maybe CustomerManagedChannelS3Storage
a} :: ChannelStorage)

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

instance Prelude.Hashable ChannelStorage

instance Prelude.NFData ChannelStorage

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