{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetServiceGraph
-- 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)
--
-- Retrieves a document that describes services that process incoming
-- requests, and downstream services that they call as a result. Root
-- services process incoming requests and make calls to downstream
-- services. Root services are applications that use the
-- <https://docs.aws.amazon.com/xray/index.html Amazon Web Services X-Ray SDK>.
-- Downstream services can be other applications, Amazon Web Services
-- resources, HTTP web APIs, or SQL databases.
--
-- This operation returns paginated results.
module Amazonka.XRay.GetServiceGraph
  ( -- * Creating a Request
    GetServiceGraph (..),
    newGetServiceGraph,

    -- * Request Lenses
    getServiceGraph_nextToken,
    getServiceGraph_groupARN,
    getServiceGraph_groupName,
    getServiceGraph_startTime,
    getServiceGraph_endTime,

    -- * Destructuring the Response
    GetServiceGraphResponse (..),
    newGetServiceGraphResponse,

    -- * Response Lenses
    getServiceGraphResponse_containsOldGroupVersions,
    getServiceGraphResponse_startTime,
    getServiceGraphResponse_nextToken,
    getServiceGraphResponse_endTime,
    getServiceGraphResponse_services,
    getServiceGraphResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.XRay.Types

-- | /See:/ 'newGetServiceGraph' smart constructor.
data GetServiceGraph = GetServiceGraph'
  { -- | Pagination token.
    GetServiceGraph -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of a group based on which you want to
    -- generate a graph.
    GetServiceGraph -> Maybe Text
groupARN :: Prelude.Maybe Prelude.Text,
    -- | The name of a group based on which you want to generate a graph.
    GetServiceGraph -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | The start of the time frame for which to generate a graph.
    GetServiceGraph -> POSIX
startTime :: Core.POSIX,
    -- | The end of the timeframe for which to generate a graph.
    GetServiceGraph -> POSIX
endTime :: Core.POSIX
  }
  deriving (GetServiceGraph -> GetServiceGraph -> Bool
(GetServiceGraph -> GetServiceGraph -> Bool)
-> (GetServiceGraph -> GetServiceGraph -> Bool)
-> Eq GetServiceGraph
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceGraph -> GetServiceGraph -> Bool
$c/= :: GetServiceGraph -> GetServiceGraph -> Bool
== :: GetServiceGraph -> GetServiceGraph -> Bool
$c== :: GetServiceGraph -> GetServiceGraph -> Bool
Prelude.Eq, ReadPrec [GetServiceGraph]
ReadPrec GetServiceGraph
Int -> ReadS GetServiceGraph
ReadS [GetServiceGraph]
(Int -> ReadS GetServiceGraph)
-> ReadS [GetServiceGraph]
-> ReadPrec GetServiceGraph
-> ReadPrec [GetServiceGraph]
-> Read GetServiceGraph
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceGraph]
$creadListPrec :: ReadPrec [GetServiceGraph]
readPrec :: ReadPrec GetServiceGraph
$creadPrec :: ReadPrec GetServiceGraph
readList :: ReadS [GetServiceGraph]
$creadList :: ReadS [GetServiceGraph]
readsPrec :: Int -> ReadS GetServiceGraph
$creadsPrec :: Int -> ReadS GetServiceGraph
Prelude.Read, Int -> GetServiceGraph -> ShowS
[GetServiceGraph] -> ShowS
GetServiceGraph -> String
(Int -> GetServiceGraph -> ShowS)
-> (GetServiceGraph -> String)
-> ([GetServiceGraph] -> ShowS)
-> Show GetServiceGraph
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceGraph] -> ShowS
$cshowList :: [GetServiceGraph] -> ShowS
show :: GetServiceGraph -> String
$cshow :: GetServiceGraph -> String
showsPrec :: Int -> GetServiceGraph -> ShowS
$cshowsPrec :: Int -> GetServiceGraph -> ShowS
Prelude.Show, (forall x. GetServiceGraph -> Rep GetServiceGraph x)
-> (forall x. Rep GetServiceGraph x -> GetServiceGraph)
-> Generic GetServiceGraph
forall x. Rep GetServiceGraph x -> GetServiceGraph
forall x. GetServiceGraph -> Rep GetServiceGraph x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceGraph x -> GetServiceGraph
$cfrom :: forall x. GetServiceGraph -> Rep GetServiceGraph x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceGraph' 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:
--
-- 'nextToken', 'getServiceGraph_nextToken' - Pagination token.
--
-- 'groupARN', 'getServiceGraph_groupARN' - The Amazon Resource Name (ARN) of a group based on which you want to
-- generate a graph.
--
-- 'groupName', 'getServiceGraph_groupName' - The name of a group based on which you want to generate a graph.
--
-- 'startTime', 'getServiceGraph_startTime' - The start of the time frame for which to generate a graph.
--
-- 'endTime', 'getServiceGraph_endTime' - The end of the timeframe for which to generate a graph.
newGetServiceGraph ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  GetServiceGraph
newGetServiceGraph :: UTCTime -> UTCTime -> GetServiceGraph
newGetServiceGraph UTCTime
pStartTime_ UTCTime
pEndTime_ =
  GetServiceGraph' :: Maybe Text
