{-# 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.Detective.Types.Graph
-- 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.Detective.Types.Graph where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A behavior graph in Detective.
--
-- /See:/ 'newGraph' smart constructor.
data Graph = Graph'
  { -- | The ARN of the behavior graph.
    Graph -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the behavior graph was created. The value is in
    -- milliseconds since the epoch.
    Graph -> Maybe POSIX
createdTime :: Prelude.Maybe Core.POSIX
  }
  deriving (Graph -> Graph -> Bool
(Graph -> Graph -> Bool) -> (Graph -> Graph -> Bool) -> Eq Graph
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Graph -> Graph -> Bool
$c/= :: Graph -> Graph -> Bool
== :: Graph -> Graph -> Bool
$c== :: Graph -> Graph -> Bool
Prelude.Eq, ReadPrec [Graph]
ReadPrec Graph
Int -> ReadS Graph
ReadS [Graph]
(Int -> ReadS Graph)
-> ReadS [Graph]
-> ReadPrec Graph
-> ReadPrec [Graph]
-> Read Graph
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Graph]
$creadListPrec :: ReadPrec [Graph]
readPrec :: ReadPrec Graph
$creadPrec :: ReadPrec Graph
readList :: ReadS [Graph]
$creadList :: ReadS [Graph]
readsPrec :: Int -> ReadS Graph
$creadsPrec :: Int -> ReadS Graph
Prelude.Read, Int -> Graph -> ShowS
[Graph] -> ShowS
Graph -> String
(Int -> Graph -> ShowS)
-> (Graph -> String) -> ([Graph] -> ShowS) -> Show Graph
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Graph] -> ShowS
$cshowList :: [Graph] -> ShowS
show :: Graph -> String
$cshow :: Graph -> String
showsPrec :: Int -> Graph -> ShowS
$cshowsPrec :: Int -> Graph -> ShowS
Prelude.Show, (forall x. Graph -> Rep Graph x)
-> (forall x. Rep Graph x -> Graph) -> Generic Graph
forall x. Rep Graph x -> Graph
forall x. Graph -> Rep Graph x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Graph x -> Graph
$cfrom :: forall x. Graph -> Rep Graph x
Prelude.Generic)

-- |
-- Create a value of 'Graph' 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', 'graph_arn' - The ARN of the behavior graph.
--
-- 'createdTime', 'graph_createdTime' - The date and time that the behavior graph was created. The value is in
-- milliseconds since the epoch.
newGraph ::
  Graph
newGraph :: Graph
newGraph =
  Graph' :: Maybe Text -> Maybe POSIX -> Graph
Graph'
    { $sel:arn:Graph' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTime:Graph' :: Maybe POSIX
createdTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the behavior graph.
graph_arn :: Lens.Lens' Graph (Prelude.Maybe Prelude.Text)
graph_arn :: (Maybe Text -> f (Maybe Text)) -> Graph -> f Graph
graph_arn = (Graph -> Maybe Text)
-> (Graph -> Maybe Text -> Graph)
-> Lens Graph Graph (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Graph' {Maybe Text
arn :: Maybe Text
$sel:arn:Graph' :: Graph -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Graph
s@Graph' {} Maybe Text
a -> Graph
s {$sel:arn:Graph' :: Maybe Text
arn = Maybe Text
a} :: Graph)

-- | The date and time that the behavior graph was created. The value is in
-- milliseconds since the epoch.
graph_createdTime :: Lens.Lens' Graph (Prelude.Maybe Prelude.UTCTime)
graph_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Graph -> f Graph
graph_createdTime = (Graph -> Maybe POSIX)
-> (Graph -> Maybe POSIX -> Graph)
-> Lens Graph Graph (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Graph' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:Graph' :: Graph -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: Graph
s@Graph' {} Maybe POSIX
a -> Graph
s {$sel:createdTime:Graph' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: Graph) ((Maybe POSIX -> f (Maybe POSIX)) -> Graph -> f Graph)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Graph
-> f Graph
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Graph where
  parseJSON :: Value -> Parser Graph
parseJSON =
    String -> (Object -> Parser Graph) -> Value -> Parser Graph
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Graph"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Graph
Graph'
            (Maybe Text -> Maybe POSIX -> Graph)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> Graph)
forall (f :: * -> *) a b. Functor 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
"Arn")
            Parser (Maybe POSIX -> Graph)
-> Parser (Maybe POSIX) -> Parser Graph
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedTime")
      )

instance Prelude.Hashable Graph

instance Prelude.NFData Graph