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

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

-- | 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.
--
-- /See:/ 'newCustomerManagedDatastoreS3Storage' smart constructor.
data CustomerManagedDatastoreS3Storage = CustomerManagedDatastoreS3Storage'
  { -- | (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 (\/).
    CustomerManagedDatastoreS3Storage -> Maybe Text
keyPrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 bucket where your data is stored.
    CustomerManagedDatastoreS3Storage -> Text
bucket :: Prelude.Text,
    -- | The ARN of the role that grants IoT Analytics permission to interact
    -- with your Amazon S3 resources.
    CustomerManagedDatastoreS3Storage -> Text
roleArn :: Prelude.Text
  }
  deriving (CustomerManagedDatastoreS3Storage
-> CustomerManagedDatastoreS3Storage -> Bool
(CustomerManagedDatastoreS3Storage
 -> CustomerManagedDatastoreS3Storage -> Bool)
-> (CustomerManagedDatastoreS3Storage
    -> CustomerManagedDatastoreS3Storage -> Bool)
-> Eq CustomerManagedDatastoreS3Storage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerManagedDatastoreS3Storage
-> CustomerManagedDatastoreS3Storage -> Bool
$c/= :: CustomerManagedDatastoreS3Storage
-> CustomerManagedDatastoreS3Storage -> Bool
== :: CustomerManagedDatastoreS3Storage
-> CustomerManagedDatastoreS3Storage -> Bool
$c== :: CustomerManagedDatastoreS3Storage
-> CustomerManagedDatastoreS3Storage -> Bool
Prelude.Eq, ReadPrec [CustomerManagedDatastoreS3Storage]
ReadPrec CustomerManagedDatastoreS3Storage
Int -> ReadS CustomerManagedDatastoreS3Storage
ReadS [CustomerManagedDatastoreS3Storage]
(Int -> ReadS CustomerManagedDatastoreS3Storage)
-> ReadS [CustomerManagedDatastoreS3Storage]
-> ReadPrec CustomerManagedDatastoreS3Storage
-> ReadPrec [CustomerManagedDatastoreS3Storage]
-> Read CustomerManagedDatastoreS3Storage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomerManagedDatastoreS3Storage]
$creadListPrec :: ReadPrec [CustomerManagedDatastoreS3Storage]
readPrec :: ReadPrec CustomerManagedDatastoreS3Storage
$creadPrec :: ReadPrec CustomerManagedDatastoreS3Storage
readList :: ReadS [CustomerManagedDatastoreS3Storage]
$creadList :: ReadS [CustomerManagedDatastoreS3Storage]
readsPrec :: Int -> ReadS CustomerManagedDatastoreS3Storage
$creadsPrec :: Int -> ReadS CustomerManagedDatastoreS3Storage
Prelude.Read, Int -> CustomerManagedDatastoreS3Storage -> ShowS
[CustomerManagedDatastoreS3Storage] -> ShowS
CustomerManagedDatastoreS3Storage -> String
(Int -> CustomerManagedDatastoreS3Storage -> ShowS)
-> (CustomerManagedDatastoreS3Storage -> String)
-> ([CustomerManagedDatastoreS3Storage] -> ShowS)
-> Show CustomerManagedDatastoreS3Storage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerManagedDatastoreS3Storage] -> ShowS
$cshowList :: [CustomerManagedDatastoreS3Storage] -> ShowS
show :: CustomerManagedDatastoreS3Storage -> String
$cshow :: CustomerManagedDatastoreS3Storage -> String
showsPrec :: Int -> CustomerManagedDatastoreS3Storage -> ShowS
$cshowsPrec :: Int -> CustomerManagedDatastoreS3Storage -> ShowS
Prelude.Show, (forall x.
 CustomerManagedDatastoreS3Storage
 -> Rep CustomerManagedDatastoreS3Storage x)
-> (forall x.
    Rep CustomerManagedDatastoreS3Storage x
    -> CustomerManagedDatastoreS3Storage)
-> Generic CustomerManagedDatastoreS3Storage
forall x.
Rep CustomerManagedDatastoreS3Storage x
-> CustomerManagedDatastoreS3Storage
forall x.
CustomerManagedDatastoreS3Storage
-> Rep CustomerManagedDatastoreS3Storage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomerManagedDatastoreS3Storage x
-> CustomerManagedDatastoreS3Storage
$cfrom :: forall x.
CustomerManagedDatastoreS3Storage
-> Rep CustomerManagedDatastoreS3Storage x
Prelude.Generic)

-- |
-- Create a value of 'CustomerManagedDatastoreS3Storage' 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', 'customerManagedDatastoreS3Storage_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', 'customerManagedDatastoreS3Storage_bucket' - The name of the Amazon S3 bucket where your data is stored.
--
-- 'roleArn', 'customerManagedDatastoreS3Storage_roleArn' - The ARN of the role that grants IoT Analytics permission to interact
-- with your Amazon S3 resources.
newCustomerManagedDatastoreS3Storage ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CustomerManagedDatastoreS3Storage
newCustomerManagedDatastoreS3Storage :: Text -> Text -> CustomerManagedDatastoreS3Storage
newCustomerManagedDatastoreS3Storage
  Text
pBucket_
  Text
pRoleArn_ =
    CustomerManagedDatastoreS3Storage' :: Maybe Text -> Text -> Text -> CustomerManagedDatastoreS3Storage
CustomerManagedDatastoreS3Storage'
      { $sel:keyPrefix:CustomerManagedDatastoreS3Storage' :: Maybe Text
keyPrefix =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:bucket:CustomerManagedDatastoreS3Storage' :: Text
bucket = Text
pBucket_,
        $sel:roleArn:CustomerManagedDatastoreS3Storage' :: Text
roleArn = Text
pRoleArn_
      }

-- | (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 (\/).
customerManagedDatastoreS3Storage_keyPrefix :: Lens.Lens' CustomerManagedDatastoreS3Storage (Prelude.Maybe Prelude.Text)
customerManagedDatastoreS3Storage_keyPrefix :: (Maybe Text -> f (Maybe Text))
-> CustomerManagedDatastoreS3Storage
-> f CustomerManagedDatastoreS3Storage
customerManagedDatastoreS3Storage_keyPrefix = (CustomerManagedDatastoreS3Storage -> Maybe Text)
-> (CustomerManagedDatastoreS3Storage
    -> Maybe Text -> CustomerManagedDatastoreS3Storage)
-> Lens
     CustomerManagedDatastoreS3Storage
     CustomerManagedDatastoreS3Storage
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedDatastoreS3Storage' {Maybe Text
keyPrefix :: Maybe Text
$sel:keyPrefix:CustomerManagedDatastoreS3Storage' :: CustomerManagedDatastoreS3Storage -> Maybe Text
keyPrefix} -> Maybe Text
keyPrefix) (\s :: CustomerManagedDatastoreS3Storage
s@CustomerManagedDatastoreS3Storage' {} Maybe Text
a -> CustomerManagedDatastoreS3Storage
s {$sel:keyPrefix:CustomerManagedDatastoreS3Storage' :: Maybe Text
keyPrefix = Maybe Text
a} :: CustomerManagedDatastoreS3Storage)

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

-- | The ARN of the role that grants IoT Analytics permission to interact
-- with your Amazon S3 resources.
customerManagedDatastoreS3Storage_roleArn :: Lens.Lens' CustomerManagedDatastoreS3Storage Prelude.Text
customerManagedDatastoreS3Storage_roleArn :: (Text -> f Text)
-> CustomerManagedDatastoreS3Storage
-> f CustomerManagedDatastoreS3Storage
customerManagedDatastoreS3Storage_roleArn = (CustomerManagedDatastoreS3Storage -> Text)
-> (CustomerManagedDatastoreS3Storage
    -> Text -> CustomerManagedDatastoreS3Storage)
-> Lens
     CustomerManagedDatastoreS3Storage
     CustomerManagedDatastoreS3Storage
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedDatastoreS3Storage' {Text
roleArn :: Text
$sel:roleArn:CustomerManagedDatastoreS3Storage' :: CustomerManagedDatastoreS3Storage -> Text
roleArn} -> Text
roleArn) (\s :: CustomerManagedDatastoreS3Storage
s@CustomerManagedDatastoreS3Storage' {} Text
a -> CustomerManagedDatastoreS3Storage
s {$sel:roleArn:CustomerManagedDatastoreS3Storage' :: Text
roleArn = Text
a} :: CustomerManagedDatastoreS3Storage)

instance
  Core.FromJSON
    CustomerManagedDatastoreS3Storage
  where
  parseJSON :: Value -> Parser CustomerManagedDatastoreS3Storage
parseJSON =
    String
-> (Object -> Parser CustomerManagedDatastoreS3Storage)
-> Value
-> Parser CustomerManagedDatastoreS3Storage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomerManagedDatastoreS3Storage"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> CustomerManagedDatastoreS3Storage
CustomerManagedDatastoreS3Storage'
            (Maybe Text -> Text -> Text -> CustomerManagedDatastoreS3Storage)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> CustomerManagedDatastoreS3Storage)
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 -> Text -> CustomerManagedDatastoreS3Storage)
-> Parser Text
-> Parser (Text -> CustomerManagedDatastoreS3Storage)
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")
            Parser (Text -> CustomerManagedDatastoreS3Storage)
-> Parser Text -> Parser CustomerManagedDatastoreS3Storage
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
"roleArn")
      )

instance
  Prelude.Hashable
    CustomerManagedDatastoreS3Storage

instance
  Prelude.NFData
    CustomerManagedDatastoreS3Storage

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