{-# 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.Omics.Types.SseConfig
-- 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.Omics.Types.SseConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Omics.Types.EncryptionType
import qualified Amazonka.Prelude as Prelude

-- | Server-side encryption (SSE) settings for a store.
--
-- /See:/ 'newSseConfig' smart constructor.
data SseConfig = SseConfig'
  { -- | An encryption key ARN.
    SseConfig -> Maybe Text
keyArn :: Prelude.Maybe Prelude.Text,
    -- | The encryption type.
    SseConfig -> EncryptionType
type' :: EncryptionType
  }
  deriving (SseConfig -> SseConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SseConfig -> SseConfig -> Bool
$c/= :: SseConfig -> SseConfig -> Bool
== :: SseConfig -> SseConfig -> Bool
$c== :: SseConfig -> SseConfig -> Bool
Prelude.Eq, ReadPrec [SseConfig]
ReadPrec SseConfig
Int -> ReadS SseConfig
ReadS [SseConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SseConfig]
$creadListPrec :: ReadPrec [SseConfig]
readPrec :: ReadPrec SseConfig
$creadPrec :: ReadPrec SseConfig
readList :: ReadS [SseConfig]
$creadList :: ReadS [SseConfig]
readsPrec :: Int -> ReadS SseConfig
$creadsPrec :: Int -> ReadS SseConfig
Prelude.Read, Int -> SseConfig -> ShowS
[SseConfig] -> ShowS
SseConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SseConfig] -> ShowS
$cshowList :: [SseConfig] -> ShowS
show :: SseConfig -> String
$cshow :: SseConfig -> String
showsPrec :: Int -> SseConfig -> ShowS
$cshowsPrec :: Int -> SseConfig -> ShowS
Prelude.Show, forall x. Rep SseConfig x -> SseConfig
forall x. SseConfig -> Rep SseConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SseConfig x -> SseConfig
$cfrom :: forall x. SseConfig -> Rep SseConfig x
Prelude.Generic)

-- |
-- Create a value of 'SseConfig' 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:
--
-- 'keyArn', 'sseConfig_keyArn' - An encryption key ARN.
--
-- 'type'', 'sseConfig_type' - The encryption type.
newSseConfig ::
  -- | 'type''
  EncryptionType ->
  SseConfig
newSseConfig :: EncryptionType -> SseConfig
newSseConfig EncryptionType
pType_ =
  SseConfig'
    { $sel:keyArn:SseConfig' :: Maybe Text
keyArn = forall a. Maybe a
Prelude.Nothing,
      $sel:type':SseConfig' :: EncryptionType
type' = EncryptionType
pType_
    }

-- | An encryption key ARN.
sseConfig_keyArn :: Lens.Lens' SseConfig (Prelude.Maybe Prelude.Text)
sseConfig_keyArn :: Lens' SseConfig (Maybe Text)
sseConfig_keyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SseConfig' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:SseConfig' :: SseConfig -> Maybe Text
keyArn} -> Maybe Text
keyArn) (\s :: SseConfig
s@SseConfig' {} Maybe Text
a -> SseConfig
s {$sel:keyArn:SseConfig' :: Maybe Text
keyArn = Maybe Text
a} :: SseConfig)

-- | The encryption type.
sseConfig_type :: Lens.Lens' SseConfig EncryptionType
sseConfig_type :: Lens' SseConfig EncryptionType
sseConfig_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SseConfig' {EncryptionType
type' :: EncryptionType
$sel:type':SseConfig' :: SseConfig -> EncryptionType
type'} -> EncryptionType
type') (\s :: SseConfig
s@SseConfig' {} EncryptionType
a -> SseConfig
s {$sel:type':SseConfig' :: EncryptionType
type' = EncryptionType
a} :: SseConfig)

instance Data.FromJSON SseConfig where
  parseJSON :: Value -> Parser SseConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SseConfig"
      ( \Object
x ->
          Maybe Text -> EncryptionType -> SseConfig
SseConfig'
            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
"keyArn")
            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
"type")
      )

instance Prelude.Hashable SseConfig where
  hashWithSalt :: Int -> SseConfig -> Int
hashWithSalt Int
_salt SseConfig' {Maybe Text
EncryptionType
type' :: EncryptionType
keyArn :: Maybe Text
$sel:type':SseConfig' :: SseConfig -> EncryptionType
$sel:keyArn:SseConfig' :: SseConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EncryptionType
type'

instance Prelude.NFData SseConfig where
  rnf :: SseConfig -> ()
rnf SseConfig' {Maybe Text
EncryptionType
type' :: EncryptionType
keyArn :: Maybe Text
$sel:type':SseConfig' :: SseConfig -> EncryptionType
$sel:keyArn:SseConfig' :: SseConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyArn seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EncryptionType
type'

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