{-# 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.AppFlow.Types.PrefixConfig
-- 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.AppFlow.Types.PrefixConfig where

import Amazonka.AppFlow.Types.PrefixFormat
import Amazonka.AppFlow.Types.PrefixType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Determines the prefix that Amazon AppFlow applies to the destination
-- folder name. You can name your destination folders according to the flow
-- frequency and date.
--
-- /See:/ 'newPrefixConfig' smart constructor.
data PrefixConfig = PrefixConfig'
  { -- | Determines the level of granularity that\'s included in the prefix.
    PrefixConfig -> Maybe PrefixFormat
prefixFormat :: Prelude.Maybe PrefixFormat,
    -- | Determines the format of the prefix, and whether it applies to the file
    -- name, file path, or both.
    PrefixConfig -> Maybe PrefixType
prefixType :: Prelude.Maybe PrefixType
  }
  deriving (PrefixConfig -> PrefixConfig -> Bool
(PrefixConfig -> PrefixConfig -> Bool)
-> (PrefixConfig -> PrefixConfig -> Bool) -> Eq PrefixConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrefixConfig -> PrefixConfig -> Bool
$c/= :: PrefixConfig -> PrefixConfig -> Bool
== :: PrefixConfig -> PrefixConfig -> Bool
$c== :: PrefixConfig -> PrefixConfig -> Bool
Prelude.Eq, ReadPrec [PrefixConfig]
ReadPrec PrefixConfig
Int -> ReadS PrefixConfig
ReadS [PrefixConfig]
(Int -> ReadS PrefixConfig)
-> ReadS [PrefixConfig]
-> ReadPrec PrefixConfig
-> ReadPrec [PrefixConfig]
-> Read PrefixConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrefixConfig]
$creadListPrec :: ReadPrec [PrefixConfig]
readPrec :: ReadPrec PrefixConfig
$creadPrec :: ReadPrec PrefixConfig
readList :: ReadS [PrefixConfig]
$creadList :: ReadS [PrefixConfig]
readsPrec :: Int -> ReadS PrefixConfig
$creadsPrec :: Int -> ReadS PrefixConfig
Prelude.Read, Int -> PrefixConfig -> ShowS
[PrefixConfig] -> ShowS
PrefixConfig -> String
(Int -> PrefixConfig -> ShowS)
-> (PrefixConfig -> String)
-> ([PrefixConfig] -> ShowS)
-> Show PrefixConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrefixConfig] -> ShowS
$cshowList :: [PrefixConfig] -> ShowS
show :: PrefixConfig -> String
$cshow :: PrefixConfig -> String
showsPrec :: Int -> PrefixConfig -> ShowS
$cshowsPrec :: Int -> PrefixConfig -> ShowS
Prelude.Show, (forall x. PrefixConfig -> Rep PrefixConfig x)
-> (forall x. Rep PrefixConfig x -> PrefixConfig)
-> Generic PrefixConfig
forall x. Rep PrefixConfig x -> PrefixConfig
forall x. PrefixConfig -> Rep PrefixConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrefixConfig x -> PrefixConfig
$cfrom :: forall x. PrefixConfig -> Rep PrefixConfig x
Prelude.Generic)

-- |
-- Create a value of 'PrefixConfig' 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:
--
-- 'prefixFormat', 'prefixConfig_prefixFormat' - Determines the level of granularity that\'s included in the prefix.
--
-- 'prefixType', 'prefixConfig_prefixType' - Determines the format of the prefix, and whether it applies to the file
-- name, file path, or both.
newPrefixConfig ::
  PrefixConfig
newPrefixConfig :: PrefixConfig
newPrefixConfig =
  PrefixConfig' :: Maybe PrefixFormat -> Maybe PrefixType -> PrefixConfig
PrefixConfig'
    { $sel:prefixFormat:PrefixConfig' :: Maybe PrefixFormat
prefixFormat = Maybe PrefixFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:prefixType:PrefixConfig' :: Maybe PrefixType
prefixType = Maybe PrefixType
forall a. Maybe a
Prelude.Nothing
    }

