{-# 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.XRay.Types.Edge
-- 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.XRay.Types.Edge where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.Alias
import Amazonka.XRay.Types.EdgeStatistics
import Amazonka.XRay.Types.HistogramEntry

-- | Information about a connection between two services.
--
-- /See:/ 'newEdge' smart constructor.
data Edge = Edge'
  { -- | The start time of the first segment on the edge.
    Edge -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | Aliases for the edge.
    Edge -> Maybe [Alias]
aliases :: Prelude.Maybe [Alias],
    -- | A histogram that maps the spread of client response times on an edge.
    Edge -> Maybe [HistogramEntry]
responseTimeHistogram :: Prelude.Maybe [HistogramEntry],
    -- | Identifier of the edge. Unique within a service map.
    Edge -> Maybe Int
referenceId :: Prelude.Maybe Prelude.Int,
    -- | The end time of the last segment on the edge.
    Edge -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | Response statistics for segments on the edge.
    Edge -> Maybe EdgeStatistics
summaryStatistics :: Prelude.Maybe EdgeStatistics
  }
  deriving (Edge -> Edge -> Bool
(Edge -> Edge -> Bool) -> (Edge -> Edge -> Bool) -> Eq Edge
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Edge -> Edge -> Bool
$c/= :: Edge -> Edge -> Bool
== :: Edge -> Edge -> Bool
$c== :: Edge -> Edge -> Bool
Prelude.Eq, ReadPrec [Edge]
ReadPrec Edge
Int -> ReadS Edge
ReadS [Edge]
(Int -> ReadS Edge)
-> ReadS [Edge] -> ReadPrec Edge -> ReadPrec [Edge] -> Read Edge
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Edge]
$creadListPrec :: ReadPrec [Edge]
readPrec :: ReadPrec Edge
$creadPrec :: ReadPrec Edge
readList :: ReadS [Edge]
$creadList :: ReadS [Edge]
readsPrec :: Int -> ReadS Edge
$creadsPrec :: Int -> ReadS Edge
Prelude.Read, Int -> Edge -> ShowS
[Edge] -> ShowS
Edge -> String
(Int -> Edge -> ShowS)
-> (Edge -> String) -> ([Edge] -> ShowS) -> Show Edge
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Edge] -> ShowS
$cshowList :: [Edge] -> ShowS
show :: Edge -> String
$cshow :: Edge -> String
showsPrec :: Int -> Edge -> ShowS
$cshowsPrec :: Int -> Edge -> ShowS
Prelude.Show, (forall x. Edge -> Rep Edge x)
-> (forall x. Rep Edge x -> Edge) -> Generic Edge
forall x. Rep Edge x -> Edge
forall x. Edge -> Rep Edge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Edge x -> Edge
$cfrom :: forall x. Edge -> Rep Edge x
Prelude.Generic)

-- |
-- Create a value of 'Edge' 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:
--
-- 'startTime', 'edge_startTime' - The start time of the first segment on the edge.
--
-- 'aliases', 'edge_aliases' - Aliases for the edge.
--
-- 'responseTimeHistogram', 'edge_responseTimeHistogram' - A histogram that maps the spread of client response times on an edge.
--
-- 'referenceId', 'edge_referenceId' - Identifier of the edge. Unique within a service map.
--
-- 'endTime', 'edge_endTime' - The end time of the last segment on the edge.
--
-- 'summaryStatistics', 'edge_summaryStatistics' - Response statistics for segments on the edge.
newEdge ::
  Edge
newEdge :: Edge
newEdge =
  Edge' :: Maybe POSIX
-> Maybe [Alias]
-> Maybe [HistogramEntry]
-> Maybe Int
-> Maybe POSIX
-> Maybe EdgeStatistics
-> Edge
Edge'
    { $sel:startTime:Edge' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:aliases:Edge' :: Maybe [Alias]
aliases = Maybe [Alias]
forall a. Maybe a
Prelude.Nothing,
      $sel:responseTimeHistogram:Edge' :: Maybe [HistogramEntry]
responseTimeHistogram = Maybe [HistogramEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:referenceId:Edge' :: Maybe Int
referenceId = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:Edge' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:summaryStatistics:Edge' :: Maybe EdgeStatistics
summaryStatistics = Maybe EdgeStatistics
forall a. Maybe a
Prelude.Nothing
    }

-- | The start time of the first segment on the edge.
edge_startTime :: Lens.Lens' Edge (Prelude.Maybe Prelude.UTCTime)
edge_startTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Edge -> f Edge
edge_startTime = (Edge -> Maybe POSIX)
-> (Edge -> Maybe POSIX -> Edge)
-> Lens Edge Edge (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:Edge' :: Edge -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: Edge
s@Edge' {} Maybe POSIX
a -> Edge
s {$sel:startTime:Edge' :: Maybe POSIX
startTime = Maybe POSIX
a} :: Edge) ((Maybe POSIX -> f (Maybe POSIX)) -> Edge -> f Edge)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Edge
-> f Edge
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

-- | Aliases for the edge.
edge_aliases :: Lens.Lens' Edge (Prelude.Maybe [Alias])
edge_aliases :: (Maybe [Alias] -> f (Maybe [Alias])) -> Edge -> f Edge
edge_aliases = (Edge -> Maybe [Alias])
-> (Edge -> Maybe [Alias] -> Edge)
-> Lens Edge Edge (Maybe [Alias]) (Maybe [Alias])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe [Alias]
aliases :: Maybe [Alias]
$sel:aliases:Edge' :: Edge -> Maybe [Alias]
aliases} -> Maybe [Alias]
aliases) (\s :: Edge
s@Edge' {} Maybe [Alias]
a -> Edge
s {$sel:aliases:Edge' :: Maybe [Alias]
aliases = Maybe [Alias]
a} :: Edge) ((Maybe [Alias] -> f (Maybe [Alias])) -> Edge -> f Edge)
-> ((Maybe [Alias] -> f (Maybe [Alias]))
    -> Maybe [Alias] -> f (Maybe [Alias]))
-> (Maybe [Alias] -> f (Maybe [Alias]))
-> Edge
-> f Edge
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Alias] [Alias] [Alias] [Alias]
-> Iso
     (Maybe [Alias]) (Maybe [Alias]) (Maybe [Alias]) (Maybe [Alias])
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 [Alias] [Alias] [Alias] [Alias]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A histogram that maps the spread of client response times on an edge.
edge_responseTimeHistogram :: Lens.Lens' Edge (Prelude.Maybe [HistogramEntry])
edge_responseTimeHistogram :: (Maybe [HistogramEntry] -> f (Maybe [HistogramEntry]))
-> Edge -> f Edge
edge_responseTimeHistogram = (Edge -> Maybe [HistogramEntry])
-> (Edge -> Maybe [HistogramEntry] -> Edge)
-> Lens Edge Edge (Maybe [HistogramEntry]) (Maybe [HistogramEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe [HistogramEntry]
responseTimeHistogram :: Maybe [HistogramEntry]
$sel:responseTimeHistogram:Edge' :: Edge -> Maybe [HistogramEntry]
responseTimeHistogram} -> Maybe [HistogramEntry]
responseTimeHistogram) (\s :: Edge
s@Edge' {} Maybe [HistogramEntry]
a -> Edge
s {$sel:responseTimeHistogram:Edge' :: Maybe [HistogramEntry]
responseTimeHistogram = Maybe [HistogramEntry]
a} :: Edge) ((Maybe [HistogramEntry] -> f (Maybe [HistogramEntry]))
 -> Edge -> f Edge)
-> ((Maybe [HistogramEntry] -> f (Maybe [HistogramEntry]))
    -> Maybe [HistogramEntry] -> f (Maybe [HistogramEntry]))
-> (Maybe [HistogramEntry] -> f (Maybe [HistogramEntry]))
-> Edge
-> f Edge
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HistogramEntry] [HistogramEntry] [HistogramEntry] [HistogramEntry]
-> Iso
     (Maybe [HistogramEntry])
     (Maybe [HistogramEntry])
     (Maybe [HistogramEntry])
     (Maybe [HistogramEntry])
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
  [HistogramEntry] [HistogramEntry] [HistogramEntry] [HistogramEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Identifier of the edge. Unique within a service map.
edge_referenceId :: Lens.Lens' Edge (Prelude.Maybe Prelude.Int)
edge_referenceId :: (Maybe Int -> f (Maybe Int)) -> Edge -> f Edge
edge_referenceId = (Edge -> Maybe Int)
-> (Edge -> Maybe Int -> Edge)
-> Lens Edge Edge (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe Int
referenceId :: Maybe Int
$sel:referenceId:Edge' :: Edge -> Maybe Int
referenceId} -> Maybe Int
referenceId) (\s :: Edge
s@Edge' {} Maybe Int
a -> Edge
s {$sel:referenceId:Edge' :: Maybe Int
referenceId = Maybe Int
a} :: Edge)

