{-# 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.DAX.DeleteSubnetGroup
-- 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 a subnet group.
--
-- You cannot delete a subnet group if it is associated with any DAX
-- clusters.
module Amazonka.DAX.DeleteSubnetGroup
  ( -- * Creating a Request
    DeleteSubnetGroup (..),
    newDeleteSubnetGroup,

    -- * Request Lenses
    deleteSubnetGroup_subnetGroupName,

    -- * Destructuring the Response
    DeleteSubnetGroupResponse (..),
    newDeleteSubnetGroupResponse,

    -- * Response Lenses
    deleteSubnetGroupResponse_deletionMessage,
    deleteSubnetGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DAX.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DeleteSubnetGroup' 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:
--
-- 'subnetGroupName', 'deleteSubnetGroup_subnetGroupName' - The name of the subnet group to delete.
newDeleteSubnetGroup ::
  -- | 'subnetGroupName'
  Prelude.Text ->
  DeleteSubnetGroup
newDeleteSubnetGroup :: Text -> DeleteSubnetGroup
newDeleteSubnetGroup Text
pSubnetGroupName_ =
  DeleteSubnetGroup' :: Text -> DeleteSubnetGroup
DeleteSubnetGroup'
    { $sel:subnetGroupName:DeleteSubnetGroup' :: Text
subnetGroupName =
        Text
pSubnetGroupName_
    }

-- | The name of the subnet group to delete.
deleteSubnetGroup_subnetGroupName :: Lens.Lens' DeleteSubnetGroup Prelude.Text
deleteSubnetGroup_subnetGroupName :: (Text -> f Text) -> DeleteSubnetGroup -> f DeleteSubnetGroup
deleteSubnetGroup_subnetGroupName = (DeleteSubnetGroup -> Text)
-> (DeleteSubnetGroup -> Text -> DeleteSubnetGroup)
-> Lens DeleteSubnetGroup DeleteSubnetGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubnetGroup' {Text
subnetGroupName :: Text
$sel:subnetGroupName:DeleteSubnetGroup' :: DeleteSubnetGroup -> Text
subnetGroupName} -> Text
subnetGroupName) (\s :: DeleteSubnetGroup
s@DeleteSubnetGroup' {} Text
a -> DeleteSubnetGroup
s {$sel:subnetGroupName:DeleteSubnetGroup' :: Text
subnetGroupName = Text
a} :: DeleteSubnetGroup)

instance Core.AWSRequest DeleteSubnetGroup where
  type
    AWSResponse DeleteSubnetGroup =
      DeleteSubnetGroupResponse
  request :: DeleteSubnetGroup -> Request DeleteSubnetGroup
request = Service -> DeleteSubnetGroup -> Request DeleteSubnetGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteSubnetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSubnetGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteSubnetGroup))
-> Logger
-> Service
-> Proxy DeleteSubnetGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteSubnetGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteSubnetGroupResponse
DeleteSubnetGroupResponse'
            (Maybe Text -> Int -> DeleteSubnetGroupResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteSubnetGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DeletionMessage")
            Either String (Int -> DeleteSubnetGroupResponse)
-> Either String Int -> Either String DeleteSubnetGroupResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteSubnetGroup

instance Prelude.NFData DeleteSubnetGroup

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

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

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

-- | /See:/ 'newDeleteSubnetGroupResponse' smart constructor.
data DeleteSubnetGroupResponse = DeleteSubnetGroupResponse'
  { -- | A user-specified message for this action (i.e., a reason for deleting
    -- the subnet group).
    DeleteSubnetGroupResponse -> Maybe Text
deletionMessage :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteSubnetGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool
(DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool)
-> (DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool)
-> Eq DeleteSubnetGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool
$c/= :: DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool
== :: DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool
$c== :: DeleteSubnetGroupResponse -> DeleteSubnetGroupResponse -> Bool
Prelude.Eq, ReadPrec [DeleteSubnetGroupResponse]
ReadPrec DeleteSubnetGroupResponse
Int -> ReadS DeleteSubnetGroupResponse
ReadS [DeleteSubnetGroupResponse]
(Int -> ReadS DeleteSubnetGroupResponse)
-> ReadS [DeleteSubnetGroupResponse]
-> ReadPrec DeleteSubnetGroupResponse
-> ReadPrec [DeleteSubnetGroupResponse]
-> Read DeleteSubnetGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSubnetGroupResponse]
$creadListPrec :: ReadPrec [DeleteSubnetGroupResponse]
readPrec :: ReadPrec DeleteSubnetGroupResponse
$creadPrec :: ReadPrec DeleteSubnetGroupResponse
readList :: ReadS [DeleteSubnetGroupResponse]
$creadList :: ReadS [DeleteSubnetGroupResponse]
readsPrec :: Int -> ReadS DeleteSubnetGroupResponse
$creadsPrec :: Int -> ReadS DeleteSubnetGroupResponse
Prelude.Read, Int -> DeleteSubnetGroupResponse -> ShowS
[DeleteSubnetGroupResponse] -> ShowS
DeleteSubnetGroupResponse -> String
(Int -> DeleteSubnetGroupResponse -> ShowS)
-> (DeleteSubnetGroupResponse -> String)
-> ([DeleteSubnetGroupResponse] -> ShowS)
-> Show DeleteSubnetGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSubnetGroupResponse] -> ShowS
$cshowList :: [DeleteSubnetGroupResponse] -> ShowS
show :: DeleteSubnetGroupResponse -> String
$cshow :: DeleteSubnetGroupResponse -> String
showsPrec :: Int -> DeleteSubnetGroupResponse -> ShowS
$cshowsPrec :: Int -> DeleteSubnetGroupResponse -> ShowS
Prelude.Show, (forall x.
 DeleteSubnetGroupResponse -> Rep DeleteSubnetGroupResponse x)
