{-# 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.DeleteConstraint
-- 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 constraint.
--
-- A delegated admin is authorized to invoke this command.
module Amazonka.ServiceCatalog.DeleteConstraint
  ( -- * Creating a Request
    DeleteConstraint (..),
    newDeleteConstraint,

    -- * Request Lenses
    deleteConstraint_acceptLanguage,
    deleteConstraint_id,

    -- * Destructuring the Response
    DeleteConstraintResponse (..),
    newDeleteConstraintResponse,

    -- * Response Lenses
    deleteConstraintResponse_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:/ 'newDeleteConstraint' smart constructor.
data DeleteConstraint = DeleteConstraint'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    DeleteConstraint -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the constraint.
    DeleteConstraint -> Text
id :: Prelude.Text
  }
  deriving (DeleteConstraint -> DeleteConstraint -> Bool
(DeleteConstraint -> DeleteConstraint -> Bool)
-> (DeleteConstraint -> DeleteConstraint -> Bool)
-> Eq DeleteConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteConstraint -> DeleteConstraint -> Bool
$c/= :: DeleteConstraint -> DeleteConstraint -> Bool
== :: DeleteConstraint -> DeleteConstraint -> Bool
$c== :: DeleteConstraint -> DeleteConstraint -> Bool
Prelude.Eq, ReadPrec [DeleteConstraint]
ReadPrec DeleteConstraint
Int -> ReadS DeleteConstraint
ReadS [DeleteConstraint]
(Int -> ReadS DeleteConstraint)
-> ReadS [DeleteConstraint]
-> ReadPrec DeleteConstraint
-> ReadPrec [DeleteConstraint]
-> Read DeleteConstraint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteConstraint]
$creadListPrec :: ReadPrec [DeleteConstraint]
readPrec :: ReadPrec DeleteConstraint
$creadPrec :: ReadPrec DeleteConstraint
readList :: ReadS [DeleteConstraint]
$creadList :: ReadS [DeleteConstraint]
readsPrec :: Int -> ReadS DeleteConstraint
$creadsPrec :: Int -> ReadS DeleteConstraint
Prelude.Read, Int -> DeleteConstraint -> ShowS
[DeleteConstraint] -> ShowS
DeleteConstraint -> String
(Int -> DeleteConstraint -> ShowS)
-> (DeleteConstraint -> String)
-> ([DeleteConstraint] -> ShowS)
-> Show DeleteConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteConstraint] -> ShowS
$cshowList :: [DeleteConstraint] -> ShowS
show :: DeleteConstraint -> String
$cshow :: DeleteConstraint -> String
showsPrec :: Int -> DeleteConstraint -> ShowS
$cshowsPrec :: Int -> DeleteConstraint -> ShowS
Prelude.Show, (forall x. DeleteConstraint -> Rep DeleteConstraint x)
-> (forall x. Rep DeleteConstraint x -> DeleteConstraint)
-> Generic DeleteConstraint
forall x. Rep DeleteConstraint x -> DeleteConstraint
forall x. DeleteConstraint -> Rep DeleteConstraint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteConstraint x -> DeleteConstraint
$cfrom :: forall x. DeleteConstraint -> Rep DeleteConstraint x
Prelude.Generic)

-- |
-- Create a value of 'DeleteConstraint' 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', 'deleteConstraint_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'id', 'deleteConstraint_id' - The identifier of the constraint.
newDeleteConstraint ::
  -- | 'id'
  Prelude.Text ->
  DeleteConstraint
newDeleteConstraint :: Text -> DeleteConstraint
newDeleteConstraint Text
pId_ =
  DeleteConstraint' :: Maybe Text -> Text -> DeleteConstraint
DeleteConstraint'
    { $sel:acceptLanguage:DeleteConstraint' :: Maybe Text
acceptLanguage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeleteConstraint' :: Text
id = Text
pId_
    }

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

-- | The identifier of the constraint.
deleteConstraint_id :: Lens.Lens' DeleteConstraint Prelude.Text
deleteConstraint_id :: (Text -> f Text) -> DeleteConstraint -> f DeleteConstraint
deleteConstraint_id = (DeleteConstraint -> Text)
-> (DeleteConstraint -> Text -> DeleteConstraint)
-> Lens DeleteConstraint DeleteConstraint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteConstraint' {Text
id :: Text
$sel:id:DeleteConstraint' :: DeleteConstraint -> Text
id} -> Text
id) (\s :: DeleteConstraint
s@DeleteConstraint' {} Text
a -> DeleteConstraint
s {$sel:id:DeleteConstraint' :: Text
id = Text
a} :: DeleteConstraint)

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

instance Prelude.NFData DeleteConstraint

instance Core.ToHeaders DeleteConstraint where
  toHeaders :: DeleteConstraint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteConstraint -> 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.DeleteConstraint" ::
                          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 DeleteConstraint where
  toJSON :: DeleteConstraint -> Value
toJSON DeleteConstraint' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeleteConstraint' :: DeleteConstraint -> Text
$sel:acceptLanguage:DeleteConstraint' :: DeleteConstraint -> 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
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteConstraintResponse