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

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

-- | 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.
--
-- /See:/ 'newIotSiteWiseCustomerManagedDatastoreS3Storage' smart constructor.
data IotSiteWiseCustomerManagedDatastoreS3Storage = IotSiteWiseCustomerManagedDatastoreS3Storage'
  { -- | (Optional) The prefix used to create the keys of the data store data
    -- objects. Each object in an Amazon S3 bucket has a key that is its unique
    -- identifier in the bucket. Each object in a bucket has exactly one key.
    -- The prefix must end with a forward slash (\/).
    IotSiteWiseCustomerManagedDatastoreS3Storage -> Maybe Text
keyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 bucket where your data is stored.
    IotSiteWiseCustomerManagedDatastoreS3Storage -> Text
bucket :: Prelude.Text
  }
  deriving (IotSiteWiseCustomerManagedDatastoreS3Storage
-> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool
(IotSiteWiseCustomerManagedDatastoreS3Storage
 -> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool)
-> (IotSiteWiseCustomerManagedDatastoreS3Storage
    -> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool)
-> Eq IotSiteWiseCustomerManagedDatastoreS3Storage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IotSiteWiseCustomerManagedDatastoreS3Storage
-> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool
$c/= :: IotSiteWiseCustomerManagedDatastoreS3Storage
-> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool
== :: IotSiteWiseCustomerManagedDatastoreS3Storage
-> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool
$c== :: IotSiteWiseCustomerManagedDatastoreS3Storage
-> IotSiteWiseCustomerManagedDatastoreS3Storage -> Bool
Prelude.Eq, ReadPrec [IotSiteWiseCustomerManagedDatastoreS3Storage]
ReadPrec IotSiteWiseCustomerManagedDatastoreS3Storage
Int -> ReadS IotSiteWiseCustomerManagedDatastoreS3Storage
ReadS [IotSiteWiseCustomerManagedDatastoreS3Storage]
(Int -> ReadS IotSiteWiseCustomerManagedDatastoreS3Storage)
-> ReadS [IotSiteWiseCustomerManagedDatastoreS3Storage]
-> ReadPrec IotSiteWiseCustomerManagedDatastoreS3Storage
-> ReadPrec [IotSiteWiseCustomerManagedDatastoreS3Storage]
-> Read IotSiteWiseCustomerManagedDatastoreS3Storage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IotSiteWiseCustomerManagedDatastoreS3Storage]
$creadListPrec :: ReadPrec [IotSiteWiseCustomerManagedDatastoreS3Storage]
readPrec :: ReadPrec IotSiteWiseCustomerManagedDatastoreS3Storage
$creadPrec :: ReadPrec IotSiteWiseCustomerManagedDatastoreS3Storage
readList :: ReadS [IotSiteWiseCustomerManagedDatastoreS3Storage]
$creadList :: ReadS [IotSiteWiseCustomerManagedDatastoreS3Storage]
readsPrec :: Int -> ReadS IotSiteWiseCustomerManagedDatastoreS3Storage
$creadsPrec :: Int -> ReadS IotSiteWiseCustomerManagedDatastoreS3Storage
Prelude.Read, Int -> IotSiteWiseCustomerManagedDatastoreS3Storage -> ShowS
[IotSiteWiseCustomerManagedDatastoreS3Storage] -> ShowS
IotSiteWiseCustomerManagedDatastoreS3Storage -> String
(Int -> IotSiteWiseCustomerManagedDatastoreS3Storage -> ShowS)
-> (IotSiteWiseCustomerManagedDatastoreS3Storage -> String)
-> ([IotSiteWiseCustomerManagedDatastoreS3Storage] -> ShowS)
-> Show IotSiteWiseCustomerManagedDatastoreS3Storage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IotSiteWiseCustomerManagedDatastoreS3Storage] -> ShowS
$cshowList :: [IotSiteWiseCustomerManagedDatastoreS3Storage] -> ShowS
show :: IotSiteWiseCustomerManagedDatastoreS3Storage -> String
$cshow :: IotSiteWiseCustomerManagedDatastoreS3Storage -> String
showsPrec :: Int -> IotSiteWiseCustomerManagedDatastoreS3Storage -> ShowS
$cshowsPrec :: Int -> IotSiteWiseCustomerManagedDatastoreS3Storage -> ShowS
Prelude.Show, (forall x.
 IotSiteWiseCustomerManagedDatastoreS3Storage
 -> Rep IotSiteWiseCustomerManagedDatastoreS3Storage x)
-> (forall x.
    Rep IotSiteWiseCustomerManagedDatastoreS3Storage x
    -> IotSiteWiseCustomerManagedDatastoreS3Storage)
-> Generic IotSiteWiseCustomerManagedDatastoreS3Storage
forall x.
Rep IotSiteWiseCustomerManagedDatastoreS3Storage x
-> IotSiteWiseCustomerManagedDatastoreS3Storage
forall x.
IotSiteWiseCustomerManagedDatastoreS3Storage
-> Rep IotSiteWiseCustomerManagedDatastoreS3Storage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IotSiteWiseCustomerManagedDatastoreS3Storage x
-> IotSiteWiseCustomerManagedDatastoreS3Storage
$cfrom :: forall x.
IotSiteWiseCustomerManagedDatastoreS3Storage
-> Rep IotSiteWiseCustomerManagedDatastoreS3Storage x
Prelude.Generic)

-- |
-- Create a value of 'IotSiteWiseCustomerManagedDatastoreS3Storage' 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:
--
-- 'keyPrefix', 'iotSiteWiseCustomerManagedDatastoreS3Storage_keyPrefix' - (Optional) The prefix used to create the keys of the data store data
-- objects. Each object in an Amazon S3 bucket has a key that is its unique
-- identifier in the bucket. Each object in a bucket has exactly one key.
-- The prefix must end with a forward slash (\/).
--
-- 'bucket', 'iotSiteWiseCustomerManagedDatastoreS3Storage_bucket' - The name of the Amazon S3 bucket where your data is stored.
newIotSiteWiseCustomerManagedDatastoreS3Storage ::
  -- | 'bucket'
  Prelude.Text ->
  IotSiteWiseCustomerManagedDatastoreS3Storage
newIotSiteWiseCustomerManagedDatastoreS3Storage :: Text -> IotSiteWiseCustomerManagedDatastoreS3Storage
newIotSiteWiseCustomerManagedDatastoreS3Storage
  Text
pBucket_ =
    IotSiteWiseCustomerManagedDatastoreS3Storage' :: Maybe Text -> Text -> IotSiteWiseCustomerManagedDatastoreS3Storage
IotSiteWiseCustomerManagedDatastoreS3Storage'
      { $sel:keyPrefix:IotSiteWiseCustomerManagedDatastoreS3Storage' :: Maybe Text
keyPrefix =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:bucket:IotSiteWiseCustomerManagedDatastoreS3Storage' :: Text
bucket = Text
pBucket_
      }

-- | (Optional) The prefix used to create the keys of the data store data
-- objects. Each object in an Amazon S3 bucket has a key that is its unique
-- identifier in the bucket. Each object in a bucket has exactly one key.
-- The prefix must end with a forward slash (\/).
iotSiteWiseCustomerManagedDatastoreS3Storage_keyPrefix :: Lens.Lens' IotSiteWiseCustomerManagedDatastoreS3Storage (Prelude.Maybe Prelude.Text)
iotSiteWiseCustomerManagedDatastoreS3Storage_keyPrefix :: (Maybe Text -> f (Maybe Text))
-> IotSiteWiseCustomerManagedDatastoreS3Storage
-> f IotSiteWiseCustomerManagedDatastoreS3Storage
iotSiteWiseCustomerManagedDatastoreS3Storage_keyPrefix = (IotSiteWiseCustomerManagedDatastoreS3Storage -> Maybe Text)
-> (IotSiteWiseCustomerManagedDatastoreS3Storage
    -> Maybe Text -> IotSiteWiseCustomerManagedDatastoreS3Storage)
-> Lens
     IotSiteWiseCustomerManagedDatastoreS3Storage
     IotSiteWiseCustomerManagedDatastoreS3Storage
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotSiteWiseCustomerManagedDatastoreS3Storage' {Maybe Text
keyPrefix :: Maybe Text
$sel:keyPrefix:IotSiteWiseCustomerManagedDatastoreS3Storage' :: IotSiteWiseCustomerManagedDatastoreS3Storage -> Maybe Text
keyPrefix} -> Maybe Text
keyPrefix) (\s :: IotSiteWiseCustomerManagedDatastoreS3Storage
s@IotSiteWiseCustomerManagedDatastoreS3Storage' {} Maybe Text
a -> IotSiteWiseCustomerManagedDatastoreS3Storage
s {$sel:keyPrefix:IotSiteWiseCustomerManagedDatastoreS3Storage' :: Maybe Text
keyPrefix = Maybe Text
a} :: IotSiteWiseCustomerManagedDatastoreS3Storage)

-- | The name of the Amazon S3 bucket where your data is stored.
iotSiteWiseCustomerManagedDatastoreS3Storage_bucket :: Lens.Lens' IotSiteWiseCustomerManagedDatastoreS3Storage Prelude.Text
iotSiteWiseCustomerManagedDatastoreS3Storage_bucket :: (Text -> f Text)
-> IotSiteWiseCustomerManagedDatastoreS3Storage
-> f IotSiteWiseCustomerManagedDatastoreS3Storage
iotSiteWiseCustomerManagedDatastoreS3Storage_bucket = (IotSiteWiseCustomerManagedDatastoreS3Storage -> Text)
-> (IotSiteWiseCustomerManagedDatastoreS3Storage
    -> Text -> IotSiteWiseCustomerManagedDatastoreS3Storage)
-> Lens
     IotSiteWiseCustomerManagedDatastoreS3Storage
     IotSiteWiseCustomerManagedDatastoreS3Storage
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IotSiteWiseCustomerManagedDatastoreS3Storage' {Text
bucket :: Text
$sel:bucket:IotSiteWiseCustomerManagedDatastoreS3Storage' :: IotSiteWiseCustomerManagedDatastoreS3Storage -> Text
bucket} -> Text
bucket) (\s :: IotSiteWiseCustomerManagedDatastoreS3Storage
s@IotSiteWiseCustomerManagedDatastoreS3Storage' {} Text
a -> IotSiteWiseCustomerManagedDatastoreS3Storage
s {$sel:bucket:IotSiteWiseCustomerManagedDatastoreS3Storage' :: Text
bucket = Text
a} :: IotSiteWiseCustomerManagedDatastoreS3Storage)

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

instance
  Prelude.Hashable
    IotSiteWiseCustomerManagedDatastoreS3Storage

instance
  Prelude.NFData
    IotSiteWiseCustomerManagedDatastoreS3Storage

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