{-# 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.DeleteImageVersion
-- 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 version of a SageMaker image. The container image the version
-- represents isn\'t deleted.
module Amazonka.SageMaker.DeleteImageVersion
  ( -- * Creating a Request
    DeleteImageVersion (..),
    newDeleteImageVersion,

    -- * Request Lenses
    deleteImageVersion_imageName,
    deleteImageVersion_version,

    -- * Destructuring the Response
    DeleteImageVersionResponse (..),
    newDeleteImageVersionResponse,

    -- * Response Lenses
    deleteImageVersionResponse_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:/ 'newDeleteImageVersion' smart constructor.
data DeleteImageVersion = DeleteImageVersion'
  { -- | The name of the image.
    DeleteImageVersion -> Text
imageName :: Prelude.Text,
    -- | The version to delete.
    DeleteImageVersion -> Natural
version :: Prelude.Natural
  }
  deriving (DeleteImageVersion -> DeleteImageVersion -> Bool
(DeleteImageVersion -> DeleteImageVersion -> Bool)
-> (DeleteImageVersion -> DeleteImageVersion -> Bool)
-> Eq DeleteImageVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteImageVersion -> DeleteImageVersion -> Bool
$c/= :: DeleteImageVersion -> DeleteImageVersion -> Bool
== :: DeleteImageVersion -> DeleteImageVersion -> Bool
$c== :: DeleteImageVersion -> DeleteImageVersion -> Bool
Prelude.Eq, ReadPrec [DeleteImageVersion]
ReadPrec DeleteImageVersion
Int -> ReadS DeleteImageVersion
ReadS [DeleteImageVersion]
(Int -> ReadS DeleteImageVersion)
-> ReadS [DeleteImageVersion]
-> ReadPrec DeleteImageVersion
-> ReadPrec [DeleteImageVersion]
-> Read DeleteImageVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteImageVersion]
$creadListPrec :: ReadPrec [DeleteImageVersion]
readPrec :: ReadPrec DeleteImageVersion
$creadPrec :: ReadPrec DeleteImageVersion
readList :: ReadS [DeleteImageVersion]
$creadList :: ReadS [DeleteImageVersion]
readsPrec :: Int -> ReadS DeleteImageVersion
$creadsPrec :: Int -> ReadS DeleteImageVersion
Prelude.Read, Int -> DeleteImageVersion -> ShowS
[DeleteImageVersion] -> ShowS
DeleteImageVersion -> String
(Int -> DeleteImageVersion -> ShowS)
-> (DeleteImageVersion -> String)
-> ([DeleteImageVersion] -> ShowS)
-> Show DeleteImageVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteImageVersion] -> ShowS
$cshowList :: [DeleteImageVersion] -> ShowS
show :: DeleteImageVersion -> String
$cshow :: DeleteImageVersion -> String
showsPrec :: Int -> DeleteImageVersion -> ShowS
$cshowsPrec :: Int -> DeleteImageVersion -> ShowS
Prelude.Show, (forall x. DeleteImageVersion -> Rep DeleteImageVersion x)
-> (forall x. Rep DeleteImageVersion x -> DeleteImageVersion)
-> Generic DeleteImageVersion
forall x. Rep DeleteImageVersion x -> DeleteImageVersion
forall x. DeleteImageVersion -> Rep DeleteImageVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteImageVersion x -> DeleteImageVersion
$cfrom :: forall x. DeleteImageVersion -> Rep DeleteImageVersion x
Prelude.Generic)

-- |
-- Create a value of 'DeleteImageVersion' 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:
--
-- 'imageName', 'deleteImageVersion_imageName' - The name of the image.
--
-- 'version', 'deleteImageVersion_version' - The version to delete.
newDeleteImageVersion ::
  -- | 'imageName'
  Prelude.Text ->
  -- | 'version'
  Prelude.Natural ->
  DeleteImageVersion
newDeleteImageVersion :: Text -> Natural -> DeleteImageVersion
newDeleteImageVersion Text
pImageName_ Natural
pVersion_ =
  DeleteImageVersion' :: Text -> Natural -> DeleteImageVersion
DeleteImageVersion'
    { $sel:imageName:DeleteImageVersion' :: Text
imageName = Text
pImageName_,
      $sel:version:DeleteImageVersion' :: Natural
version = Natural
pVersion_
    }

-- | The name of the image.
deleteImageVersion_imageName :: Lens.Lens' DeleteImageVersion Prelude.Text
deleteImageVersion_imageName :: (Text -> f Text) -> DeleteImageVersion -> f DeleteImageVersion
deleteImageVersion_imageName = (DeleteImageVersion -> Text)
-> (DeleteImageVersion -> Text -> DeleteImageVersion)
-> Lens DeleteImageVersion DeleteImageVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImageVersion' {Text
imageName :: Text
$sel:imageName:DeleteImageVersion' :: DeleteImageVersion -> Text
imageName} -> Text
imageName) (\s :: DeleteImageVersion
s@DeleteImageVersion' {} Text
a -> DeleteImageVersion
s {$sel:imageName:DeleteImageVersion' :: Text
imageName = Text
a} :: DeleteImageVersion)

-- | The version to delete.
deleteImageVersion_version :: Lens.Lens' DeleteImageVersion Prelude.Natural
deleteImageVersion_version :: (Natural -> f Natural)
-> DeleteImageVersion -> f DeleteImageVersion
deleteImageVersion_version = (DeleteImageVersion -> Natural)
-> (DeleteImageVersion -> Natural -> DeleteImageVersion)
-> Lens DeleteImageVersion DeleteImageVersion Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImageVersion' {Natural
version :: Natural
$sel:version:DeleteImageVersion' :: DeleteImageVersion -> Natural
version} -> Natural
version) (\s :: DeleteImageVersion
s@DeleteImageVersion' {} Natural
a -> DeleteImageVersion
s {$sel:version:DeleteImageVersion' :: Natural
version = Natural
a} :: DeleteImageVersion)

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

instance Prelude.NFData DeleteImageVersion

instance Core.ToHeaders DeleteImageVersion where
  toHeaders :: DeleteImageVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteImageVersion -> 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.DeleteImageVersion" ::
                          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 DeleteImageVersion where
  toJSON :: DeleteImageVersion -> Value
toJSON DeleteImageVersion' {Natural
Text
version :: Natural
imageName :: Text
$sel:version:DeleteImageVersion' :: DeleteImageVersion -> Natural
$sel:imageName:DeleteImageVersion' :: DeleteImageVersion -> 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
"ImageName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
imageName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Version" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
version)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteImageVersionResponse