{-# 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.Lightsail.GetContainerLog
-- 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)
--
-- Returns the log events of a container of your Amazon Lightsail container
-- service.
--
-- If your container service has more than one node (i.e., a scale greater
-- than 1), then the log events that are returned for the specified
-- container are merged from all nodes on your container service.
--
-- Container logs are retained for a certain amount of time. For more
-- information, see
-- <https://docs.aws.amazon.com/general/latest/gr/lightsail.html Amazon Lightsail endpoints and quotas>
-- in the /AWS General Reference/.
module Amazonka.Lightsail.GetContainerLog
  ( -- * Creating a Request
    GetContainerLog (..),
    newGetContainerLog,

    -- * Request Lenses
    getContainerLog_startTime,
    getContainerLog_endTime,
    getContainerLog_pageToken,
    getContainerLog_filterPattern,
    getContainerLog_serviceName,
    getContainerLog_containerName,

    -- * Destructuring the Response
    GetContainerLogResponse (..),
    newGetContainerLogResponse,

    -- * Response Lenses
    getContainerLogResponse_nextPageToken,
    getContainerLogResponse_logEvents,
    getContainerLogResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetContainerLog' smart constructor.
data GetContainerLog = GetContainerLog'
  { -- | The start of the time interval for which to get log data.
    --
    -- Constraints:
    --
    -- -   Specified in Coordinated Universal Time (UTC).
    --
    -- -   Specified in the Unix time format.
    --
    --     For example, if you wish to use a start time of October 1, 2018, at
    --     8 PM UTC, specify @1538424000@ as the start time.
    --
    -- You can convert a human-friendly time to Unix time format using a
    -- converter like <https://www.epochconverter.com/ Epoch converter>.
    GetContainerLog -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The end of the time interval for which to get log data.
    --
    -- Constraints:
    --
    -- -   Specified in Coordinated Universal Time (UTC).
    --
    -- -   Specified in the Unix time format.
    --
    --     For example, if you wish to use an end time of October 1, 2018, at 9
    --     PM UTC, specify @1538427600@ as the end time.
    --
    -- You can convert a human-friendly time to Unix time format using a
    -- converter like <https://www.epochconverter.com/ Epoch converter>.
    GetContainerLog -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | The token to advance to the next page of results from your request.
    --
    -- To get a page token, perform an initial @GetContainerLog@ request. If
    -- your results are paginated, the response will return a next page token
    -- that you can specify as the page token in a subsequent request.
    GetContainerLog -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text,
    -- | The pattern to use to filter the returned log events to a specific term.
    --
    -- The following are a few examples of filter patterns that you can
    -- specify:
    --
    -- -   To return all log events, specify a filter pattern of @\"\"@.
    --
    -- -   To exclude log events that contain the @ERROR@ term, and return all
    --     other log events, specify a filter pattern of @\"-ERROR\"@.
    --
    -- -   To return log events that contain the @ERROR@ term, specify a filter
    --     pattern of @\"ERROR\"@.
    --
    -- -   To return log events that contain both the @ERROR@ and @Exception@
    --     terms, specify a filter pattern of @\"ERROR Exception\"@.
    --
    -- -   To return log events that contain the @ERROR@ /or/ the @Exception@
    --     term, specify a filter pattern of @\"?ERROR ?Exception\"@.
    GetContainerLog -> Maybe Text
filterPattern :: Prelude.Maybe Prelude.Text,
    -- | The name of the container service for which to get a container log.
    GetContainerLog -> Text
serviceName :: Prelude.Text,
    -- | The name of the container that is either running or previously ran on
    -- the container service for which to return a log.
    GetContainerLog -> Text
containerName :: Prelude.Text
  }
  deriving (GetContainerLog -> GetContainerLog -> Bool
(GetContainerLog -> GetContainerLog -> Bool)
-> (GetContainerLog -> GetContainerLog -> Bool)
-> Eq GetContainerLog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerLog -> GetContainerLog -> Bool
$c/= :: GetContainerLog -> GetContainerLog -> Bool
== :: GetContainerLog -> GetContainerLog -> Bool
$c== :: GetContainerLog -> GetContainerLog -> Bool
Prelude.Eq, ReadPrec [GetContainerLog]
ReadPrec GetContainerLog
Int -> ReadS GetContainerLog
ReadS [GetContainerLog]
(Int -> ReadS GetContainerLog)
-> ReadS [GetContainerLog]
-> ReadPrec GetContainerLog
-> ReadPrec [GetContainerLog]
-> Read GetContainerLog
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerLog]
$creadListPrec :: ReadPrec [GetContainerLog]
readPrec :: ReadPrec GetContainerLog
$creadPrec :: ReadPrec GetContainerLog
readList :: ReadS [GetContainerLog]
$creadList :: ReadS [GetContainerLog]
readsPrec :: Int -> ReadS GetContainerLog
$creadsPrec :: Int -> ReadS GetContainerLog
Prelude.Read, Int -> GetContainerLog -> ShowS
[GetContainerLog] -> ShowS
GetContainerLog -> String
(Int -> GetContainerLog -> ShowS)
-> (GetContainerLog -> String)
-> ([GetContainerLog] -> ShowS)
-> Show GetContainerLog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerLog] -> ShowS
$cshowList :: [GetContainerLog] -> ShowS
show :: GetContainerLog -> String
$cshow :: GetContainerLog -> String
showsPrec :: Int -> GetContainerLog -> ShowS
$cshowsPrec :: Int -> GetContainerLog -> ShowS
Prelude.Show, (forall x. GetContainerLog -> Rep GetContainerLog x)
-> (forall x. Rep GetContainerLog x -> GetContainerLog)
-> Generic GetContainerLog
forall x. Rep GetContainerLog x -> GetContainerLog
forall x. GetContainerLog -> Rep GetContainerLog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContainerLog x -> GetContainerLog
$cfrom :: forall x. GetContainerLog -> Rep GetContainerLog x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerLog' 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', 'getContainerLog_startTime' - The start of the time interval for which to get log data.
--
-- Constraints:
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   Specified in the Unix time format.
--
--     For example, if you wish to use a start time of October 1, 2018, at
--     8 PM UTC, specify @1538424000@ as the start time.
--
-- You can convert a human-friendly time to Unix time format using a
-- converter like <https://www.epochconverter.com/ Epoch converter>.
--
-- 'endTime', 'getContainerLog_endTime' - The end of the time interval for which to get log data.
--
-- Constraints:
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   Specified in the Unix time format.
--
--     For example, if you wish to use an end time of October 1, 2018, at 9
--     PM UTC, specify @1538427600@ as the end time.
--
-- You can convert a human-friendly time to Unix time format using a
-- converter like <https://www.epochconverter.com/ Epoch converter>.
--
-- 'pageToken', 'getContainerLog_pageToken' - The token to advance to the next page of results from your request.
--
-- To get a page token, perform an initial @GetContainerLog@ request. If
-- your results are paginated, the response will return a next page token
-- that you can specify as the page token in a subsequent request.
--
-- 'filterPattern', 'getContainerLog_filterPattern' - The pattern to use to filter the returned log events to a specific term.
--
-- The following are a few examples of filter patterns that you can
-- specify:
--
-- -   To return all log events, specify a filter pattern of @\"\"@.
--
-- -   To exclude log events that contain the @ERROR@ term, and return all
--     other log events, specify a filter pattern of @\"-ERROR\"@.
--
-- -   To return log events that contain the @ERROR@ term, specify a filter
--     pattern of @\"ERROR\"@.
--
-- -   To return log events that contain both the @ERROR@ and @Exception@
--     terms, specify a filter pattern of @\"ERROR Exception\"@.
--
-- -   To return log events that contain the @ERROR@ /or/ the @Exception@
--     term, specify a filter pattern of @\"?ERROR ?Exception\"@.
--
-- 'serviceName', 'getContainerLog_serviceName' - The name of the container service for which to get a container log.
--
-- 'containerName', 'getContainerLog_containerName' - The name of the container that is either running or previously ran on
-- the container service for which to return a log.
newGetContainerLog ::
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'containerName'
  Prelude.Text ->
  GetContainerLog
newGetContainerLog :: Text -> Text -> GetContainerLog
newGetContainerLog Text
pServiceName_ Text
pContainerName_ =
  GetContainerLog' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> GetContainerLog
GetContainerLog'
    { $sel:startTime:GetContainerLog' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:GetContainerLog' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:pageToken:GetContainerLog' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filterPattern:GetContainerLog' :: Maybe Text
filterPattern = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:GetContainerLog' :: Text
serviceName = Text
pServiceName_,
      $sel:containerName:GetContainerLog' :: Text
containerName = Text
pContainerName_
    }

-- | The start of the time interval for which to get log data.
--
-- Constraints:
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   Specified in the Unix time format.
--
--     For example, if you wish to use a start time of October 1, 2018, at
--     8 PM UTC, specify @1538424000@ as the start time.
--
-- You can convert a human-friendly time to Unix time format using a
-- converter like <https://www.epochconverter.com/ Epoch converter>.
getContainerLog_startTime :: Lens.Lens' GetContainerLog (Prelude.Maybe Prelude.UTCTime)
getContainerLog_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetContainerLog -> f GetContainerLog
getContainerLog_startTime = (GetContainerLog -> Maybe POSIX)
-> (GetContainerLog -> Maybe POSIX -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:GetContainerLog' :: GetContainerLog -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: GetContainerLog
s@GetContainerLog' {} Maybe POSIX
a -> GetContainerLog
s {$sel:startTime:GetContainerLog' :: Maybe POSIX
startTime = Maybe POSIX
a} :: GetContainerLog) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetContainerLog -> f GetContainerLog)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetContainerLog
-> f GetContainerLog
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 end of the time interval for which to get log data.
--
-- Constraints:
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   Specified in the Unix time format.
--
--     For example, if you wish to use an end time of October 1, 2018, at 9
--     PM UTC, specify @1538427600@ as the end time.
--
-- You can convert a human-friendly time to Unix time format using a
-- converter like <https://www.epochconverter.com/ Epoch converter>.
getContainerLog_endTime :: Lens.Lens' GetContainerLog (Prelude.Maybe Prelude.UTCTime)
getContainerLog_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetContainerLog -> f GetContainerLog
getContainerLog_endTime = (GetContainerLog -> Maybe POSIX)
-> (GetContainerLog -> Maybe POSIX -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:GetContainerLog' :: GetContainerLog -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: GetContainerLog
s@GetContainerLog' {} Maybe POSIX
a -> GetContainerLog
s {$sel:endTime:GetContainerLog' :: Maybe POSIX
endTime = Maybe POSIX
a} :: GetContainerLog) ((Maybe POSIX -> f (Maybe POSIX))
 -> GetContainerLog -> f GetContainerLog)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetContainerLog
-> f GetContainerLog
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 token to advance to the next page of results from your request.
--
-- To get a page token, perform an initial @GetContainerLog@ request. If
-- your results are paginated, the response will return a next page token
-- that you can specify as the page token in a subsequent request.
getContainerLog_pageToken :: Lens.Lens' GetContainerLog (Prelude.Maybe Prelude.Text)
getContainerLog_pageToken :: (Maybe Text -> f (Maybe Text))
-> GetContainerLog -> f GetContainerLog
getContainerLog_pageToken = (GetContainerLog -> Maybe Text)
-> (GetContainerLog -> Maybe Text -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetContainerLog' :: GetContainerLog -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: GetContainerLog
s@GetContainerLog' {} Maybe Text
a -> GetContainerLog
s {$sel:pageToken:GetContainerLog' :: Maybe Text
pageToken = Maybe Text
a} :: GetContainerLog)

-- | The pattern to use to filter the returned log events to a specific term.
--
-- The following are a few examples of filter patterns that you can
-- specify:
--
-- -   To return all log events, specify a filter pattern of @\"\"@.
--
-- -   To exclude log events that contain the @ERROR@ term, and return all
--     other log events, specify a filter pattern of @\"-ERROR\"@.
--
-- -   To return log events that contain the @ERROR@ term, specify a filter
--     pattern of @\"ERROR\"@.
--
-- -   To return log events that contain both the @ERROR@ and @Exception@
--     terms, specify a filter pattern of @\"ERROR Exception\"@.
--
-- -   To return log events that contain the @ERROR@ /or/ the @Exception@
--     term, specify a filter pattern of @\"?ERROR ?Exception\"@.
getContainerLog_filterPattern :: Lens.Lens' GetContainerLog (Prelude.Maybe Prelude.Text)
getContainerLog_filterPattern :: (Maybe Text -> f (Maybe Text))
-> GetContainerLog -> f GetContainerLog
getContainerLog_filterPattern = (GetContainerLog -> Maybe Text)
-> (GetContainerLog -> Maybe Text -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Maybe Text
filterPattern :: Maybe Text
$sel:filterPattern:GetContainerLog' :: GetContainerLog -> Maybe Text
filterPattern} -> Maybe Text
filterPattern) (\s :: GetContainerLog
s@GetContainerLog' {} Maybe Text
a -> GetContainerLog
s {$sel:filterPattern:GetContainerLog' :: Maybe Text
filterPattern = Maybe Text
a} :: GetContainerLog)

-- | The name of the container service for which to get a container log.
getContainerLog_serviceName :: Lens.Lens' GetContainerLog Prelude.Text
getContainerLog_serviceName :: (Text -> f Text) -> GetContainerLog -> f GetContainerLog
getContainerLog_serviceName = (GetContainerLog -> Text)
-> (GetContainerLog -> Text -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Text
serviceName :: Text
$sel:serviceName:GetContainerLog' :: GetContainerLog -> Text
serviceName} -> Text
serviceName) (\s :: GetContainerLog
s@GetContainerLog' {} Text
a -> GetContainerLog
s {$sel:serviceName:GetContainerLog' :: Text
serviceName = Text
a} :: GetContainerLog)

-- | The name of the container that is either running or previously ran on
-- the container service for which to return a log.
getContainerLog_containerName :: Lens.Lens' GetContainerLog Prelude.Text
getContainerLog_containerName :: (Text -> f Text) -> GetContainerLog -> f GetContainerLog
getContainerLog_containerName = (GetContainerLog -> Text)
-> (GetContainerLog -> Text -> GetContainerLog)
-> Lens GetContainerLog GetContainerLog Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLog' {Text
containerName :: Text
$sel:containerName:GetContainerLog' :: GetContainerLog -> Text
containerName} -> Text
containerName) (\s :: GetContainerLog
s@GetContainerLog' {} Text
a -> GetContainerLog
s {$sel:containerName:GetContainerLog' :: Text
containerName = Text
a} :: GetContainerLog)

instance Core.AWSRequest GetContainerLog where
  type
    AWSResponse GetContainerLog =
      GetContainerLogResponse
  request :: GetContainerLog -> Request GetContainerLog
request = Service -> GetContainerLog -> Request GetContainerLog
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetContainerLog
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetContainerLog)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetContainerLog))
-> Logger
-> Service
-> Proxy GetContainerLog
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetContainerLog)))
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 Text
-> Maybe [ContainerServiceLogEvent]
-> Int
-> GetContainerLogResponse
GetContainerLogResponse'
            (Maybe Text
 -> Maybe [ContainerServiceLogEvent]
 -> Int
 -> GetContainerLogResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [ContainerServiceLogEvent]
      -> Int -> GetContainerLogResponse)
forall (f :: * -> *) a b. Functor 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
"nextPageToken")
            Either
  String
  (Maybe [ContainerServiceLogEvent]
   -> Int -> GetContainerLogResponse)
