{-# 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.Inspector.Types.ResourceGroup
-- 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.Inspector.Types.ResourceGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types.ResourceGroupTag
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a resource group. The resource group defines
-- a set of tags that, when queried, identify the AWS resources that make
-- up the assessment target. This data type is used as the response element
-- in the DescribeResourceGroups action.
--
-- /See:/ 'newResourceGroup' smart constructor.
data ResourceGroup = ResourceGroup'
  { -- | The ARN of the resource group.
    ResourceGroup -> Text
arn :: Prelude.Text,
    -- | The tags (key and value pairs) of the resource group. This data type
    -- property is used in the CreateResourceGroup action.
    ResourceGroup -> NonEmpty ResourceGroupTag
tags :: Prelude.NonEmpty ResourceGroupTag,
    -- | The time at which resource group is created.
    ResourceGroup -> POSIX
createdAt :: Data.POSIX
  }
  deriving (ResourceGroup -> ResourceGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceGroup -> ResourceGroup -> Bool
$c/= :: ResourceGroup -> ResourceGroup -> Bool
== :: ResourceGroup -> ResourceGroup -> Bool
$c== :: ResourceGroup -> ResourceGroup -> Bool
Prelude.Eq, ReadPrec [ResourceGroup]
ReadPrec ResourceGroup
Int -> ReadS ResourceGroup
ReadS [ResourceGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceGroup]
$creadListPrec :: ReadPrec [ResourceGroup]
readPrec :: ReadPrec ResourceGroup
$creadPrec :: ReadPrec ResourceGroup
readList :: ReadS [ResourceGroup]
$creadList :: ReadS [ResourceGroup]
readsPrec :: Int -> ReadS ResourceGroup
$creadsPrec :: Int -> ReadS ResourceGroup
Prelude.Read, Int -> ResourceGroup -> ShowS
[ResourceGroup] -> ShowS
ResourceGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceGroup] -> ShowS
$cshowList :: [ResourceGroup] -> ShowS
show :: ResourceGroup -> String
$cshow :: ResourceGroup -> String
showsPrec :: Int -> ResourceGroup -> ShowS
$cshowsPrec :: Int -> ResourceGroup -> ShowS
Prelude.Show, forall x. Rep ResourceGroup x -> ResourceGroup
forall x. ResourceGroup -> Rep ResourceGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceGroup x -> ResourceGroup
$cfrom :: forall x. ResourceGroup -> Rep ResourceGroup x
Prelude.Generic)

-- |
-- Create a value of 'ResourceGroup' 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:
--
-- 'arn', 'resourceGroup_arn' - The ARN of the resource group.
--
-- 'tags', 'resourceGroup_tags' - The tags (key and value pairs) of the resource group. This data type
-- property is used in the CreateResourceGroup action.
--
-- 'createdAt', 'resourceGroup_createdAt' - The time at which resource group is created.
newResourceGroup ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'tags'
  Prelude.NonEmpty ResourceGroupTag ->
  -- | 'createdAt'
  Prelude.UTCTime ->
  ResourceGroup
newResourceGroup :: Text -> NonEmpty ResourceGroupTag -> UTCTime -> ResourceGroup
newResourceGroup Text
pArn_ NonEmpty ResourceGroupTag
pTags_ UTCTime
pCreatedAt_ =
  ResourceGroup'
    { $sel:arn:ResourceGroup' :: Text
arn = Text
pArn_,
      $sel:tags:ResourceGroup' :: NonEmpty ResourceGroupTag
tags = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty ResourceGroupTag
pTags_,
      $sel:createdAt:ResourceGroup' :: POSIX
createdAt = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreatedAt_
    }

-- | The ARN of the resource group.
resourceGroup_arn :: Lens.Lens' ResourceGroup Prelude.Text
resourceGroup_arn :: Lens' ResourceGroup Text
resourceGroup_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceGroup' {Text
arn :: Text
$sel:arn:ResourceGroup' :: ResourceGroup -> Text
arn} -> Text
arn) (\s :: ResourceGroup
s@ResourceGroup' {} Text
a -> ResourceGroup
s {$sel:arn:ResourceGroup' :: Text
arn = Text
a} :: ResourceGroup)

-- | The tags (key and value pairs) of the resource group. This data type
-- property is used in the CreateResourceGroup action.
resourceGroup_tags :: Lens.Lens' ResourceGroup (Prelude.NonEmpty ResourceGroupTag)
resourceGroup_tags :: Lens' ResourceGroup (NonEmpty ResourceGroupTag)
resourceGroup_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceGroup' {NonEmpty ResourceGroupTag
tags :: NonEmpty ResourceGroupTag
$sel:tags:ResourceGroup' :: ResourceGroup -> NonEmpty ResourceGroupTag
tags} -> NonEmpty ResourceGroupTag
tags) (\s :: ResourceGroup
s@ResourceGroup' {} NonEmpty ResourceGroupTag
a -> ResourceGroup
s {$sel:tags:ResourceGroup' :: NonEmpty ResourceGroupTag
tags = NonEmpty ResourceGroupTag
a} :: ResourceGroup) 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

-- | The time at which resource group is created.
resourceGroup_createdAt :: Lens.Lens' ResourceGroup Prelude.UTCTime
resourceGroup_createdAt :: Lens' ResourceGroup UTCTime
resourceGroup_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceGroup' {POSIX
createdAt :: POSIX
$sel:createdAt:ResourceGroup' :: ResourceGroup -> POSIX
createdAt} -> POSIX
createdAt) (\s :: ResourceGroup
s@ResourceGroup' {} POSIX
a -> ResourceGroup
s {$sel:createdAt:ResourceGroup' :: POSIX
createdAt = POSIX
a} :: ResourceGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON ResourceGroup where
  parseJSON :: Value -> Parser ResourceGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceGroup"
      ( \Object
x ->
          Text -> NonEmpty ResourceGroupTag -> POSIX -> ResourceGroup
ResourceGroup'
            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
"arn")
            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
"tags")
            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
"createdAt")
      )

instance Prelude.Hashable ResourceGroup where
  hashWithSalt :: Int -> ResourceGroup -> Int
hashWithSalt Int
_salt ResourceGroup' {NonEmpty ResourceGroupTag
Text
POSIX
createdAt :: POSIX
tags :: NonEmpty ResourceGroupTag
arn :: Text
$sel:createdAt:ResourceGroup' :: ResourceGroup -> POSIX
$sel:tags:ResourceGroup' :: ResourceGroup -> NonEmpty ResourceGroupTag
$sel:arn:ResourceGroup' :: ResourceGroup -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty ResourceGroupTag
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
createdAt

instance Prelude.NFData ResourceGroup where
  rnf :: ResourceGroup -> ()
rnf ResourceGroup' {NonEmpty ResourceGroupTag
Text
POSIX
createdAt :: POSIX
tags :: NonEmpty ResourceGroupTag
arn :: Text
$sel:createdAt:ResourceGroup' :: ResourceGroup -> POSIX
$sel:tags:ResourceGroup' :: ResourceGroup -> NonEmpty ResourceGroupTag
$sel:arn:ResourceGroup' :: ResourceGroup -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty ResourceGroupTag
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
createdAt