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

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
import Amazonka.S3.Internal

-- | A metadata key-value pair to store with an object.
--
-- /See:/ 'newMetadataEntry' smart constructor.
data MetadataEntry = MetadataEntry'
  { -- | Name of the Object.
    MetadataEntry -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Value of the Object.
    MetadataEntry -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (MetadataEntry -> MetadataEntry -> Bool
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]
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
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. 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:
--
-- 'name', 'metadataEntry_name' - Name of the Object.
--
-- 'value', 'metadataEntry_value' - Value of the Object.
newMetadataEntry ::
  MetadataEntry
newMetadataEntry :: MetadataEntry
newMetadataEntry =
  MetadataEntry'
    { $sel:name:MetadataEntry' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:MetadataEntry' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | Name of the Object.
metadataEntry_name :: Lens.Lens' MetadataEntry (Prelude.Maybe Prelude.Text)
metadataEntry_name :: Lens' MetadataEntry (Maybe Text)
metadataEntry_name = 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)

-- | Value of the Object.
metadataEntry_value :: Lens.Lens' MetadataEntry (Prelude.Maybe Prelude.Text)
metadataEntry_value :: Lens' MetadataEntry (Maybe Text)
metadataEntry_value = 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)

instance Prelude.Hashable MetadataEntry where
  hashWithSalt :: Int -> MetadataEntry -> Int
hashWithSalt Int
_salt MetadataEntry' {Maybe Text
value :: Maybe Text
name :: Maybe Text
$sel:value:MetadataEntry' :: MetadataEntry -> Maybe Text
$sel:name:MetadataEntry' :: MetadataEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData MetadataEntry where
  rnf :: MetadataEntry -> ()
rnf MetadataEntry' {Maybe Text
value :: Maybe Text
name :: Maybe Text
$sel:value:MetadataEntry' :: MetadataEntry -> Maybe Text
$sel:name:MetadataEntry' :: MetadataEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

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