{-# 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.Transfer.Types.S3Tag
-- 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.Transfer.Types.S3Tag 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

-- | Specifies the key-value pair that are assigned to a file during the
-- execution of a Tagging step.
--
-- /See:/ 'newS3Tag' smart constructor.
data S3Tag = S3Tag'
  { -- | The name assigned to the tag that you create.
    S3Tag -> Text
key :: Prelude.Text,
    -- | The value that corresponds to the key.
    S3Tag -> Text
value :: Prelude.Text
  }
  deriving (S3Tag -> S3Tag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Tag -> S3Tag -> Bool
$c/= :: S3Tag -> S3Tag -> Bool
== :: S3Tag -> S3Tag -> Bool
$c== :: S3Tag -> S3Tag -> Bool
Prelude.Eq, ReadPrec [S3Tag]
ReadPrec S3Tag
Int -> ReadS S3Tag
ReadS [S3Tag]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Tag]
$creadListPrec :: ReadPrec [S3Tag]
readPrec :: ReadPrec S3Tag
$creadPrec :: ReadPrec S3Tag
readList :: ReadS [S3Tag]
$creadList :: ReadS [S3Tag]
readsPrec :: Int -> ReadS S3Tag
$creadsPrec :: Int -> ReadS S3Tag
Prelude.Read, Int -> S3Tag -> ShowS
[S3Tag] -> ShowS
S3Tag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Tag] -> ShowS
$cshowList :: [S3Tag] -> ShowS
show :: S3Tag -> String
$cshow :: S3Tag -> String
showsPrec :: Int -> S3Tag -> ShowS
$cshowsPrec :: Int -> S3Tag -> ShowS
Prelude.Show, forall x. Rep S3Tag x -> S3Tag
forall x. S3Tag -> Rep S3Tag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Tag x -> S3Tag
$cfrom :: forall x. S3Tag -> Rep S3Tag x
Prelude.Generic)

-- |
-- Create a value of 'S3Tag' 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:
--
-- 'key', 's3Tag_key' - The name assigned to the tag that you create.
--
-- 'value', 's3Tag_value' - The value that corresponds to the key.
newS3Tag ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  S3Tag
newS3Tag :: Text -> Text -> S3Tag
newS3Tag Text
pKey_ Text
pValue_ =
  S3Tag' {$sel:key:S3Tag' :: Text
key = Text
pKey_, $sel:value:S3Tag' :: Text
value = Text
pValue_}

-- | The name assigned to the tag that you create.
s3Tag_key :: Lens.Lens' S3Tag Prelude.Text
s3Tag_key :: Lens' S3Tag Text
s3Tag_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Tag' {Text
key :: Text
$sel:key:S3Tag' :: S3Tag -> Text
key} -> Text
key) (\s :: S3Tag
s@S3Tag' {} Text
a -> S3Tag
s {$sel:key:S3Tag' :: Text
key = Text
a} :: S3Tag)

-- | The value that corresponds to the key.
s3Tag_value :: Lens.Lens' S3Tag Prelude.Text
s3Tag_value :: Lens' S3Tag Text
s3Tag_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Tag' {Text
value :: Text
$sel:value:S3Tag' :: S3Tag -> Text
value} -> Text
value) (\s :: S3Tag
s@S3Tag' {} Text
a -> S3Tag
s {$sel:value:S3Tag' :: Text
value = Text
a} :: S3Tag)

instance Data.FromJSON S3Tag where
  parseJSON :: Value -> Parser S3Tag
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Tag"
      ( \Object
x ->
          Text -> Text -> S3Tag
S3Tag'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

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

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

instance Data.ToJSON S3Tag where
  toJSON :: S3Tag -> Value
toJSON S3Tag' {Text
value :: Text
key :: Text
$sel:value:S3Tag' :: S3Tag -> Text
$sel:key:S3Tag' :: S3Tag -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )