{-# 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.CaptureContentTypeHeader
-- 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.CaptureContentTypeHeader 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

-- | Configuration specifying how to treat different headers. If no headers
-- are specified SageMaker will by default base64 encode when capturing the
-- data.
--
-- /See:/ 'newCaptureContentTypeHeader' smart constructor.
data CaptureContentTypeHeader = CaptureContentTypeHeader'
  { -- | The list of all content type headers that SageMaker will treat as CSV
    -- and capture accordingly.
    CaptureContentTypeHeader -> Maybe (NonEmpty Text)
csvContentTypes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The list of all content type headers that SageMaker will treat as JSON
    -- and capture accordingly.
    CaptureContentTypeHeader -> Maybe (NonEmpty Text)
jsonContentTypes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (CaptureContentTypeHeader -> CaptureContentTypeHeader -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptureContentTypeHeader -> CaptureContentTypeHeader -> Bool
$c/= :: CaptureContentTypeHeader -> CaptureContentTypeHeader -> Bool
== :: CaptureContentTypeHeader -> CaptureContentTypeHeader -> Bool
$c== :: CaptureContentTypeHeader -> CaptureContentTypeHeader -> Bool
Prelude.Eq, ReadPrec [CaptureContentTypeHeader]
ReadPrec CaptureContentTypeHeader
Int -> ReadS CaptureContentTypeHeader
ReadS [CaptureContentTypeHeader]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptureContentTypeHeader]
$creadListPrec :: ReadPrec [CaptureContentTypeHeader]
readPrec :: ReadPrec CaptureContentTypeHeader
$creadPrec :: ReadPrec CaptureContentTypeHeader
readList :: ReadS [CaptureContentTypeHeader]
$creadList :: ReadS [CaptureContentTypeHeader]
readsPrec :: Int -> ReadS CaptureContentTypeHeader
$creadsPrec :: Int -> ReadS CaptureContentTypeHeader
Prelude.Read, Int -> CaptureContentTypeHeader -> ShowS
[CaptureContentTypeHeader] -> ShowS
CaptureContentTypeHeader -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptureContentTypeHeader] -> ShowS
$cshowList :: [CaptureContentTypeHeader] -> ShowS
show :: CaptureContentTypeHeader -> String
$cshow :: CaptureContentTypeHeader -> String
showsPrec :: Int -> CaptureContentTypeHeader -> ShowS
$cshowsPrec :: Int -> CaptureContentTypeHeader -> ShowS
Prelude.Show, forall x.
Rep CaptureContentTypeHeader x -> CaptureContentTypeHeader
forall x.
CaptureContentTypeHeader -> Rep CaptureContentTypeHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CaptureContentTypeHeader x -> CaptureContentTypeHeader
$cfrom :: forall x.
CaptureContentTypeHeader -> Rep CaptureContentTypeHeader x
Prelude.Generic)

-- |
-- Create a value of 'CaptureContentTypeHeader' 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:
--
-- 'csvContentTypes', 'captureContentTypeHeader_csvContentTypes' - The list of all content type headers that SageMaker will treat as CSV
-- and capture accordingly.
--
-- 'jsonContentTypes', 'captureContentTypeHeader_jsonContentTypes' - The list of all content type headers that SageMaker will treat as JSON
-- and capture accordingly.
newCaptureContentTypeHeader ::
  CaptureContentTypeHeader
newCaptureContentTypeHeader :: CaptureContentTypeHeader
newCaptureContentTypeHeader =
  CaptureContentTypeHeader'
    { $sel:csvContentTypes:CaptureContentTypeHeader' :: Maybe (NonEmpty Text)
csvContentTypes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:jsonContentTypes:CaptureContentTypeHeader' :: Maybe (NonEmpty Text)
jsonContentTypes = forall a. Maybe a
Prelude.Nothing
    }

-- | The list of all content type headers that SageMaker will treat as CSV
-- and capture accordingly.
captureContentTypeHeader_csvContentTypes :: Lens.Lens' CaptureContentTypeHeader (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
captureContentTypeHeader_csvContentTypes :: Lens' CaptureContentTypeHeader (Maybe (NonEmpty Text))
captureContentTypeHeader_csvContentTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptureContentTypeHeader' {Maybe (NonEmpty Text)
csvContentTypes :: Maybe (NonEmpty Text)
$sel:csvContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
csvContentTypes} -> Maybe (NonEmpty Text)
csvContentTypes) (\s :: CaptureContentTypeHeader
s@CaptureContentTypeHeader' {} Maybe (NonEmpty Text)
a -> CaptureContentTypeHeader
s {$sel:csvContentTypes:CaptureContentTypeHeader' :: Maybe (NonEmpty Text)
csvContentTypes = Maybe (NonEmpty Text)
a} :: CaptureContentTypeHeader) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of all content type headers that SageMaker will treat as JSON
-- and capture accordingly.
captureContentTypeHeader_jsonContentTypes :: Lens.Lens' CaptureContentTypeHeader (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
captureContentTypeHeader_jsonContentTypes :: Lens' CaptureContentTypeHeader (Maybe (NonEmpty Text))
captureContentTypeHeader_jsonContentTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptureContentTypeHeader' {Maybe (NonEmpty Text)
jsonContentTypes :: Maybe (NonEmpty Text)
$sel:jsonContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
jsonContentTypes} -> Maybe (NonEmpty Text)
jsonContentTypes) (\s :: CaptureContentTypeHeader
s@CaptureContentTypeHeader' {} Maybe (NonEmpty Text)
a -> CaptureContentTypeHeader
s {$sel:jsonContentTypes:CaptureContentTypeHeader' :: Maybe (NonEmpty Text)
jsonContentTypes = Maybe (NonEmpty Text)
a} :: CaptureContentTypeHeader) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON CaptureContentTypeHeader where
  parseJSON :: Value -> Parser CaptureContentTypeHeader
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CaptureContentTypeHeader"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text) -> CaptureContentTypeHeader
CaptureContentTypeHeader'
            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
"CsvContentTypes")
            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
"JsonContentTypes")
      )

instance Prelude.Hashable CaptureContentTypeHeader where
  hashWithSalt :: Int -> CaptureContentTypeHeader -> Int
hashWithSalt Int
_salt CaptureContentTypeHeader' {Maybe (NonEmpty Text)
jsonContentTypes :: Maybe (NonEmpty Text)
csvContentTypes :: Maybe (NonEmpty Text)
$sel:jsonContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
$sel:csvContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
csvContentTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
jsonContentTypes

instance Prelude.NFData CaptureContentTypeHeader where
  rnf :: CaptureContentTypeHeader -> ()
rnf CaptureContentTypeHeader' {Maybe (NonEmpty Text)
jsonContentTypes :: Maybe (NonEmpty Text)
csvContentTypes :: Maybe (NonEmpty Text)
$sel:jsonContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
$sel:csvContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
csvContentTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
jsonContentTypes

instance Data.ToJSON CaptureContentTypeHeader where
  toJSON :: CaptureContentTypeHeader -> Value
toJSON CaptureContentTypeHeader' {Maybe (NonEmpty Text)
jsonContentTypes :: Maybe (NonEmpty Text)
csvContentTypes :: Maybe (NonEmpty Text)
$sel:jsonContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
$sel:csvContentTypes:CaptureContentTypeHeader' :: CaptureContentTypeHeader -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CsvContentTypes" 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 (NonEmpty Text)
csvContentTypes,
            (Key
"JsonContentTypes" 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 (NonEmpty Text)
jsonContentTypes
          ]
      )