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

import Amazonka.AppFlow.Types.WriteOperationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The properties that can be applied to a field when connector is being
-- used as a destination.
--
-- /See:/ 'newDestinationFieldProperties' smart constructor.
data DestinationFieldProperties = DestinationFieldProperties'
  { -- | Specifies whether the field can be updated during an @UPDATE@ or
    -- @UPSERT@ write operation.
    DestinationFieldProperties -> Maybe Bool
isUpdatable :: Prelude.Maybe Prelude.Bool,
    -- | Specifies if the destination field can have a null value.
    DestinationFieldProperties -> Maybe Bool
isNullable :: Prelude.Maybe Prelude.Bool,
    -- | A list of supported write operations. For each write operation listed,
    -- this field can be used in @idFieldNames@ when that write operation is
    -- present as a destination option.
    DestinationFieldProperties -> Maybe [WriteOperationType]
supportedWriteOperations :: Prelude.Maybe [WriteOperationType],
    -- | Specifies if the flow run can either insert new rows in the destination
    -- field if they do not already exist, or update them if they do.
    DestinationFieldProperties -> Maybe Bool
isUpsertable :: Prelude.Maybe Prelude.Bool,
    -- | Specifies if the destination field can be created by the current user.
    DestinationFieldProperties -> Maybe Bool
isCreatable :: Prelude.Maybe Prelude.Bool
  }
  deriving (DestinationFieldProperties -> DestinationFieldProperties -> Bool
(DestinationFieldProperties -> DestinationFieldProperties -> Bool)
-> (DestinationFieldProperties
    -> DestinationFieldProperties -> Bool)
-> Eq DestinationFieldProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DestinationFieldProperties -> DestinationFieldProperties -> Bool
$c/= :: DestinationFieldProperties -> DestinationFieldProperties -> Bool
== :: DestinationFieldProperties -> DestinationFieldProperties -> Bool
$c== :: DestinationFieldProperties -> DestinationFieldProperties -> Bool
Prelude.Eq, ReadPrec [DestinationFieldProperties]
ReadPrec DestinationFieldProperties
Int -> ReadS DestinationFieldProperties
ReadS [DestinationFieldProperties]
(Int -> ReadS DestinationFieldProperties)
-> ReadS [DestinationFieldProperties]
-> ReadPrec DestinationFieldProperties
-> ReadPrec [DestinationFieldProperties]
-> Read DestinationFieldProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DestinationFieldProperties]
$creadListPrec :: ReadPrec [DestinationFieldProperties]
readPrec :: ReadPrec DestinationFieldProperties
$creadPrec :: ReadPrec DestinationFieldProperties
readList :: ReadS [DestinationFieldProperties]
$creadList :: ReadS [DestinationFieldProperties]
readsPrec :: Int -> ReadS DestinationFieldProperties
$creadsPrec :: Int -> ReadS DestinationFieldProperties
Prelude.Read, Int -> DestinationFieldProperties -> ShowS
[DestinationFieldProperties] -> ShowS
DestinationFieldProperties -> String
(Int -> DestinationFieldProperties -> ShowS)
-> (DestinationFieldProperties -> String)
-> ([DestinationFieldProperties] -> ShowS)
-> Show DestinationFieldProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DestinationFieldProperties] -> ShowS
$cshowList :: [DestinationFieldProperties] -> ShowS
show :: DestinationFieldProperties -> String
$cshow :: DestinationFieldProperties -> String
showsPrec :: Int -> DestinationFieldProperties -> ShowS
$cshowsPrec :: Int -> DestinationFieldProperties -> ShowS
Prelude.Show, (forall x.
 DestinationFieldProperties -> Rep DestinationFieldProperties x)
-> (forall x.
    Rep DestinationFieldProperties x -> DestinationFieldProperties)
-> Generic DestinationFieldProperties
forall x.
Rep DestinationFieldProperties x -> DestinationFieldProperties
forall x.
DestinationFieldProperties -> Rep DestinationFieldProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DestinationFieldProperties x -> DestinationFieldProperties
$cfrom :: forall x.
DestinationFieldProperties -> Rep DestinationFieldProperties x
Prelude.Generic)

