{-# 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.ServiceCatalog.DeleteProduct
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified product.
--
-- You cannot delete a product if it was shared with you or is associated
-- with a portfolio.
--
-- A delegated admin is authorized to invoke this command.
module Amazonka.ServiceCatalog.DeleteProduct
  ( -- * Creating a Request
    DeleteProduct (..),
    newDeleteProduct,

    -- * Request Lenses
    deleteProduct_acceptLanguage,
    deleteProduct_id,

    -- * Destructuring the Response
    DeleteProductResponse (..),
    newDeleteProductResponse,

    -- * Response Lenses
    deleteProductResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteProduct' smart constructor.
data DeleteProduct = DeleteProduct'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    DeleteProduct -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The product identifier.
    DeleteProduct -> Text
id :: Prelude.Text
  }
  deriving (DeleteProduct -> DeleteProduct -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProduct -> DeleteProduct -> Bool
$c/= :: DeleteProduct -> DeleteProduct -> Bool
== :: DeleteProduct -> DeleteProduct -> Bool
$c== :: DeleteProduct -> DeleteProduct -> Bool
Prelude.Eq, ReadPrec [DeleteProduct]
ReadPrec DeleteProduct
Int -> ReadS DeleteProduct
ReadS [DeleteProduct]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProduct]
$creadListPrec :: ReadPrec [DeleteProduct]
readPrec :: ReadPrec DeleteProduct
$creadPrec :: ReadPrec DeleteProduct
readList :: ReadS [DeleteProduct]
$creadList :: ReadS [DeleteProduct]
readsPrec :: Int -> ReadS DeleteProduct
$creadsPrec :: Int -> ReadS DeleteProduct
Prelude.Read, Int -> DeleteProduct -> ShowS
[DeleteProduct] -> ShowS
DeleteProduct -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProduct] -> ShowS
$cshowList :: [DeleteProduct] -> ShowS
show :: DeleteProduct -> String
$cshow :: DeleteProduct -> String
showsPrec :: Int -> DeleteProduct -> ShowS
$cshowsPrec :: Int -> DeleteProduct -> ShowS
Prelude.Show, forall x. Rep DeleteProduct x -> DeleteProduct
forall x. DeleteProduct -> Rep DeleteProduct x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProduct x -> DeleteProduct
$cfrom :: forall x. DeleteProduct -> Rep DeleteProduct x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProduct' 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:
--
-- 'acceptLanguage', 'deleteProduct_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'id', 'deleteProduct_id' - The product identifier.
newDeleteProduct ::
  -- | 'id'
  Prelude.Text ->
  DeleteProduct
newDeleteProduct :: Text -> DeleteProduct
newDeleteProduct Text
pId_ =
  DeleteProduct'
    { $sel:acceptLanguage:DeleteProduct' :: Maybe Text
acceptLanguage = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteProduct' :: Text
id = Text
pId_
    }

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
deleteProduct_acceptLanguage :: Lens.Lens' DeleteProduct (Prelude.Maybe Prelude.Text)
deleteProduct_acceptLanguage :: Lens' DeleteProduct (Maybe Text)
deleteProduct_acceptLanguage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProduct' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:DeleteProduct' :: DeleteProduct -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: DeleteProduct
s@DeleteProduct' {} Maybe Text
a -> DeleteProduct
s {$sel:acceptLanguage:DeleteProduct' :: Maybe Text
acceptLanguage = Maybe Text
a} :: DeleteProduct)

-- | The product identifier.
deleteProduct_id :: Lens.Lens' DeleteProduct Prelude.Text
deleteProduct_id :: Lens' DeleteProduct Text
deleteProduct_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProduct' {Text
id :: Text
$sel:id:DeleteProduct' :: DeleteProduct -> Text
id} -> Text
id) (\s :: DeleteProduct
s@DeleteProduct' {} Text
a -> DeleteProduct
s {$sel:id:DeleteProduct' :: Text
id = Text
a} :: DeleteProduct)

instance Core.AWSRequest DeleteProduct where
  type
    AWSResponse DeleteProduct =
      DeleteProductResponse
  request :: (Service -> Service) -> DeleteProduct -> Request DeleteProduct
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 DeleteProduct
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProduct)))
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 -> DeleteProductResponse
DeleteProductResponse'
            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 DeleteProduct where
  hashWithSalt :: Int -> DeleteProduct -> Int
hashWithSalt Int
_salt DeleteProduct' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeleteProduct' :: DeleteProduct -> Text
$sel:acceptLanguage:DeleteProduct' :: DeleteProduct -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
acceptLanguage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DeleteProduct where
  rnf :: DeleteProduct -> ()
rnf DeleteProduct' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeleteProduct' :: DeleteProduct -> Text
$sel:acceptLanguage:DeleteProduct' :: DeleteProduct -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
acceptLanguage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DeleteProduct where
  toHeaders :: DeleteProduct -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWS242ServiceCatalogService.DeleteProduct" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteProduct where
  toJSON :: DeleteProduct -> Value
toJSON DeleteProduct' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeleteProduct' :: DeleteProduct -> Text
$sel:acceptLanguage:DeleteProduct' :: DeleteProduct -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AcceptLanguage" 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 Text
acceptLanguage,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

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

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

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

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

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