{-# 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.DeleteDataSource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the data source permanently. This operation breaks all the
-- datasets that reference the deleted data source.
module Amazonka.QuickSight.DeleteDataSource
  ( -- * Creating a Request
    DeleteDataSource (..),
    newDeleteDataSource,

    -- * Request Lenses
    deleteDataSource_awsAccountId,
    deleteDataSource_dataSourceId,

    -- * Destructuring the Response
    DeleteDataSourceResponse (..),
    newDeleteDataSourceResponse,

    -- * Response Lenses
    deleteDataSourceResponse_arn,
    deleteDataSourceResponse_dataSourceId,
    deleteDataSourceResponse_requestId,
    deleteDataSourceResponse_status,
  )
where

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

-- | /See:/ 'newDeleteDataSource' smart constructor.
data DeleteDataSource = DeleteDataSource'
  { -- | The Amazon Web Services account ID.
    DeleteDataSource -> Text
awsAccountId :: Prelude.Text,
    -- | The ID of the data source. This ID is unique per Amazon Web Services
    -- Region for each Amazon Web Services account.
    DeleteDataSource -> Text
dataSourceId :: Prelude.Text
  }
  deriving (DeleteDataSource -> DeleteDataSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDataSource -> DeleteDataSource -> Bool
$c/= :: DeleteDataSource -> DeleteDataSource -> Bool
== :: DeleteDataSource -> DeleteDataSource -> Bool
$c== :: DeleteDataSource -> DeleteDataSource -> Bool
Prelude.Eq, ReadPrec [DeleteDataSource]
ReadPrec DeleteDataSource
Int -> ReadS DeleteDataSource
ReadS [DeleteDataSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDataSource]
$creadListPrec :: ReadPrec [DeleteDataSource]
readPrec :: ReadPrec DeleteDataSource
$creadPrec :: ReadPrec DeleteDataSource
readList :: ReadS [DeleteDataSource]
$creadList :: ReadS [DeleteDataSource]
readsPrec :: Int -> ReadS DeleteDataSource
$creadsPrec :: Int -> ReadS DeleteDataSource
Prelude.Read, Int -> DeleteDataSource -> ShowS
[DeleteDataSource] -> ShowS
DeleteDataSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDataSource] -> ShowS
$cshowList :: [DeleteDataSource] -> ShowS
show :: DeleteDataSource -> String
$cshow :: DeleteDataSource -> String
showsPrec :: Int -> DeleteDataSource -> ShowS
$cshowsPrec :: Int -> DeleteDataSource -> ShowS
Prelude.Show, forall x. Rep DeleteDataSource x -> DeleteDataSource
forall x. DeleteDataSource -> Rep DeleteDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDataSource x -> DeleteDataSource
$cfrom :: forall x. DeleteDataSource -> Rep DeleteDataSource x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDataSource' 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', 'deleteDataSource_awsAccountId' - The Amazon Web Services account ID.
--
-- 'dataSourceId', 'deleteDataSource_dataSourceId' - The ID of the data source. This ID is unique per Amazon Web Services
-- Region for each Amazon Web Services account.
newDeleteDataSource ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'dataSourceId'
  Prelude.Text ->
  DeleteDataSource
newDeleteDataSource :: Text -> Text -> DeleteDataSource
newDeleteDataSource Text
pAwsAccountId_ Text
pDataSourceId_ =
  DeleteDataSource'
    { $sel:awsAccountId:DeleteDataSource' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:dataSourceId:DeleteDataSource' :: Text
dataSourceId = Text
pDataSourceId_
    }

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

-- | The ID of the data source. This ID is unique per Amazon Web Services
-- Region for each Amazon Web Services account.
deleteDataSource_dataSourceId :: Lens.Lens' DeleteDataSource Prelude.Text
deleteDataSource_dataSourceId :: Lens' DeleteDataSource Text
deleteDataSource_dataSourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataSource' {Text
dataSourceId :: Text
$sel:dataSourceId:DeleteDataSource' :: DeleteDataSource -> Text
dataSourceId} -> Text
dataSourceId) (\s :: DeleteDataSource
s@DeleteDataSource' {} Text
a -> DeleteDataSource
s {$sel:dataSourceId:DeleteDataSource' :: Text
dataSourceId = Text
a} :: DeleteDataSource)

instance Core.AWSRequest DeleteDataSource where
  type
    AWSResponse DeleteDataSource =
      DeleteDataSourceResponse
  request :: (Service -> Service)
-> DeleteDataSource -> Request DeleteDataSource
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteDataSource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDataSource)))
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 Text
-> Maybe Text -> Maybe Text -> Int -> DeleteDataSourceResponse
DeleteDataSourceResponse'
            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
"Arn")
            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
"DataSourceId")
            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
"RequestId")
            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 DeleteDataSource where
  hashWithSalt :: Int -> DeleteDataSource -> Int
hashWithSalt Int
_salt DeleteDataSource' {Text
dataSourceId :: Text
awsAccountId :: Text
$sel:dataSourceId:DeleteDataSource' :: DeleteDataSource -> Text
$sel:awsAccountId:DeleteDataSource' :: DeleteDataSource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataSourceId

instance Prelude.NFData DeleteDataSource where
  rnf :: DeleteDataSource -> ()
rnf DeleteDataSource' {Text
dataSourceId :: Text
awsAccountId :: Text
$sel:dataSourceId:DeleteDataSource' :: DeleteDataSource -> Text
$sel:awsAccountId:DeleteDataSource' :: DeleteDataSource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dataSourceId

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

instance Data.ToPath DeleteDataSource where
  toPath :: DeleteDataSource -> ByteString
toPath DeleteDataSource' {Text
dataSourceId :: Text
awsAccountId :: Text
$sel:dataSourceId:DeleteDataSource' :: DeleteDataSource -> Text
$sel:awsAccountId:DeleteDataSource' :: DeleteDataSource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/data-sources/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
dataSourceId
      ]

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

-- | /See:/ 'newDeleteDataSourceResponse' smart constructor.
data DeleteDataSourceResponse = DeleteDataSourceResponse'
  { -- | The Amazon Resource Name (ARN) of the data source that you deleted.
    DeleteDataSourceResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the data source. This ID is unique per Amazon Web Services
    -- Region for each Amazon Web Services account.
    DeleteDataSourceResponse -> Maybe Text
dataSourceId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services request ID for this operation.
    DeleteDataSourceResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    DeleteDataSourceResponse -> Int
status :: Prelude.Int
  }
  deriving (DeleteDataSourceResponse -> DeleteDataSourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDataSourceResponse -> DeleteDataSourceResponse -> Bool
$c/= :: DeleteDataSourceResponse -> DeleteDataSourceResponse -> Bool
== :: DeleteDataSourceResponse -> DeleteDataSourceResponse -> Bool
$c== :: DeleteDataSourceResponse -> DeleteDataSourceResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDataSourceResponse]
ReadPrec DeleteDataSourceResponse
Int -> ReadS DeleteDataSourceResponse
ReadS [DeleteDataSourceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDataSourceResponse]
$creadListPrec :: ReadPrec [DeleteDataSourceResponse]
readPrec :: ReadPrec DeleteDataSourceResponse
$creadPrec :: ReadPrec DeleteDataSourceResponse
readList :: ReadS [DeleteDataSourceResponse]
$creadList :: ReadS [DeleteDataSourceResponse]
readsPrec :: Int -> ReadS DeleteDataSourceResponse
$creadsPrec :: Int -> ReadS DeleteDataSourceResponse
Prelude.Read, Int -> DeleteDataSourceResponse -> ShowS
[DeleteDataSourceResponse] -> ShowS
DeleteDataSourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDataSourceResponse] -> ShowS
$cshowList :: [DeleteDataSourceResponse] -> ShowS
show :: DeleteDataSourceResponse -> String
$cshow :: DeleteDataSourceResponse -> String
showsPrec :: Int -> DeleteDataSourceResponse -> ShowS
$cshowsPrec :: Int -> DeleteDataSourceResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteDataSourceResponse x -> DeleteDataSourceResponse
forall x.
DeleteDataSourceResponse -> Rep DeleteDataSourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDataSourceResponse x -> DeleteDataSourceResponse
$cfrom :: forall x.
DeleteDataSourceResponse -> Rep DeleteDataSourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDataSourceResponse' 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:
--
-- 'arn', 'deleteDataSourceResponse_arn' - The Amazon Resource Name (ARN) of the data source that you deleted.
--
-- 'dataSourceId', 'deleteDataSourceResponse_dataSourceId' - The ID of the data source. This ID is unique per Amazon Web Services
-- Region for each Amazon Web Services account.
--
-- 'requestId', 'deleteDataSourceResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'status', 'deleteDataSourceResponse_status' - The HTTP status of the request.
newDeleteDataSourceResponse ::
  -- | 'status'
  Prelude.Int ->
  DeleteDataSourceResponse
newDeleteDataSourceResponse :: Int -> DeleteDataSourceResponse
newDeleteDataSourceResponse Int
pStatus_ =
  DeleteDataSourceResponse'
    { $sel:arn:DeleteDataSourceResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:dataSourceId:DeleteDataSourceResponse' :: Maybe Text
dataSourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:DeleteDataSourceResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:DeleteDataSourceResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Resource Name (ARN) of the data source that you deleted.
deleteDataSourceResponse_arn :: Lens.Lens' DeleteDataSourceResponse (Prelude.Maybe Prelude.Text)
deleteDataSourceResponse_arn :: Lens' DeleteDataSourceResponse (Maybe Text)
deleteDataSourceResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataSourceResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DeleteDataSourceResponse
s@DeleteDataSourceResponse' {} Maybe Text
a -> DeleteDataSourceResponse
s {$sel:arn:DeleteDataSourceResponse' :: Maybe Text
arn = Maybe Text
a} :: DeleteDataSourceResponse)

-- | The ID of the data source. This ID is unique per Amazon Web Services
-- Region for each Amazon Web Services account.
deleteDataSourceResponse_dataSourceId :: Lens.Lens' DeleteDataSourceResponse (Prelude.Maybe Prelude.Text)
deleteDataSourceResponse_dataSourceId :: Lens' DeleteDataSourceResponse (Maybe Text)
deleteDataSourceResponse_dataSourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataSourceResponse' {Maybe Text
dataSourceId :: Maybe Text
$sel:dataSourceId:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Maybe Text
dataSourceId} -> Maybe Text
dataSourceId) (\s :: DeleteDataSourceResponse
s@DeleteDataSourceResponse' {} Maybe Text
a -> DeleteDataSourceResponse
s {$sel:dataSourceId:DeleteDataSourceResponse' :: Maybe Text
dataSourceId = Maybe Text
a} :: DeleteDataSourceResponse)

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

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

instance Prelude.NFData DeleteDataSourceResponse where
  rnf :: DeleteDataSourceResponse -> ()
rnf DeleteDataSourceResponse' {Int
Maybe Text
status :: Int
requestId :: Maybe Text
dataSourceId :: Maybe Text
arn :: Maybe Text
$sel:status:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Int
$sel:requestId:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Maybe Text
$sel:dataSourceId:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Maybe Text
$sel:arn:DeleteDataSourceResponse' :: DeleteDataSourceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataSourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
status