-- |
-- Create a value of 'DestinationFieldProperties' 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:
--
-- 'isUpdatable', 'destinationFieldProperties_isUpdatable' - Specifies whether the field can be updated during an @UPDATE@ or
-- @UPSERT@ write operation.
--
-- 'isNullable', 'destinationFieldProperties_isNullable' - Specifies if the destination field can have a null value.
--
-- 'supportedWriteOperations', 'destinationFieldProperties_supportedWriteOperations' - A list of supported write operations. For each write operation listed,
-- this field can be used in @idFieldNames@ when that write operation is
-- present as a destination option.
--
-- 'isUpsertable', 'destinationFieldProperties_isUpsertable' - Specifies if the flow run can either insert new rows in the destination
-- field if they do not already exist, or update them if they do.
--
-- 'isCreatable', 'destinationFieldProperties_isCreatable' - Specifies if the destination field can be created by the current user.
newDestinationFieldProperties ::
  DestinationFieldProperties
newDestinationFieldProperties :: DestinationFieldProperties
newDestinationFieldProperties =
  DestinationFieldProperties' :: Maybe Bool
-> Maybe Bool
-> Maybe [WriteOperationType]
-> Maybe Bool
-> Maybe Bool
-> DestinationFieldProperties
DestinationFieldProperties'
    { $sel:isUpdatable:DestinationFieldProperties' :: Maybe Bool
isUpdatable =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:isNullable:DestinationFieldProperties' :: Maybe Bool
isNullable = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:supportedWriteOperations:DestinationFieldProperties' :: Maybe [WriteOperationType]
supportedWriteOperations = Maybe [WriteOperationType]
forall a. Maybe a
Prelude.Nothing,
      $sel:isUpsertable:DestinationFieldProperties' :: Maybe Bool
isUpsertable = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:isCreatable:DestinationFieldProperties' :: Maybe Bool
isCreatable = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the field can be updated during an @UPDATE@ or
-- @UPSERT@ write operation.
destinationFieldProperties_isUpdatable :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isUpdatable :: (Maybe Bool -> f (Maybe Bool))
-> DestinationFieldProperties -> f DestinationFieldProperties
destinationFieldProperties_isUpdatable = (DestinationFieldProperties -> Maybe Bool)
-> (DestinationFieldProperties
    -> Maybe Bool -> DestinationFieldProperties)
-> Lens
     DestinationFieldProperties
     DestinationFieldProperties
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe Bool
isUpdatable :: Maybe Bool
$sel:isUpdatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
isUpdatable} -> Maybe Bool
isUpdatable) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe Bool
a -> DestinationFieldProperties
s {$sel:isUpdatable:DestinationFieldProperties' :: Maybe Bool
isUpdatable = Maybe Bool
a} :: DestinationFieldProperties)

-- | Specifies if the destination field can have a null value.
destinationFieldProperties_isNullable :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isNullable :: (Maybe Bool -> f (Maybe Bool))
-> DestinationFieldProperties -> f DestinationFieldProperties
destinationFieldProperties_isNullable = (DestinationFieldProperties -> Maybe Bool)
-> (DestinationFieldProperties
    -> Maybe Bool -> DestinationFieldProperties)
-> Lens
     DestinationFieldProperties
     DestinationFieldProperties
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe Bool
isNullable :: Maybe Bool
$sel:isNullable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
isNullable} -> Maybe Bool
isNullable) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe Bool
a -> DestinationFieldProperties
s {$sel:isNullable:DestinationFieldProperties' :: Maybe Bool
isNullable = Maybe Bool
a} :: DestinationFieldProperties)

-- | A list of supported write operations. For each write operation listed,
-- this field can be used in @idFieldNames@ when that write operation is
-- present as a destination option.
destinationFieldProperties_supportedWriteOperations :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe [WriteOperationType])
destinationFieldProperties_supportedWriteOperations :: (Maybe [WriteOperationType] -> f (Maybe [WriteOperationType]))
-> DestinationFieldProperties -> f DestinationFieldProperties
destinationFieldProperties_supportedWriteOperations = (DestinationFieldProperties -> Maybe [WriteOperationType])
-> (DestinationFieldProperties
    -> Maybe [WriteOperationType] -> DestinationFieldProperties)
-> Lens
     DestinationFieldProperties
     DestinationFieldProperties
     (Maybe [WriteOperationType])
     (Maybe [WriteOperationType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe [WriteOperationType]
supportedWriteOperations :: Maybe [WriteOperationType]
$sel:supportedWriteOperations:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe [WriteOperationType]
supportedWriteOperations} -> Maybe [WriteOperationType]
supportedWriteOperations) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe [WriteOperationType]
a -> DestinationFieldProperties
s {$sel:supportedWriteOperations:DestinationFieldProperties' :: Maybe [WriteOperationType]
supportedWriteOperations = Maybe [WriteOperationType]
a} :: DestinationFieldProperties) ((Maybe [WriteOperationType] -> f (Maybe [WriteOperationType]))
 -> DestinationFieldProperties -> f DestinationFieldProperties)