-> Maybe Text -> Maybe Text -> POSIX -> POSIX -> GetServiceGraph
GetServiceGraph'
    { $sel:nextToken:GetServiceGraph' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupARN:GetServiceGraph' :: Maybe Text
groupARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:GetServiceGraph' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:GetServiceGraph' :: POSIX
startTime = 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
pStartTime_,
      $sel:endTime:GetServiceGraph' :: POSIX
endTime = 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
pEndTime_
    }

-- | Pagination token.
getServiceGraph_nextToken :: Lens.Lens' GetServiceGraph (Prelude.Maybe Prelude.Text)
getServiceGraph_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetServiceGraph -> f GetServiceGraph
getServiceGraph_nextToken = (GetServiceGraph -> Maybe Text)
-> (GetServiceGraph -> Maybe Text -> GetServiceGraph)
-> Lens GetServiceGraph GetServiceGraph (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraph' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetServiceGraph' :: GetServiceGraph -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetServiceGraph
s@GetServiceGraph' {} Maybe Text
a -> GetServiceGraph
s {$sel:nextToken:GetServiceGraph' :: Maybe Text
nextToken = Maybe Text
a} :: GetServiceGraph)

-- | The Amazon Resource Name (ARN) of a group based on which you want to
-- generate a graph.
getServiceGraph_groupARN :: Lens.Lens' GetServiceGraph (Prelude.Maybe Prelude.Text)
getServiceGraph_groupARN :: (Maybe Text -> f (Maybe Text))
-> GetServiceGraph -> f GetServiceGraph
getServiceGraph_groupARN = (GetServiceGraph -> Maybe Text)
-> (GetServiceGraph -> Maybe Text -> GetServiceGraph)
-> Lens GetServiceGraph GetServiceGraph (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraph' {Maybe Text
groupARN :: Maybe Text
$sel:groupARN:GetServiceGraph' :: GetServiceGraph -> Maybe Text
groupARN} -> Maybe Text
groupARN) (\s :: GetServiceGraph
s@GetServiceGraph' {} Maybe Text
a -> GetServiceGraph
s {$sel:groupARN:GetServiceGraph' :: Maybe Text
groupARN = Maybe Text
a} :: GetServiceGraph)

-- | The name of a group based on which you want to generate a graph.
getServiceGraph_groupName :: Lens.Lens' GetServiceGraph (Prelude.Maybe Prelude.Text)
getServiceGraph_groupName :: (Maybe Text -> f (Maybe Text))
-> GetServiceGraph -> f GetServiceGraph
getServiceGraph_groupName = (GetServiceGraph -> Maybe Text)
-> (GetServiceGraph -> Maybe Text -> GetServiceGraph)
-> Lens GetServiceGraph GetServiceGraph (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraph' {Maybe Text
groupName :: Maybe Text
$sel:groupName:GetServiceGraph' :: GetServiceGraph -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: GetServiceGraph
s@GetServiceGraph' {} Maybe Text
a -> GetServiceGraph
s {$sel:groupName:GetServiceGraph' :: Maybe Text
groupName = Maybe Text
a} :: GetServiceGraph)

