{-# 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.SSM.DeleteParameter
-- 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)
--
-- Delete a parameter from the system. After deleting a parameter, wait for
-- at least 30 seconds to create a parameter with the same name.
module Amazonka.SSM.DeleteParameter
  ( -- * Creating a Request
    DeleteParameter (..),
    newDeleteParameter,

    -- * Request Lenses
    deleteParameter_name,

    -- * Destructuring the Response
    DeleteParameterResponse (..),
    newDeleteParameterResponse,

    -- * Response Lenses
    deleteParameterResponse_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.SSM.Types

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

-- |
-- Create a value of 'DeleteParameter' 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:
--
-- 'name', 'deleteParameter_name' - The name of the parameter to delete.
newDeleteParameter ::
  -- | 'name'
  Prelude.Text ->
  DeleteParameter
newDeleteParameter :: Text -> DeleteParameter
newDeleteParameter Text
pName_ =
  DeleteParameter' :: Text -> DeleteParameter
DeleteParameter' {$sel:name:DeleteParameter' :: Text
name = Text
pName_}

-- | The name of the parameter to delete.
deleteParameter_name :: Lens.Lens' DeleteParameter Prelude.Text
deleteParameter_name :: (Text -> f Text) -> DeleteParameter -> f DeleteParameter
deleteParameter_name = (DeleteParameter -> Text)
-> (DeleteParameter -> Text -> DeleteParameter)
-> Lens DeleteParameter DeleteParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteParameter' {Text
name :: Text
$sel:name:DeleteParameter' :: DeleteParameter -> Text
name} -> Text
name) (\s :: DeleteParameter
s@DeleteParameter' {} Text
a -> DeleteParameter
s {$sel:name:DeleteParameter' :: Text
name = Text
a} :: DeleteParameter)

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

instance Prelude.NFData DeleteParameter

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

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

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

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

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

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

instance Prelude.NFData DeleteParameterResponse