{-# 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.Discovery.StopContinuousExport
-- 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)
--
-- Stop the continuous flow of agent\'s discovered data into Amazon Athena.
module Amazonka.Discovery.StopContinuousExport
  ( -- * Creating a Request
    StopContinuousExport (..),
    newStopContinuousExport,

    -- * Request Lenses
    stopContinuousExport_exportId,

    -- * Destructuring the Response
    StopContinuousExportResponse (..),
    newStopContinuousExportResponse,

    -- * Response Lenses
    stopContinuousExportResponse_startTime,
    stopContinuousExportResponse_stopTime,
    stopContinuousExportResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStopContinuousExport' smart constructor.
data StopContinuousExport = StopContinuousExport'
  { -- | The unique ID assigned to this export.
    StopContinuousExport -> Text
exportId :: Prelude.Text
  }
  deriving (StopContinuousExport -> StopContinuousExport -> Bool
(StopContinuousExport -> StopContinuousExport -> Bool)
-> (StopContinuousExport -> StopContinuousExport -> Bool)
-> Eq StopContinuousExport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopContinuousExport -> StopContinuousExport -> Bool
$c/= :: StopContinuousExport -> StopContinuousExport -> Bool
== :: StopContinuousExport -> StopContinuousExport -> Bool
$c== :: StopContinuousExport -> StopContinuousExport -> Bool
Prelude.Eq, ReadPrec [StopContinuousExport]
ReadPrec StopContinuousExport
Int -> ReadS StopContinuousExport
ReadS [StopContinuousExport]
(Int -> ReadS StopContinuousExport)
-> ReadS [StopContinuousExport]
-> ReadPrec StopContinuousExport
-> ReadPrec [StopContinuousExport]
-> Read StopContinuousExport
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopContinuousExport]
$creadListPrec :: ReadPrec [StopContinuousExport]
readPrec :: ReadPrec StopContinuousExport
$creadPrec :: ReadPrec StopContinuousExport
readList :: ReadS [StopContinuousExport]
$creadList :: ReadS [StopContinuousExport]
readsPrec :: Int -> ReadS StopContinuousExport
$creadsPrec :: Int -> ReadS StopContinuousExport
Prelude.Read, Int -> StopContinuousExport -> ShowS
[StopContinuousExport] -> ShowS
StopContinuousExport -> String
(Int -> StopContinuousExport -> ShowS)
-> (StopContinuousExport -> String)
-> ([StopContinuousExport] -> ShowS)
-> Show StopContinuousExport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopContinuousExport] -> ShowS
$cshowList :: [StopContinuousExport] -> ShowS
show :: StopContinuousExport -> String
$cshow :: StopContinuousExport -> String
showsPrec :: Int -> StopContinuousExport -> ShowS
$cshowsPrec :: Int -> StopContinuousExport -> ShowS
Prelude.Show, (forall x. StopContinuousExport -> Rep StopContinuousExport x)
-> (forall x. Rep StopContinuousExport x -> StopContinuousExport)
-> Generic StopContinuousExport
forall x. Rep StopContinuousExport x -> StopContinuousExport
forall x. StopContinuousExport -> Rep StopContinuousExport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopContinuousExport x -> StopContinuousExport
$cfrom :: forall x. StopContinuousExport -> Rep StopContinuousExport x
Prelude.Generic)

-- |
-- Create a value of 'StopContinuousExport' 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:
--
-- 'exportId', 'stopContinuousExport_exportId' - The unique ID assigned to this export.
newStopContinuousExport ::
  -- | 'exportId'
  Prelude.Text ->
  StopContinuousExport
newStopContinuousExport :: Text -> StopContinuousExport
newStopContinuousExport Text
pExportId_ =
  StopContinuousExport' :: Text -> StopContinuousExport
StopContinuousExport' {$sel:exportId:StopContinuousExport' :: Text
exportId = Text
pExportId_}

-- | The unique ID assigned to this export.
stopContinuousExport_exportId :: Lens.Lens' StopContinuousExport Prelude.Text
stopContinuousExport_exportId :: (Text -> f Text) -> StopContinuousExport -> f StopContinuousExport
stopContinuousExport_exportId = (StopContinuousExport -> Text)
-> (StopContinuousExport -> Text -> StopContinuousExport)
-> Lens StopContinuousExport StopContinuousExport Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopContinuousExport' {Text
exportId :: Text
$sel:exportId:StopContinuousExport' :: StopContinuousExport -> Text
exportId} -> Text
exportId) (\s :: StopContinuousExport
s@StopContinuousExport' {} Text
a -> StopContinuousExport
s {$sel:exportId:StopContinuousExport' :: Text
exportId = Text
a} :: StopContinuousExport)

