{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 if the destination field can be created by the current user.
    DestinationFieldProperties -> Maybe Bool
isCreatable :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether the field can use the default value during a Create
    -- operation.
    DestinationFieldProperties -> Maybe Bool
isDefaultedOnCreate :: Prelude.Maybe Prelude.Bool,
    -- | Specifies if the destination field can have a null value.
    DestinationFieldProperties -> Maybe Bool
isNullable :: Prelude.Maybe Prelude.Bool,
    -- | 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 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,
    -- | 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]
  }
  deriving (DestinationFieldProperties -> DestinationFieldProperties -> Bool
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]
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
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.
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:
--
-- 'isCreatable', 'destinationFieldProperties_isCreatable' - Specifies if the destination field can be created by the current user.
--
-- 'isDefaultedOnCreate', 'destinationFieldProperties_isDefaultedOnCreate' - Specifies whether the field can use the default value during a Create
-- operation.
--
-- 'isNullable', 'destinationFieldProperties_isNullable' - Specifies if the destination field can have a null value.
--
-- 'isUpdatable', 'destinationFieldProperties_isUpdatable' - Specifies whether the field can be updated during an @UPDATE@ or
-- @UPSERT@ write operation.
--
-- '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.
--
-- '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.
newDestinationFieldProperties ::
  DestinationFieldProperties
newDestinationFieldProperties :: DestinationFieldProperties
newDestinationFieldProperties =
  DestinationFieldProperties'
    { $sel:isCreatable:DestinationFieldProperties' :: Maybe Bool
isCreatable =
        forall a. Maybe a
Prelude.Nothing,
      $sel:isDefaultedOnCreate:DestinationFieldProperties' :: Maybe Bool
isDefaultedOnCreate = forall a. Maybe a
Prelude.Nothing,
      $sel:isNullable:DestinationFieldProperties' :: Maybe Bool
isNullable = forall a. Maybe a
Prelude.Nothing,
      $sel:isUpdatable:DestinationFieldProperties' :: Maybe Bool
isUpdatable = forall a. Maybe a
Prelude.Nothing,
      $sel:isUpsertable:DestinationFieldProperties' :: Maybe Bool
isUpsertable = forall a. Maybe a
Prelude.Nothing,
      $sel:supportedWriteOperations:DestinationFieldProperties' :: Maybe [WriteOperationType]
supportedWriteOperations = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies if the destination field can be created by the current user.
destinationFieldProperties_isCreatable :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isCreatable :: Lens' DestinationFieldProperties (Maybe Bool)
destinationFieldProperties_isCreatable = 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)

-- | Specifies whether the field can use the default value during a Create
-- operation.
destinationFieldProperties_isDefaultedOnCreate :: Lens.Lens' DestinationFieldProperties (Prelude.Maybe Prelude.Bool)
destinationFieldProperties_isDefaultedOnCreate :: Lens' DestinationFieldProperties (Maybe Bool)
destinationFieldProperties_isDefaultedOnCreate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DestinationFieldProperties' {Maybe Bool
isDefaultedOnCreate :: Maybe Bool
$sel:isDefaultedOnCreate:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
isDefaultedOnCreate} -> Maybe Bool
isDefaultedOnCreate) (\s :: DestinationFieldProperties
s@DestinationFieldProperties' {} Maybe Bool
a -> DestinationFieldProperties
s {$sel:isDefaultedOnCreate:DestinationFieldProperties' :: Maybe Bool
isDefaultedOnCreate = 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 :: Lens' DestinationFieldProperties (Maybe Bool)
destinationFieldProperties_isNullable = 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)

-- | 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 :: Lens' DestinationFieldProperties (Maybe Bool)
destinationFieldProperties_isUpdatable = 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 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 :: Lens' DestinationFieldProperties (Maybe Bool)
destinationFieldProperties_isUpsertable = 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)

-- | 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 :: Lens' DestinationFieldProperties (Maybe [WriteOperationType])
destinationFieldProperties_supportedWriteOperations = 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) 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 DestinationFieldProperties where
  parseJSON :: Value -> Parser DestinationFieldProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DestinationFieldProperties"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe [WriteOperationType]
-> DestinationFieldProperties
DestinationFieldProperties'
            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
"isCreatable")
            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
"isDefaultedOnCreate")
            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
"isNullable")
            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
"isUpdatable")
            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
"isUpsertable")
            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
"supportedWriteOperations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable DestinationFieldProperties where
  hashWithSalt :: Int -> DestinationFieldProperties -> Int
hashWithSalt Int
_salt DestinationFieldProperties' {Maybe Bool
Maybe [WriteOperationType]
supportedWriteOperations :: Maybe [WriteOperationType]
isUpsertable :: Maybe Bool
isUpdatable :: Maybe Bool
isNullable :: Maybe Bool
isDefaultedOnCreate :: Maybe Bool
isCreatable :: Maybe Bool
$sel:supportedWriteOperations:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe [WriteOperationType]
$sel:isUpsertable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isUpdatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isNullable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isDefaultedOnCreate:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isCreatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isCreatable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isDefaultedOnCreate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isNullable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isUpdatable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isUpsertable
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [WriteOperationType]
supportedWriteOperations

instance Prelude.NFData DestinationFieldProperties where
  rnf :: DestinationFieldProperties -> ()
rnf DestinationFieldProperties' {Maybe Bool
Maybe [WriteOperationType]
supportedWriteOperations :: Maybe [WriteOperationType]
isUpsertable :: Maybe Bool
isUpdatable :: Maybe Bool
isNullable :: Maybe Bool
isDefaultedOnCreate :: Maybe Bool
isCreatable :: Maybe Bool
$sel:supportedWriteOperations:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe [WriteOperationType]
$sel:isUpsertable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isUpdatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isNullable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isDefaultedOnCreate:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
$sel:isCreatable:DestinationFieldProperties' :: DestinationFieldProperties -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isCreatable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isDefaultedOnCreate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isNullable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isUpdatable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isUpsertable
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [WriteOperationType]
supportedWriteOperations