-> ((Maybe [WriteOperationType] -> f (Maybe [WriteOperationType]))
    -> Maybe [WriteOperationType] -> f (Maybe [WriteOperationType]))
-> (Maybe [WriteOperationType] -> f (Maybe [WriteOperationType]))
-> DestinationFieldProperties
-> f DestinationFieldProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [WriteOperationType]
  [WriteOperationType]
  [WriteOperationType]
  [WriteOperationType]
-> Iso
     (Maybe [WriteOperationType])
     (Maybe [WriteOperationType])
     (Maybe [WriteOperationType])
     (Maybe [WriteOperationType])
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 AnIso
  [WriteOperationType]
  [WriteOperationType]
  [WriteOperationType]
  [WriteOperationType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies if the flow run can either insert new rows in the destination
-- field if they do not already exist, or update them if they do.
destinationFieldProperties_isUpsertable :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isUpsertable :: (Maybe Bool -> f (Maybe Bool))
-> DestinationFieldProperties -> f DestinationFieldProperties
destinationFieldProperties_isUpsertable = (DestinationFieldProperties -> Maybe Bool)
-> (DestinationFieldProperties
    -> Maybe Bool -> DestinationFieldProperties)
-> Lens
     DestinationFieldProperties
     DestinationFieldProperties
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe Bool
isUpsertable :: Maybe Bool
$sel:isUpsertable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
isUpsertable} -> Maybe Bool
isUpsertable) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe Bool
a -> DestinationFieldProperties
s {$sel:isUpsertable:DestinationFieldProperties' :: Maybe Bool
isUpsertable = Maybe Bool
a} :: DestinationFieldProperties)

-- | Specifies if the destination field can be created by the current user.
destinationFieldProperties_isCreatable :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isCreatable :: (Maybe Bool -> f (Maybe Bool))
-> DestinationFieldProperties -> f DestinationFieldProperties
destinationFieldProperties_isCreatable = (DestinationFieldProperties -> Maybe Bool)
-> (DestinationFieldProperties
    -> Maybe Bool -> DestinationFieldProperties)
-> Lens
     DestinationFieldProperties
     DestinationFieldProperties
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe Bool
isCreatable :: Maybe Bool
$sel:isCreatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
isCreatable} -> Maybe Bool
isCreatable) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe Bool
a -> DestinationFieldProperties
s {$sel:isCreatable:DestinationFieldProperties' :: Maybe Bool
isCreatable = Maybe Bool
a} :: DestinationFieldProperties)

instance Core.FromJSON DestinationFieldProperties where
  parseJSON :: Value -> Parser DestinationFieldProperties
parseJSON =
    String
-> (Object -> Parser DestinationFieldProperties)
-> Value
-> Parser DestinationFieldProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DestinationFieldProperties"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe [WriteOperationType]
-> Maybe Bool
-> Maybe Bool
-> DestinationFieldProperties
DestinationFieldProperties'
            (Maybe Bool
 -> Maybe Bool
 -> Maybe [WriteOperationType]
 -> Maybe Bool
 -> Maybe Bool
 -> DestinationFieldProperties)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe [WriteOperationType]
      -> Maybe Bool
      -> Maybe Bool
      -> DestinationFieldProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isUpdatable")
            Parser
  (Maybe Bool
   -> Maybe [WriteOperationType]
   -> Maybe Bool
   -> Maybe Bool
   -> DestinationFieldProperties)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [WriteOperationType]
      -> Maybe Bool -> Maybe Bool -> DestinationFieldProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isNullable")
            Parser
  (Maybe [WriteOperationType]
   -> Maybe Bool -> Maybe Bool -> DestinationFieldProperties)
-> Parser (Maybe [WriteOperationType])
-> Parser (Maybe Bool -> Maybe Bool -> DestinationFieldProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [WriteOperationType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"supportedWriteOperations"
                            Parser (Maybe (Maybe [WriteOperationType]))
-> Maybe [WriteOperationType]
-> Parser (Maybe [WriteOperationType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [WriteOperationType]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> Maybe Bool -> DestinationFieldProperties)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> DestinationFieldProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isUpsertable")
            Parser (Maybe Bool -> DestinationFieldProperties)
-> Parser (Maybe Bool) -> Parser DestinationFieldProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isCreatable")
      )

instance Prelude.Hashable DestinationFieldProperties

instance Prelude.NFData DestinationFieldProperties