instance Core.AWSRequest StopContinuousExport where
  type
    AWSResponse StopContinuousExport =
      StopContinuousExportResponse
  request :: StopContinuousExport -> Request StopContinuousExport
request = Service -> StopContinuousExport -> Request StopContinuousExport
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopContinuousExport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopContinuousExport)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopContinuousExport))
-> Logger
-> Service
-> Proxy StopContinuousExport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopContinuousExport)))
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 POSIX -> Maybe POSIX -> Int -> StopContinuousExportResponse
StopContinuousExportResponse'
            (Maybe POSIX -> Maybe POSIX -> Int -> StopContinuousExportResponse)
-> Either String (Maybe POSIX)
-> Either
     String (Maybe POSIX -> Int -> StopContinuousExportResponse)
forall (f :: * -> *) a b. Functor 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 POSIX -> Int -> StopContinuousExportResponse)
-> Either String (Maybe POSIX)
-> Either String (Int -> StopContinuousExportResponse)
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
"stopTime")
            Either String (Int -> StopContinuousExportResponse)
-> Either String Int -> Either String StopContinuousExportResponse
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 StopContinuousExport

instance Prelude.NFData StopContinuousExport

instance Core.ToHeaders StopContinuousExport where
  toHeaders :: StopContinuousExport -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopContinuousExport -> 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
"AWSPoseidonService_V2015_11_01.StopContinuousExport" ::
                          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 StopContinuousExport where
  toJSON :: StopContinuousExport -> Value
toJSON StopContinuousExport' {Text
exportId :: Text
$sel:exportId:StopContinuousExport' :: StopContinuousExport -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"exportId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
exportId)]
      )

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

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

-- | /See:/ 'newStopContinuousExportResponse' smart constructor.
data StopContinuousExportResponse = StopContinuousExportResponse'
  { -- | Timestamp that represents when this continuous export started collecting
    -- data.
    StopContinuousExportResponse -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | Timestamp that represents when this continuous export was stopped.
    StopContinuousExportResponse -> Maybe POSIX
stopTime :: Prelude.Maybe Core.POSIX,
    -- | The response's http status code.
    StopContinuousExportResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
(StopContinuousExportResponse
 -> StopContinuousExportResponse -> Bool)
-> (StopContinuousExportResponse
    -> StopContinuousExportResponse -> Bool)
-> Eq StopContinuousExportResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
$c/= :: StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
== :: StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
$c== :: StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
Prelude.Eq, ReadPrec [StopContinuousExportResponse]
ReadPrec StopContinuousExportResponse
Int -> ReadS StopContinuousExportResponse
ReadS [StopContinuousExportResponse]
(Int -> ReadS StopContinuousExportResponse)
-> ReadS [StopContinuousExportResponse]
-> ReadPrec StopContinuousExportResponse
-> ReadPrec [StopContinuousExportResponse]
-> Read StopContinuousExportResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopContinuousExportResponse]
$creadListPrec :: ReadPrec [StopContinuousExportResponse]
readPrec :: ReadPrec StopContinuousExportResponse
$creadPrec :: ReadPrec StopContinuousExportResponse
readList :: ReadS [StopContinuousExportResponse]
$creadList :: ReadS [StopContinuousExportResponse]
readsPrec :: Int -> ReadS StopContinuousExportResponse
$creadsPrec :: Int -> ReadS StopContinuousExportResponse
Prelude.Read, Int -> StopContinuousExportResponse -> ShowS
[StopContinuousExportResponse] -> ShowS
StopContinuousExportResponse -> String
(Int -> StopContinuousExportResponse -> ShowS)
-> (StopContinuousExportResponse -> String)
-> ([StopContinuousExportResponse] -> ShowS)
-> Show StopContinuousExportResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopContinuousExportResponse] -> ShowS
$cshowList :: [StopContinuousExportResponse] -> ShowS
show :: StopContinuousExportResponse -> String
$cshow :: StopContinuousExportResponse -> String
showsPrec :: Int -> StopContinuousExportResponse -> ShowS
$cshowsPrec :: Int -> StopContinuousExportResponse -> ShowS
Prelude.Show, (forall x.
 StopContinuousExportResponse -> Rep StopContinuousExportResponse x)
-> (forall x.
    Rep StopContinuousExportResponse x -> StopContinuousExportResponse)
-> Generic StopContinuousExportResponse
forall x.
Rep StopContinuousExportResponse x -> StopContinuousExportResponse
forall x.
StopContinuousExportResponse -> Rep StopContinuousExportResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopContinuousExportResponse x -> StopContinuousExportResponse
$cfrom :: forall x.
StopContinuousExportResponse -> Rep StopContinuousExportResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopContinuousExportResponse' 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', 'stopContinuousExportResponse_startTime' - Timestamp that represents when this continuous export started collecting
-- data.
--
-- 'stopTime', 'stopContinuousExportResponse_stopTime' - Timestamp that represents when this continuous export was stopped.
--
-- 'httpStatus', 'stopContinuousExportResponse_httpStatus' - The response's http status code.
newStopContinuousExportResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopContinuousExportResponse
newStopContinuousExportResponse :: Int -> StopContinuousExportResponse
newStopContinuousExportResponse Int
pHttpStatus_ =
  StopContinuousExportResponse' :: Maybe POSIX -> Maybe POSIX -> Int -> StopContinuousExportResponse
StopContinuousExportResponse'
    { $sel:startTime:StopContinuousExportResponse' :: Maybe POSIX
startTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:stopTime:StopContinuousExportResponse' :: Maybe POSIX
stopTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopContinuousExportResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Timestamp that represents when this continuous export started collecting
-- data.
stopContinuousExportResponse_startTime :: Lens.Lens' StopContinuousExportResponse (Prelude.Maybe Prelude.UTCTime)
stopContinuousExportResponse_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> StopContinuousExportResponse -> f StopContinuousExportResponse
stopContinuousExportResponse_startTime = (StopContinuousExportResponse -> Maybe POSIX)
-> (StopContinuousExportResponse
    -> Maybe POSIX -> StopContinuousExportResponse)
-> Lens
     StopContinuousExportResponse
     StopContinuousExportResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopContinuousExportResponse' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:StopContinuousExportResponse' :: StopContinuousExportResponse -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: StopContinuousExportResponse
s@StopContinuousExportResponse' {} Maybe POSIX
a -> StopContinuousExportResponse
s {$sel:startTime:StopContinuousExportResponse' :: Maybe POSIX
startTime = Maybe POSIX
a} :: StopContinuousExportResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> StopContinuousExportResponse -> f StopContinuousExportResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> StopContinuousExportResponse
-> f StopContinuousExportResponse
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

-- | Timestamp that represents when this continuous export was stopped.
stopContinuousExportResponse_stopTime :: Lens.Lens' StopContinuousExportResponse (Prelude.Maybe Prelude.UTCTime)
stopContinuousExportResponse_stopTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> StopContinuousExportResponse -> f StopContinuousExportResponse
stopContinuousExportResponse_stopTime = (StopContinuousExportResponse -> Maybe POSIX)
-> (StopContinuousExportResponse
    -> Maybe POSIX -> StopContinuousExportResponse)
-> Lens
     StopContinuousExportResponse
     StopContinuousExportResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopContinuousExportResponse' {Maybe POSIX
stopTime :: Maybe POSIX
$sel:stopTime:StopContinuousExportResponse' :: StopContinuousExportResponse -> Maybe POSIX
stopTime} -> Maybe POSIX
stopTime) (\s :: StopContinuousExportResponse
s@StopContinuousExportResponse' {} Maybe POSIX
a -> StopContinuousExportResponse
s {$sel:stopTime:StopContinuousExportResponse' :: Maybe POSIX
stopTime = Maybe POSIX
a} :: StopContinuousExportResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> StopContinuousExportResponse -> f StopContinuousExportResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> StopContinuousExportResponse
-> f StopContinuousExportResponse
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 response's http status code.
stopContinuousExportResponse_httpStatus :: Lens.Lens' StopContinuousExportResponse Prelude.Int
stopContinuousExportResponse_httpStatus :: (Int -> f Int)
-> StopContinuousExportResponse -> f StopContinuousExportResponse
stopContinuousExportResponse_httpStatus = (StopContinuousExportResponse -> Int)
-> (StopContinuousExportResponse
    -> Int -> StopContinuousExportResponse)
-> Lens
     StopContinuousExportResponse StopContinuousExportResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopContinuousExportResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopContinuousExportResponse' :: StopContinuousExportResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StopContinuousExportResponse
s@StopContinuousExportResponse' {} Int
a -> StopContinuousExportResponse
s {$sel:httpStatus:StopContinuousExportResponse' :: Int
httpStatus = Int
a} :: StopContinuousExportResponse)

instance Prelude.NFData StopContinuousExportResponse