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

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

-- | Provides information about how to store model training results (model
-- artifacts).
--
-- /See:/ 'newOutputDataConfig' smart constructor.
data OutputDataConfig = OutputDataConfig'
  { -- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
    -- key that Amazon SageMaker uses to encrypt the model artifacts at rest
    -- using Amazon S3 server-side encryption. The @KmsKeyId@ can be any of the
    -- following formats:
    --
    -- -   \/\/ KMS Key ID
    --
    --     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
    --
    -- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
    --
    --     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
    --
    -- -   \/\/ KMS Key Alias
    --
    --     @\"alias\/ExampleAlias\"@
    --
    -- -   \/\/ Amazon Resource Name (ARN) of a KMS Key Alias
    --
    --     @\"arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias\"@
    --
    -- If you use a KMS key ID or an alias of your KMS key, the Amazon
    -- SageMaker execution role must include permissions to call @kms:Encrypt@.
    -- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
    -- KMS key for Amazon S3 for your role\'s account. Amazon SageMaker uses
    -- server-side encryption with KMS-managed keys for @OutputDataConfig@. If
    -- you use a bucket policy with an @s3:PutObject@ permission that only
    -- allows objects with server-side encryption, set the condition key of
    -- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html KMS-Managed Encryption Keys>
    -- in the /Amazon Simple Storage Service Developer Guide./
    --
    -- The KMS key policy must grant permission to the IAM role that you
    -- specify in your @CreateTrainingJob@, @CreateTransformJob@, or
    -- @CreateHyperParameterTuningJob@ requests. For more information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html Using Key Policies in Amazon Web Services KMS>
    -- in the /Amazon Web Services Key Management Service Developer Guide/.
    OutputDataConfig -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | Identifies the S3 path where you want Amazon SageMaker to store the
    -- model artifacts. For example, @s3:\/\/bucket-name\/key-name-prefix@.
    OutputDataConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (OutputDataConfig -> OutputDataConfig -> Bool
(OutputDataConfig -> OutputDataConfig -> Bool)
-> (OutputDataConfig -> OutputDataConfig -> Bool)
-> Eq OutputDataConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputDataConfig -> OutputDataConfig -> Bool
$c/= :: OutputDataConfig -> OutputDataConfig -> Bool
== :: OutputDataConfig -> OutputDataConfig -> Bool
$c== :: OutputDataConfig -> OutputDataConfig -> Bool
Prelude.Eq, ReadPrec [OutputDataConfig]
ReadPrec OutputDataConfig
Int -> ReadS OutputDataConfig
ReadS [OutputDataConfig]
(Int -> ReadS OutputDataConfig)
-> ReadS [OutputDataConfig]
-> ReadPrec OutputDataConfig
-> ReadPrec [OutputDataConfig]
-> Read OutputDataConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputDataConfig]
$creadListPrec :: ReadPrec [OutputDataConfig]
readPrec :: ReadPrec OutputDataConfig
$creadPrec :: ReadPrec OutputDataConfig
readList :: ReadS [OutputDataConfig]
$creadList :: ReadS [OutputDataConfig]
readsPrec :: Int -> ReadS OutputDataConfig
$creadsPrec :: Int -> ReadS OutputDataConfig
Prelude.Read, Int -> OutputDataConfig -> ShowS
[OutputDataConfig] -> ShowS
OutputDataConfig -> String
(Int -> OutputDataConfig -> ShowS)
-> (OutputDataConfig -> String)
-> ([OutputDataConfig] -> ShowS)
-> Show OutputDataConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputDataConfig] -> ShowS
$cshowList :: [OutputDataConfig] -> ShowS
show :: OutputDataConfig -> String
$cshow :: OutputDataConfig -> String
showsPrec :: Int -> OutputDataConfig -> ShowS
$cshowsPrec :: Int -> OutputDataConfig -> ShowS
Prelude.Show, (forall x. OutputDataConfig -> Rep OutputDataConfig x)
-> (forall x. Rep OutputDataConfig x -> OutputDataConfig)
-> Generic OutputDataConfig
forall x. Rep OutputDataConfig x -> OutputDataConfig
forall x. OutputDataConfig -> Rep OutputDataConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputDataConfig x -> OutputDataConfig
$cfrom :: forall x. OutputDataConfig -> Rep OutputDataConfig x
Prelude.Generic)

-- |
-- Create a value of 'OutputDataConfig' 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', 'outputDataConfig_kmsKeyId' - The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the model artifacts at rest
-- using Amazon S3 server-side encryption. The @KmsKeyId@ can be any of the
-- following formats:
--
-- -   \/\/ KMS Key ID
--
--     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
--
--     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ KMS Key Alias
--
--     @\"alias\/ExampleAlias\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key Alias
--
--     @\"arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias\"@
--
-- If you use a KMS key ID or an alias of your KMS key, the Amazon
-- SageMaker execution role must include permissions to call @kms:Encrypt@.
-- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
-- KMS key for Amazon S3 for your role\'s account. Amazon SageMaker uses
-- server-side encryption with KMS-managed keys for @OutputDataConfig@. If
-- you use a bucket policy with an @s3:PutObject@ permission that only
-- allows objects with server-side encryption, set the condition key of
-- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html KMS-Managed Encryption Keys>
-- in the /Amazon Simple Storage Service Developer Guide./
--
-- The KMS key policy must grant permission to the IAM role that you
-- specify in your @CreateTrainingJob@, @CreateTransformJob@, or
-- @CreateHyperParameterTuningJob@ requests. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html Using Key Policies in Amazon Web Services KMS>
-- in the /Amazon Web Services Key Management Service Developer Guide/.
--
-- 's3OutputPath', 'outputDataConfig_s3OutputPath' - Identifies the S3 path where you want Amazon SageMaker to store the
-- model artifacts. For example, @s3:\/\/bucket-name\/key-name-prefix@.
newOutputDataConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  OutputDataConfig
newOutputDataConfig :: Text -> OutputDataConfig
newOutputDataConfig Text
pS3OutputPath_ =
  OutputDataConfig' :: Maybe Text -> Text -> OutputDataConfig
