{-# 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.Glue.Types.PartitionInput
-- 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.Glue.Types.PartitionInput where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.StorageDescriptor
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The structure used to create and update a partition.
--
-- /See:/ 'newPartitionInput' smart constructor.
data PartitionInput = PartitionInput'
  { -- | The values of the partition. Although this parameter is not required by
    -- the SDK, you must specify this parameter for a valid input.
    --
    -- The values for the keys for the new partition must be passed as an array
    -- of String objects that must be ordered in the same order as the
    -- partition keys appearing in the Amazon S3 prefix. Otherwise Glue will
    -- add the values to the wrong keys.
    PartitionInput -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The last time at which column statistics were computed for this
    -- partition.
    PartitionInput -> Maybe POSIX
lastAnalyzedTime :: Prelude.Maybe Core.POSIX,
    -- | Provides information about the physical location where the partition is
    -- stored.
    PartitionInput -> Maybe StorageDescriptor
storageDescriptor :: Prelude.Maybe StorageDescriptor,
    -- | These key-value pairs define partition parameters.
    PartitionInput -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The last time at which the partition was accessed.
    PartitionInput -> Maybe POSIX
lastAccessTime :: Prelude.Maybe Core.POSIX
  }
  deriving (PartitionInput -> PartitionInput -> Bool
(PartitionInput -> PartitionInput -> Bool)
-> (PartitionInput -> PartitionInput -> Bool) -> Eq PartitionInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartitionInput -> PartitionInput -> Bool
$c/= :: PartitionInput -> PartitionInput -> Bool
== :: PartitionInput -> PartitionInput -> Bool
$c== :: PartitionInput -> PartitionInput -> Bool
Prelude.Eq, ReadPrec [PartitionInput]
ReadPrec PartitionInput
Int -> ReadS PartitionInput
ReadS [PartitionInput]
(Int -> ReadS PartitionInput)
-> ReadS [PartitionInput]
-> ReadPrec PartitionInput
-> ReadPrec [PartitionInput]
-> Read PartitionInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartitionInput]
$creadListPrec :: ReadPrec [PartitionInput]
readPrec :: ReadPrec PartitionInput
$creadPrec :: ReadPrec PartitionInput
readList :: ReadS [PartitionInput]
$creadList :: ReadS [PartitionInput]
readsPrec :: Int -> ReadS PartitionInput
$creadsPrec :: Int -> ReadS PartitionInput
Prelude.Read, Int -> PartitionInput -> ShowS
[PartitionInput] -> ShowS
PartitionInput -> String
(Int -> PartitionInput -> ShowS)
-> (PartitionInput -> String)
-> ([PartitionInput] -> ShowS)
-> Show PartitionInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartitionInput] -> ShowS
$cshowList :: [PartitionInput] -> ShowS
show :: PartitionInput -> String
$cshow :: PartitionInput -> String
showsPrec :: Int -> PartitionInput -> ShowS
$cshowsPrec :: Int -> PartitionInput -> ShowS
Prelude.Show, (forall x. PartitionInput -> Rep PartitionInput x)
-> (forall x. Rep PartitionInput x -> PartitionInput)
-> Generic PartitionInput
forall x. Rep PartitionInput x -> PartitionInput
forall x. PartitionInput -> Rep PartitionInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartitionInput x -> PartitionInput
$cfrom :: forall x. PartitionInput -> Rep PartitionInput x
Prelude.Generic)

-- |
-- Create a value of 'PartitionInput' 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:
--
-- 'values', 'partitionInput_values' - The values of the partition. Although this parameter is not required by
-- the SDK, you must specify this parameter for a valid input.
--
-- The values for the keys for the new partition must be passed as an array
-- of String objects that must be ordered in the same order as the
-- partition keys appearing in the Amazon S3 prefix. Otherwise Glue will
-- add the values to the wrong keys.
--
-- 'lastAnalyzedTime', 'partitionInput_lastAnalyzedTime' - The last time at which column statistics were computed for this
-- partition.
--
-- 'storageDescriptor', 'partitionInput_storageDescriptor' - Provides information about the physical location where the partition is
-- stored.
--
-- 'parameters', 'partitionInput_parameters' - These key-value pairs define partition parameters.
--
-- 'lastAccessTime', 'partitionInput_lastAccessTime' - The last time at which the partition was accessed.
newPartitionInput ::
  PartitionInput
newPartitionInput :: PartitionInput
newPartitionInput =
  PartitionInput' :: Maybe [Text]
-> Maybe POSIX
-> Maybe StorageDescriptor
-> Maybe (HashMap Text Text)
-> Maybe POSIX
-> PartitionInput
PartitionInput'
    { $sel:values:PartitionInput' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:lastAnalyzedTime:PartitionInput' :: Maybe POSIX
lastAnalyzedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:storageDescriptor:PartitionInput' :: Maybe StorageDescriptor
storageDescriptor = Maybe StorageDescriptor
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:PartitionInput' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:lastAccessTime:PartitionInput' :: Maybe POSIX
lastAccessTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The values of the partition. Although this parameter is not required by
-- the SDK, you must specify this parameter for a valid input.
--
-- The values for the keys for the new partition must be passed as an array
-- of String objects that must be ordered in the same order as the
-- partition keys appearing in the Amazon S3 prefix. Otherwise Glue will
-- add the values to the wrong keys.
partitionInput_values :: Lens.Lens' PartitionInput (Prelude.Maybe [Prelude.Text])
partitionInput_values :: (Maybe [Text] -> f (Maybe [Text]))
-> PartitionInput -> f PartitionInput
partitionInput_values = (PartitionInput -> Maybe [Text])
-> (PartitionInput -> Maybe [Text] -> PartitionInput)
-> Lens PartitionInput PartitionInput (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionInput' {Maybe [Text]
values :: Maybe [Text]
$sel:values:PartitionInput' :: PartitionInput -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: PartitionInput
s@PartitionInput' {} Maybe [Text]
a -> PartitionInput
s {$sel:values:PartitionInput' :: Maybe [Text]
values = Maybe [Text]
a} :: PartitionInput) ((Maybe [Text] -> f (Maybe [Text]))
 -> PartitionInput -> f PartitionInput)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PartitionInput
-> f PartitionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The last time at which column statistics were computed for this
-- partition.
partitionInput_lastAnalyzedTime :: Lens.Lens' PartitionInput (Prelude.Maybe Prelude.UTCTime)
partitionInput_lastAnalyzedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PartitionInput -> f PartitionInput
partitionInput_lastAnalyzedTime = (PartitionInput -> Maybe POSIX)
-> (PartitionInput -> Maybe POSIX -> PartitionInput)
-> Lens PartitionInput PartitionInput (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionInput' {Maybe POSIX
lastAnalyzedTime :: Maybe POSIX
$sel:lastAnalyzedTime:PartitionInput' :: PartitionInput -> Maybe POSIX
lastAnalyzedTime} -> Maybe POSIX
lastAnalyzedTime) (\s :: PartitionInput
s@PartitionInput' {} Maybe POSIX
a -> PartitionInput
s {$sel:lastAnalyzedTime:PartitionInput' :: Maybe POSIX
lastAnalyzedTime = Maybe POSIX
a} :: PartitionInput) ((Maybe POSIX -> f (Maybe POSIX))
 -> PartitionInput -> f PartitionInput)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PartitionInput
-> f PartitionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Provides information about the physical location where the partition is
-- stored.
partitionInput_storageDescriptor :: Lens.Lens' PartitionInput (Prelude.Maybe StorageDescriptor)
partitionInput_storageDescriptor :: (Maybe StorageDescriptor -> f (Maybe StorageDescriptor))
-> PartitionInput -> f PartitionInput
partitionInput_storageDescriptor = (PartitionInput -> Maybe StorageDescriptor)
-> (PartitionInput -> Maybe StorageDescriptor -> PartitionInput)
-> Lens
     PartitionInput
     PartitionInput
     (Maybe StorageDescriptor)
     (Maybe StorageDescriptor)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionInput' {Maybe StorageDescriptor