-- | The start of the time frame for which to generate a graph.
getServiceGraph_startTime :: Lens.Lens' GetServiceGraph Prelude.UTCTime
getServiceGraph_startTime :: (UTCTime -> f UTCTime) -> GetServiceGraph -> f GetServiceGraph
getServiceGraph_startTime = (GetServiceGraph -> POSIX)
-> (GetServiceGraph -> POSIX -> GetServiceGraph)
-> Lens GetServiceGraph GetServiceGraph POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraph' {POSIX
startTime :: POSIX
$sel:startTime:GetServiceGraph' :: GetServiceGraph -> POSIX
startTime} -> POSIX
startTime) (\s :: GetServiceGraph
s@GetServiceGraph' {} POSIX
a -> GetServiceGraph
s {$sel:startTime:GetServiceGraph' :: POSIX
startTime = POSIX
a} :: GetServiceGraph) ((POSIX -> f POSIX) -> GetServiceGraph -> f GetServiceGraph)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetServiceGraph
-> f GetServiceGraph
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

-- | The end of the timeframe for which to generate a graph.
getServiceGraph_endTime :: Lens.Lens' GetServiceGraph Prelude.UTCTime
getServiceGraph_endTime :: (UTCTime -> f UTCTime) -> GetServiceGraph -> f GetServiceGraph
getServiceGraph_endTime = (GetServiceGraph -> POSIX)
-> (GetServiceGraph -> POSIX -> GetServiceGraph)
-> Lens GetServiceGraph GetServiceGraph POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraph' {POSIX
endTime :: POSIX
$sel:endTime:GetServiceGraph' :: GetServiceGraph -> POSIX
endTime} -> POSIX
endTime) (\s :: GetServiceGraph
s@GetServiceGraph' {} POSIX
a -> GetServiceGraph
s {$sel:endTime:GetServiceGraph' :: POSIX
endTime = POSIX
a} :: GetServiceGraph) ((POSIX -> f POSIX) -> GetServiceGraph -> f GetServiceGraph)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> GetServiceGraph
-> f GetServiceGraph
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.AWSPager GetServiceGraph where
  page :: GetServiceGraph
-> AWSResponse GetServiceGraph -> Maybe GetServiceGraph
page GetServiceGraph
rq AWSResponse GetServiceGraph
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetServiceGraph
GetServiceGraphResponse
rs
            GetServiceGraphResponse
-> Getting (First Text) GetServiceGraphResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetServiceGraphResponse
-> Const (First Text) GetServiceGraphResponse
Lens' GetServiceGraphResponse (Maybe Text)
getServiceGraphResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetServiceGraphResponse
 -> Const (First Text) GetServiceGraphResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetServiceGraphResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetServiceGraph
forall a. Maybe a
Prelude.Nothing
    | Maybe [ServiceInfo] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetServiceGraph
GetServiceGraphResponse
rs
            GetServiceGraphResponse
-> Getting
     (First [ServiceInfo]) GetServiceGraphResponse [ServiceInfo]
-> Maybe [ServiceInfo]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ServiceInfo]
 -> Const (First [ServiceInfo]) (Maybe [ServiceInfo]))
-> GetServiceGraphResponse
-> Const (First [ServiceInfo]) GetServiceGraphResponse
Lens' GetServiceGraphResponse (Maybe [ServiceInfo])
getServiceGraphResponse_services
              ((Maybe [ServiceInfo]
  -> Const (First [ServiceInfo]) (Maybe [ServiceInfo]))
 -> GetServiceGraphResponse
 -> Const (First [ServiceInfo]) GetServiceGraphResponse)
-> (([ServiceInfo] -> Const (First [ServiceInfo]) [ServiceInfo])
    -> Maybe [ServiceInfo]
    -> Const (First [ServiceInfo]) (Maybe [ServiceInfo]))
-> Getting
     (First [ServiceInfo]) GetServiceGraphResponse [ServiceInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ServiceInfo] -> Const (First [ServiceInfo]) [ServiceInfo])
-> Maybe [ServiceInfo]
-> Const (First [ServiceInfo]) (Maybe [ServiceInfo])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetServiceGraph
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetServiceGraph -> Maybe GetServiceGraph
forall a. a -> Maybe a
Prelude.Just (GetServiceGraph -> Maybe GetServiceGraph)
-> GetServiceGraph -> Maybe GetServiceGraph
forall a b. (a -> b) -> a -> b
Prelude.$
        GetServiceGraph
rq
          GetServiceGraph
-> (GetServiceGraph -> GetServiceGraph) -> GetServiceGraph
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetServiceGraph -> Identity GetServiceGraph
Lens GetServiceGraph GetServiceGraph (Maybe Text) (Maybe Text)
getServiceGraph_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetServiceGraph -> Identity GetServiceGraph)
-> Maybe Text -> GetServiceGraph -> GetServiceGraph
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetServiceGraph
GetServiceGraphResponse
rs
          GetServiceGraphResponse
-> Getting (First Text) GetServiceGraphResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetServiceGraphResponse
-> Const (First Text) GetServiceGraphResponse
Lens' GetServiceGraphResponse (Maybe Text)
getServiceGraphResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetServiceGraphResponse
 -> Const (First Text) GetServiceGraphResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetServiceGraphResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetServiceGraph where
  type
    AWSResponse GetServiceGraph =
      GetServiceGraphResponse
  request :: GetServiceGraph -> Request GetServiceGraph
request = Service -> GetServiceGraph -> Request GetServiceGraph
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetServiceGraph
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetServiceGraph)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetServiceGraph))
-> Logger
-> Service
-> Proxy GetServiceGraph
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetServiceGraph)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Bool
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe [ServiceInfo]
-> Int
-> GetServiceGraphResponse
GetServiceGraphResponse'
            (Maybe Bool
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe [ServiceInfo]
 -> Int
 -> GetServiceGraphResponse)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [ServiceInfo]
      -> Int
      -> GetServiceGraphResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContainsOldGroupVersions")
            Either
  String
  (Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [ServiceInfo]
   -> Int
   -> GetServiceGraphResponse)