-- | Determines the level of granularity that\'s included in the prefix.
prefixConfig_prefixFormat :: Lens.Lens' PrefixConfig (Prelude.Maybe PrefixFormat)
prefixConfig_prefixFormat :: (Maybe PrefixFormat -> f (Maybe PrefixFormat))
-> PrefixConfig -> f PrefixConfig
prefixConfig_prefixFormat = (PrefixConfig -> Maybe PrefixFormat)
-> (PrefixConfig -> Maybe PrefixFormat -> PrefixConfig)
-> Lens
     PrefixConfig PrefixConfig (Maybe PrefixFormat) (Maybe PrefixFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefixConfig' {Maybe PrefixFormat
prefixFormat :: Maybe PrefixFormat
$sel:prefixFormat:PrefixConfig' :: PrefixConfig -> Maybe PrefixFormat
prefixFormat} -> Maybe PrefixFormat
prefixFormat) (\s :: PrefixConfig
s@PrefixConfig' {} Maybe PrefixFormat
a -> PrefixConfig
s {$sel:prefixFormat:PrefixConfig' :: Maybe PrefixFormat
prefixFormat = Maybe PrefixFormat
a} :: PrefixConfig)

-- | Determines the format of the prefix, and whether it applies to the file
-- name, file path, or both.
prefixConfig_prefixType :: Lens.Lens' PrefixConfig (Prelude.Maybe PrefixType)
prefixConfig_prefixType :: (Maybe PrefixType -> f (Maybe PrefixType))
-> PrefixConfig -> f PrefixConfig
prefixConfig_prefixType = (PrefixConfig -> Maybe PrefixType)
-> (PrefixConfig -> Maybe PrefixType -> PrefixConfig)
-> Lens
     PrefixConfig PrefixConfig (Maybe PrefixType) (Maybe PrefixType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefixConfig' {Maybe PrefixType
prefixType :: Maybe PrefixType
$sel:prefixType:PrefixConfig' :: PrefixConfig -> Maybe PrefixType
prefixType} -> Maybe PrefixType
prefixType) (\s :: PrefixConfig
s@PrefixConfig' {} Maybe PrefixType
a -> PrefixConfig
s {$sel:prefixType:PrefixConfig' :: Maybe PrefixType
prefixType = Maybe PrefixType
a} :: PrefixConfig)

instance Core.FromJSON PrefixConfig where
  parseJSON :: Value -> Parser PrefixConfig
parseJSON =
    String
-> (Object -> Parser PrefixConfig) -> Value -> Parser PrefixConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PrefixConfig"
      ( \Object
x ->
          Maybe PrefixFormat -> Maybe PrefixType -> PrefixConfig
PrefixConfig'
            (Maybe PrefixFormat -> Maybe PrefixType -> PrefixConfig)
-> Parser (Maybe PrefixFormat)
-> Parser (Maybe PrefixType -> PrefixConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PrefixFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefixFormat")
            Parser (Maybe PrefixType -> PrefixConfig)
-> Parser (Maybe PrefixType) -> Parser PrefixConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PrefixType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefixType")
      )

instance Prelude.Hashable PrefixConfig

instance Prelude.NFData PrefixConfig

instance Core.ToJSON PrefixConfig where
  toJSON :: PrefixConfig -> Value
toJSON PrefixConfig' {Maybe PrefixFormat
Maybe PrefixType
prefixType :: Maybe PrefixType
prefixFormat :: Maybe PrefixFormat
$sel:prefixType:PrefixConfig' :: PrefixConfig -> Maybe PrefixType
$sel:prefixFormat:PrefixConfig' :: PrefixConfig -> Maybe PrefixFormat
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"prefixFormat" Text -> PrefixFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PrefixFormat -> Pair) -> Maybe PrefixFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PrefixFormat
prefixFormat,
            (Text
"prefixType" Text -> PrefixType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PrefixType -> Pair) -> Maybe PrefixType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PrefixType
prefixType
          ]
      )