-> (forall x.
    Rep DeleteSubnetGroupResponse x -> DeleteSubnetGroupResponse)
-> Generic DeleteSubnetGroupResponse
forall x.
Rep DeleteSubnetGroupResponse x -> DeleteSubnetGroupResponse
forall x.
DeleteSubnetGroupResponse -> Rep DeleteSubnetGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteSubnetGroupResponse x -> DeleteSubnetGroupResponse
$cfrom :: forall x.
DeleteSubnetGroupResponse -> Rep DeleteSubnetGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSubnetGroupResponse' 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:
--
-- 'deletionMessage', 'deleteSubnetGroupResponse_deletionMessage' - A user-specified message for this action (i.e., a reason for deleting
-- the subnet group).
--
-- 'httpStatus', 'deleteSubnetGroupResponse_httpStatus' - The response's http status code.
newDeleteSubnetGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteSubnetGroupResponse
newDeleteSubnetGroupResponse :: Int -> DeleteSubnetGroupResponse
newDeleteSubnetGroupResponse Int
pHttpStatus_ =
  DeleteSubnetGroupResponse' :: Maybe Text -> Int -> DeleteSubnetGroupResponse
DeleteSubnetGroupResponse'
    { $sel:deletionMessage:DeleteSubnetGroupResponse' :: Maybe Text
deletionMessage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteSubnetGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A user-specified message for this action (i.e., a reason for deleting
-- the subnet group).
deleteSubnetGroupResponse_deletionMessage :: Lens.Lens' DeleteSubnetGroupResponse (Prelude.Maybe Prelude.Text)
deleteSubnetGroupResponse_deletionMessage :: (Maybe Text -> f (Maybe Text))
-> DeleteSubnetGroupResponse -> f DeleteSubnetGroupResponse
deleteSubnetGroupResponse_deletionMessage = (DeleteSubnetGroupResponse -> Maybe Text)
-> (DeleteSubnetGroupResponse
    -> Maybe Text -> DeleteSubnetGroupResponse)
-> Lens
     DeleteSubnetGroupResponse
     DeleteSubnetGroupResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSubnetGroupResponse' {Maybe Text
deletionMessage :: Maybe Text
$sel:deletionMessage:DeleteSubnetGroupResponse' :: DeleteSubnetGroupResponse -> Maybe Text
deletionMessage} -> Maybe Text
deletionMessage) (\s :: DeleteSubnetGroupResponse
s@DeleteSubnetGroupResponse' {} Maybe Text
a -> DeleteSubnetGroupResponse
s {$sel:deletionMessage:DeleteSubnetGroupResponse' :: Maybe Text
deletionMessage = Maybe Text
a} :: DeleteSubnetGroupResponse)

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

instance Prelude.NFData DeleteSubnetGroupResponse