{-# 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 #-}
module Amazonka.SecurityHub.Types.Resource where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.DataClassificationDetails
import Amazonka.SecurityHub.Types.Partition
import Amazonka.SecurityHub.Types.ResourceDetails
data Resource = Resource'
{
Resource -> Maybe DataClassificationDetails
dataClassification :: Prelude.Maybe DataClassificationDetails,
Resource -> Maybe Partition
partition :: Prelude.Maybe Partition,
Resource -> Maybe ResourceDetails
details :: Prelude.Maybe ResourceDetails,
Resource -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
Resource -> Maybe Text
resourceRole :: Prelude.Maybe Prelude.Text,
Resource -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
Resource -> Text
type' :: Prelude.Text,
Resource -> Text
id :: Prelude.Text
}
deriving (Resource -> Resource -> Bool
(Resource -> Resource -> Bool)
-> (Resource -> Resource -> Bool) -> Eq Resource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resource -> Resource -> Bool
$c/= :: Resource -> Resource -> Bool
== :: Resource -> Resource -> Bool
$c== :: Resource -> Resource -> Bool
Prelude.Eq, ReadPrec [Resource]
ReadPrec Resource
Int -> ReadS Resource
ReadS [Resource]
(Int -> ReadS Resource)
-> ReadS [Resource]
-> ReadPrec Resource
-> ReadPrec [Resource]
-> Read Resource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resource]
$creadListPrec :: ReadPrec [Resource]
readPrec :: ReadPrec Resource
$creadPrec :: ReadPrec Resource
readList :: ReadS [Resource]
$creadList :: ReadS [Resource]
readsPrec :: Int -> ReadS Resource
$creadsPrec :: Int -> ReadS Resource
Prelude.Read, Int -> Resource -> ShowS
[Resource] -> ShowS
Resource -> String
(Int -> Resource -> ShowS)
-> (Resource -> String) -> ([Resource] -> ShowS) -> Show Resource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resource] -> ShowS
$cshowList :: [Resource] -> ShowS
show :: Resource -> String
$cshow :: Resource -> String
showsPrec :: Int -> Resource -> ShowS
$cshowsPrec :: Int -> Resource -> ShowS
Prelude.Show, (forall x. Resource -> Rep Resource x)
-> (forall x. Rep Resource x -> Resource) -> Generic Resource
forall x. Rep Resource x -> Resource
forall x. Resource -> Rep Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resource x -> Resource
$cfrom :: forall x. Resource -> Rep Resource x
Prelude.Generic)
newResource ::
Prelude.Text ->
Prelude.Text ->
Resource
newResource :: Text -> Text -> Resource
newResource Text
pType_ Text
pId_ =
Resource' :: Maybe DataClassificationDetails
-> Maybe Partition
-> Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource
Resource'
{ $sel:dataClassification:Resource' :: Maybe DataClassificationDetails
dataClassification = Maybe DataClassificationDetails
forall a. Maybe a
Prelude.Nothing,
$sel:partition:Resource' :: Maybe Partition
partition = Maybe Partition
forall a. Maybe a
Prelude.Nothing,
$sel:details:Resource' :: Maybe ResourceDetails
details = Maybe ResourceDetails
forall a. Maybe a
Prelude.Nothing,
$sel:region:Resource' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:resourceRole:Resource' :: Maybe Text
resourceRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:Resource' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:type':Resource' :: Text
type' = Text
pType_,
$sel:id:Resource' :: Text
id = Text
pId_
}
resource_dataClassification :: Lens.Lens' Resource (Prelude.Maybe DataClassificationDetails)
resource_dataClassification :: (Maybe DataClassificationDetails
-> f (Maybe DataClassificationDetails))
-> Resource -> f Resource
resource_dataClassification = (Resource -> Maybe DataClassificationDetails)
-> (Resource -> Maybe DataClassificationDetails -> Resource)
-> Lens
Resource
Resource
(Maybe DataClassificationDetails)
(Maybe DataClassificationDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe DataClassificationDetails
dataClassification :: Maybe DataClassificationDetails
$sel:dataClassification:Resource' :: Resource -> Maybe DataClassificationDetails
dataClassification} -> Maybe DataClassificationDetails
dataClassification) (\s :: Resource
s@Resource' {} Maybe DataClassificationDetails
a -> Resource
s {$sel:dataClassification:Resource' :: Maybe DataClassificationDetails
dataClassification = Maybe DataClassificationDetails
a} :: Resource)
resource_partition :: Lens.Lens' Resource (Prelude.Maybe Partition)
resource_partition :: (Maybe Partition -> f (Maybe Partition)) -> Resource -> f Resource
resource_partition = (Resource -> Maybe Partition)
-> (Resource -> Maybe Partition -> Resource)
-> Lens Resource Resource (Maybe Partition) (Maybe Partition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Partition
partition :: Maybe Partition
$sel:partition:Resource' :: Resource -> Maybe Partition
partition} -> Maybe Partition
partition) (\s :: Resource
s@Resource' {} Maybe Partition
a -> Resource
s {$sel:partition:Resource' :: Maybe Partition
partition = Maybe Partition
a} :: Resource)
resource_details :: Lens.Lens' Resource (Prelude.Maybe ResourceDetails)
resource_details :: (Maybe ResourceDetails -> f (Maybe ResourceDetails))
-> Resource -> f Resource
resource_details = (Resource -> Maybe ResourceDetails)
-> (Resource -> Maybe ResourceDetails -> Resource)
-> Lens
Resource Resource (Maybe ResourceDetails) (Maybe ResourceDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe ResourceDetails
details :: Maybe ResourceDetails
$sel:details:Resource' :: Resource -> Maybe ResourceDetails
details} -> Maybe ResourceDetails
details) (\s :: Resource
s@Resource' {} Maybe ResourceDetails
a -> Resource
s {$sel:details:Resource' :: Maybe ResourceDetails
details = Maybe ResourceDetails
a} :: Resource)
resource_region :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_region :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_region = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
region :: Maybe Text
$sel:region:Resource' :: Resource -> Maybe Text
region} -> Maybe Text
region) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:region:Resource' :: Maybe Text
region = Maybe Text
a} :: Resource)
resource_resourceRole :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_resourceRole :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_resourceRole = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
resourceRole :: Maybe Text
$sel:resourceRole:Resource' :: Resource -> Maybe Text
resourceRole} -> Maybe Text
resourceRole) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:resourceRole:Resource' :: Maybe Text
resourceRole = Maybe Text
a} :: Resource)
resource_tags :: Lens.Lens' Resource (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
resource_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Resource -> f Resource
resource_tags = (Resource -> Maybe (HashMap Text Text))
-> (Resource -> Maybe (HashMap Text Text) -> Resource)
-> Lens
Resource
Resource
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:Resource' :: Resource -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: Resource
s@Resource' {} Maybe (HashMap Text Text)
a -> Resource
s {$sel:tags:Resource' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: Resource) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Resource -> f Resource)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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 AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
resource_type :: Lens.Lens' Resource Prelude.Text
resource_type :: (Text -> f Text) -> Resource -> f Resource
resource_type = (Resource -> Text)
-> (Resource -> Text -> Resource)
-> Lens Resource Resource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Text
type' :: Text
$sel:type':Resource' :: Resource -> Text
type'} -> Text
type') (\s :: Resource
s@Resource' {} Text
a -> Resource
s {$sel:type':Resource' :: Text
type' = Text
a} :: Resource)
resource_id :: Lens.Lens' Resource Prelude.Text
resource_id :: (Text -> f Text) -> Resource -> f Resource
resource_id = (Resource -> Text)
-> (Resource -> Text -> Resource)
-> Lens Resource Resource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Text
id :: Text
$sel:id:Resource' :: Resource -> Text
id} -> Text
id) (\s :: Resource
s@Resource' {} Text
a -> Resource
s {$sel:id:Resource' :: Text
id = Text
a} :: Resource)
instance Core.FromJSON Resource where
parseJSON :: Value -> Parser Resource
parseJSON =
String -> (Object -> Parser Resource) -> Value -> Parser Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Resource"
( \Object
x ->
Maybe DataClassificationDetails
-> Maybe Partition
-> Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource
Resource'
(Maybe DataClassificationDetails
-> Maybe Partition
-> Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
-> Parser (Maybe DataClassificationDetails)
-> Parser
(Maybe Partition
-> Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DataClassificationDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataClassification")
Parser
(Maybe Partition
-> Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
-> Parser (Maybe Partition)
-> Parser
(Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Partition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Partition")
Parser
(Maybe ResourceDetails
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
-> Parser (Maybe ResourceDetails)
-> Parser
(Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Details")
Parser
(Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Resource)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> Maybe (HashMap Text Text) -> Text -> Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Region")
Parser
(Maybe Text
-> Maybe (HashMap Text Text) -> Text -> Text -> Resource)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> Text -> Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceRole")
Parser (Maybe (HashMap Text Text) -> Text -> Text -> Resource)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Text -> Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Tags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
Parser (Text -> Text -> Resource)
-> Parser Text -> Parser (Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
Parser (Text -> Resource) -> Parser Text -> Parser Resource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
)
instance Prelude.Hashable Resource
instance Prelude.NFData Resource
instance Core.ToJSON Resource where
toJSON :: Resource -> Value
toJSON Resource' {Maybe Text
Maybe (HashMap Text Text)
Maybe Partition
Maybe DataClassificationDetails
Maybe ResourceDetails
Text
id :: Text
type' :: Text
tags :: Maybe (HashMap Text Text)
resourceRole :: Maybe Text
region :: Maybe Text
details :: Maybe ResourceDetails
partition :: Maybe Partition
dataClassification :: Maybe DataClassificationDetails
$sel:id:Resource' :: Resource -> Text
$sel:type':Resource' :: Resource -> Text
$sel:tags:Resource' :: Resource -> Maybe (HashMap Text Text)
$sel:resourceRole:Resource' :: Resource -> Maybe Text
$sel:region:Resource' :: Resource -> Maybe Text
$sel:details:Resource' :: Resource -> Maybe ResourceDetails
$sel:partition:Resource' :: Resource -> Maybe Partition
$sel:dataClassification:Resource' :: Resource -> Maybe DataClassificationDetails
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DataClassification" Text -> DataClassificationDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(DataClassificationDetails -> Pair)
-> Maybe DataClassificationDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DataClassificationDetails
dataClassification,
(Text
"Partition" Text -> Partition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Partition -> Pair) -> Maybe Partition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Partition
partition,
(Text
"Details" Text -> ResourceDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ResourceDetails -> Pair) -> Maybe ResourceDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceDetails
details,
(Text
"Region" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
region,
(Text
"ResourceRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceRole,
(Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
]
)