OutputDataConfig'
    { $sel:kmsKeyId:OutputDataConfig' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:OutputDataConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | The Amazon Web Services Key Management Service (Amazon Web Services KMS)
-- key that Amazon SageMaker uses to encrypt the model artifacts at rest
-- using Amazon S3 server-side encryption. The @KmsKeyId@ can be any of the
-- following formats:
--
-- -   \/\/ KMS Key ID
--
--     @\"1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key
--
--     @\"arn:aws:kms:us-west-2:111122223333:key\/1234abcd-12ab-34cd-56ef-1234567890ab\"@
--
-- -   \/\/ KMS Key Alias
--
--     @\"alias\/ExampleAlias\"@
--
-- -   \/\/ Amazon Resource Name (ARN) of a KMS Key Alias
--
--     @\"arn:aws:kms:us-west-2:111122223333:alias\/ExampleAlias\"@
--
-- If you use a KMS key ID or an alias of your KMS key, the Amazon
-- SageMaker execution role must include permissions to call @kms:Encrypt@.
-- If you don\'t provide a KMS key ID, Amazon SageMaker uses the default
-- KMS key for Amazon S3 for your role\'s account. Amazon SageMaker uses
-- server-side encryption with KMS-managed keys for @OutputDataConfig@. If
-- you use a bucket policy with an @s3:PutObject@ permission that only
-- allows objects with server-side encryption, set the condition key of
-- @s3:x-amz-server-side-encryption@ to @\"aws:kms\"@. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html KMS-Managed Encryption Keys>
-- in the /Amazon Simple Storage Service Developer Guide./
--
-- The KMS key policy must grant permission to the IAM role that you
-- specify in your @CreateTrainingJob@, @CreateTransformJob@, or
-- @CreateHyperParameterTuningJob@ requests. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html Using Key Policies in Amazon Web Services KMS>
-- in the /Amazon Web Services Key Management Service Developer Guide/.
outputDataConfig_kmsKeyId :: Lens.Lens' OutputDataConfig (Prelude.Maybe Prelude.Text)
outputDataConfig_kmsKeyId :: (Maybe Text -> f (Maybe Text))
-> OutputDataConfig -> f OutputDataConfig
outputDataConfig_kmsKeyId = (OutputDataConfig -> Maybe Text)
-> (OutputDataConfig -> Maybe Text -> OutputDataConfig)
-> Lens OutputDataConfig OutputDataConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputDataConfig' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:OutputDataConfig' :: OutputDataConfig -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: OutputDataConfig
s@OutputDataConfig' {} Maybe Text
a -> OutputDataConfig
s {$sel:kmsKeyId:OutputDataConfig' :: Maybe Text
kmsKeyId = Maybe Text
a} :: OutputDataConfig)

-- | Identifies the S3 path where you want Amazon SageMaker to store the
-- model artifacts. For example, @s3:\/\/bucket-name\/key-name-prefix@.
outputDataConfig_s3OutputPath :: Lens.Lens' OutputDataConfig Prelude.Text
outputDataConfig_s3OutputPath :: (Text -> f Text) -> OutputDataConfig -> f OutputDataConfig
outputDataConfig_s3OutputPath = (OutputDataConfig -> Text)
-> (OutputDataConfig -> Text -> OutputDataConfig)
-> Lens OutputDataConfig OutputDataConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputDataConfig' {Text
s3OutputPath :: Text
$sel:s3OutputPath:OutputDataConfig' :: OutputDataConfig -> Text
s3OutputPath} -> Text
s3OutputPath) (\s :: OutputDataConfig
s@OutputDataConfig' {} Text
a -> OutputDataConfig
s {$sel:s3OutputPath:OutputDataConfig' :: Text
s3OutputPath = Text
a} :: OutputDataConfig)

instance Core.FromJSON OutputDataConfig where
  parseJSON :: Value -> Parser OutputDataConfig
parseJSON =
    String
-> (Object -> Parser OutputDataConfig)
-> Value
-> Parser OutputDataConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputDataConfig"
      ( \Object
x ->
          Maybe Text -> Text -> OutputDataConfig
OutputDataConfig'
            (Maybe Text -> Text -> OutputDataConfig)
-> Parser (Maybe Text) -> Parser (Text -> OutputDataConfig)
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 (Text -> OutputDataConfig)
-> Parser Text -> Parser OutputDataConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3OutputPath")
      )

instance Prelude.Hashable OutputDataConfig

instance Prelude.NFData OutputDataConfig

instance Core.ToJSON OutputDataConfig where
  toJSON :: OutputDataConfig -> Value
toJSON OutputDataConfig' {Maybe Text
Text
s3OutputPath :: Text
kmsKeyId :: Maybe Text
$sel:s3OutputPath:OutputDataConfig' :: OutputDataConfig -> Text
$sel:kmsKeyId:OutputDataConfig' :: OutputDataConfig -> 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
"S3OutputPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3OutputPath)
          ]
      )