{-# 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.WorkSpaces.DeleteWorkspaceImage
-- 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 specified image from your account. To delete an image, you
-- must first delete any bundles that are associated with the image and
-- unshare the image if it is shared with other accounts.
module Amazonka.WorkSpaces.DeleteWorkspaceImage
  ( -- * Creating a Request
    DeleteWorkspaceImage (..),
    newDeleteWorkspaceImage,

    -- * Request Lenses
    deleteWorkspaceImage_imageId,

    -- * Destructuring the Response
    DeleteWorkspaceImageResponse (..),
    newDeleteWorkspaceImageResponse,

    -- * Response Lenses
    deleteWorkspaceImageResponse_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.WorkSpaces.Types

-- | /See:/ 'newDeleteWorkspaceImage' smart constructor.
data DeleteWorkspaceImage = DeleteWorkspaceImage'
  { -- | The identifier of the image.
    DeleteWorkspaceImage -> Text
imageId :: Prelude.Text
  }
  deriving (DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool
(DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool)
-> (DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool)
-> Eq DeleteWorkspaceImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool
$c/= :: DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool
== :: DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool
$c== :: DeleteWorkspaceImage -> DeleteWorkspaceImage -> Bool
Prelude.Eq, ReadPrec [DeleteWorkspaceImage]
ReadPrec DeleteWorkspaceImage
Int -> ReadS DeleteWorkspaceImage
ReadS [DeleteWorkspaceImage]
(Int -> ReadS DeleteWorkspaceImage)
-> ReadS [DeleteWorkspaceImage]
-> ReadPrec DeleteWorkspaceImage
-> ReadPrec [DeleteWorkspaceImage]
-> Read DeleteWorkspaceImage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWorkspaceImage]
$creadListPrec :: ReadPrec [DeleteWorkspaceImage]
readPrec :: ReadPrec DeleteWorkspaceImage
$creadPrec :: ReadPrec DeleteWorkspaceImage
readList :: ReadS [DeleteWorkspaceImage]
$creadList :: ReadS [DeleteWorkspaceImage]
readsPrec :: Int -> ReadS DeleteWorkspaceImage
$creadsPrec :: Int -> ReadS DeleteWorkspaceImage
Prelude.Read, Int -> DeleteWorkspaceImage -> ShowS
[DeleteWorkspaceImage] -> ShowS
DeleteWorkspaceImage -> String
(Int -> DeleteWorkspaceImage -> ShowS)
-> (DeleteWorkspaceImage -> String)
-> ([DeleteWorkspaceImage] -> ShowS)
-> Show DeleteWorkspaceImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkspaceImage] -> ShowS
$cshowList :: [DeleteWorkspaceImage] -> ShowS
show :: DeleteWorkspaceImage -> String
$cshow :: DeleteWorkspaceImage -> String
showsPrec :: Int -> DeleteWorkspaceImage -> ShowS
$cshowsPrec :: Int -> DeleteWorkspaceImage -> ShowS
Prelude.Show, (forall x. DeleteWorkspaceImage -> Rep DeleteWorkspaceImage x)
-> (forall x. Rep DeleteWorkspaceImage x -> DeleteWorkspaceImage)
-> Generic DeleteWorkspaceImage
forall x. Rep DeleteWorkspaceImage x -> DeleteWorkspaceImage
forall x. DeleteWorkspaceImage -> Rep DeleteWorkspaceImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkspaceImage x -> DeleteWorkspaceImage
$cfrom :: forall x. DeleteWorkspaceImage -> Rep DeleteWorkspaceImage x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkspaceImage' 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:
--
-- 'imageId', 'deleteWorkspaceImage_imageId' - The identifier of the image.
newDeleteWorkspaceImage ::
  -- | 'imageId'
  Prelude.Text ->
  DeleteWorkspaceImage
newDeleteWorkspaceImage :: Text -> DeleteWorkspaceImage
newDeleteWorkspaceImage Text
pImageId_ =
  DeleteWorkspaceImage' :: Text -> DeleteWorkspaceImage
DeleteWorkspaceImage' {$sel:imageId:DeleteWorkspaceImage' :: Text
imageId = Text
pImageId_}

-- | The identifier of the image.
deleteWorkspaceImage_imageId :: Lens.Lens' DeleteWorkspaceImage Prelude.Text
deleteWorkspaceImage_imageId :: (Text -> f Text) -> DeleteWorkspaceImage -> f DeleteWorkspaceImage
deleteWorkspaceImage_imageId = (DeleteWorkspaceImage -> Text)
-> (DeleteWorkspaceImage -> Text -> DeleteWorkspaceImage)
-> Lens DeleteWorkspaceImage DeleteWorkspaceImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkspaceImage' {Text
imageId :: Text
$sel:imageId:DeleteWorkspaceImage' :: DeleteWorkspaceImage -> Text
imageId} -> Text
imageId) (\s :: DeleteWorkspaceImage
s@DeleteWorkspaceImage' {} Text
a -> DeleteWorkspaceImage
s {$sel:imageId:DeleteWorkspaceImage' :: Text
imageId = Text
a} :: DeleteWorkspaceImage)

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

instance Prelude.NFData DeleteWorkspaceImage

instance Core.ToHeaders DeleteWorkspaceImage where
  toHeaders :: DeleteWorkspaceImage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteWorkspaceImage -> 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
"WorkspacesService.DeleteWorkspaceImage" ::
                          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 DeleteWorkspaceImage where
  toJSON :: DeleteWorkspaceImage -> Value
toJSON DeleteWorkspaceImage' {Text
imageId :: Text
$sel:imageId:DeleteWorkspaceImage' :: DeleteWorkspaceImage -> 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
"ImageId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
imageId)]
      )

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

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

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

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

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

instance Prelude.NFData DeleteWorkspaceImageResponse