{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Discovery.Types
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
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]
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
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. 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' {$sel:exportId:StopContinuousExport' :: Text
exportId = Text
pExportId_}

-- | The unique ID assigned to this export.
stopContinuousExport_exportId :: Lens.Lens' StopContinuousExport Prelude.Text
stopContinuousExport_exportId :: Lens' StopContinuousExport Text
stopContinuousExport_exportId = 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 :: (Service -> Service)
-> StopContinuousExport -> Request StopContinuousExport
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StopContinuousExport
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopContinuousExport)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"startTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"stopTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StopContinuousExport where
  hashWithSalt :: Int -> StopContinuousExport -> Int
hashWithSalt Int
_salt StopContinuousExport' {Text
exportId :: Text
$sel:exportId:StopContinuousExport' :: StopContinuousExport -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
exportId

instance Prelude.NFData StopContinuousExport where
  rnf :: StopContinuousExport -> ()
rnf StopContinuousExport' {Text
exportId :: Text
$sel:exportId:StopContinuousExport' :: StopContinuousExport -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
exportId

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

instance Data.ToJSON StopContinuousExport where
  toJSON :: StopContinuousExport -> Value
toJSON StopContinuousExport' {Text
exportId :: Text
$sel:exportId:StopContinuousExport' :: StopContinuousExport -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"exportId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
exportId)]
      )

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

instance Data.ToQuery StopContinuousExport where
  toQuery :: StopContinuousExport -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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 Data.POSIX,
    -- | Timestamp that represents when this continuous export was stopped.
    StopContinuousExportResponse -> Maybe POSIX
stopTime :: Prelude.Maybe Data.POSIX,
    -- | The response's http status code.
    StopContinuousExportResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopContinuousExportResponse
-> StopContinuousExportResponse -> Bool
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]
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
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.
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'
    { $sel:startTime:StopContinuousExportResponse' :: Maybe POSIX
startTime =
        forall a. Maybe a
Prelude.Nothing,
      $sel:stopTime:StopContinuousExportResponse' :: Maybe POSIX
stopTime = 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 :: Lens' StopContinuousExportResponse (Maybe UTCTime)
stopContinuousExportResponse_startTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Timestamp that represents when this continuous export was stopped.
stopContinuousExportResponse_stopTime :: Lens.Lens' StopContinuousExportResponse (Prelude.Maybe Prelude.UTCTime)
stopContinuousExportResponse_stopTime :: Lens' StopContinuousExportResponse (Maybe UTCTime)
stopContinuousExportResponse_stopTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The response's http status code.
stopContinuousExportResponse_httpStatus :: Lens.Lens' StopContinuousExportResponse Prelude.Int
stopContinuousExportResponse_httpStatus :: Lens' StopContinuousExportResponse Int
stopContinuousExportResponse_httpStatus = 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 where
  rnf :: StopContinuousExportResponse -> ()
rnf StopContinuousExportResponse' {Int
Maybe POSIX
httpStatus :: Int
stopTime :: Maybe POSIX
startTime :: Maybe POSIX
$sel:httpStatus:StopContinuousExportResponse' :: StopContinuousExportResponse -> Int
$sel:stopTime:StopContinuousExportResponse' :: StopContinuousExportResponse -> Maybe POSIX
$sel:startTime:StopContinuousExportResponse' :: StopContinuousExportResponse -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
stopTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus