{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTAnalytics.Types.ChannelStorage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTAnalytics.Types.CustomerManagedChannelS3Storage
import Amazonka.IoTAnalytics.Types.ServiceManagedChannelS3Storage
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 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,
    -- | 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
  }
  deriving (ChannelStorage -> ChannelStorage -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newChannelStorage ::
  ChannelStorage
newChannelStorage :: ChannelStorage
newChannelStorage =
  ChannelStorage'
    { $sel:customerManagedS3:ChannelStorage' :: Maybe CustomerManagedChannelS3Storage
customerManagedS3 =
        forall a. Maybe a
Prelude.Nothing,
      $sel:serviceManagedS3:ChannelStorage' :: Maybe ServiceManagedChannelS3Storage
serviceManagedS3 = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ChannelStorage (Maybe CustomerManagedChannelS3Storage)
channelStorage_customerManagedS3 = 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)

-- | 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 :: Lens' ChannelStorage (Maybe ServiceManagedChannelS3Storage)
channelStorage_serviceManagedS3 = 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)

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

instance Prelude.Hashable ChannelStorage where
  hashWithSalt :: Int -> ChannelStorage -> Int
hashWithSalt Int
_salt ChannelStorage' {Maybe CustomerManagedChannelS3Storage
Maybe ServiceManagedChannelS3Storage
serviceManagedS3 :: Maybe ServiceManagedChannelS3Storage
customerManagedS3 :: Maybe CustomerManagedChannelS3Storage
$sel:serviceManagedS3:ChannelStorage' :: ChannelStorage -> Maybe ServiceManagedChannelS3Storage
$sel:customerManagedS3:ChannelStorage' :: ChannelStorage -> Maybe CustomerManagedChannelS3Storage
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomerManagedChannelS3Storage
customerManagedS3
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ServiceManagedChannelS3Storage
serviceManagedS3

instance Prelude.NFData ChannelStorage where
  rnf :: ChannelStorage -> ()
rnf ChannelStorage' {Maybe CustomerManagedChannelS3Storage
Maybe ServiceManagedChannelS3Storage
serviceManagedS3 :: Maybe ServiceManagedChannelS3Storage
customerManagedS3 :: Maybe CustomerManagedChannelS3Storage
$sel:serviceManagedS3:ChannelStorage' :: ChannelStorage -> Maybe ServiceManagedChannelS3Storage
$sel:customerManagedS3:ChannelStorage' :: ChannelStorage -> Maybe CustomerManagedChannelS3Storage
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomerManagedChannelS3Storage
customerManagedS3
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ServiceManagedChannelS3Storage
serviceManagedS3

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