{-# 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.HoneyCode.Types.ColumnMetadata
-- 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.HoneyCode.Types.ColumnMetadata where

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.Format
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Metadata for column in the table.
--
-- /See:/ 'newColumnMetadata' smart constructor.
data ColumnMetadata = ColumnMetadata'
  { -- | The name of the column.
    ColumnMetadata -> Sensitive Text
name :: Core.Sensitive Prelude.Text,
    -- | The format of the column.
    ColumnMetadata -> Format
format :: Format
  }
  deriving (ColumnMetadata -> ColumnMetadata -> Bool
(ColumnMetadata -> ColumnMetadata -> Bool)
-> (ColumnMetadata -> ColumnMetadata -> Bool) -> Eq ColumnMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnMetadata -> ColumnMetadata -> Bool
$c/= :: ColumnMetadata -> ColumnMetadata -> Bool
== :: ColumnMetadata -> ColumnMetadata -> Bool
$c== :: ColumnMetadata -> ColumnMetadata -> Bool
Prelude.Eq, Int -> ColumnMetadata -> ShowS
[ColumnMetadata] -> ShowS
ColumnMetadata -> String
(Int -> ColumnMetadata -> ShowS)
-> (ColumnMetadata -> String)
-> ([ColumnMetadata] -> ShowS)
-> Show ColumnMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnMetadata] -> ShowS
$cshowList :: [ColumnMetadata] -> ShowS
show :: ColumnMetadata -> String
$cshow :: ColumnMetadata -> String
showsPrec :: Int -> ColumnMetadata -> ShowS
$cshowsPrec :: Int -> ColumnMetadata -> ShowS
Prelude.Show, (forall x. ColumnMetadata -> Rep ColumnMetadata x)
-> (forall x. Rep ColumnMetadata x -> ColumnMetadata)
-> Generic ColumnMetadata
forall x. Rep ColumnMetadata x -> ColumnMetadata
forall x. ColumnMetadata -> Rep ColumnMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnMetadata x -> ColumnMetadata
$cfrom :: forall x. ColumnMetadata -> Rep ColumnMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ColumnMetadata' 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:
--
-- 'name', 'columnMetadata_name' - The name of the column.
--
-- 'format', 'columnMetadata_format' - The format of the column.
newColumnMetadata ::
  -- | 'name'
  Prelude.Text ->
  -- | 'format'
  Format ->
  ColumnMetadata
newColumnMetadata :: Text -> Format -> ColumnMetadata
newColumnMetadata Text
pName_ Format
pFormat_ =
  ColumnMetadata' :: Sensitive Text -> Format -> ColumnMetadata
ColumnMetadata'
    { $sel:name:ColumnMetadata' :: Sensitive Text
name =
        Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pName_,
      $sel:format:ColumnMetadata' :: Format
format = Format
pFormat_
    }

-- | The name of the column.
columnMetadata_name :: Lens.Lens' ColumnMetadata Prelude.Text
columnMetadata_name :: (Text -> f Text) -> ColumnMetadata -> f ColumnMetadata
columnMetadata_name = (ColumnMetadata -> Sensitive Text)
-> (ColumnMetadata -> Sensitive Text -> ColumnMetadata)
-> Lens
     ColumnMetadata ColumnMetadata (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnMetadata' {Sensitive Text
name :: Sensitive Text
$sel:name:ColumnMetadata' :: ColumnMetadata -> Sensitive Text
name} -> Sensitive Text
name) (\s :: ColumnMetadata
s@ColumnMetadata' {} Sensitive Text
a -> ColumnMetadata
s {$sel:name:ColumnMetadata' :: Sensitive Text
name = Sensitive Text
a} :: ColumnMetadata) ((Sensitive Text -> f (Sensitive Text))
 -> ColumnMetadata -> f ColumnMetadata)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ColumnMetadata
-> f ColumnMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The format of the column.
columnMetadata_format :: Lens.Lens' ColumnMetadata Format
columnMetadata_format :: (Format -> f Format) -> ColumnMetadata -> f ColumnMetadata
columnMetadata_format = (ColumnMetadata -> Format)
-> (ColumnMetadata -> Format -> ColumnMetadata)
-> Lens ColumnMetadata ColumnMetadata Format Format
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnMetadata' {Format
format :: Format
$sel:format:ColumnMetadata' :: ColumnMetadata -> Format
format} -> Format
format) (\s :: ColumnMetadata
s@ColumnMetadata' {} Format
a -> ColumnMetadata
s {$sel:format:ColumnMetadata' :: Format
format = Format
a} :: ColumnMetadata)

instance Core.FromJSON ColumnMetadata where
  parseJSON :: Value -> Parser ColumnMetadata
parseJSON =
    String
-> (Object -> Parser ColumnMetadata)
-> Value
-> Parser ColumnMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ColumnMetadata"
      ( \Object
x ->
          Sensitive Text -> Format -> ColumnMetadata
ColumnMetadata'
            (Sensitive Text -> Format -> ColumnMetadata)
-> Parser (Sensitive Text) -> Parser (Format -> ColumnMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name") Parser (Format -> ColumnMetadata)
-> Parser Format -> Parser ColumnMetadata
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Format
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"format")
      )

instance Prelude.Hashable ColumnMetadata

instance Prelude.NFData ColumnMetadata