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

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.ResourceGroupTag
import qualified Amazonka.Lens as Lens
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 :: Core.POSIX
  }
  deriving (ResourceGroup -> ResourceGroup -> Bool
(ResourceGroup -> ResourceGroup -> Bool)
-> (ResourceGroup -> ResourceGroup -> Bool) -> Eq ResourceGroup
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]
(Int -> ReadS ResourceGroup)
-> ReadS [ResourceGroup]
-> ReadPrec ResourceGroup
-> ReadPrec [ResourceGroup]
-> Read 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
(Int -> ResourceGroup -> ShowS)
-> (ResourceGroup -> String)
-> ([ResourceGroup] -> ShowS)
-> Show ResourceGroup
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. ResourceGroup -> Rep ResourceGroup x)
-> (forall x. Rep ResourceGroup x -> ResourceGroup)
-> Generic ResourceGroup
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' :: Text -> NonEmpty ResourceGroupTag -> POSIX -> ResourceGroup
ResourceGroup'
    { $sel:arn:ResourceGroup' :: Text
arn = Text
pArn_,
      $sel:tags:ResourceGroup' :: NonEmpty ResourceGroupTag
tags = Tagged
  (NonEmpty ResourceGroupTag) (Identity (NonEmpty ResourceGroupTag))
-> Tagged
     (NonEmpty ResourceGroupTag) (Identity (NonEmpty ResourceGroupTag))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty ResourceGroupTag) (Identity (NonEmpty ResourceGroupTag))
 -> Tagged
      (NonEmpty ResourceGroupTag) (Identity (NonEmpty ResourceGroupTag)))
-> NonEmpty ResourceGroupTag -> NonEmpty ResourceGroupTag
forall t b. AReview t b -> b -> t
Lens.# NonEmpty ResourceGroupTag
pTags_,
      $sel:createdAt:ResourceGroup' :: POSIX
createdAt = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
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 :: (Text -> f Text) -> ResourceGroup -> f ResourceGroup
resourceGroup_arn = (ResourceGroup -> Text)
-> (ResourceGroup -> Text -> ResourceGroup)
-> Lens ResourceGroup ResourceGroup Text Text
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 :: (NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
-> ResourceGroup -> f ResourceGroup
resourceGroup_tags = (ResourceGroup -> NonEmpty ResourceGroupTag)
-> (ResourceGroup -> NonEmpty ResourceGroupTag -> ResourceGroup)
-> Lens
     ResourceGroup
     ResourceGroup
     (NonEmpty ResourceGroupTag)
     (NonEmpty ResourceGroupTag)
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) ((NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
 -> ResourceGroup -> f ResourceGroup)
-> ((NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
    -> NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
-> (NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
-> ResourceGroup
-> f ResourceGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag))
-> NonEmpty ResourceGroupTag -> f (NonEmpty ResourceGroupTag)
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 :: (UTCTime -> f UTCTime) -> ResourceGroup -> f ResourceGroup
resourceGroup_createdAt = (ResourceGroup -> POSIX)
-> (ResourceGroup -> POSIX -> ResourceGroup)
-> Lens ResourceGroup ResourceGroup POSIX POSIX
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) ((POSIX -> f POSIX) -> ResourceGroup -> f ResourceGroup)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ResourceGroup
-> f ResourceGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable ResourceGroup

instance Prelude.NFData ResourceGroup