-> Either String (Maybe POSIX)
-> Either
     String
     (Maybe Text
      -> Maybe POSIX
      -> Maybe [ServiceInfo]
      -> Int
      -> GetServiceGraphResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StartTime")
            Either
  String
  (Maybe Text
   -> Maybe POSIX
   -> Maybe [ServiceInfo]
   -> Int
   -> GetServiceGraphResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe POSIX
      -> Maybe [ServiceInfo] -> Int -> GetServiceGraphResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either
  String
  (Maybe POSIX
   -> Maybe [ServiceInfo] -> Int -> GetServiceGraphResponse)
-> Either String (Maybe POSIX)
-> Either
     String (Maybe [ServiceInfo] -> Int -> GetServiceGraphResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EndTime")
            Either
  String (Maybe [ServiceInfo] -> Int -> GetServiceGraphResponse)
-> Either String (Maybe [ServiceInfo])
-> Either String (Int -> GetServiceGraphResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [ServiceInfo]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Services" Either String (Maybe (Maybe [ServiceInfo]))
-> Maybe [ServiceInfo] -> Either String (Maybe [ServiceInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ServiceInfo]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetServiceGraphResponse)
-> Either String Int -> Either String GetServiceGraphResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetServiceGraph

instance Prelude.NFData GetServiceGraph

instance Core.ToHeaders GetServiceGraph where
  toHeaders :: GetServiceGraph -> ResponseHeaders
toHeaders = ResponseHeaders -> GetServiceGraph -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON GetServiceGraph where
  toJSON :: GetServiceGraph -> Value
toJSON GetServiceGraph' {Maybe Text
POSIX
endTime :: POSIX
startTime :: POSIX
groupName :: Maybe Text
groupARN :: Maybe Text
nextToken :: Maybe Text
$sel:endTime:GetServiceGraph' :: GetServiceGraph -> POSIX
$sel:startTime:GetServiceGraph' :: GetServiceGraph -> POSIX
$sel:groupName:GetServiceGraph' :: GetServiceGraph -> Maybe Text
$sel:groupARN:GetServiceGraph' :: GetServiceGraph -> Maybe Text
$sel:nextToken:GetServiceGraph' :: GetServiceGraph -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" 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
nextToken,
            (Text
"GroupARN" 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
groupARN,
            (Text
"GroupName" 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
groupName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StartTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime)
          ]
      )

instance Core.ToPath GetServiceGraph where
  toPath :: GetServiceGraph -> ByteString
toPath = ByteString -> GetServiceGraph -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/ServiceGraph"

instance Core.ToQuery GetServiceGraph where
  toQuery :: GetServiceGraph -> QueryString
toQuery = QueryString -> GetServiceGraph -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetServiceGraphResponse' smart constructor.
data GetServiceGraphResponse = GetServiceGraphResponse'
  { -- | A flag indicating whether the group\'s filter expression has been
    -- consistent, or if the returned service graph may show traces from an
    -- older version of the group\'s filter expression.
    GetServiceGraphResponse -> Maybe Bool
containsOldGroupVersions :: Prelude.Maybe Prelude.Bool,
    -- | The start of the time frame for which the graph was generated.
    GetServiceGraphResponse -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | Pagination token.
    GetServiceGraphResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The end of the time frame for which the graph was generated.
    GetServiceGraphResponse -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | The services that have processed a traced request during the specified
    -- time frame.
    GetServiceGraphResponse -> Maybe [ServiceInfo]
services :: Prelude.Maybe [ServiceInfo],
    -- | The response's http status code.
    GetServiceGraphResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetServiceGraphResponse -> GetServiceGraphResponse -> Bool
(GetServiceGraphResponse -> GetServiceGraphResponse -> Bool)
-> (GetServiceGraphResponse -> GetServiceGraphResponse -> Bool)
-> Eq GetServiceGraphResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceGraphResponse -> GetServiceGraphResponse -> Bool
$c/= :: GetServiceGraphResponse -> GetServiceGraphResponse -> Bool
== :: GetServiceGraphResponse -> GetServiceGraphResponse -> Bool
$c== :: GetServiceGraphResponse -> GetServiceGraphResponse -> Bool
Prelude.Eq, ReadPrec [GetServiceGraphResponse]
ReadPrec GetServiceGraphResponse
Int -> ReadS GetServiceGraphResponse
ReadS [GetServiceGraphResponse]
(Int -> ReadS GetServiceGraphResponse)
-> ReadS [GetServiceGraphResponse]
-> ReadPrec GetServiceGraphResponse
-> ReadPrec [GetServiceGraphResponse]
-> Read GetServiceGraphResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceGraphResponse]
$creadListPrec :: ReadPrec [GetServiceGraphResponse]
readPrec :: ReadPrec GetServiceGraphResponse
$creadPrec :: ReadPrec GetServiceGraphResponse
readList :: ReadS [GetServiceGraphResponse]
$creadList :: ReadS [GetServiceGraphResponse]
readsPrec :: Int -> ReadS GetServiceGraphResponse
$creadsPrec :: Int -> ReadS GetServiceGraphResponse
Prelude.Read, Int -> GetServiceGraphResponse -> ShowS
[GetServiceGraphResponse] -> ShowS
GetServiceGraphResponse -> String
(Int -> GetServiceGraphResponse -> ShowS)
-> (GetServiceGraphResponse -> String)
-> ([GetServiceGraphResponse] -> ShowS)
-> Show GetServiceGraphResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceGraphResponse] -> ShowS
$cshowList :: [GetServiceGraphResponse] -> ShowS
show :: GetServiceGraphResponse -> String
$cshow :: GetServiceGraphResponse -> String
showsPrec :: Int -> GetServiceGraphResponse -> ShowS
$cshowsPrec :: Int -> GetServiceGraphResponse -> ShowS
Prelude.Show, (forall x.
 GetServiceGraphResponse -> Rep GetServiceGraphResponse x)
-> (forall x.
    Rep GetServiceGraphResponse x -> GetServiceGraphResponse)
-> Generic GetServiceGraphResponse
forall x. Rep GetServiceGraphResponse x -> GetServiceGraphResponse
forall x. GetServiceGraphResponse -> Rep GetServiceGraphResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceGraphResponse x -> GetServiceGraphResponse
$cfrom :: forall x. GetServiceGraphResponse -> Rep GetServiceGraphResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceGraphResponse' 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:
--
-- 'containsOldGroupVersions', 'getServiceGraphResponse_containsOldGroupVersions' - A flag indicating whether the group\'s filter expression has been
-- consistent, or if the returned service graph may show traces from an
-- older version of the group\'s filter expression.
--
-- 'startTime', 'getServiceGraphResponse_startTime' - The start of the time frame for which the graph was generated.
--
-- 'nextToken', 'getServiceGraphResponse_nextToken' - Pagination token.
--
-- 'endTime', 'getServiceGraphResponse_endTime' - The end of the time frame for which the graph was generated.
--
-- 'services', 'getServiceGraphResponse_services' - The services that have processed a traced request during the specified
-- time frame.
--
-- 'httpStatus', 'getServiceGraphResponse_httpStatus' - The response's http status code.
newGetServiceGraphResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceGraphResponse
newGetServiceGraphResponse :: Int -> GetServiceGraphResponse
newGetServiceGraphResponse Int
pHttpStatus_ =
  GetServiceGraphResponse' :: Maybe Bool
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe [ServiceInfo]
-> Int
-> GetServiceGraphResponse
GetServiceGraphResponse'
    { $sel:containsOldGroupVersions:GetServiceGraphResponse' :: Maybe Bool
containsOldGroupVersions =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:GetServiceGraphResponse' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetServiceGraphResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:GetServiceGraphResponse' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:services:GetServiceGraphResponse' :: Maybe [ServiceInfo]
services = Maybe [ServiceInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceGraphResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A flag indicating whether the group\'s filter expression has been
-- consistent, or if the returned service graph may show traces from an
-- older version of the group\'s filter expression.
getServiceGraphResponse_containsOldGroupVersions :: Lens.Lens' GetServiceGraphResponse (Prelude.Maybe Prelude.Bool)
getServiceGraphResponse_containsOldGroupVersions :: (Maybe Bool -> f (Maybe Bool))
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_containsOldGroupVersions = (GetServiceGraphResponse -> Maybe Bool)
-> (GetServiceGraphResponse
    -> Maybe Bool -> GetServiceGraphResponse)
-> Lens
     GetServiceGraphResponse
     GetServiceGraphResponse
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Maybe Bool
containsOldGroupVersions :: Maybe Bool
$sel:containsOldGroupVersions:GetServiceGraphResponse' :: GetServiceGraphResponse -> Maybe Bool
containsOldGroupVersions} -> Maybe Bool
containsOldGroupVersions) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Maybe Bool
a -> GetServiceGraphResponse
s {$sel:containsOldGroupVersions:GetServiceGraphResponse' :: Maybe Bool
containsOldGroupVersions = Maybe Bool
a} :: GetServiceGraphResponse)

-- | The start of the time frame for which the graph was generated.
getServiceGraphResponse_startTime :: Lens.Lens' GetServiceGraphResponse (Prelude.Maybe Prelude.UTCTime)
getServiceGraphResponse_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_startTime = (GetServiceGraphResponse -> Maybe POSIX)
-> (GetServiceGraphResponse
    -> Maybe POSIX -> GetServiceGraphResponse)
-> Lens
     GetServiceGraphResponse
     GetServiceGraphResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:GetServiceGraphResponse' :: GetServiceGraphResponse -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Maybe POSIX
a -> GetServiceGraphResponse
s {$sel:startTime:GetServiceGraphResponse' :: Maybe POSIX
startTime = Maybe POSIX
a} :: GetServiceGraphResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetServiceGraphResponse -> f GetServiceGraphResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetServiceGraphResponse
-> f GetServiceGraphResponse
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

-- | Pagination token.
getServiceGraphResponse_nextToken :: Lens.Lens' GetServiceGraphResponse (Prelude.Maybe Prelude.Text)
getServiceGraphResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_nextToken = (GetServiceGraphResponse -> Maybe Text)
-> (GetServiceGraphResponse
    -> Maybe Text -> GetServiceGraphResponse)
-> Lens' GetServiceGraphResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetServiceGraphResponse' :: GetServiceGraphResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Maybe Text
a -> GetServiceGraphResponse
s {$sel:nextToken:GetServiceGraphResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetServiceGraphResponse)

-- | The end of the time frame for which the graph was generated.
getServiceGraphResponse_endTime :: Lens.Lens' GetServiceGraphResponse (Prelude.Maybe Prelude.UTCTime)
getServiceGraphResponse_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_endTime = (GetServiceGraphResponse -> Maybe POSIX)
-> (GetServiceGraphResponse
    -> Maybe POSIX -> GetServiceGraphResponse)
-> Lens
     GetServiceGraphResponse
     GetServiceGraphResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:GetServiceGraphResponse' :: GetServiceGraphResponse -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Maybe POSIX
a -> GetServiceGraphResponse
s {$sel:endTime:GetServiceGraphResponse' :: Maybe POSIX
endTime = Maybe POSIX
a} :: GetServiceGraphResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetServiceGraphResponse -> f GetServiceGraphResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetServiceGraphResponse
-> f GetServiceGraphResponse
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

-- | The services that have processed a traced request during the specified
-- time frame.
getServiceGraphResponse_services :: Lens.Lens' GetServiceGraphResponse (Prelude.Maybe [ServiceInfo])
getServiceGraphResponse_services :: (Maybe [ServiceInfo] -> f (Maybe [ServiceInfo]))
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_services = (GetServiceGraphResponse -> Maybe [ServiceInfo])
-> (GetServiceGraphResponse
    -> Maybe [ServiceInfo] -> GetServiceGraphResponse)
-> Lens' GetServiceGraphResponse (Maybe [ServiceInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Maybe [ServiceInfo]
services :: Maybe [ServiceInfo]
$sel:services:GetServiceGraphResponse' :: GetServiceGraphResponse -> Maybe [ServiceInfo]
services} -> Maybe [ServiceInfo]
services) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Maybe [ServiceInfo]
a -> GetServiceGraphResponse
s {$sel:services:GetServiceGraphResponse' :: Maybe [ServiceInfo]
services = Maybe [ServiceInfo]
a} :: GetServiceGraphResponse) ((Maybe [ServiceInfo] -> f (Maybe [ServiceInfo]))
 -> GetServiceGraphResponse -> f GetServiceGraphResponse)
-> ((Maybe [ServiceInfo] -> f (Maybe [ServiceInfo]))
    -> Maybe [ServiceInfo] -> f (Maybe [ServiceInfo]))
-> (Maybe [ServiceInfo] -> f (Maybe [ServiceInfo]))
-> GetServiceGraphResponse
-> f GetServiceGraphResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ServiceInfo] [ServiceInfo] [ServiceInfo] [ServiceInfo]
-> Iso
     (Maybe [ServiceInfo])
     (Maybe [ServiceInfo])
     (Maybe [ServiceInfo])
     (Maybe [ServiceInfo])
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 [ServiceInfo] [ServiceInfo] [ServiceInfo] [ServiceInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getServiceGraphResponse_httpStatus :: Lens.Lens' GetServiceGraphResponse Prelude.Int
getServiceGraphResponse_httpStatus :: (Int -> f Int)
-> GetServiceGraphResponse -> f GetServiceGraphResponse
getServiceGraphResponse_httpStatus = (GetServiceGraphResponse -> Int)
-> (GetServiceGraphResponse -> Int -> GetServiceGraphResponse)
-> Lens GetServiceGraphResponse GetServiceGraphResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceGraphResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetServiceGraphResponse' :: GetServiceGraphResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetServiceGraphResponse
s@GetServiceGraphResponse' {} Int
a -> GetServiceGraphResponse
s {$sel:httpStatus:GetServiceGraphResponse' :: Int
httpStatus = Int
a} :: GetServiceGraphResponse)

instance Prelude.NFData GetServiceGraphResponse