{-# 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-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.SageMaker.Types.ProcessingOutputConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ProcessingOutputConfig -> ProcessingOutputConfig -> Bool)
-> (ProcessingOutputConfig -> ProcessingOutputConfig -> Bool)
-> Eq ProcessingOutputConfig
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]
(Int -> ReadS ProcessingOutputConfig)
-> ReadS [ProcessingOutputConfig]
-> ReadPrec ProcessingOutputConfig
-> ReadPrec [ProcessingOutputConfig]
-> Read 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
(Int -> ProcessingOutputConfig -> ShowS)
-> (ProcessingOutputConfig -> String)
-> ([ProcessingOutputConfig] -> ShowS)
-> Show ProcessingOutputConfig
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. ProcessingOutputConfig -> Rep ProcessingOutputConfig x)
-> (forall x.
    Rep ProcessingOutputConfig x -> ProcessingOutputConfig)
-> Generic ProcessingOutputConfig
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' :: Maybe Text -> [ProcessingOutput] -> ProcessingOutputConfig
ProcessingOutputConfig'
    { $sel:kmsKeyId:ProcessingOutputConfig' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:ProcessingOutputConfig' :: [ProcessingOutput]
outputs = [ProcessingOutput]
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 :: (Maybe Text -> f (Maybe Text))
-> ProcessingOutputConfig -> f ProcessingOutputConfig
processingOutputConfig_kmsKeyId = (ProcessingOutputConfig -> Maybe Text)
-> (ProcessingOutputConfig -> Maybe Text -> ProcessingOutputConfig)
-> Lens
     ProcessingOutputConfig
     ProcessingOutputConfig
     (Maybe Text)
     (Maybe Text)
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 :: ([ProcessingOutput] -> f [ProcessingOutput])
-> ProcessingOutputConfig -> f ProcessingOutputConfig
processingOutputConfig_outputs = (ProcessingOutputConfig -> [ProcessingOutput])
-> (ProcessingOutputConfig
    -> [ProcessingOutput] -> ProcessingOutputConfig)
-> Lens
     ProcessingOutputConfig
     ProcessingOutputConfig
     [ProcessingOutput]
     [ProcessingOutput]
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) (([ProcessingOutput] -> f [ProcessingOutput])
 -> ProcessingOutputConfig -> f ProcessingOutputConfig)
-> (([ProcessingOutput] -> f [ProcessingOutput])
    -> [ProcessingOutput] -> f [ProcessingOutput])
-> ([ProcessingOutput] -> f [ProcessingOutput])
-> ProcessingOutputConfig
-> f ProcessingOutputConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProcessingOutput] -> f [ProcessingOutput])
-> [ProcessingOutput] -> f [ProcessingOutput]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ProcessingOutputConfig

instance Prelude.NFData ProcessingOutputConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KmsKeyId" 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
kmsKeyId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Outputs" Text -> [ProcessingOutput] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ProcessingOutput]
outputs)
          ]
      )