{-# 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.Pinpoint.Types.TagsModel
-- 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.Pinpoint.Types.TagsModel 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 tags (keys and values) for an application, campaign,
-- message template, or segment.
--
-- /See:/ 'newTagsModel' smart constructor.
data TagsModel = TagsModel'
  { -- | A string-to-string map of key-value pairs that defines the tags for an
    -- application, campaign, message template, or segment. Each of these
    -- resources can have a maximum of 50 tags.
    --
    -- Each tag consists of a required tag key and an associated tag value. The
    -- maximum length of a tag key is 128 characters. The maximum length of a
    -- tag value is 256 characters.
    TagsModel -> HashMap Text Text
tags :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (TagsModel -> TagsModel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagsModel -> TagsModel -> Bool
$c/= :: TagsModel -> TagsModel -> Bool
== :: TagsModel -> TagsModel -> Bool
$c== :: TagsModel -> TagsModel -> Bool
Prelude.Eq, ReadPrec [TagsModel]
ReadPrec TagsModel
Int -> ReadS TagsModel
ReadS [TagsModel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagsModel]
$creadListPrec :: ReadPrec [TagsModel]
readPrec :: ReadPrec TagsModel
$creadPrec :: ReadPrec TagsModel
readList :: ReadS [TagsModel]
$creadList :: ReadS [TagsModel]
readsPrec :: Int -> ReadS TagsModel
$creadsPrec :: Int -> ReadS TagsModel
Prelude.Read, Int -> TagsModel -> ShowS
[TagsModel] -> ShowS
TagsModel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagsModel] -> ShowS
$cshowList :: [TagsModel] -> ShowS
show :: TagsModel -> String
$cshow :: TagsModel -> String
showsPrec :: Int -> TagsModel -> ShowS
$cshowsPrec :: Int -> TagsModel -> ShowS
Prelude.Show, forall x. Rep TagsModel x -> TagsModel
forall x. TagsModel -> Rep TagsModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagsModel x -> TagsModel
$cfrom :: forall x. TagsModel -> Rep TagsModel x
Prelude.Generic)

-- |
-- Create a value of 'TagsModel' 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:
--
-- 'tags', 'tagsModel_tags' - A string-to-string map of key-value pairs that defines the tags for an
-- application, campaign, message template, or segment. Each of these
-- resources can have a maximum of 50 tags.
--
-- Each tag consists of a required tag key and an associated tag value. The
-- maximum length of a tag key is 128 characters. The maximum length of a
-- tag value is 256 characters.
newTagsModel ::
  TagsModel
newTagsModel :: TagsModel
newTagsModel = TagsModel' {$sel:tags:TagsModel' :: HashMap Text Text
tags = forall a. Monoid a => a
Prelude.mempty}

-- | A string-to-string map of key-value pairs that defines the tags for an
-- application, campaign, message template, or segment. Each of these
-- resources can have a maximum of 50 tags.
--
-- Each tag consists of a required tag key and an associated tag value. The
-- maximum length of a tag key is 128 characters. The maximum length of a
-- tag value is 256 characters.
tagsModel_tags :: Lens.Lens' TagsModel (Prelude.HashMap Prelude.Text Prelude.Text)
tagsModel_tags :: Lens' TagsModel (HashMap Text Text)
tagsModel_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagsModel' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:TagsModel' :: TagsModel -> HashMap Text Text
tags} -> HashMap Text Text
tags) (\s :: TagsModel
s@TagsModel' {} HashMap Text Text
a -> TagsModel
s {$sel:tags:TagsModel' :: HashMap Text Text
tags = HashMap Text Text
a} :: TagsModel) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON TagsModel where
  parseJSON :: Value -> Parser TagsModel
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagsModel"
      ( \Object
x ->
          HashMap Text Text -> TagsModel
TagsModel'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TagsModel where
  hashWithSalt :: Int -> TagsModel -> Int
hashWithSalt Int
_salt TagsModel' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:TagsModel' :: TagsModel -> HashMap Text Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
tags

instance Prelude.NFData TagsModel where
  rnf :: TagsModel -> ()
rnf TagsModel' {HashMap Text Text
tags :: HashMap Text Text
$sel:tags:TagsModel' :: TagsModel -> HashMap Text Text
..} = forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
tags

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