{-# 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.QuickSight.CancelIngestion
-- 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)
--
-- Cancels an ongoing ingestion of data into SPICE.
module Amazonka.QuickSight.CancelIngestion
  ( -- * Creating a Request
    CancelIngestion (..),
    newCancelIngestion,

    -- * Request Lenses
    cancelIngestion_awsAccountId,
    cancelIngestion_dataSetId,
    cancelIngestion_ingestionId,

    -- * Destructuring the Response
    CancelIngestionResponse (..),
    newCancelIngestionResponse,

    -- * Response Lenses
    cancelIngestionResponse_requestId,
    cancelIngestionResponse_arn,
    cancelIngestionResponse_ingestionId,
    cancelIngestionResponse_status,
  )
where

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

-- | /See:/ 'newCancelIngestion' smart constructor.
data CancelIngestion = CancelIngestion'
  { -- | The Amazon Web Services account ID.
    CancelIngestion -> Text
awsAccountId :: Prelude.Text,
    -- | The ID of the dataset used in the ingestion.
    CancelIngestion -> Text
dataSetId :: Prelude.Text,
    -- | An ID for the ingestion.
    CancelIngestion -> Text
ingestionId :: Prelude.Text
  }
  deriving (CancelIngestion -> CancelIngestion -> Bool
(CancelIngestion -> CancelIngestion -> Bool)
-> (CancelIngestion -> CancelIngestion -> Bool)
-> Eq CancelIngestion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelIngestion -> CancelIngestion -> Bool
$c/= :: CancelIngestion -> CancelIngestion -> Bool
== :: CancelIngestion -> CancelIngestion -> Bool
$c== :: CancelIngestion -> CancelIngestion -> Bool
Prelude.Eq, ReadPrec [CancelIngestion]
ReadPrec CancelIngestion
Int -> ReadS CancelIngestion
ReadS [CancelIngestion]
(Int -> ReadS CancelIngestion)
-> ReadS [CancelIngestion]
-> ReadPrec CancelIngestion
-> ReadPrec [CancelIngestion]
-> Read CancelIngestion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelIngestion]
$creadListPrec :: ReadPrec [CancelIngestion]
readPrec :: ReadPrec CancelIngestion
$creadPrec :: ReadPrec CancelIngestion
readList :: ReadS [CancelIngestion]
$creadList :: ReadS [CancelIngestion]
readsPrec :: Int -> ReadS CancelIngestion
$creadsPrec :: Int -> ReadS CancelIngestion
Prelude.Read, Int -> CancelIngestion -> ShowS
[CancelIngestion] -> ShowS
CancelIngestion -> String
(Int -> CancelIngestion -> ShowS)
-> (CancelIngestion -> String)
-> ([CancelIngestion] -> ShowS)
-> Show CancelIngestion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelIngestion] -> ShowS
$cshowList :: [CancelIngestion] -> ShowS
show :: CancelIngestion -> String
$cshow :: CancelIngestion -> String
showsPrec :: Int -> CancelIngestion -> ShowS
$cshowsPrec :: Int -> CancelIngestion -> ShowS
Prelude.Show, (forall x. CancelIngestion -> Rep CancelIngestion x)
-> (forall x. Rep CancelIngestion x -> CancelIngestion)
-> Generic CancelIngestion
forall x. Rep CancelIngestion x -> CancelIngestion
forall x. CancelIngestion -> Rep CancelIngestion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelIngestion x -> CancelIngestion
$cfrom :: forall x. CancelIngestion -> Rep CancelIngestion x
Prelude.Generic)

-- |
-- Create a value of 'CancelIngestion' 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:
--
-- 'awsAccountId', 'cancelIngestion_awsAccountId' - The Amazon Web Services account ID.
--
-- 'dataSetId', 'cancelIngestion_dataSetId' - The ID of the dataset used in the ingestion.
--
-- 'ingestionId', 'cancelIngestion_ingestionId' - An ID for the ingestion.
newCancelIngestion ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'dataSetId'
  Prelude.Text ->
  -- | 'ingestionId'
  Prelude.Text ->
  CancelIngestion
newCancelIngestion :: Text -> Text -> Text -> CancelIngestion
newCancelIngestion
  Text
pAwsAccountId_
  Text
pDataSetId_
  Text
pIngestionId_ =
    CancelIngestion' :: Text -> Text -> Text -> CancelIngestion
CancelIngestion'
      { $sel:awsAccountId:CancelIngestion' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:dataSetId:CancelIngestion' :: Text
dataSetId = Text
pDataSetId_,
        $sel:ingestionId:CancelIngestion' :: Text
ingestionId = Text
pIngestionId_
      }

-- | The Amazon Web Services account ID.
cancelIngestion_awsAccountId :: Lens.Lens' CancelIngestion Prelude.Text
cancelIngestion_awsAccountId :: (Text -> f Text) -> CancelIngestion -> f CancelIngestion
cancelIngestion_awsAccountId = (CancelIngestion -> Text)
-> (CancelIngestion -> Text -> CancelIngestion)
-> Lens CancelIngestion CancelIngestion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestion' {Text
awsAccountId :: Text
$sel:awsAccountId:CancelIngestion' :: CancelIngestion -> Text
awsAccountId} -> Text
awsAccountId) (\s :: CancelIngestion
s@CancelIngestion' {} Text
a -> CancelIngestion
s {$sel:awsAccountId:CancelIngestion' :: Text
awsAccountId = Text
a} :: CancelIngestion)

-- | The ID of the dataset used in the ingestion.
cancelIngestion_dataSetId :: Lens.Lens' CancelIngestion Prelude.Text
cancelIngestion_dataSetId :: (Text -> f Text) -> CancelIngestion -> f CancelIngestion
cancelIngestion_dataSetId = (CancelIngestion -> Text)
-> (CancelIngestion -> Text -> CancelIngestion)
-> Lens CancelIngestion CancelIngestion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestion' {Text
dataSetId :: Text
$sel:dataSetId:CancelIngestion' :: CancelIngestion -> Text
dataSetId} -> Text
dataSetId) (\s :: CancelIngestion
s@CancelIngestion' {} Text
a -> CancelIngestion
s {$sel:dataSetId:CancelIngestion' :: Text
dataSetId = Text
a} :: CancelIngestion)

-- | An ID for the ingestion.
cancelIngestion_ingestionId :: Lens.Lens' CancelIngestion Prelude.Text
cancelIngestion_ingestionId :: (Text -> f Text) -> CancelIngestion -> f CancelIngestion
cancelIngestion_ingestionId = (CancelIngestion -> Text)
-> (CancelIngestion -> Text -> CancelIngestion)
-> Lens CancelIngestion CancelIngestion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestion' {Text
ingestionId :: Text
$sel:ingestionId:CancelIngestion' :: CancelIngestion -> Text
ingestionId} -> Text
ingestionId) (\s :: CancelIngestion
s@CancelIngestion' {} Text
a -> CancelIngestion
s {$sel:ingestionId:CancelIngestion' :: Text
ingestionId = Text
a} :: CancelIngestion)

instance Core.AWSRequest CancelIngestion where
  type
    AWSResponse CancelIngestion =
      CancelIngestionResponse
  request :: CancelIngestion -> Request CancelIngestion
request = Service -> CancelIngestion -> Request CancelIngestion
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelIngestion
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelIngestion)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelIngestion))
-> Logger
-> Service
-> Proxy CancelIngestion
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelIngestion)))
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 Text -> Maybe Text -> Int -> CancelIngestionResponse
CancelIngestionResponse'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Int -> CancelIngestionResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> CancelIngestionResponse)
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
"RequestId")
            Either
  String (Maybe Text -> Maybe Text -> Int -> CancelIngestionResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CancelIngestionResponse)
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
"Arn")
            Either String (Maybe Text -> Int -> CancelIngestionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CancelIngestionResponse)
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
"IngestionId")
            Either String (Int -> CancelIngestionResponse)
-> Either String Int -> Either String CancelIngestionResponse
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 CancelIngestion

instance Prelude.NFData CancelIngestion

instance Core.ToHeaders CancelIngestion where
  toHeaders :: CancelIngestion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelIngestion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath CancelIngestion where
  toPath :: CancelIngestion -> ByteString
toPath CancelIngestion' {Text
ingestionId :: Text
dataSetId :: Text
awsAccountId :: Text
$sel:ingestionId:CancelIngestion' :: CancelIngestion -> Text
$sel:dataSetId:CancelIngestion' :: CancelIngestion -> Text
$sel:awsAccountId:CancelIngestion' :: CancelIngestion -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/data-sets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
dataSetId,
        ByteString
"/ingestions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
ingestionId
      ]

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

-- | /See:/ 'newCancelIngestionResponse' smart constructor.
data CancelIngestionResponse = CancelIngestionResponse'
  { -- | The Amazon Web Services request ID for this operation.
    CancelIngestionResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the data ingestion.
    CancelIngestionResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | An ID for the ingestion.
    CancelIngestionResponse -> Maybe Text
ingestionId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    CancelIngestionResponse -> Int
status :: Prelude.Int
  }
  deriving (CancelIngestionResponse -> CancelIngestionResponse -> Bool
(CancelIngestionResponse -> CancelIngestionResponse -> Bool)
-> (CancelIngestionResponse -> CancelIngestionResponse -> Bool)
-> Eq CancelIngestionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelIngestionResponse -> CancelIngestionResponse -> Bool
$c/= :: CancelIngestionResponse -> CancelIngestionResponse -> Bool
== :: CancelIngestionResponse -> CancelIngestionResponse -> Bool
$c== :: CancelIngestionResponse -> CancelIngestionResponse -> Bool
Prelude.Eq, ReadPrec [CancelIngestionResponse]
ReadPrec CancelIngestionResponse
Int -> ReadS CancelIngestionResponse
ReadS [CancelIngestionResponse]
(Int -> ReadS CancelIngestionResponse)
-> ReadS [CancelIngestionResponse]
-> ReadPrec CancelIngestionResponse
-> ReadPrec [CancelIngestionResponse]
-> Read CancelIngestionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelIngestionResponse]
$creadListPrec :: ReadPrec [CancelIngestionResponse]
readPrec :: ReadPrec CancelIngestionResponse
$creadPrec :: ReadPrec CancelIngestionResponse
readList :: ReadS [CancelIngestionResponse]
$creadList :: ReadS [CancelIngestionResponse]
readsPrec :: Int -> ReadS CancelIngestionResponse
$creadsPrec :: Int -> ReadS CancelIngestionResponse
Prelude.Read, Int -> CancelIngestionResponse -> ShowS
[CancelIngestionResponse] -> ShowS
CancelIngestionResponse -> String
(Int -> CancelIngestionResponse -> ShowS)
-> (CancelIngestionResponse -> String)
-> ([CancelIngestionResponse] -> ShowS)
-> Show CancelIngestionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelIngestionResponse] -> ShowS
$cshowList :: [CancelIngestionResponse] -> ShowS
show :: CancelIngestionResponse -> String
$cshow :: CancelIngestionResponse -> String
showsPrec :: Int -> CancelIngestionResponse -> ShowS
$cshowsPrec :: Int -> CancelIngestionResponse -> ShowS
Prelude.Show, (forall x.
 CancelIngestionResponse -> Rep CancelIngestionResponse x)
-> (forall x.
    Rep CancelIngestionResponse x -> CancelIngestionResponse)
-> Generic CancelIngestionResponse
forall x. Rep CancelIngestionResponse x -> CancelIngestionResponse
forall x. CancelIngestionResponse -> Rep CancelIngestionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelIngestionResponse x -> CancelIngestionResponse
$cfrom :: forall x. CancelIngestionResponse -> Rep CancelIngestionResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelIngestionResponse' 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:
--
-- 'requestId', 'cancelIngestionResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'arn', 'cancelIngestionResponse_arn' - The Amazon Resource Name (ARN) for the data ingestion.
--
-- 'ingestionId', 'cancelIngestionResponse_ingestionId' - An ID for the ingestion.
--
-- 'status', 'cancelIngestionResponse_status' - The HTTP status of the request.
newCancelIngestionResponse ::
  -- | 'status'
  Prelude.Int ->
  CancelIngestionResponse
newCancelIngestionResponse :: Int -> CancelIngestionResponse
newCancelIngestionResponse Int
pStatus_ =
  CancelIngestionResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CancelIngestionResponse
CancelIngestionResponse'
    { $sel:requestId:CancelIngestionResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CancelIngestionResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ingestionId:CancelIngestionResponse' :: Maybe Text
ingestionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:CancelIngestionResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
cancelIngestionResponse_requestId :: Lens.Lens' CancelIngestionResponse (Prelude.Maybe Prelude.Text)
cancelIngestionResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> CancelIngestionResponse -> f CancelIngestionResponse
cancelIngestionResponse_requestId = (CancelIngestionResponse -> Maybe Text)
-> (CancelIngestionResponse
    -> Maybe Text -> CancelIngestionResponse)
-> Lens
     CancelIngestionResponse
     CancelIngestionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestionResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:CancelIngestionResponse' :: CancelIngestionResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: CancelIngestionResponse
s@CancelIngestionResponse' {} Maybe Text
a -> CancelIngestionResponse
s {$sel:requestId:CancelIngestionResponse' :: Maybe Text
requestId = Maybe Text
a} :: CancelIngestionResponse)

-- | The Amazon Resource Name (ARN) for the data ingestion.
cancelIngestionResponse_arn :: Lens.Lens' CancelIngestionResponse (Prelude.Maybe Prelude.Text)
cancelIngestionResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CancelIngestionResponse -> f CancelIngestionResponse
cancelIngestionResponse_arn = (CancelIngestionResponse -> Maybe Text)
-> (CancelIngestionResponse
    -> Maybe Text -> CancelIngestionResponse)
-> Lens
     CancelIngestionResponse
     CancelIngestionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestionResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CancelIngestionResponse' :: CancelIngestionResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CancelIngestionResponse
s@CancelIngestionResponse' {} Maybe Text
a -> CancelIngestionResponse
s {$sel:arn:CancelIngestionResponse' :: Maybe Text
arn = Maybe Text
a} :: CancelIngestionResponse)

-- | An ID for the ingestion.
cancelIngestionResponse_ingestionId :: Lens.Lens' CancelIngestionResponse (Prelude.Maybe Prelude.Text)
cancelIngestionResponse_ingestionId :: (Maybe Text -> f (Maybe Text))
-> CancelIngestionResponse -> f CancelIngestionResponse
cancelIngestionResponse_ingestionId = (CancelIngestionResponse -> Maybe Text)
-> (CancelIngestionResponse
    -> Maybe Text -> CancelIngestionResponse)
-> Lens
     CancelIngestionResponse
     CancelIngestionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestionResponse' {Maybe Text
ingestionId :: Maybe Text
$sel:ingestionId:CancelIngestionResponse' :: CancelIngestionResponse -> Maybe Text
ingestionId} -> Maybe Text
ingestionId) (\s :: CancelIngestionResponse
s@CancelIngestionResponse' {} Maybe Text
a -> CancelIngestionResponse
s {$sel:ingestionId:CancelIngestionResponse' :: Maybe Text
ingestionId = Maybe Text
a} :: CancelIngestionResponse)

-- | The HTTP status of the request.
cancelIngestionResponse_status :: Lens.Lens' CancelIngestionResponse Prelude.Int
cancelIngestionResponse_status :: (Int -> f Int)
-> CancelIngestionResponse -> f CancelIngestionResponse
cancelIngestionResponse_status = (CancelIngestionResponse -> Int)
-> (CancelIngestionResponse -> Int -> CancelIngestionResponse)
-> Lens CancelIngestionResponse CancelIngestionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelIngestionResponse' {Int
status :: Int
$sel:status:CancelIngestionResponse' :: CancelIngestionResponse -> Int
status} -> Int
status) (\s :: CancelIngestionResponse
s@CancelIngestionResponse' {} Int
a -> CancelIngestionResponse
s {$sel:status:CancelIngestionResponse' :: Int
status = Int
a} :: CancelIngestionResponse)

instance Prelude.NFData CancelIngestionResponse