-- | The end time of the last segment on the edge.
edge_endTime :: Lens.Lens' Edge (Prelude.Maybe Prelude.UTCTime)
edge_endTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Edge -> f Edge
edge_endTime = (Edge -> Maybe POSIX)
-> (Edge -> Maybe POSIX -> Edge)
-> Lens Edge Edge (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:Edge' :: Edge -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: Edge
s@Edge' {} Maybe POSIX
a -> Edge
s {$sel:endTime:Edge' :: Maybe POSIX
endTime = Maybe POSIX
a} :: Edge) ((Maybe POSIX -> f (Maybe POSIX)) -> Edge -> f Edge)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Edge
-> f Edge
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

-- | Response statistics for segments on the edge.
edge_summaryStatistics :: Lens.Lens' Edge (Prelude.Maybe EdgeStatistics)
edge_summaryStatistics :: (Maybe EdgeStatistics -> f (Maybe EdgeStatistics))
-> Edge -> f Edge
edge_summaryStatistics = (Edge -> Maybe EdgeStatistics)
-> (Edge -> Maybe EdgeStatistics -> Edge)
-> Lens Edge Edge (Maybe EdgeStatistics) (Maybe EdgeStatistics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe EdgeStatistics
summaryStatistics :: Maybe EdgeStatistics
$sel:summaryStatistics:Edge' :: Edge -> Maybe EdgeStatistics
summaryStatistics} -> Maybe EdgeStatistics
summaryStatistics) (\s :: Edge
s@Edge' {} Maybe EdgeStatistics
a -> Edge
s {$sel:summaryStatistics:Edge' :: Maybe EdgeStatistics
summaryStatistics = Maybe EdgeStatistics
a} :: Edge)

instance Core.FromJSON Edge where
  parseJSON :: Value -> Parser Edge
parseJSON =
    String -> (Object -> Parser Edge) -> Value -> Parser Edge
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Edge"
      ( \Object
x ->
          Maybe POSIX
-> Maybe [Alias]
-> Maybe [HistogramEntry]
-> Maybe Int
-> Maybe POSIX
-> Maybe EdgeStatistics
-> Edge
Edge'
            (Maybe POSIX
 -> Maybe [Alias]
 -> Maybe [HistogramEntry]
 -> Maybe Int
 -> Maybe POSIX
 -> Maybe EdgeStatistics
 -> Edge)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [Alias]
      -> Maybe [HistogramEntry]
      -> Maybe Int
      -> Maybe POSIX
      -> Maybe EdgeStatistics
      -> Edge)
forall (f :: * -> *) a b. Functor 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
"StartTime")
            Parser
  (Maybe [Alias]
   -> Maybe [HistogramEntry]
   -> Maybe Int
   -> Maybe POSIX
   -> Maybe EdgeStatistics
   -> Edge)
-> Parser (Maybe [Alias])
-> Parser
     (Maybe [HistogramEntry]
      -> Maybe Int -> Maybe POSIX -> Maybe EdgeStatistics -> Edge)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Alias]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Aliases" Parser (Maybe (Maybe [Alias]))
-> Maybe [Alias] -> Parser (Maybe [Alias])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Alias]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [HistogramEntry]
   -> Maybe Int -> Maybe POSIX -> Maybe EdgeStatistics -> Edge)
-> Parser (Maybe [HistogramEntry])
-> Parser
     (Maybe Int -> Maybe POSIX -> Maybe EdgeStatistics -> Edge)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [HistogramEntry]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResponseTimeHistogram"
                            Parser (Maybe (Maybe [HistogramEntry]))
-> Maybe [HistogramEntry] -> Parser (Maybe [HistogramEntry])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [HistogramEntry]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Int -> Maybe POSIX -> Maybe EdgeStatistics -> Edge)
-> Parser (Maybe Int)
-> Parser (Maybe POSIX -> Maybe EdgeStatistics -> Edge)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReferenceId")
            Parser (Maybe POSIX -> Maybe EdgeStatistics -> Edge)
-> Parser (Maybe POSIX) -> Parser (Maybe EdgeStatistics -> Edge)
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
"EndTime")
            Parser (Maybe EdgeStatistics -> Edge)
-> Parser (Maybe EdgeStatistics) -> Parser Edge
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EdgeStatistics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SummaryStatistics")
      )

instance Prelude.Hashable Edge

instance Prelude.NFData Edge