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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(S3Tag -> S3Tag -> Bool) -> (S3Tag -> S3Tag -> Bool) -> Eq S3Tag
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]
(Int -> ReadS S3Tag)
-> ReadS [S3Tag]
-> ReadPrec S3Tag
-> ReadPrec [S3Tag]
-> Read 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
(Int -> S3Tag -> ShowS)
-> (S3Tag -> String) -> ([S3Tag] -> ShowS) -> Show S3Tag
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. S3Tag -> Rep S3Tag x)
-> (forall x. Rep S3Tag x -> S3Tag) -> Generic S3Tag
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' :: Text -> Text -> S3Tag
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 :: (Text -> f Text) -> S3Tag -> f S3Tag
s3Tag_key = (S3Tag -> Text)
-> (S3Tag -> Text -> S3Tag) -> Lens S3Tag S3Tag Text Text
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 :: (Text -> f Text) -> S3Tag -> f S3Tag
s3Tag_value = (S3Tag -> Text)
-> (S3Tag -> Text -> S3Tag) -> Lens S3Tag S3Tag Text Text
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 Core.FromJSON S3Tag where
  parseJSON :: Value -> Parser S3Tag
parseJSON =
    String -> (Object -> Parser S3Tag) -> Value -> Parser S3Tag
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Tag"
      ( \Object
x ->
          Text -> Text -> S3Tag
S3Tag'
            (Text -> Text -> S3Tag) -> Parser Text -> Parser (Text -> S3Tag)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Key") Parser (Text -> S3Tag) -> Parser Text -> Parser S3Tag
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Value")
      )

instance Prelude.Hashable S3Tag

instance Prelude.NFData S3Tag

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )