{-# 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.DevOpsGuru.Types.TagCollection
-- 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.DevOpsGuru.Types.TagCollection 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

-- | A collection of Amazon Web Services tags.
--
-- Tags help you identify and organize your Amazon Web Services resources.
-- Many Amazon Web Services services support tagging, so you can assign the
-- same tag to resources from different services to indicate that the
-- resources are related. For example, you can assign the same tag to an
-- Amazon DynamoDB table resource that you assign to an Lambda function.
-- For more information about using tags, see the
-- <https://d1.awsstatic.com/whitepapers/aws-tagging-best-practices.pdf Tagging best practices>
-- whitepaper.
--
-- Each Amazon Web Services tag has two parts.
--
-- -   A tag /key/ (for example, @CostCenter@, @Environment@, @Project@, or
--     @Secret@). Tag /keys/ are case-sensitive.
--
-- -   An optional field known as a tag /value/ (for example,
--     @111122223333@, @Production@, or a team name). Omitting the tag
--     /value/ is the same as using an empty string. Like tag /keys/, tag
--     /values/ are case-sensitive.
--
-- Together these are known as /key/-/value/ pairs.
--
-- The string used for a /key/ in a tag that you use to define your
-- resource coverage must begin with the prefix @Devops-guru-@. The tag
-- /key/ might be @DevOps-Guru-deployment-application@ or
-- @devops-guru-rds-application@. When you create a /key/, the case of
-- characters in the /key/ can be whatever you choose. After you create a
-- /key/, it is case-sensitive. For example, DevOps Guru works with a /key/
-- named @devops-guru-rds@ and a /key/ named @DevOps-Guru-RDS@, and these
-- act as two different /keys/. Possible /key/\//value/ pairs in your
-- application might be @Devops-Guru-production-application\/RDS@ or
-- @Devops-Guru-production-application\/containers@.
--
-- /See:/ 'newTagCollection' smart constructor.
data TagCollection = TagCollection'
  { -- | An Amazon Web Services tag /key/ that is used to identify the Amazon Web
    -- Services resources that DevOps Guru analyzes. All Amazon Web Services
    -- resources in your account and Region tagged with this /key/ make up your
    -- DevOps Guru application and analysis boundary.
    --
    -- The string used for a /key/ in a tag that you use to define your
    -- resource coverage must begin with the prefix @Devops-guru-@. The tag
    -- /key/ might be @DevOps-Guru-deployment-application@ or
    -- @devops-guru-rds-application@. When you create a /key/, the case of
    -- characters in the /key/ can be whatever you choose. After you create a
    -- /key/, it is case-sensitive. For example, DevOps Guru works with a /key/
    -- named @devops-guru-rds@ and a /key/ named @DevOps-Guru-RDS@, and these
    -- act as two different /keys/. Possible /key/\//value/ pairs in your
    -- application might be @Devops-Guru-production-application\/RDS@ or
    -- @Devops-Guru-production-application\/containers@.
    TagCollection -> Text
appBoundaryKey :: Prelude.Text,
    -- | The values in an Amazon Web Services tag collection.
    --
    -- The tag\'s /value/ is an optional field used to associate a string with
    -- the tag /key/ (for example, @111122223333@, @Production@, or a team
    -- name). The /key/ and /value/ are the tag\'s /key/ pair. Omitting the tag
    -- /value/ is the same as using an empty string. Like tag /keys/, tag
    -- /values/ are case-sensitive. You can specify a maximum of 256 characters
    -- for a tag value.
    TagCollection -> [Text]
tagValues :: [Prelude.Text]
  }
  deriving (TagCollection -> TagCollection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TagCollection -> TagCollection -> Bool
$c/= :: TagCollection -> TagCollection -> Bool
== :: TagCollection -> TagCollection -> Bool
$c== :: TagCollection -> TagCollection -> Bool
Prelude.Eq, ReadPrec [TagCollection]
ReadPrec TagCollection
Int -> ReadS TagCollection
ReadS [TagCollection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TagCollection]
$creadListPrec :: ReadPrec [TagCollection]
readPrec :: ReadPrec TagCollection
$creadPrec :: ReadPrec TagCollection
readList :: ReadS [TagCollection]
$creadList :: ReadS [TagCollection]
readsPrec :: Int -> ReadS TagCollection
$creadsPrec :: Int -> ReadS TagCollection
Prelude.Read, Int -> TagCollection -> ShowS
[TagCollection] -> ShowS
TagCollection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TagCollection] -> ShowS
$cshowList :: [TagCollection] -> ShowS
show :: TagCollection -> String
$cshow :: TagCollection -> String
showsPrec :: Int -> TagCollection -> ShowS
$cshowsPrec :: Int -> TagCollection -> ShowS
Prelude.Show, forall x. Rep TagCollection x -> TagCollection
forall x. TagCollection -> Rep TagCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TagCollection x -> TagCollection
$cfrom :: forall x. TagCollection -> Rep TagCollection x
Prelude.Generic)

-- |
-- Create a value of 'TagCollection' 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:
--
-- 'appBoundaryKey', 'tagCollection_appBoundaryKey' - An Amazon Web Services tag /key/ that is used to identify the Amazon Web
-- Services resources that DevOps Guru analyzes. All Amazon Web Services
-- resources in your account and Region tagged with this /key/ make up your
-- DevOps Guru application and analysis boundary.
--
-- The string used for a /key/ in a tag that you use to define your
-- resource coverage must begin with the prefix @Devops-guru-@. The tag
-- /key/ might be @DevOps-Guru-deployment-application@ or
-- @devops-guru-rds-application@. When you create a /key/, the case of
-- characters in the /key/ can be whatever you choose. After you create a
-- /key/, it is case-sensitive. For example, DevOps Guru works with a /key/
-- named @devops-guru-rds@ and a /key/ named @DevOps-Guru-RDS@, and these
-- act as two different /keys/. Possible /key/\//value/ pairs in your
-- application might be @Devops-Guru-production-application\/RDS@ or
-- @Devops-Guru-production-application\/containers@.
--
-- 'tagValues', 'tagCollection_tagValues' - The values in an Amazon Web Services tag collection.
--
-- The tag\'s /value/ is an optional field used to associate a string with
-- the tag /key/ (for example, @111122223333@, @Production@, or a team
-- name). The /key/ and /value/ are the tag\'s /key/ pair. Omitting the tag
-- /value/ is the same as using an empty string. Like tag /keys/, tag
-- /values/ are case-sensitive. You can specify a maximum of 256 characters
-- for a tag value.
newTagCollection ::
  -- | 'appBoundaryKey'
  Prelude.Text ->
  TagCollection
newTagCollection :: Text -> TagCollection
newTagCollection Text
pAppBoundaryKey_ =
  TagCollection'
    { $sel:appBoundaryKey:TagCollection' :: Text
appBoundaryKey = Text
pAppBoundaryKey_,
      $sel:tagValues:TagCollection' :: [Text]
tagValues = forall a. Monoid a => a
Prelude.mempty
    }

-- | An Amazon Web Services tag /key/ that is used to identify the Amazon Web
-- Services resources that DevOps Guru analyzes. All Amazon Web Services
-- resources in your account and Region tagged with this /key/ make up your
-- DevOps Guru application and analysis boundary.
--
-- The string used for a /key/ in a tag that you use to define your
-- resource coverage must begin with the prefix @Devops-guru-@. The tag
-- /key/ might be @DevOps-Guru-deployment-application@ or
-- @devops-guru-rds-application@. When you create a /key/, the case of
-- characters in the /key/ can be whatever you choose. After you create a
-- /key/, it is case-sensitive. For example, DevOps Guru works with a /key/
-- named @devops-guru-rds@ and a /key/ named @DevOps-Guru-RDS@, and these
-- act as two different /keys/. Possible /key/\//value/ pairs in your
-- application might be @Devops-Guru-production-application\/RDS@ or
-- @Devops-Guru-production-application\/containers@.
tagCollection_appBoundaryKey :: Lens.Lens' TagCollection Prelude.Text
tagCollection_appBoundaryKey :: Lens' TagCollection Text
tagCollection_appBoundaryKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCollection' {Text
appBoundaryKey :: Text
$sel:appBoundaryKey:TagCollection' :: TagCollection -> Text
appBoundaryKey} -> Text
appBoundaryKey) (\s :: TagCollection
s@TagCollection' {} Text
a -> TagCollection
s {$sel:appBoundaryKey:TagCollection' :: Text
appBoundaryKey = Text
a} :: TagCollection)

-- | The values in an Amazon Web Services tag collection.
--
-- The tag\'s /value/ is an optional field used to associate a string with
-- the tag /key/ (for example, @111122223333@, @Production@, or a team
-- name). The /key/ and /value/ are the tag\'s /key/ pair. Omitting the tag
-- /value/ is the same as using an empty string. Like tag /keys/, tag
-- /values/ are case-sensitive. You can specify a maximum of 256 characters
-- for a tag value.
tagCollection_tagValues :: Lens.Lens' TagCollection [Prelude.Text]
tagCollection_tagValues :: Lens' TagCollection [Text]
tagCollection_tagValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TagCollection' {[Text]
tagValues :: [Text]
$sel:tagValues:TagCollection' :: TagCollection -> [Text]
tagValues} -> [Text]
tagValues) (\s :: TagCollection
s@TagCollection' {} [Text]
a -> TagCollection
s {$sel:tagValues:TagCollection' :: [Text]
tagValues = [Text]
a} :: TagCollection) 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 TagCollection where
  parseJSON :: Value -> Parser TagCollection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TagCollection"
      ( \Object
x ->
          Text -> [Text] -> TagCollection
TagCollection'
            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
"AppBoundaryKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TagValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TagCollection where
  hashWithSalt :: Int -> TagCollection -> Int
hashWithSalt Int
_salt TagCollection' {[Text]
Text
tagValues :: [Text]
appBoundaryKey :: Text
$sel:tagValues:TagCollection' :: TagCollection -> [Text]
$sel:appBoundaryKey:TagCollection' :: TagCollection -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appBoundaryKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
tagValues

instance Prelude.NFData TagCollection where
  rnf :: TagCollection -> ()
rnf TagCollection' {[Text]
Text
tagValues :: [Text]
appBoundaryKey :: Text
$sel:tagValues:TagCollection' :: TagCollection -> [Text]
$sel:appBoundaryKey:TagCollection' :: TagCollection -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
appBoundaryKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
tagValues

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