{-# 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.GroundStation.Types.S3RecordingConfig
-- 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.GroundStation.Types.S3RecordingConfig 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

-- | Information about an S3 recording @Config@.
--
-- /See:/ 'newS3RecordingConfig' smart constructor.
data S3RecordingConfig = S3RecordingConfig'
  { -- | S3 Key prefix to prefice data files.
    S3RecordingConfig -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | ARN of the bucket to record to.
    S3RecordingConfig -> Text
bucketArn :: Prelude.Text,
    -- | ARN of the role Ground Station assumes to write data to the bucket.
    S3RecordingConfig -> Text
roleArn :: Prelude.Text
  }
  deriving (S3RecordingConfig -> S3RecordingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3RecordingConfig -> S3RecordingConfig -> Bool
$c/= :: S3RecordingConfig -> S3RecordingConfig -> Bool
== :: S3RecordingConfig -> S3RecordingConfig -> Bool
$c== :: S3RecordingConfig -> S3RecordingConfig -> Bool
Prelude.Eq, ReadPrec [S3RecordingConfig]
ReadPrec S3RecordingConfig
Int -> ReadS S3RecordingConfig
ReadS [S3RecordingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3RecordingConfig]
$creadListPrec :: ReadPrec [S3RecordingConfig]
readPrec :: ReadPrec S3RecordingConfig
$creadPrec :: ReadPrec S3RecordingConfig
readList :: ReadS [S3RecordingConfig]
$creadList :: ReadS [S3RecordingConfig]
readsPrec :: Int -> ReadS S3RecordingConfig
$creadsPrec :: Int -> ReadS S3RecordingConfig
Prelude.Read, Int -> S3RecordingConfig -> ShowS
[S3RecordingConfig] -> ShowS
S3RecordingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3RecordingConfig] -> ShowS
$cshowList :: [S3RecordingConfig] -> ShowS
show :: S3RecordingConfig -> String
$cshow :: S3RecordingConfig -> String
showsPrec :: Int -> S3RecordingConfig -> ShowS
$cshowsPrec :: Int -> S3RecordingConfig -> ShowS
Prelude.Show, forall x. Rep S3RecordingConfig x -> S3RecordingConfig
forall x. S3RecordingConfig -> Rep S3RecordingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3RecordingConfig x -> S3RecordingConfig
$cfrom :: forall x. S3RecordingConfig -> Rep S3RecordingConfig x
Prelude.Generic)

-- |
-- Create a value of 'S3RecordingConfig' 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:
--
-- 'prefix', 's3RecordingConfig_prefix' - S3 Key prefix to prefice data files.
--
-- 'bucketArn', 's3RecordingConfig_bucketArn' - ARN of the bucket to record to.
--
-- 'roleArn', 's3RecordingConfig_roleArn' - ARN of the role Ground Station assumes to write data to the bucket.
newS3RecordingConfig ::
  -- | 'bucketArn'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  S3RecordingConfig
newS3RecordingConfig :: Text -> Text -> S3RecordingConfig
newS3RecordingConfig Text
pBucketArn_ Text
pRoleArn_ =
  S3RecordingConfig'
    { $sel:prefix:S3RecordingConfig' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketArn:S3RecordingConfig' :: Text
bucketArn = Text
pBucketArn_,
      $sel:roleArn:S3RecordingConfig' :: Text
roleArn = Text
pRoleArn_
    }

-- | S3 Key prefix to prefice data files.
s3RecordingConfig_prefix :: Lens.Lens' S3RecordingConfig (Prelude.Maybe Prelude.Text)
s3RecordingConfig_prefix :: Lens' S3RecordingConfig (Maybe Text)
s3RecordingConfig_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3RecordingConfig' {Maybe Text
prefix :: Maybe Text
$sel:prefix:S3RecordingConfig' :: S3RecordingConfig -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: S3RecordingConfig
s@S3RecordingConfig' {} Maybe Text
a -> S3RecordingConfig
s {$sel:prefix:S3RecordingConfig' :: Maybe Text
prefix = Maybe Text
a} :: S3RecordingConfig)

-- | ARN of the bucket to record to.
s3RecordingConfig_bucketArn :: Lens.Lens' S3RecordingConfig Prelude.Text
s3RecordingConfig_bucketArn :: Lens' S3RecordingConfig Text
s3RecordingConfig_bucketArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3RecordingConfig' {Text
bucketArn :: Text
$sel:bucketArn:S3RecordingConfig' :: S3RecordingConfig -> Text
bucketArn} -> Text
bucketArn) (\s :: S3RecordingConfig
s@S3RecordingConfig' {} Text
a -> S3RecordingConfig
s {$sel:bucketArn:S3RecordingConfig' :: Text
bucketArn = Text
a} :: S3RecordingConfig)

-- | ARN of the role Ground Station assumes to write data to the bucket.
s3RecordingConfig_roleArn :: Lens.Lens' S3RecordingConfig Prelude.Text
s3RecordingConfig_roleArn :: Lens' S3RecordingConfig Text
s3RecordingConfig_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3RecordingConfig' {Text
roleArn :: Text
$sel:roleArn:S3RecordingConfig' :: S3RecordingConfig -> Text
roleArn} -> Text
roleArn) (\s :: S3RecordingConfig
s@S3RecordingConfig' {} Text
a -> S3RecordingConfig
s {$sel:roleArn:S3RecordingConfig' :: Text
roleArn = Text
a} :: S3RecordingConfig)

instance Data.FromJSON S3RecordingConfig where
  parseJSON :: Value -> Parser S3RecordingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3RecordingConfig"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> S3RecordingConfig
S3RecordingConfig'
            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
"prefix")
            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
"bucketArn")
            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 S3RecordingConfig where
  hashWithSalt :: Int -> S3RecordingConfig -> Int
hashWithSalt Int
_salt S3RecordingConfig' {Maybe Text
Text
roleArn :: Text
bucketArn :: Text
prefix :: Maybe Text
$sel:roleArn:S3RecordingConfig' :: S3RecordingConfig -> Text
$sel:bucketArn:S3RecordingConfig' :: S3RecordingConfig -> Text
$sel:prefix:S3RecordingConfig' :: S3RecordingConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

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

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