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

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

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

-- |
-- Create a value of 'CustomerManagedChannelS3Storage' 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', 'customerManagedChannelS3Storage_keyPrefix' - (Optional) The prefix used to create the keys of the channel data
-- objects. Each object in an 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', 'customerManagedChannelS3Storage_bucket' - The name of the S3 bucket in which channel data is stored.
--
-- 'roleArn', 'customerManagedChannelS3Storage_roleArn' - The ARN of the role that grants IoT Analytics permission to interact
-- with your Amazon S3 resources.
newCustomerManagedChannelS3Storage ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CustomerManagedChannelS3Storage
newCustomerManagedChannelS3Storage :: Text -> Text -> CustomerManagedChannelS3Storage
newCustomerManagedChannelS3Storage Text
pBucket_ Text
pRoleArn_ =
  CustomerManagedChannelS3Storage'
    { $sel:keyPrefix:CustomerManagedChannelS3Storage' :: Maybe Text
keyPrefix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:CustomerManagedChannelS3Storage' :: Text
bucket = Text
pBucket_,
      $sel:roleArn:CustomerManagedChannelS3Storage' :: Text
roleArn = Text
pRoleArn_
    }

-- | (Optional) The prefix used to create the keys of the channel data
-- objects. Each object in an 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 (\/).
customerManagedChannelS3Storage_keyPrefix :: Lens.Lens' CustomerManagedChannelS3Storage (Prelude.Maybe Prelude.Text)
customerManagedChannelS3Storage_keyPrefix :: Lens' CustomerManagedChannelS3Storage (Maybe Text)
customerManagedChannelS3Storage_keyPrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedChannelS3Storage' {Maybe Text
keyPrefix :: Maybe Text
$sel:keyPrefix:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Maybe Text
keyPrefix} -> Maybe Text
keyPrefix) (\s :: CustomerManagedChannelS3Storage
s@CustomerManagedChannelS3Storage' {} Maybe Text
a -> CustomerManagedChannelS3Storage
s {$sel:keyPrefix:CustomerManagedChannelS3Storage' :: Maybe Text
keyPrefix = Maybe Text
a} :: CustomerManagedChannelS3Storage)

-- | The name of the S3 bucket in which channel data is stored.
customerManagedChannelS3Storage_bucket :: Lens.Lens' CustomerManagedChannelS3Storage Prelude.Text
customerManagedChannelS3Storage_bucket :: Lens' CustomerManagedChannelS3Storage Text
customerManagedChannelS3Storage_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedChannelS3Storage' {Text
bucket :: Text
$sel:bucket:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Text
bucket} -> Text
bucket) (\s :: CustomerManagedChannelS3Storage
s@CustomerManagedChannelS3Storage' {} Text
a -> CustomerManagedChannelS3Storage
s {$sel:bucket:CustomerManagedChannelS3Storage' :: Text
bucket = Text
a} :: CustomerManagedChannelS3Storage)

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

instance
  Data.FromJSON
    CustomerManagedChannelS3Storage
  where
  parseJSON :: Value -> Parser CustomerManagedChannelS3Storage
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomerManagedChannelS3Storage"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> CustomerManagedChannelS3Storage
CustomerManagedChannelS3Storage'
            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
"keyPrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"bucket")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"roleArn")
      )

instance
  Prelude.Hashable
    CustomerManagedChannelS3Storage
  where
  hashWithSalt :: Int -> CustomerManagedChannelS3Storage -> Int
hashWithSalt
    Int
_salt
    CustomerManagedChannelS3Storage' {Maybe Text
Text
roleArn :: Text
bucket :: Text
keyPrefix :: Maybe Text
$sel:roleArn:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Text
$sel:bucket:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Text
$sel:keyPrefix:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyPrefix
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucket
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance
  Prelude.NFData
    CustomerManagedChannelS3Storage
  where
  rnf :: CustomerManagedChannelS3Storage -> ()
rnf CustomerManagedChannelS3Storage' {Maybe Text
Text
roleArn :: Text
bucket :: Text
keyPrefix :: Maybe Text
$sel:roleArn:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Text
$sel:bucket:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Text
$sel:keyPrefix:CustomerManagedChannelS3Storage' :: CustomerManagedChannelS3Storage -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyPrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

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