{-# 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.DeleteProvisioningArtifact
-- 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 provisioning artifact (also known as a version)
-- for the specified product.
--
-- You cannot delete a provisioning artifact associated with a product that
-- was shared with you. You cannot delete the last provisioning artifact
-- for a product, because a product must have at least one provisioning
-- artifact.
module Amazonka.ServiceCatalog.DeleteProvisioningArtifact
  ( -- * Creating a Request
    DeleteProvisioningArtifact (..),
    newDeleteProvisioningArtifact,

    -- * Request Lenses
    deleteProvisioningArtifact_acceptLanguage,
    deleteProvisioningArtifact_productId,
    deleteProvisioningArtifact_provisioningArtifactId,

    -- * Destructuring the Response
    DeleteProvisioningArtifactResponse (..),
    newDeleteProvisioningArtifactResponse,

    -- * Response Lenses
    deleteProvisioningArtifactResponse_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.ServiceCatalog.Types

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

-- |
-- Create a value of 'DeleteProvisioningArtifact' 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', 'deleteProvisioningArtifact_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'productId', 'deleteProvisioningArtifact_productId' - The product identifier.
--
-- 'provisioningArtifactId', 'deleteProvisioningArtifact_provisioningArtifactId' - The identifier of the provisioning artifact.
newDeleteProvisioningArtifact ::
  -- | 'productId'
  Prelude.Text ->
  -- | 'provisioningArtifactId'
  Prelude.Text ->
  DeleteProvisioningArtifact
newDeleteProvisioningArtifact :: Text -> Text -> DeleteProvisioningArtifact
newDeleteProvisioningArtifact
  Text
pProductId_
  Text
pProvisioningArtifactId_ =
    DeleteProvisioningArtifact' :: Maybe Text -> Text -> Text -> DeleteProvisioningArtifact
DeleteProvisioningArtifact'
      { $sel:acceptLanguage:DeleteProvisioningArtifact' :: Maybe Text
acceptLanguage =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:productId:DeleteProvisioningArtifact' :: Text
productId = Text
pProductId_,
        $sel:provisioningArtifactId:DeleteProvisioningArtifact' :: Text
provisioningArtifactId =
          Text
pProvisioningArtifactId_
      }

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

-- | The product identifier.
deleteProvisioningArtifact_productId :: Lens.Lens' DeleteProvisioningArtifact Prelude.Text
deleteProvisioningArtifact_productId :: (Text -> f Text)
-> DeleteProvisioningArtifact -> f DeleteProvisioningArtifact
deleteProvisioningArtifact_productId = (DeleteProvisioningArtifact -> Text)
-> (DeleteProvisioningArtifact
    -> Text -> DeleteProvisioningArtifact)
-> Lens
     DeleteProvisioningArtifact DeleteProvisioningArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProvisioningArtifact' {Text
productId :: Text
$sel:productId:DeleteProvisioningArtifact' :: DeleteProvisioningArtifact -> Text
productId} -> Text
productId) (\s :: DeleteProvisioningArtifact
s@DeleteProvisioningArtifact' {} Text
a -> DeleteProvisioningArtifact
s {$sel:productId:DeleteProvisioningArtifact' :: Text
productId = Text
a} :: DeleteProvisioningArtifact)

-- | The identifier of the provisioning artifact.
deleteProvisioningArtifact_provisioningArtifactId :: Lens.Lens' DeleteProvisioningArtifact Prelude.Text
deleteProvisioningArtifact_provisioningArtifactId :: (Text -> f Text)
-> DeleteProvisioningArtifact -> f DeleteProvisioningArtifact
deleteProvisioningArtifact_provisioningArtifactId = (DeleteProvisioningArtifact -> Text)
-> (DeleteProvisioningArtifact
    -> Text -> DeleteProvisioningArtifact)
-> Lens
     DeleteProvisioningArtifact DeleteProvisioningArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProvisioningArtifact' {Text
provisioningArtifactId :: Text
$sel:provisioningArtifactId:DeleteProvisioningArtifact' :: DeleteProvisioningArtifact -> Text
provisioningArtifactId} -> Text
provisioningArtifactId) (\s :: DeleteProvisioningArtifact
s@DeleteProvisioningArtifact' {} Text
a -> DeleteProvisioningArtifact
s {$sel:provisioningArtifactId:DeleteProvisioningArtifact' :: Text
provisioningArtifactId = Text
a} :: DeleteProvisioningArtifact)

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

instance Prelude.NFData DeleteProvisioningArtifact

instance Core.ToHeaders DeleteProvisioningArtifact where
  toHeaders :: DeleteProvisioningArtifact -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteProvisioningArtifact -> 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
"AWS242ServiceCatalogService.DeleteProvisioningArtifact" ::
                          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 DeleteProvisioningArtifact where
  toJSON :: DeleteProvisioningArtifact -> Value
toJSON DeleteProvisioningArtifact' {Maybe Text
Text
provisioningArtifactId :: Text
productId :: Text
acceptLanguage :: Maybe Text
$sel:provisioningArtifactId:DeleteProvisioningArtifact' :: DeleteProvisioningArtifact -> Text
$sel:productId:DeleteProvisioningArtifact' :: DeleteProvisioningArtifact -> Text
$sel:acceptLanguage:DeleteProvisioningArtifact' :: DeleteProvisioningArtifact -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AcceptLanguage" 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
acceptLanguage,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ProvisioningArtifactId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
provisioningArtifactId
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteProvisioningArtifactResponse