{-# 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.SageMaker.DeletePipeline
-- 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 a pipeline if there are no running instances of the pipeline. To
-- delete a pipeline, you must stop all running instances of the pipeline
-- using the @StopPipelineExecution@ API. When you delete a pipeline, all
-- instances of the pipeline are deleted.
module Amazonka.SageMaker.DeletePipeline
  ( -- * Creating a Request
    DeletePipeline (..),
    newDeletePipeline,

    -- * Request Lenses
    deletePipeline_pipelineName,
    deletePipeline_clientRequestToken,

    -- * Destructuring the Response
    DeletePipelineResponse (..),
    newDeletePipelineResponse,

    -- * Response Lenses
    deletePipelineResponse_pipelineArn,
    deletePipelineResponse_httpStatus,
  )
where

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
import Amazonka.SageMaker.Types

-- | /See:/ 'newDeletePipeline' smart constructor.
data DeletePipeline = DeletePipeline'
  { -- | The name of the pipeline to delete.
    DeletePipeline -> Text
pipelineName :: Prelude.Text,
    -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the operation. An idempotent operation completes no more
    -- than one time.
    DeletePipeline -> Text
clientRequestToken :: Prelude.Text
  }
  deriving (DeletePipeline -> DeletePipeline -> Bool
(DeletePipeline -> DeletePipeline -> Bool)
-> (DeletePipeline -> DeletePipeline -> Bool) -> Eq DeletePipeline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePipeline -> DeletePipeline -> Bool
$c/= :: DeletePipeline -> DeletePipeline -> Bool
== :: DeletePipeline -> DeletePipeline -> Bool
$c== :: DeletePipeline -> DeletePipeline -> Bool
Prelude.Eq, ReadPrec [DeletePipeline]
ReadPrec DeletePipeline
Int -> ReadS DeletePipeline
ReadS [DeletePipeline]
(Int -> ReadS DeletePipeline)
-> ReadS [DeletePipeline]
-> ReadPrec DeletePipeline
-> ReadPrec [DeletePipeline]
-> Read DeletePipeline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePipeline]
$creadListPrec :: ReadPrec [DeletePipeline]
readPrec :: ReadPrec DeletePipeline
$creadPrec :: ReadPrec DeletePipeline
readList :: ReadS [DeletePipeline]
$creadList :: ReadS [DeletePipeline]
readsPrec :: Int -> ReadS DeletePipeline
$creadsPrec :: Int -> ReadS DeletePipeline
Prelude.Read, Int -> DeletePipeline -> ShowS
[DeletePipeline] -> ShowS
DeletePipeline -> String
(Int -> DeletePipeline -> ShowS)
-> (DeletePipeline -> String)
-> ([DeletePipeline] -> ShowS)
-> Show DeletePipeline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePipeline] -> ShowS
$cshowList :: [DeletePipeline] -> ShowS
show :: DeletePipeline -> String
$cshow :: DeletePipeline -> String
showsPrec :: Int -> DeletePipeline -> ShowS
$cshowsPrec :: Int -> DeletePipeline -> ShowS
Prelude.Show, (forall x. DeletePipeline -> Rep DeletePipeline x)
-> (forall x. Rep DeletePipeline x -> DeletePipeline)
-> Generic DeletePipeline
forall x. Rep DeletePipeline x -> DeletePipeline
forall x. DeletePipeline -> Rep DeletePipeline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePipeline x -> DeletePipeline
$cfrom :: forall x. DeletePipeline -> Rep DeletePipeline x
Prelude.Generic)

-- |
-- Create a value of 'DeletePipeline' 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:
--
-- 'pipelineName', 'deletePipeline_pipelineName' - The name of the pipeline to delete.
--
-- 'clientRequestToken', 'deletePipeline_clientRequestToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the operation. An idempotent operation completes no more
-- than one time.
newDeletePipeline ::
  -- | 'pipelineName'
  Prelude.Text ->
  -- | 'clientRequestToken'
  Prelude.Text ->
  DeletePipeline
newDeletePipeline :: Text -> Text -> DeletePipeline
newDeletePipeline Text
pPipelineName_ Text
pClientRequestToken_ =
  DeletePipeline' :: Text -> Text -> DeletePipeline
DeletePipeline'
    { $sel:pipelineName:DeletePipeline' :: Text
pipelineName = Text
pPipelineName_,
      $sel:clientRequestToken:DeletePipeline' :: Text
clientRequestToken = Text
pClientRequestToken_
    }

-- | The name of the pipeline to delete.
deletePipeline_pipelineName :: Lens.Lens' DeletePipeline Prelude.Text
deletePipeline_pipelineName :: (Text -> f Text) -> DeletePipeline -> f DeletePipeline
deletePipeline_pipelineName = (DeletePipeline -> Text)
-> (DeletePipeline -> Text -> DeletePipeline)
-> Lens DeletePipeline DeletePipeline Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePipeline' {Text
pipelineName :: Text
$sel:pipelineName:DeletePipeline' :: DeletePipeline -> Text
pipelineName} -> Text
pipelineName) (\s :: DeletePipeline
s@DeletePipeline' {} Text
a -> DeletePipeline
s {$sel:pipelineName:DeletePipeline' :: Text
pipelineName = Text
a} :: DeletePipeline)

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the operation. An idempotent operation completes no more
-- than one time.
deletePipeline_clientRequestToken :: Lens.Lens' DeletePipeline Prelude.Text
deletePipeline_clientRequestToken :: (Text -> f Text) -> DeletePipeline -> f DeletePipeline
deletePipeline_clientRequestToken = (DeletePipeline -> Text)
-> (DeletePipeline -> Text -> DeletePipeline)
-> Lens DeletePipeline DeletePipeline Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePipeline' {Text
clientRequestToken :: Text
$sel:clientRequestToken:DeletePipeline' :: DeletePipeline -> Text
clientRequestToken} -> Text
clientRequestToken) (\s :: DeletePipeline
s@DeletePipeline' {} Text
a -> DeletePipeline
s {$sel:clientRequestToken:DeletePipeline' :: Text
clientRequestToken = Text
a} :: DeletePipeline)

instance Core.AWSRequest DeletePipeline where
  type
    AWSResponse DeletePipeline =
      DeletePipelineResponse
  request :: DeletePipeline -> Request DeletePipeline
request = Service -> DeletePipeline -> Request DeletePipeline
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePipeline
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePipeline)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeletePipeline))
-> Logger
-> Service
-> Proxy DeletePipeline
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePipeline)))
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 -> Int -> DeletePipelineResponse
DeletePipelineResponse'
            (Maybe Text -> Int -> DeletePipelineResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeletePipelineResponse)
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
"PipelineArn")
            Either String (Int -> DeletePipelineResponse)
-> Either String Int -> Either String DeletePipelineResponse
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 DeletePipeline

instance Prelude.NFData DeletePipeline

instance Core.ToHeaders DeletePipeline where
  toHeaders :: DeletePipeline -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePipeline -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"SageMaker.DeletePipeline" :: Prelude.ByteString),
            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.ToJSON DeletePipeline where
  toJSON :: DeletePipeline -> Value
toJSON DeletePipeline' {Text
clientRequestToken :: Text
pipelineName :: Text
$sel:clientRequestToken:DeletePipeline' :: DeletePipeline -> Text
$sel:pipelineName:DeletePipeline' :: DeletePipeline -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PipelineName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientRequestToken)
          ]
      )

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

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

-- | /See:/ 'newDeletePipelineResponse' smart constructor.
data DeletePipelineResponse = DeletePipelineResponse'
  { -- | The Amazon Resource Name (ARN) of the pipeline to delete.
    DeletePipelineResponse -> Maybe Text
pipelineArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeletePipelineResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeletePipelineResponse -> DeletePipelineResponse -> Bool
(DeletePipelineResponse -> DeletePipelineResponse -> Bool)
-> (DeletePipelineResponse -> DeletePipelineResponse -> Bool)
-> Eq DeletePipelineResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePipelineResponse -> DeletePipelineResponse -> Bool
$c/= :: DeletePipelineResponse -> DeletePipelineResponse -> Bool
== :: DeletePipelineResponse -> DeletePipelineResponse -> Bool
$c== :: DeletePipelineResponse -> DeletePipelineResponse -> Bool
Prelude.Eq, ReadPrec [DeletePipelineResponse]
ReadPrec DeletePipelineResponse
Int -> ReadS DeletePipelineResponse
ReadS [DeletePipelineResponse]
(Int -> ReadS DeletePipelineResponse)
-> ReadS [DeletePipelineResponse]
-> ReadPrec DeletePipelineResponse
-> ReadPrec [DeletePipelineResponse]
-> Read DeletePipelineResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePipelineResponse]
$creadListPrec :: ReadPrec [DeletePipelineResponse]
readPrec :: ReadPrec DeletePipelineResponse
$creadPrec :: ReadPrec DeletePipelineResponse
readList :: ReadS [DeletePipelineResponse]
$creadList :: ReadS [DeletePipelineResponse]
readsPrec :: Int -> ReadS DeletePipelineResponse
$creadsPrec :: Int -> ReadS DeletePipelineResponse
Prelude.Read, Int -> DeletePipelineResponse -> ShowS
[DeletePipelineResponse] -> ShowS
DeletePipelineResponse -> String
(Int -> DeletePipelineResponse -> ShowS)
-> (DeletePipelineResponse -> String)
-> ([DeletePipelineResponse] -> ShowS)
-> Show DeletePipelineResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePipelineResponse] -> ShowS
$cshowList :: [DeletePipelineResponse] -> ShowS
show :: DeletePipelineResponse -> String
$cshow :: DeletePipelineResponse -> String
showsPrec :: Int -> DeletePipelineResponse -> ShowS
$cshowsPrec :: Int -> DeletePipelineResponse -> ShowS
Prelude.Show, (forall x. DeletePipelineResponse -> Rep DeletePipelineResponse x)
-> (forall x.
    Rep DeletePipelineResponse x -> DeletePipelineResponse)
-> Generic DeletePipelineResponse
forall x. Rep DeletePipelineResponse x -> DeletePipelineResponse
forall x. DeletePipelineResponse -> Rep DeletePipelineResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePipelineResponse x -> DeletePipelineResponse
$cfrom :: forall x. DeletePipelineResponse -> Rep DeletePipelineResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeletePipelineResponse' 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:
--
-- 'pipelineArn', 'deletePipelineResponse_pipelineArn' - The Amazon Resource Name (ARN) of the pipeline to delete.
--
-- 'httpStatus', 'deletePipelineResponse_httpStatus' - The response's http status code.
newDeletePipelineResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeletePipelineResponse
newDeletePipelineResponse :: Int -> DeletePipelineResponse
newDeletePipelineResponse Int
pHttpStatus_ =
  DeletePipelineResponse' :: Maybe Text -> Int -> DeletePipelineResponse
DeletePipelineResponse'
    { $sel:pipelineArn:DeletePipelineResponse' :: Maybe Text
pipelineArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeletePipelineResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the pipeline to delete.
deletePipelineResponse_pipelineArn :: Lens.Lens' DeletePipelineResponse (Prelude.Maybe Prelude.Text)
deletePipelineResponse_pipelineArn :: (Maybe Text -> f (Maybe Text))
-> DeletePipelineResponse -> f DeletePipelineResponse
deletePipelineResponse_pipelineArn = (DeletePipelineResponse -> Maybe Text)
-> (DeletePipelineResponse -> Maybe Text -> DeletePipelineResponse)
-> Lens
     DeletePipelineResponse
     DeletePipelineResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePipelineResponse' {Maybe Text
pipelineArn :: Maybe Text
$sel:pipelineArn:DeletePipelineResponse' :: DeletePipelineResponse -> Maybe Text
pipelineArn} -> Maybe Text
pipelineArn) (\s :: DeletePipelineResponse
s@DeletePipelineResponse' {} Maybe Text
a -> DeletePipelineResponse
s {$sel:pipelineArn:DeletePipelineResponse' :: Maybe Text
pipelineArn = Maybe Text
a} :: DeletePipelineResponse)

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

instance Prelude.NFData DeletePipelineResponse