{-# 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.DeleteArtifact
-- 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 an artifact. Either @ArtifactArn@ or @Source@ must be specified.
module Amazonka.SageMaker.DeleteArtifact
  ( -- * Creating a Request
    DeleteArtifact (..),
    newDeleteArtifact,

    -- * Request Lenses
    deleteArtifact_source,
    deleteArtifact_artifactArn,

    -- * Destructuring the Response
    DeleteArtifactResponse (..),
    newDeleteArtifactResponse,

    -- * Response Lenses
    deleteArtifactResponse_artifactArn,
    deleteArtifactResponse_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:/ 'newDeleteArtifact' smart constructor.
data DeleteArtifact = DeleteArtifact'
  { -- | The URI of the source.
    DeleteArtifact -> Maybe ArtifactSource
source :: Prelude.Maybe ArtifactSource,
    -- | The Amazon Resource Name (ARN) of the artifact to delete.
    DeleteArtifact -> Maybe Text
artifactArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteArtifact -> DeleteArtifact -> Bool
(DeleteArtifact -> DeleteArtifact -> Bool)
-> (DeleteArtifact -> DeleteArtifact -> Bool) -> Eq DeleteArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteArtifact -> DeleteArtifact -> Bool
$c/= :: DeleteArtifact -> DeleteArtifact -> Bool
== :: DeleteArtifact -> DeleteArtifact -> Bool
$c== :: DeleteArtifact -> DeleteArtifact -> Bool
Prelude.Eq, ReadPrec [DeleteArtifact]
ReadPrec DeleteArtifact
Int -> ReadS DeleteArtifact
ReadS [DeleteArtifact]
(Int -> ReadS DeleteArtifact)
-> ReadS [DeleteArtifact]
-> ReadPrec DeleteArtifact
-> ReadPrec [DeleteArtifact]
-> Read DeleteArtifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteArtifact]
$creadListPrec :: ReadPrec [DeleteArtifact]
readPrec :: ReadPrec DeleteArtifact
$creadPrec :: ReadPrec DeleteArtifact
readList :: ReadS [DeleteArtifact]
$creadList :: ReadS [DeleteArtifact]
readsPrec :: Int -> ReadS DeleteArtifact
$creadsPrec :: Int -> ReadS DeleteArtifact
Prelude.Read, Int -> DeleteArtifact -> ShowS
[DeleteArtifact] -> ShowS
DeleteArtifact -> String
(Int -> DeleteArtifact -> ShowS)
-> (DeleteArtifact -> String)
-> ([DeleteArtifact] -> ShowS)
-> Show DeleteArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteArtifact] -> ShowS
$cshowList :: [DeleteArtifact] -> ShowS
show :: DeleteArtifact -> String
$cshow :: DeleteArtifact -> String
showsPrec :: Int -> DeleteArtifact -> ShowS
$cshowsPrec :: Int -> DeleteArtifact -> ShowS
Prelude.Show, (forall x. DeleteArtifact -> Rep DeleteArtifact x)
-> (forall x. Rep DeleteArtifact x -> DeleteArtifact)
-> Generic DeleteArtifact
forall x. Rep DeleteArtifact x -> DeleteArtifact
forall x. DeleteArtifact -> Rep DeleteArtifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteArtifact x -> DeleteArtifact
$cfrom :: forall x. DeleteArtifact -> Rep DeleteArtifact x
Prelude.Generic)

-- |
-- Create a value of 'DeleteArtifact' 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:
--
-- 'source', 'deleteArtifact_source' - The URI of the source.
--
-- 'artifactArn', 'deleteArtifact_artifactArn' - The Amazon Resource Name (ARN) of the artifact to delete.
newDeleteArtifact ::
  DeleteArtifact
newDeleteArtifact :: DeleteArtifact
newDeleteArtifact =
  DeleteArtifact' :: Maybe ArtifactSource -> Maybe Text -> DeleteArtifact
DeleteArtifact'
    { $sel:source:DeleteArtifact' :: Maybe ArtifactSource
source = Maybe ArtifactSource
forall a. Maybe a
Prelude.Nothing,
      $sel:artifactArn:DeleteArtifact' :: Maybe Text
artifactArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The URI of the source.
deleteArtifact_source :: Lens.Lens' DeleteArtifact (Prelude.Maybe ArtifactSource)
deleteArtifact_source :: (Maybe ArtifactSource -> f (Maybe ArtifactSource))
-> DeleteArtifact -> f DeleteArtifact
deleteArtifact_source = (DeleteArtifact -> Maybe ArtifactSource)
-> (DeleteArtifact -> Maybe ArtifactSource -> DeleteArtifact)
-> Lens
     DeleteArtifact
     DeleteArtifact
     (Maybe ArtifactSource)
     (Maybe ArtifactSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteArtifact' {Maybe ArtifactSource
source :: Maybe ArtifactSource
$sel:source:DeleteArtifact' :: DeleteArtifact -> Maybe ArtifactSource
source} -> Maybe ArtifactSource
source) (\s :: DeleteArtifact
s@DeleteArtifact' {} Maybe ArtifactSource
a -> DeleteArtifact
s {$sel:source:DeleteArtifact' :: Maybe ArtifactSource
source = Maybe ArtifactSource
a} :: DeleteArtifact)

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

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

instance Prelude.NFData DeleteArtifact

instance Core.ToHeaders DeleteArtifact where
  toHeaders :: DeleteArtifact -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteArtifact -> 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.DeleteArtifact" :: 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 DeleteArtifact where
  toJSON :: DeleteArtifact -> Value
toJSON DeleteArtifact' {Maybe Text
Maybe ArtifactSource
artifactArn :: Maybe Text
source :: Maybe ArtifactSource
$sel:artifactArn:DeleteArtifact' :: DeleteArtifact -> Maybe Text
$sel:source:DeleteArtifact' :: DeleteArtifact -> Maybe ArtifactSource
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Source" Text -> ArtifactSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ArtifactSource -> Pair) -> Maybe ArtifactSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ArtifactSource
source,
            (Text
"ArtifactArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
artifactArn
          ]
      )

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

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

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

-- |
-- Create a value of 'DeleteArtifactResponse' 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:
--
-- 'artifactArn', 'deleteArtifactResponse_artifactArn' - The Amazon Resource Name (ARN) of the artifact.
--
-- 'httpStatus', 'deleteArtifactResponse_httpStatus' - The response's http status code.
newDeleteArtifactResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteArtifactResponse
newDeleteArtifactResponse :: Int -> DeleteArtifactResponse
newDeleteArtifactResponse Int
pHttpStatus_ =
  DeleteArtifactResponse' :: Maybe Text -> Int -> DeleteArtifactResponse
DeleteArtifactResponse'
    { $sel:artifactArn:DeleteArtifactResponse' :: Maybe Text
artifactArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteArtifactResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the artifact.
deleteArtifactResponse_artifactArn :: Lens.Lens' DeleteArtifactResponse (Prelude.Maybe Prelude.Text)
deleteArtifactResponse_artifactArn :: (Maybe Text -> f (Maybe Text))
-> DeleteArtifactResponse -> f DeleteArtifactResponse
deleteArtifactResponse_artifactArn = (DeleteArtifactResponse -> Maybe Text)
-> (DeleteArtifactResponse -> Maybe Text -> DeleteArtifactResponse)
-> Lens
     DeleteArtifactResponse
     DeleteArtifactResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteArtifactResponse' {Maybe Text
artifactArn :: Maybe Text
$sel:artifactArn:DeleteArtifactResponse' :: DeleteArtifactResponse -> Maybe Text
artifactArn} -> Maybe Text
artifactArn) (\s :: DeleteArtifactResponse
s@DeleteArtifactResponse' {} Maybe Text
a -> DeleteArtifactResponse
s {$sel:artifactArn:DeleteArtifactResponse' :: Maybe Text
artifactArn = Maybe Text
a} :: DeleteArtifactResponse)

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

instance Prelude.NFData DeleteArtifactResponse