{-# 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.ResourceCollection
-- 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.ResourceCollection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types.CloudFormationCollection
import Amazonka.DevOpsGuru.Types.TagCollection
import qualified Amazonka.Prelude as Prelude

-- | A collection of Amazon Web Services resources supported by DevOps Guru.
-- The two types of Amazon Web Services resource collections supported are
-- Amazon Web Services CloudFormation stacks and Amazon Web Services
-- resources that contain the same Amazon Web Services tag. DevOps Guru can
-- be configured to analyze the Amazon Web Services resources that are
-- defined in the stacks or that are tagged using the same tag /key/. You
-- can specify up to 500 Amazon Web Services CloudFormation stacks.
--
-- /See:/ 'newResourceCollection' smart constructor.
data ResourceCollection = ResourceCollection'
  { -- | An array of the names of Amazon Web Services CloudFormation stacks. The
    -- stacks define Amazon Web Services resources that DevOps Guru analyzes.
    -- You can specify up to 500 Amazon Web Services CloudFormation stacks.
    ResourceCollection -> Maybe CloudFormationCollection
cloudFormation :: Prelude.Maybe CloudFormationCollection,
    -- | The Amazon Web Services tags that are used by resources in the resource
    -- collection.
    --
    -- 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@.
    ResourceCollection -> Maybe [TagCollection]
tags :: Prelude.Maybe [TagCollection]
  }
  deriving (ResourceCollection -> ResourceCollection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceCollection -> ResourceCollection -> Bool
$c/= :: ResourceCollection -> ResourceCollection -> Bool
== :: ResourceCollection -> ResourceCollection -> Bool
$c== :: ResourceCollection -> ResourceCollection -> Bool
Prelude.Eq, ReadPrec [ResourceCollection]
ReadPrec ResourceCollection
Int -> ReadS ResourceCollection
ReadS [ResourceCollection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceCollection]
$creadListPrec :: ReadPrec [ResourceCollection]
readPrec :: ReadPrec ResourceCollection
$creadPrec :: ReadPrec ResourceCollection
readList :: ReadS [ResourceCollection]
$creadList :: ReadS [ResourceCollection]
readsPrec :: Int -> ReadS ResourceCollection
$creadsPrec :: Int -> ReadS ResourceCollection
Prelude.Read, Int -> ResourceCollection -> ShowS
[ResourceCollection] -> ShowS
ResourceCollection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceCollection] -> ShowS
$cshowList :: [ResourceCollection] -> ShowS
show :: ResourceCollection -> String
$cshow :: ResourceCollection -> String
showsPrec :: Int -> ResourceCollection -> ShowS
$cshowsPrec :: Int -> ResourceCollection -> ShowS
Prelude.Show, forall x. Rep ResourceCollection x -> ResourceCollection
forall x. ResourceCollection -> Rep ResourceCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceCollection x -> ResourceCollection
$cfrom :: forall x. ResourceCollection -> Rep ResourceCollection x
Prelude.Generic)

-- |
-- Create a value of 'ResourceCollection' 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:
--
-- 'cloudFormation', 'resourceCollection_cloudFormation' - An array of the names of Amazon Web Services CloudFormation stacks. The
-- stacks define Amazon Web Services resources that DevOps Guru analyzes.
-- You can specify up to 500 Amazon Web Services CloudFormation stacks.
--
-- 'tags', 'resourceCollection_tags' - The Amazon Web Services tags that are used by resources in the resource
-- collection.
--
-- 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@.
newResourceCollection ::
  ResourceCollection
newResourceCollection :: ResourceCollection
newResourceCollection =
  ResourceCollection'
    { $sel:cloudFormation:ResourceCollection' :: Maybe CloudFormationCollection
cloudFormation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ResourceCollection' :: Maybe [TagCollection]
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of the names of Amazon Web Services CloudFormation stacks. The
-- stacks define Amazon Web Services resources that DevOps Guru analyzes.
-- You can specify up to 500 Amazon Web Services CloudFormation stacks.
resourceCollection_cloudFormation :: Lens.Lens' ResourceCollection (Prelude.Maybe CloudFormationCollection)
resourceCollection_cloudFormation :: Lens' ResourceCollection (Maybe CloudFormationCollection)
resourceCollection_cloudFormation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceCollection' {Maybe CloudFormationCollection
cloudFormation :: Maybe CloudFormationCollection
$sel:cloudFormation:ResourceCollection' :: ResourceCollection -> Maybe CloudFormationCollection
cloudFormation} -> Maybe CloudFormationCollection
cloudFormation) (\s :: ResourceCollection
s@ResourceCollection' {} Maybe CloudFormationCollection
a -> ResourceCollection
s {$sel:cloudFormation:ResourceCollection' :: Maybe CloudFormationCollection
cloudFormation = Maybe CloudFormationCollection
a} :: ResourceCollection)

-- | The Amazon Web Services tags that are used by resources in the resource
-- collection.
--
-- 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@.
resourceCollection_tags :: Lens.Lens' ResourceCollection (Prelude.Maybe [TagCollection])
resourceCollection_tags :: Lens' ResourceCollection (Maybe [TagCollection])
resourceCollection_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceCollection' {Maybe [TagCollection]
tags :: Maybe [TagCollection]
$sel:tags:ResourceCollection' :: ResourceCollection -> Maybe [TagCollection]
tags} -> Maybe [TagCollection]
tags) (\s :: ResourceCollection
s@ResourceCollection' {} Maybe [TagCollection]
a -> ResourceCollection
s {$sel:tags:ResourceCollection' :: Maybe [TagCollection]
tags = Maybe [TagCollection]
a} :: ResourceCollection) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ResourceCollection where
  parseJSON :: Value -> Parser ResourceCollection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceCollection"
      ( \Object
x ->
          Maybe CloudFormationCollection
-> Maybe [TagCollection] -> ResourceCollection
ResourceCollection'
            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
"CloudFormation")
            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
"Tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResourceCollection where
  hashWithSalt :: Int -> ResourceCollection -> Int
hashWithSalt Int
_salt ResourceCollection' {Maybe [TagCollection]
Maybe CloudFormationCollection
tags :: Maybe [TagCollection]
cloudFormation :: Maybe CloudFormationCollection
$sel:tags:ResourceCollection' :: ResourceCollection -> Maybe [TagCollection]
$sel:cloudFormation:ResourceCollection' :: ResourceCollection -> Maybe CloudFormationCollection
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CloudFormationCollection
cloudFormation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TagCollection]
tags

instance Prelude.NFData ResourceCollection where
  rnf :: ResourceCollection -> ()
rnf ResourceCollection' {Maybe [TagCollection]
Maybe CloudFormationCollection
tags :: Maybe [TagCollection]
cloudFormation :: Maybe CloudFormationCollection
$sel:tags:ResourceCollection' :: ResourceCollection -> Maybe [TagCollection]
$sel:cloudFormation:ResourceCollection' :: ResourceCollection -> Maybe CloudFormationCollection
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CloudFormationCollection
cloudFormation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TagCollection]
tags

instance Data.ToJSON ResourceCollection where
  toJSON :: ResourceCollection -> Value
toJSON ResourceCollection' {Maybe [TagCollection]
Maybe CloudFormationCollection
tags :: Maybe [TagCollection]
cloudFormation :: Maybe CloudFormationCollection
$sel:tags:ResourceCollection' :: ResourceCollection -> Maybe [TagCollection]
$sel:cloudFormation:ResourceCollection' :: ResourceCollection -> Maybe CloudFormationCollection
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CloudFormation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudFormationCollection
cloudFormation,
            (Key
"Tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagCollection]
tags
          ]
      )