-> Either String (Maybe [ContainerServiceLogEvent])
-> Either String (Int -> GetContainerLogResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (Maybe [ContainerServiceLogEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"logEvents" Either String (Maybe (Maybe [ContainerServiceLogEvent]))
-> Maybe [ContainerServiceLogEvent]
-> Either String (Maybe [ContainerServiceLogEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ContainerServiceLogEvent]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetContainerLogResponse)
-> Either String Int -> Either String GetContainerLogResponse
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 GetContainerLog

instance Prelude.NFData GetContainerLog

instance Core.ToHeaders GetContainerLog where
  toHeaders :: GetContainerLog -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetContainerLog -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.GetContainerLog" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetContainerLog where
  toJSON :: GetContainerLog -> Value
toJSON GetContainerLog' {Maybe Text
Maybe POSIX
Text
containerName :: Text
serviceName :: Text
filterPattern :: Maybe Text
pageToken :: Maybe Text
endTime :: Maybe POSIX
startTime :: Maybe POSIX
$sel:containerName:GetContainerLog' :: GetContainerLog -> Text
$sel:serviceName:GetContainerLog' :: GetContainerLog -> Text
$sel:filterPattern:GetContainerLog' :: GetContainerLog -> Maybe Text
$sel:pageToken:GetContainerLog' :: GetContainerLog -> Maybe Text
$sel:endTime:GetContainerLog' :: GetContainerLog -> Maybe POSIX
$sel:startTime:GetContainerLog' :: GetContainerLog -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startTime,
            (Text
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
endTime,
            (Text
"pageToken" 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
pageToken,
            (Text
"filterPattern" 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
filterPattern,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"serviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"containerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName)
          ]
      )

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

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

-- | /See:/ 'newGetContainerLogResponse' smart constructor.
data GetContainerLogResponse = GetContainerLogResponse'
  { -- | The token to advance to the next page of results from your request.
    --
    -- A next page token is not returned if there are no more results to
    -- display.
    --
    -- To get the next page of results, perform another @GetContainerLog@
    -- request and specify the next page token using the @pageToken@ parameter.
    GetContainerLogResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | An array of objects that describe the log events of a container.
    GetContainerLogResponse -> Maybe [ContainerServiceLogEvent]
logEvents :: Prelude.Maybe [ContainerServiceLogEvent],
    -- | The response's http status code.
    GetContainerLogResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContainerLogResponse -> GetContainerLogResponse -> Bool
(GetContainerLogResponse -> GetContainerLogResponse -> Bool)
-> (GetContainerLogResponse -> GetContainerLogResponse -> Bool)
-> Eq GetContainerLogResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerLogResponse -> GetContainerLogResponse -> Bool
$c/= :: GetContainerLogResponse -> GetContainerLogResponse -> Bool
== :: GetContainerLogResponse -> GetContainerLogResponse -> Bool
$c== :: GetContainerLogResponse -> GetContainerLogResponse -> Bool
Prelude.Eq, ReadPrec [GetContainerLogResponse]
ReadPrec GetContainerLogResponse
Int -> ReadS GetContainerLogResponse
ReadS [GetContainerLogResponse]
(Int -> ReadS GetContainerLogResponse)
-> ReadS [GetContainerLogResponse]
-> ReadPrec GetContainerLogResponse
-> ReadPrec [GetContainerLogResponse]
-> Read GetContainerLogResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerLogResponse]
$creadListPrec :: ReadPrec [GetContainerLogResponse]
readPrec :: ReadPrec GetContainerLogResponse
$creadPrec :: ReadPrec GetContainerLogResponse
readList :: ReadS [GetContainerLogResponse]
$creadList :: ReadS [GetContainerLogResponse]
readsPrec :: Int -> ReadS GetContainerLogResponse
$creadsPrec :: Int -> ReadS GetContainerLogResponse
Prelude.Read, Int -> GetContainerLogResponse -> ShowS
[GetContainerLogResponse] -> ShowS
GetContainerLogResponse -> String
(Int -> GetContainerLogResponse -> ShowS)
-> (GetContainerLogResponse -> String)
-> ([GetContainerLogResponse] -> ShowS)
-> Show GetContainerLogResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerLogResponse] -> ShowS
$cshowList :: [GetContainerLogResponse] -> ShowS
show :: GetContainerLogResponse -> String
$cshow :: GetContainerLogResponse -> String
showsPrec :: Int -> GetContainerLogResponse -> ShowS
$cshowsPrec :: Int -> GetContainerLogResponse -> ShowS
Prelude.Show, (forall x.
 GetContainerLogResponse -> Rep GetContainerLogResponse x)
-> (forall x.
    Rep GetContainerLogResponse x -> GetContainerLogResponse)
-> Generic GetContainerLogResponse
forall x. Rep GetContainerLogResponse x -> GetContainerLogResponse
forall x. GetContainerLogResponse -> Rep GetContainerLogResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContainerLogResponse x -> GetContainerLogResponse
$cfrom :: forall x. GetContainerLogResponse -> Rep GetContainerLogResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerLogResponse' 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:
--
-- 'nextPageToken', 'getContainerLogResponse_nextPageToken' - The token to advance to the next page of results from your request.
--
-- A next page token is not returned if there are no more results to
-- display.
--
-- To get the next page of results, perform another @GetContainerLog@
-- request and specify the next page token using the @pageToken@ parameter.
--
-- 'logEvents', 'getContainerLogResponse_logEvents' - An array of objects that describe the log events of a container.
--
-- 'httpStatus', 'getContainerLogResponse_httpStatus' - The response's http status code.
newGetContainerLogResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContainerLogResponse
newGetContainerLogResponse :: Int -> GetContainerLogResponse
newGetContainerLogResponse Int
pHttpStatus_ =
  GetContainerLogResponse' :: Maybe Text
-> Maybe [ContainerServiceLogEvent]
-> Int
-> GetContainerLogResponse
GetContainerLogResponse'
    { $sel:nextPageToken:GetContainerLogResponse' :: Maybe Text
nextPageToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logEvents:GetContainerLogResponse' :: Maybe [ContainerServiceLogEvent]
logEvents = Maybe [ContainerServiceLogEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContainerLogResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to advance to the next page of results from your request.
--
-- A next page token is not returned if there are no more results to
-- display.
--
-- To get the next page of results, perform another @GetContainerLog@
-- request and specify the next page token using the @pageToken@ parameter.
getContainerLogResponse_nextPageToken :: Lens.Lens' GetContainerLogResponse (Prelude.Maybe Prelude.Text)
getContainerLogResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> GetContainerLogResponse -> f GetContainerLogResponse
getContainerLogResponse_nextPageToken = (GetContainerLogResponse -> Maybe Text)
-> (GetContainerLogResponse
    -> Maybe Text -> GetContainerLogResponse)
-> Lens
     GetContainerLogResponse
     GetContainerLogResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLogResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetContainerLogResponse' :: GetContainerLogResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetContainerLogResponse
s@GetContainerLogResponse' {} Maybe Text
a -> GetContainerLogResponse
s {$sel:nextPageToken:GetContainerLogResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetContainerLogResponse)

-- | An array of objects that describe the log events of a container.
getContainerLogResponse_logEvents :: Lens.Lens' GetContainerLogResponse (Prelude.Maybe [ContainerServiceLogEvent])
getContainerLogResponse_logEvents :: (Maybe [ContainerServiceLogEvent]
 -> f (Maybe [ContainerServiceLogEvent]))
-> GetContainerLogResponse -> f GetContainerLogResponse
getContainerLogResponse_logEvents = (GetContainerLogResponse -> Maybe [ContainerServiceLogEvent])
-> (GetContainerLogResponse
    -> Maybe [ContainerServiceLogEvent] -> GetContainerLogResponse)
-> Lens
     GetContainerLogResponse
     GetContainerLogResponse
     (Maybe [ContainerServiceLogEvent])
     (Maybe [ContainerServiceLogEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerLogResponse' {Maybe [ContainerServiceLogEvent]
logEvents :: Maybe [ContainerServiceLogEvent]
$sel:logEvents:GetContainerLogResponse' :: GetContainerLogResponse -> Maybe [ContainerServiceLogEvent]
logEvents} -> Maybe [ContainerServiceLogEvent]
logEvents) (\s :: GetContainerLogResponse
s@GetContainerLogResponse' {} Maybe [ContainerServiceLogEvent]
a -> GetContainerLogResponse
s {$sel:logEvents:GetContainerLogResponse' :: Maybe [ContainerServiceLogEvent]
logEvents = Maybe [ContainerServiceLogEvent]
a} :: GetContainerLogResponse) ((Maybe [ContainerServiceLogEvent]
  -> f (Maybe [ContainerServiceLogEvent]))
 -> GetContainerLogResponse -> f GetContainerLogResponse)
-> ((Maybe [ContainerServiceLogEvent]
     -> f (Maybe [ContainerServiceLogEvent]))
    -> Maybe [ContainerServiceLogEvent]
    -> f (Maybe [ContainerServiceLogEvent]))
-> (Maybe [ContainerServiceLogEvent]
    -> f (Maybe [ContainerServiceLogEvent]))
-> GetContainerLogResponse
-> f GetContainerLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
-> Iso
     (Maybe [ContainerServiceLogEvent])
     (Maybe [ContainerServiceLogEvent])
     (Maybe [ContainerServiceLogEvent])
     (Maybe [ContainerServiceLogEvent])
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
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
  [ContainerServiceLogEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetContainerLogResponse