{-# 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.AppIntegrationS.DeleteDataIntegration
-- 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)
--
-- Deletes the DataIntegration. Only DataIntegrations that don\'t have any
-- DataIntegrationAssociations can be deleted. Deleting a DataIntegration
-- also deletes the underlying Amazon AppFlow flow and service linked role.
--
-- You cannot create a DataIntegration association for a DataIntegration
-- that has been previously associated. Use a different DataIntegration, or
-- recreate the DataIntegration using the
-- <https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_CreateDataIntegration.html CreateDataIntegration>
-- API.
module Amazonka.AppIntegrationS.DeleteDataIntegration
  ( -- * Creating a Request
    DeleteDataIntegration (..),
    newDeleteDataIntegration,

    -- * Request Lenses
    deleteDataIntegration_dataIntegrationIdentifier,

    -- * Destructuring the Response
    DeleteDataIntegrationResponse (..),
    newDeleteDataIntegrationResponse,

    -- * Response Lenses
    deleteDataIntegrationResponse_httpStatus,
  )
where

import Amazonka.AppIntegrationS.Types
import qualified Amazonka.Core as Core
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:/ 'newDeleteDataIntegration' smart constructor.
data DeleteDataIntegration = DeleteDataIntegration'
  { -- | A unique identifier for the DataIntegration.
    DeleteDataIntegration -> Text
dataIntegrationIdentifier :: Prelude.Text
  }
  deriving (DeleteDataIntegration -> DeleteDataIntegration -> Bool
(DeleteDataIntegration -> DeleteDataIntegration -> Bool)
-> (DeleteDataIntegration -> DeleteDataIntegration -> Bool)
-> Eq DeleteDataIntegration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDataIntegration -> DeleteDataIntegration -> Bool
$c/= :: DeleteDataIntegration -> DeleteDataIntegration -> Bool
== :: DeleteDataIntegration -> DeleteDataIntegration -> Bool
$c== :: DeleteDataIntegration -> DeleteDataIntegration -> Bool
Prelude.Eq, ReadPrec [DeleteDataIntegration]
ReadPrec DeleteDataIntegration
Int -> ReadS DeleteDataIntegration
ReadS [DeleteDataIntegration]
(Int -> ReadS DeleteDataIntegration)
-> ReadS [DeleteDataIntegration]
-> ReadPrec DeleteDataIntegration
-> ReadPrec [DeleteDataIntegration]
-> Read DeleteDataIntegration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDataIntegration]
$creadListPrec :: ReadPrec [DeleteDataIntegration]
readPrec :: ReadPrec DeleteDataIntegration
$creadPrec :: ReadPrec DeleteDataIntegration
readList :: ReadS [DeleteDataIntegration]
$creadList :: ReadS [DeleteDataIntegration]
readsPrec :: Int -> ReadS DeleteDataIntegration
$creadsPrec :: Int -> ReadS DeleteDataIntegration
Prelude.Read, Int -> DeleteDataIntegration -> ShowS
[DeleteDataIntegration] -> ShowS
DeleteDataIntegration -> String
(Int -> DeleteDataIntegration -> ShowS)
-> (DeleteDataIntegration -> String)
-> ([DeleteDataIntegration] -> ShowS)
-> Show DeleteDataIntegration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDataIntegration] -> ShowS
$cshowList :: [DeleteDataIntegration] -> ShowS
show :: DeleteDataIntegration -> String
$cshow :: DeleteDataIntegration -> String
showsPrec :: Int -> DeleteDataIntegration -> ShowS
$cshowsPrec :: Int -> DeleteDataIntegration -> ShowS
Prelude.Show, (forall x. DeleteDataIntegration -> Rep DeleteDataIntegration x)
-> (forall x. Rep DeleteDataIntegration x -> DeleteDataIntegration)
-> Generic DeleteDataIntegration
forall x. Rep DeleteDataIntegration x -> DeleteDataIntegration
forall x. DeleteDataIntegration -> Rep DeleteDataIntegration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDataIntegration x -> DeleteDataIntegration
$cfrom :: forall x. DeleteDataIntegration -> Rep DeleteDataIntegration x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDataIntegration' 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:
--
-- 'dataIntegrationIdentifier', 'deleteDataIntegration_dataIntegrationIdentifier' - A unique identifier for the DataIntegration.
newDeleteDataIntegration ::
  -- | 'dataIntegrationIdentifier'
  Prelude.Text ->
  DeleteDataIntegration
newDeleteDataIntegration :: Text -> DeleteDataIntegration
newDeleteDataIntegration Text
pDataIntegrationIdentifier_ =
  DeleteDataIntegration' :: Text -> DeleteDataIntegration
DeleteDataIntegration'
    { $sel:dataIntegrationIdentifier:DeleteDataIntegration' :: Text
dataIntegrationIdentifier =
        Text
pDataIntegrationIdentifier_
    }

-- | A unique identifier for the DataIntegration.
deleteDataIntegration_dataIntegrationIdentifier :: Lens.Lens' DeleteDataIntegration Prelude.Text
deleteDataIntegration_dataIntegrationIdentifier :: (Text -> f Text)
-> DeleteDataIntegration -> f DeleteDataIntegration
deleteDataIntegration_dataIntegrationIdentifier = (DeleteDataIntegration -> Text)
-> (DeleteDataIntegration -> Text -> DeleteDataIntegration)
-> Lens DeleteDataIntegration DeleteDataIntegration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDataIntegration' {Text
dataIntegrationIdentifier :: Text
$sel:dataIntegrationIdentifier:DeleteDataIntegration' :: DeleteDataIntegration -> Text
dataIntegrationIdentifier} -> Text
dataIntegrationIdentifier) (\s :: DeleteDataIntegration
s@DeleteDataIntegration' {} Text
a -> DeleteDataIntegration
s {$sel:dataIntegrationIdentifier:DeleteDataIntegration' :: Text
dataIntegrationIdentifier = Text
a} :: DeleteDataIntegration)

instance Core.AWSRequest DeleteDataIntegration where
  type
    AWSResponse DeleteDataIntegration =
      DeleteDataIntegrationResponse
  request :: DeleteDataIntegration -> Request DeleteDataIntegration
request = Service -> DeleteDataIntegration -> Request DeleteDataIntegration
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDataIntegration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDataIntegration)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteDataIntegration))
-> Logger
-> Service
-> Proxy DeleteDataIntegration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDataIntegration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteDataIntegrationResponse
DeleteDataIntegrationResponse'
            (Int -> DeleteDataIntegrationResponse)
-> Either String Int -> Either String DeleteDataIntegrationResponse
forall (f :: * -> *) a b. Functor 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 DeleteDataIntegration

instance Prelude.NFData DeleteDataIntegration

instance Core.ToHeaders DeleteDataIntegration where
  toHeaders :: DeleteDataIntegration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDataIntegration -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DeleteDataIntegration where
  toPath :: DeleteDataIntegration -> ByteString
toPath DeleteDataIntegration' {Text
dataIntegrationIdentifier :: Text
$sel:dataIntegrationIdentifier:DeleteDataIntegration' :: DeleteDataIntegration -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/dataIntegrations/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
dataIntegrationIdentifier
      ]

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

-- | /See:/ 'newDeleteDataIntegrationResponse' smart constructor.
data DeleteDataIntegrationResponse = DeleteDataIntegrationResponse'
  { -- | The response's http status code.
    DeleteDataIntegrationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDataIntegrationResponse
-> DeleteDataIntegrationResponse -> Bool
(DeleteDataIntegrationResponse
 -> DeleteDataIntegrationResponse -> Bool)
-> (DeleteDataIntegrationResponse
    -> DeleteDataIntegrationResponse -> Bool)
-> Eq DeleteDataIntegrationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDataIntegrationResponse
-> DeleteDataIntegrationResponse -> Bool
$c/= :: DeleteDataIntegrationResponse
-> DeleteDataIntegrationResponse -> Bool
== :: DeleteDataIntegrationResponse
-> DeleteDataIntegrationResponse -> Bool
$c== :: DeleteDataIntegrationResponse
-> DeleteDataIntegrationResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDataIntegrationResponse]
ReadPrec DeleteDataIntegrationResponse
Int -> ReadS DeleteDataIntegrationResponse
ReadS [DeleteDataIntegrationResponse]
(Int -> ReadS DeleteDataIntegrationResponse)
-> ReadS [DeleteDataIntegrationResponse]
-> ReadPrec DeleteDataIntegrationResponse
-> ReadPrec [DeleteDataIntegrationResponse]
-> Read DeleteDataIntegrationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDataIntegrationResponse]
$creadListPrec :: ReadPrec [DeleteDataIntegrationResponse]
readPrec :: ReadPrec DeleteDataIntegrationResponse
$creadPrec :: ReadPrec DeleteDataIntegrationResponse
readList :: ReadS [DeleteDataIntegrationResponse]
$creadList :: ReadS [DeleteDataIntegrationResponse]
readsPrec :: Int -> ReadS DeleteDataIntegrationResponse
$creadsPrec :: Int -> ReadS DeleteDataIntegrationResponse
Prelude.Read, Int -> DeleteDataIntegrationResponse -> ShowS
[DeleteDataIntegrationResponse] -> ShowS
DeleteDataIntegrationResponse -> String
(Int -> DeleteDataIntegrationResponse -> ShowS)
-> (DeleteDataIntegrationResponse -> String)
-> ([DeleteDataIntegrationResponse] -> ShowS)
-> Show DeleteDataIntegrationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDataIntegrationResponse] -> ShowS
$cshowList :: [DeleteDataIntegrationResponse] -> ShowS
show :: DeleteDataIntegrationResponse -> String
$cshow :: DeleteDataIntegrationResponse -> String
showsPrec :: Int -> DeleteDataIntegrationResponse -> ShowS
$cshowsPrec :: Int -> DeleteDataIntegrationResponse -> ShowS
Prelude.Show, (forall x.
 DeleteDataIntegrationResponse
 -> Rep DeleteDataIntegrationResponse x)
-> (forall x.
    Rep DeleteDataIntegrationResponse x
    -> DeleteDataIntegrationResponse)
-> Generic DeleteDataIntegrationResponse
forall x.
Rep DeleteDataIntegrationResponse x
-> DeleteDataIntegrationResponse
forall x.
DeleteDataIntegrationResponse
-> Rep DeleteDataIntegrationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDataIntegrationResponse x
-> DeleteDataIntegrationResponse
$cfrom :: forall x.
DeleteDataIntegrationResponse
-> Rep DeleteDataIntegrationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDataIntegrationResponse' 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:
--
-- 'httpStatus', 'deleteDataIntegrationResponse_httpStatus' - The response's http status code.
newDeleteDataIntegrationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDataIntegrationResponse
newDeleteDataIntegrationResponse :: Int -> DeleteDataIntegrationResponse
newDeleteDataIntegrationResponse Int
pHttpStatus_ =
  DeleteDataIntegrationResponse' :: Int -> DeleteDataIntegrationResponse
DeleteDataIntegrationResponse'
    { $sel:httpStatus:DeleteDataIntegrationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteDataIntegrationResponse