{-# 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.S3.Types.MetadataEntry
-- 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.S3.Types.MetadataEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | A metadata key-value pair to store with an object.
--
-- /See:/ 'newMetadataEntry' smart constructor.
data MetadataEntry = MetadataEntry'
  { -- | Value of the Object.
    MetadataEntry -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | Name of the Object.
    MetadataEntry -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (MetadataEntry -> MetadataEntry -> Bool
(MetadataEntry -> MetadataEntry -> Bool)
-> (MetadataEntry -> MetadataEntry -> Bool) -> Eq MetadataEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetadataEntry -> MetadataEntry -> Bool
$c/= :: MetadataEntry -> MetadataEntry -> Bool
== :: MetadataEntry -> MetadataEntry -> Bool
$c== :: MetadataEntry -> MetadataEntry -> Bool
Prelude.Eq, ReadPrec [MetadataEntry]
ReadPrec MetadataEntry
Int -> ReadS MetadataEntry
ReadS [MetadataEntry]
(Int -> ReadS MetadataEntry)
-> ReadS [MetadataEntry]
-> ReadPrec MetadataEntry
-> ReadPrec [MetadataEntry]
-> Read MetadataEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetadataEntry]
$creadListPrec :: ReadPrec [MetadataEntry]
readPrec :: ReadPrec MetadataEntry
$creadPrec :: ReadPrec MetadataEntry
readList :: ReadS [MetadataEntry]
$creadList :: ReadS [MetadataEntry]
readsPrec :: Int -> ReadS MetadataEntry
$creadsPrec :: Int -> ReadS MetadataEntry
Prelude.Read, Int -> MetadataEntry -> ShowS
[MetadataEntry] -> ShowS
MetadataEntry -> String
(Int -> MetadataEntry -> ShowS)
-> (MetadataEntry -> String)
-> ([MetadataEntry] -> ShowS)
-> Show MetadataEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetadataEntry] -> ShowS
$cshowList :: [MetadataEntry] -> ShowS
show :: MetadataEntry -> String
$cshow :: MetadataEntry -> String
showsPrec :: Int -> MetadataEntry -> ShowS
$cshowsPrec :: Int -> MetadataEntry -> ShowS
Prelude.Show, (forall x. MetadataEntry -> Rep MetadataEntry x)
-> (forall x. Rep MetadataEntry x -> MetadataEntry)
-> Generic MetadataEntry
forall x. Rep MetadataEntry x -> MetadataEntry
forall x. MetadataEntry -> Rep MetadataEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetadataEntry x -> MetadataEntry
$cfrom :: forall x. MetadataEntry -> Rep MetadataEntry x
Prelude.Generic)

-- |
-- Create a value of 'MetadataEntry' 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:
--
-- 'value', 'metadataEntry_value' - Value of the Object.
--
-- 'name', 'metadataEntry_name' - Name of the Object.
newMetadataEntry ::
  MetadataEntry
newMetadataEntry :: MetadataEntry
newMetadataEntry =
  MetadataEntry' :: Maybe Text -> Maybe Text -> MetadataEntry
MetadataEntry'
    { $sel:value:MetadataEntry' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:MetadataEntry' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Value of the Object.
metadataEntry_value :: Lens.Lens' MetadataEntry (Prelude.Maybe Prelude.Text)
metadataEntry_value :: (Maybe Text -> f (Maybe Text)) -> MetadataEntry -> f MetadataEntry
metadataEntry_value = (MetadataEntry -> Maybe Text)
-> (MetadataEntry -> Maybe Text -> MetadataEntry)
-> Lens MetadataEntry MetadataEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetadataEntry' {Maybe Text
value :: Maybe Text
$sel:value:MetadataEntry' :: MetadataEntry -> Maybe Text
value} -> Maybe Text
value) (\s :: MetadataEntry
s@MetadataEntry' {} Maybe Text
a -> MetadataEntry
s {$sel:value:MetadataEntry' :: Maybe Text
value = Maybe Text
a} :: MetadataEntry)

-- | Name of the Object.
metadataEntry_name :: Lens.Lens' MetadataEntry (Prelude.Maybe Prelude.Text)
metadataEntry_name :: (Maybe Text -> f (Maybe Text)) -> MetadataEntry -> f MetadataEntry
metadataEntry_name = (MetadataEntry -> Maybe Text)
-> (MetadataEntry -> Maybe Text -> MetadataEntry)
-> Lens MetadataEntry MetadataEntry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetadataEntry' {Maybe Text
name :: Maybe Text
$sel:name:MetadataEntry' :: MetadataEntry -> Maybe Text
name} -> Maybe Text
name) (\s :: MetadataEntry
s@MetadataEntry' {} Maybe Text
a -> MetadataEntry
s {$sel:name:MetadataEntry' :: Maybe Text
name = Maybe Text
a} :: MetadataEntry)

instance Prelude.Hashable MetadataEntry

instance Prelude.NFData MetadataEntry

instance Core.ToXML MetadataEntry where
  toXML :: MetadataEntry -> XML
toXML MetadataEntry' {Maybe Text
name :: Maybe Text
value :: Maybe Text
$sel:name:MetadataEntry' :: MetadataEntry -> Maybe Text
$sel:value:MetadataEntry' :: MetadataEntry -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"Value" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
value, Name
"Name" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
name]