{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.PartitionInput where

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

-- | The structure used to create and update a partition.
--
-- /See:/ 'newPartitionInput' smart constructor.
data PartitionInput = PartitionInput'
  { -- | The last time at which the partition was accessed.
    PartitionInput -> Maybe POSIX
lastAccessTime :: Prelude.Maybe Data.POSIX,
    -- | The last time at which column statistics were computed for this
    -- partition.
    PartitionInput -> Maybe POSIX
lastAnalyzedTime :: Prelude.Maybe Data.POSIX,
    -- | These key-value pairs define partition parameters.
    PartitionInput -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Provides information about the physical location where the partition is
    -- stored.
    PartitionInput -> Maybe StorageDescriptor
storageDescriptor :: Prelude.Maybe StorageDescriptor,
    -- | 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]
  }
  deriving (PartitionInput -> PartitionInput -> Bool
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]
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
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. 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:
--
-- 'lastAccessTime', 'partitionInput_lastAccessTime' - The last time at which the partition was accessed.
--
-- 'lastAnalyzedTime', 'partitionInput_lastAnalyzedTime' - The last time at which column statistics were computed for this
-- partition.
--
-- 'parameters', 'partitionInput_parameters' - These key-value pairs define partition parameters.
--
-- 'storageDescriptor', 'partitionInput_storageDescriptor' - Provides information about the physical location where the partition is
-- stored.
--
-- '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.
newPartitionInput ::
  PartitionInput
newPartitionInput :: PartitionInput
newPartitionInput =
  PartitionInput'
    { $sel:lastAccessTime:PartitionInput' :: Maybe POSIX
lastAccessTime = forall a. Maybe a
Prelude.Nothing,
      $sel:lastAnalyzedTime:PartitionInput' :: Maybe POSIX
lastAnalyzedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:PartitionInput' :: Maybe (HashMap Text Text)
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:storageDescriptor:PartitionInput' :: Maybe StorageDescriptor
storageDescriptor = forall a. Maybe a
Prelude.Nothing,
      $sel:values:PartitionInput' :: Maybe [Text]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The last time at which the partition was accessed.
partitionInput_lastAccessTime :: Lens.Lens' PartitionInput (Prelude.Maybe Prelude.UTCTime)
partitionInput_lastAccessTime :: Lens' PartitionInput (Maybe UTCTime)
partitionInput_lastAccessTime = 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) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The last time at which column statistics were computed for this
-- partition.
partitionInput_lastAnalyzedTime :: Lens.Lens' PartitionInput (Prelude.Maybe Prelude.UTCTime)
partitionInput_lastAnalyzedTime :: Lens' PartitionInput (Maybe UTCTime)
partitionInput_lastAnalyzedTime = 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) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | These key-value pairs define partition parameters.
partitionInput_parameters :: Lens.Lens' PartitionInput (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
partitionInput_parameters :: Lens' PartitionInput (Maybe (HashMap Text Text))
partitionInput_parameters = 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) 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

-- | Provides information about the physical location where the partition is
-- stored.
partitionInput_storageDescriptor :: Lens.Lens' PartitionInput (Prelude.Maybe StorageDescriptor)
partitionInput_storageDescriptor :: Lens' PartitionInput (Maybe StorageDescriptor)
partitionInput_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)

-- | 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 :: Lens' PartitionInput (Maybe [Text])
partitionInput_values = 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) 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 Prelude.Hashable PartitionInput where
  hashWithSalt :: Int -> PartitionInput -> Int
hashWithSalt Int
_salt PartitionInput' {Maybe [Text]
Maybe (HashMap Text Text)
Maybe POSIX
Maybe StorageDescriptor
values :: Maybe [Text]
storageDescriptor :: Maybe StorageDescriptor
parameters :: Maybe (HashMap Text Text)
lastAnalyzedTime :: Maybe POSIX
lastAccessTime :: Maybe POSIX
$sel:values:PartitionInput' :: PartitionInput -> Maybe [Text]
$sel:storageDescriptor:PartitionInput' :: PartitionInput -> Maybe StorageDescriptor
$sel:parameters:PartitionInput' :: PartitionInput -> Maybe (HashMap Text Text)
$sel:lastAnalyzedTime:PartitionInput' :: PartitionInput -> Maybe POSIX
$sel:lastAccessTime:PartitionInput' :: PartitionInput -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastAccessTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastAnalyzedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StorageDescriptor
storageDescriptor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData PartitionInput where
  rnf :: PartitionInput -> ()
rnf PartitionInput' {Maybe [Text]
Maybe (HashMap Text Text)
Maybe POSIX
Maybe StorageDescriptor
values :: Maybe [Text]
storageDescriptor :: Maybe StorageDescriptor
parameters :: Maybe (HashMap Text Text)
lastAnalyzedTime :: Maybe POSIX
lastAccessTime :: Maybe POSIX
$sel:values:PartitionInput' :: PartitionInput -> Maybe [Text]
$sel:storageDescriptor:PartitionInput' :: PartitionInput -> Maybe StorageDescriptor
$sel:parameters:PartitionInput' :: PartitionInput -> Maybe (HashMap Text Text)
$sel:lastAnalyzedTime:PartitionInput' :: PartitionInput -> Maybe POSIX
$sel:lastAccessTime:PartitionInput' :: PartitionInput -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastAccessTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastAnalyzedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StorageDescriptor
storageDescriptor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

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