storageDescriptor :: Maybe StorageDescriptor
$sel:storageDescriptor:PartitionInput' :: PartitionInput -> Maybe StorageDescriptor
storageDescriptor} -> Maybe StorageDescriptor
storageDescriptor) (\s :: PartitionInput
s@PartitionInput' {} Maybe StorageDescriptor
a -> PartitionInput
s {$sel:storageDescriptor:PartitionInput' :: Maybe StorageDescriptor
storageDescriptor = Maybe StorageDescriptor
a} :: PartitionInput)

-- | These key-value pairs define partition parameters.
partitionInput_parameters :: Lens.Lens' PartitionInput (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
partitionInput_parameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PartitionInput -> f PartitionInput
partitionInput_parameters = (PartitionInput -> Maybe (HashMap Text Text))
-> (PartitionInput -> Maybe (HashMap Text Text) -> PartitionInput)
-> Lens
     PartitionInput
     PartitionInput
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionInput' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:PartitionInput' :: PartitionInput -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: PartitionInput
s@PartitionInput' {} Maybe (HashMap Text Text)
a -> PartitionInput
s {$sel:parameters:PartitionInput' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: PartitionInput) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> PartitionInput -> f PartitionInput)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PartitionInput
-> f PartitionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The last time at which the partition was accessed.
partitionInput_lastAccessTime :: Lens.Lens' PartitionInput (Prelude.Maybe Prelude.UTCTime)
partitionInput_lastAccessTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PartitionInput -> f PartitionInput
partitionInput_lastAccessTime = (PartitionInput -> Maybe POSIX)
-> (PartitionInput -> Maybe POSIX -> PartitionInput)
-> Lens PartitionInput PartitionInput (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionInput' {Maybe POSIX
lastAccessTime :: Maybe POSIX
$sel:lastAccessTime:PartitionInput' :: PartitionInput -> Maybe POSIX
lastAccessTime} -> Maybe POSIX
lastAccessTime) (\s :: PartitionInput
s@PartitionInput' {} Maybe POSIX
a -> PartitionInput
s {$sel:lastAccessTime:PartitionInput' :: Maybe POSIX
lastAccessTime = Maybe POSIX
a} :: PartitionInput) ((Maybe POSIX -> f (Maybe POSIX))
 -> PartitionInput -> f PartitionInput)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PartitionInput
-> f PartitionInput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable PartitionInput

instance Prelude.NFData PartitionInput

instance Core.ToJSON PartitionInput where
  toJSON :: PartitionInput -> Value
toJSON PartitionInput' {Maybe [Text]
Maybe (HashMap Text Text)
Maybe POSIX
Maybe StorageDescriptor
lastAccessTime :: Maybe POSIX
parameters :: Maybe (HashMap Text Text)
storageDescriptor :: Maybe StorageDescriptor
lastAnalyzedTime :: Maybe POSIX
values :: Maybe [Text]
$sel:lastAccessTime:PartitionInput' :: PartitionInput -> Maybe POSIX
$sel:parameters:PartitionInput' :: PartitionInput -> Maybe (HashMap Text Text)
$sel:storageDescriptor:PartitionInput' :: PartitionInput -> Maybe StorageDescriptor
$sel:lastAnalyzedTime:PartitionInput' :: PartitionInput -> Maybe POSIX
$sel:values:PartitionInput' :: PartitionInput -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Values" 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]
values,
            (Text
"LastAnalyzedTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
lastAnalyzedTime,
            (Text
"StorageDescriptor" Text -> StorageDescriptor -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StorageDescriptor -> Pair)
-> Maybe StorageDescriptor -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StorageDescriptor
storageDescriptor,
            (Text
"Parameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
parameters,
            (Text
"LastAccessTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
lastAccessTime
          ]
      )