{-# 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.AppFlow.DeleteFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables your application to delete an existing flow. Before deleting the
-- flow, Amazon AppFlow validates the request by checking the flow
-- configuration and status. You can delete flows one at a time.
module Amazonka.AppFlow.DeleteFlow
  ( -- * Creating a Request
    DeleteFlow (..),
    newDeleteFlow,

    -- * Request Lenses
    deleteFlow_forceDelete,
    deleteFlow_flowName,

    -- * Destructuring the Response
    DeleteFlowResponse (..),
    newDeleteFlowResponse,

    -- * Response Lenses
    deleteFlowResponse_httpStatus,
  )
where

import Amazonka.AppFlow.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteFlow' smart constructor.
data DeleteFlow = DeleteFlow'
  { -- | Indicates whether Amazon AppFlow should delete the flow, even if it is
    -- currently in use.
    DeleteFlow -> Maybe Bool
forceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The specified name of the flow. Spaces are not allowed. Use underscores
    -- (_) or hyphens (-) only.
    DeleteFlow -> Text
flowName :: Prelude.Text
  }
  deriving (DeleteFlow -> DeleteFlow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFlow -> DeleteFlow -> Bool
$c/= :: DeleteFlow -> DeleteFlow -> Bool
== :: DeleteFlow -> DeleteFlow -> Bool
$c== :: DeleteFlow -> DeleteFlow -> Bool
Prelude.Eq, ReadPrec [DeleteFlow]
ReadPrec DeleteFlow
Int -> ReadS DeleteFlow
ReadS [DeleteFlow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFlow]
$creadListPrec :: ReadPrec [DeleteFlow]
readPrec :: ReadPrec DeleteFlow
$creadPrec :: ReadPrec DeleteFlow
readList :: ReadS [DeleteFlow]
$creadList :: ReadS [DeleteFlow]
readsPrec :: Int -> ReadS DeleteFlow
$creadsPrec :: Int -> ReadS DeleteFlow
Prelude.Read, Int -> DeleteFlow -> ShowS
[DeleteFlow] -> ShowS
DeleteFlow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFlow] -> ShowS
$cshowList :: [DeleteFlow] -> ShowS
show :: DeleteFlow -> String
$cshow :: DeleteFlow -> String
showsPrec :: Int -> DeleteFlow -> ShowS
$cshowsPrec :: Int -> DeleteFlow -> ShowS
Prelude.Show, forall x. Rep DeleteFlow x -> DeleteFlow
forall x. DeleteFlow -> Rep DeleteFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFlow x -> DeleteFlow
$cfrom :: forall x. DeleteFlow -> Rep DeleteFlow x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFlow' 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:
--
-- 'forceDelete', 'deleteFlow_forceDelete' - Indicates whether Amazon AppFlow should delete the flow, even if it is
-- currently in use.
--
-- 'flowName', 'deleteFlow_flowName' - The specified name of the flow. Spaces are not allowed. Use underscores
-- (_) or hyphens (-) only.
newDeleteFlow ::
  -- | 'flowName'
  Prelude.Text ->
  DeleteFlow
newDeleteFlow :: Text -> DeleteFlow
newDeleteFlow Text
pFlowName_ =
  DeleteFlow'
    { $sel:forceDelete:DeleteFlow' :: Maybe Bool
forceDelete = forall a. Maybe a
Prelude.Nothing,
      $sel:flowName:DeleteFlow' :: Text
flowName = Text
pFlowName_
    }

-- | Indicates whether Amazon AppFlow should delete the flow, even if it is
-- currently in use.
deleteFlow_forceDelete :: Lens.Lens' DeleteFlow (Prelude.Maybe Prelude.Bool)
deleteFlow_forceDelete :: Lens' DeleteFlow (Maybe Bool)
deleteFlow_forceDelete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFlow' {Maybe Bool
forceDelete :: Maybe Bool
$sel:forceDelete:DeleteFlow' :: DeleteFlow -> Maybe Bool
forceDelete} -> Maybe Bool
forceDelete) (\s :: DeleteFlow
s@DeleteFlow' {} Maybe Bool
a -> DeleteFlow
s {$sel:forceDelete:DeleteFlow' :: Maybe Bool
forceDelete = Maybe Bool
a} :: DeleteFlow)

-- | The specified name of the flow. Spaces are not allowed. Use underscores
-- (_) or hyphens (-) only.
deleteFlow_flowName :: Lens.Lens' DeleteFlow Prelude.Text
deleteFlow_flowName :: Lens' DeleteFlow Text
deleteFlow_flowName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFlow' {Text
flowName :: Text
$sel:flowName:DeleteFlow' :: DeleteFlow -> Text
flowName} -> Text
flowName) (\s :: DeleteFlow
s@DeleteFlow' {} Text
a -> DeleteFlow
s {$sel:flowName:DeleteFlow' :: Text
flowName = Text
a} :: DeleteFlow)

instance Core.AWSRequest DeleteFlow where
  type AWSResponse DeleteFlow = DeleteFlowResponse
  request :: (Service -> Service) -> DeleteFlow -> Request DeleteFlow
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 DeleteFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFlow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteFlowResponse
DeleteFlowResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteFlow where
  hashWithSalt :: Int -> DeleteFlow -> Int
hashWithSalt Int
_salt DeleteFlow' {Maybe Bool
Text
flowName :: Text
forceDelete :: Maybe Bool
$sel:flowName:DeleteFlow' :: DeleteFlow -> Text
$sel:forceDelete:DeleteFlow' :: DeleteFlow -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
forceDelete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowName

instance Prelude.NFData DeleteFlow where
  rnf :: DeleteFlow -> ()
rnf DeleteFlow' {Maybe Bool
Text
flowName :: Text
forceDelete :: Maybe Bool
$sel:flowName:DeleteFlow' :: DeleteFlow -> Text
$sel:forceDelete:DeleteFlow' :: DeleteFlow -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
forceDelete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
flowName

instance Data.ToHeaders DeleteFlow where
  toHeaders :: DeleteFlow -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteFlow where
  toJSON :: DeleteFlow -> Value
toJSON DeleteFlow' {Maybe Bool
Text
flowName :: Text
forceDelete :: Maybe Bool
$sel:flowName:DeleteFlow' :: DeleteFlow -> Text
$sel:forceDelete:DeleteFlow' :: DeleteFlow -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"forceDelete" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceDelete,
            forall a. a -> Maybe a
Prelude.Just (Key
"flowName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
flowName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteFlowResponse where
  rnf :: DeleteFlowResponse -> ()
rnf DeleteFlowResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteFlowResponse' :: DeleteFlowResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus