{-# 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.SageMaker.Types.ProcessingOutputConfig
-- 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.SageMaker.Types.ProcessingOutputConfig 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
import Amazonka.SageMaker.Types.ProcessingOutput

-- | Configuration for uploading output from the processing container.
--
-- /See:/ 'newProcessingOutputConfig' smart constructor.
data ProcessingOutputConfig = ProcessingOutputConfig'
  { -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that Amazon SageMaker uses to encrypt the processing job output.
    -- @KmsKeyId@ can be an ID of a KMS key, ARN of a KMS key, alias of a KMS
    -- key, or alias of a KMS key. The @KmsKeyId@ is applied to all outputs.
    ProcessingOutputConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | An array of outputs configuring the data to upload from the processing
    -- container.
    ProcessingOutputConfig -> [ProcessingOutput]
outputs :: [ProcessingOutput]
  }
  deriving (ProcessingOutputConfig -> ProcessingOutputConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingOutputConfig -> ProcessingOutputConfig -> Bool
$c/= :: ProcessingOutputConfig -> ProcessingOutputConfig -> Bool
== :: ProcessingOutputConfig -> ProcessingOutputConfig -> Bool
$c== :: ProcessingOutputConfig -> ProcessingOutputConfig -> Bool
Prelude.Eq, ReadPrec [ProcessingOutputConfig]
ReadPrec ProcessingOutputConfig
Int -> ReadS ProcessingOutputConfig
ReadS [ProcessingOutputConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingOutputConfig]
$creadListPrec :: ReadPrec [ProcessingOutputConfig]
readPrec :: ReadPrec ProcessingOutputConfig
$creadPrec :: ReadPrec ProcessingOutputConfig
readList :: ReadS [ProcessingOutputConfig]
$creadList :: ReadS [ProcessingOutputConfig]
readsPrec :: Int -> ReadS ProcessingOutputConfig
$creadsPrec :: Int -> ReadS ProcessingOutputConfig
Prelude.Read, Int -> ProcessingOutputConfig -> ShowS
[ProcessingOutputConfig] -> ShowS
ProcessingOutputConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingOutputConfig] -> ShowS
$cshowList :: [ProcessingOutputConfig] -> ShowS
show :: ProcessingOutputConfig -> String
$cshow :: ProcessingOutputConfig -> String
showsPrec :: Int -> ProcessingOutputConfig -> ShowS
$cshowsPrec :: Int -> ProcessingOutputConfig -> ShowS
Prelude.Show, forall x. Rep ProcessingOutputConfig x -> ProcessingOutputConfig
forall x. ProcessingOutputConfig -> Rep ProcessingOutputConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessingOutputConfig x -> ProcessingOutputConfig
$cfrom :: forall x. ProcessingOutputConfig -> Rep ProcessingOutputConfig x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingOutputConfig' 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:
--
-- 'kmsKeyId', 'processingOutputConfig_kmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the processing job output.
-- @KmsKeyId@ can be an ID of a KMS key, ARN of a KMS key, alias of a KMS
-- key, or alias of a KMS key. The @KmsKeyId@ is applied to all outputs.
--
-- 'outputs', 'processingOutputConfig_outputs' - An array of outputs configuring the data to upload from the processing
-- container.
newProcessingOutputConfig ::
  ProcessingOutputConfig
newProcessingOutputConfig :: ProcessingOutputConfig
newProcessingOutputConfig =
  ProcessingOutputConfig'
    { $sel:kmsKeyId:ProcessingOutputConfig' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:ProcessingOutputConfig' :: [ProcessingOutput]
outputs = forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the processing job output.
-- @KmsKeyId@ can be an ID of a KMS key, ARN of a KMS key, alias of a KMS
-- key, or alias of a KMS key. The @KmsKeyId@ is applied to all outputs.
processingOutputConfig_kmsKeyId :: Lens.Lens' ProcessingOutputConfig (Prelude.Maybe Prelude.Text)
processingOutputConfig_kmsKeyId :: Lens' ProcessingOutputConfig (Maybe Text)
processingOutputConfig_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingOutputConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:ProcessingOutputConfig' :: ProcessingOutputConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: ProcessingOutputConfig
s@ProcessingOutputConfig' {} Maybe Text
a -> ProcessingOutputConfig
s {$sel:kmsKeyId:ProcessingOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: ProcessingOutputConfig)

-- | An array of outputs configuring the data to upload from the processing
-- container.
processingOutputConfig_outputs :: Lens.Lens' ProcessingOutputConfig [ProcessingOutput]
processingOutputConfig_outputs :: Lens' ProcessingOutputConfig [ProcessingOutput]
processingOutputConfig_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingOutputConfig' {[ProcessingOutput]
outputs :: [ProcessingOutput]
$sel:outputs:ProcessingOutputConfig' :: ProcessingOutputConfig -> [ProcessingOutput]
outputs} -> [ProcessingOutput]
outputs) (\s :: ProcessingOutputConfig
s@ProcessingOutputConfig' {} [ProcessingOutput]
a -> ProcessingOutputConfig
s {$sel:outputs:ProcessingOutputConfig' :: [ProcessingOutput]
outputs = [ProcessingOutput]
a} :: ProcessingOutputConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ProcessingOutputConfig where
  parseJSON :: Value -> Parser ProcessingOutputConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProcessingOutputConfig"
      ( \Object
x ->
          Maybe Text -> [ProcessingOutput] -> ProcessingOutputConfig
ProcessingOutputConfig'
            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
"KmsKeyId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Outputs" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ProcessingOutputConfig where
  hashWithSalt :: Int -> ProcessingOutputConfig -> Int
hashWithSalt Int
_salt ProcessingOutputConfig' {[ProcessingOutput]
Maybe Text
outputs :: [ProcessingOutput]
kmsKeyId :: Maybe Text
$sel:outputs:ProcessingOutputConfig' :: ProcessingOutputConfig -> [ProcessingOutput]
$sel:kmsKeyId:ProcessingOutputConfig' :: ProcessingOutputConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ProcessingOutput]
outputs

instance Prelude.NFData ProcessingOutputConfig where
  rnf :: ProcessingOutputConfig -> ()
rnf ProcessingOutputConfig' {[ProcessingOutput]
Maybe Text
outputs :: [ProcessingOutput]
kmsKeyId :: Maybe Text
$sel:outputs:ProcessingOutputConfig' :: ProcessingOutputConfig -> [ProcessingOutput]
$sel:kmsKeyId:ProcessingOutputConfig' :: ProcessingOutputConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ProcessingOutput]
outputs

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