{-# 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.Route53Resolver.DeleteResolverRule
-- 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 Resolver rule. Before you can delete a Resolver rule, you must
-- disassociate it from all the VPCs that you associated the Resolver rule
-- with. For more information, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_route53resolver_DisassociateResolverRule.html DisassociateResolverRule>.
module Amazonka.Route53Resolver.DeleteResolverRule
  ( -- * Creating a Request
    DeleteResolverRule (..),
    newDeleteResolverRule,

    -- * Request Lenses
    deleteResolverRule_resolverRuleId,

    -- * Destructuring the Response
    DeleteResolverRuleResponse (..),
    newDeleteResolverRuleResponse,

    -- * Response Lenses
    deleteResolverRuleResponse_resolverRule,
    deleteResolverRuleResponse_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.Route53Resolver.Types

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

-- |
-- Create a value of 'DeleteResolverRule' 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:
--
-- 'resolverRuleId', 'deleteResolverRule_resolverRuleId' - The ID of the Resolver rule that you want to delete.
newDeleteResolverRule ::
  -- | 'resolverRuleId'
  Prelude.Text ->
  DeleteResolverRule
newDeleteResolverRule :: Text -> DeleteResolverRule
newDeleteResolverRule Text
pResolverRuleId_ =
  DeleteResolverRule' :: Text -> DeleteResolverRule
DeleteResolverRule'
    { $sel:resolverRuleId:DeleteResolverRule' :: Text
resolverRuleId =
        Text
pResolverRuleId_
    }

-- | The ID of the Resolver rule that you want to delete.
deleteResolverRule_resolverRuleId :: Lens.Lens' DeleteResolverRule Prelude.Text
deleteResolverRule_resolverRuleId :: (Text -> f Text) -> DeleteResolverRule -> f DeleteResolverRule
deleteResolverRule_resolverRuleId = (DeleteResolverRule -> Text)
-> (DeleteResolverRule -> Text -> DeleteResolverRule)
-> Lens DeleteResolverRule DeleteResolverRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResolverRule' {Text
resolverRuleId :: Text
$sel:resolverRuleId:DeleteResolverRule' :: DeleteResolverRule -> Text
resolverRuleId} -> Text
resolverRuleId) (\s :: DeleteResolverRule
s@DeleteResolverRule' {} Text
a -> DeleteResolverRule
s {$sel:resolverRuleId:DeleteResolverRule' :: Text
resolverRuleId = Text
a} :: DeleteResolverRule)

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

instance Prelude.NFData DeleteResolverRule

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

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

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

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

-- |
-- Create a value of 'DeleteResolverRuleResponse' 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:
--
-- 'resolverRule', 'deleteResolverRuleResponse_resolverRule' - Information about the @DeleteResolverRule@ request, including the status
-- of the request.
--
-- 'httpStatus', 'deleteResolverRuleResponse_httpStatus' - The response's http status code.
newDeleteResolverRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteResolverRuleResponse
newDeleteResolverRuleResponse :: Int -> DeleteResolverRuleResponse
newDeleteResolverRuleResponse Int
pHttpStatus_ =
  DeleteResolverRuleResponse' :: Maybe ResolverRule -> Int -> DeleteResolverRuleResponse
DeleteResolverRuleResponse'
    { $sel:resolverRule:DeleteResolverRuleResponse' :: Maybe ResolverRule
resolverRule =
        Maybe ResolverRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteResolverRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the @DeleteResolverRule@ request, including the status
-- of the request.
deleteResolverRuleResponse_resolverRule :: Lens.Lens' DeleteResolverRuleResponse (Prelude.Maybe ResolverRule)
deleteResolverRuleResponse_resolverRule :: (Maybe ResolverRule -> f (Maybe ResolverRule))
-> DeleteResolverRuleResponse -> f DeleteResolverRuleResponse
deleteResolverRuleResponse_resolverRule = (DeleteResolverRuleResponse -> Maybe ResolverRule)
-> (DeleteResolverRuleResponse
    -> Maybe ResolverRule -> DeleteResolverRuleResponse)
-> Lens
     DeleteResolverRuleResponse
     DeleteResolverRuleResponse
     (Maybe ResolverRule)
     (Maybe ResolverRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResolverRuleResponse' {Maybe ResolverRule
resolverRule :: Maybe ResolverRule
$sel:resolverRule:DeleteResolverRuleResponse' :: DeleteResolverRuleResponse -> Maybe ResolverRule
resolverRule} -> Maybe ResolverRule
resolverRule) (\s :: DeleteResolverRuleResponse
s@DeleteResolverRuleResponse' {} Maybe ResolverRule
a -> DeleteResolverRuleResponse
s {$sel:resolverRule:DeleteResolverRuleResponse' :: Maybe ResolverRule
resolverRule = Maybe ResolverRule
a} :: DeleteResolverRuleResponse)

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

instance Prelude.NFData DeleteResolverRuleResponse