{-# 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.DisassociateResolverRule
-- 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)
--
-- Removes the association between a specified Resolver rule and a
-- specified VPC.
--
-- If you disassociate a Resolver rule from a VPC, Resolver stops
-- forwarding DNS queries for the domain name that you specified in the
-- Resolver rule.
module Amazonka.Route53Resolver.DisassociateResolverRule
  ( -- * Creating a Request
    DisassociateResolverRule (..),
    newDisassociateResolverRule,

    -- * Request Lenses
    disassociateResolverRule_vPCId,
    disassociateResolverRule_resolverRuleId,

    -- * Destructuring the Response
    DisassociateResolverRuleResponse (..),
    newDisassociateResolverRuleResponse,

    -- * Response Lenses
    disassociateResolverRuleResponse_resolverRuleAssociation,
    disassociateResolverRuleResponse_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:/ 'newDisassociateResolverRule' smart constructor.
data DisassociateResolverRule = DisassociateResolverRule'
  { -- | The ID of the VPC that you want to disassociate the Resolver rule from.
    DisassociateResolverRule -> Text
vPCId :: Prelude.Text,
    -- | The ID of the Resolver rule that you want to disassociate from the
    -- specified VPC.
    DisassociateResolverRule -> Text
resolverRuleId :: Prelude.Text
  }
  deriving (DisassociateResolverRule -> DisassociateResolverRule -> Bool
(DisassociateResolverRule -> DisassociateResolverRule -> Bool)
-> (DisassociateResolverRule -> DisassociateResolverRule -> Bool)
-> Eq DisassociateResolverRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateResolverRule -> DisassociateResolverRule -> Bool
$c/= :: DisassociateResolverRule -> DisassociateResolverRule -> Bool
== :: DisassociateResolverRule -> DisassociateResolverRule -> Bool
$c== :: DisassociateResolverRule -> DisassociateResolverRule -> Bool
Prelude.Eq, ReadPrec [DisassociateResolverRule]
ReadPrec DisassociateResolverRule
Int -> ReadS DisassociateResolverRule
ReadS [DisassociateResolverRule]
(Int -> ReadS DisassociateResolverRule)
-> ReadS [DisassociateResolverRule]
-> ReadPrec DisassociateResolverRule
-> ReadPrec [DisassociateResolverRule]
-> Read DisassociateResolverRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateResolverRule]
$creadListPrec :: ReadPrec [DisassociateResolverRule]
readPrec :: ReadPrec DisassociateResolverRule
$creadPrec :: ReadPrec DisassociateResolverRule
readList :: ReadS [DisassociateResolverRule]
$creadList :: ReadS [DisassociateResolverRule]
readsPrec :: Int -> ReadS DisassociateResolverRule
$creadsPrec :: Int -> ReadS DisassociateResolverRule
Prelude.Read, Int -> DisassociateResolverRule -> ShowS
[DisassociateResolverRule] -> ShowS
DisassociateResolverRule -> String
(Int -> DisassociateResolverRule -> ShowS)
-> (DisassociateResolverRule -> String)
-> ([DisassociateResolverRule] -> ShowS)
-> Show DisassociateResolverRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateResolverRule] -> ShowS
$cshowList :: [DisassociateResolverRule] -> ShowS
show :: DisassociateResolverRule -> String
$cshow :: DisassociateResolverRule -> String
showsPrec :: Int -> DisassociateResolverRule -> ShowS
$cshowsPrec :: Int -> DisassociateResolverRule -> ShowS
Prelude.Show, (forall x.
 DisassociateResolverRule -> Rep DisassociateResolverRule x)
-> (forall x.
    Rep DisassociateResolverRule x -> DisassociateResolverRule)
-> Generic DisassociateResolverRule
forall x.
Rep DisassociateResolverRule x -> DisassociateResolverRule
forall x.
DisassociateResolverRule -> Rep DisassociateResolverRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateResolverRule x -> DisassociateResolverRule
$cfrom :: forall x.
DisassociateResolverRule -> Rep DisassociateResolverRule x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateResolverRule' 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:
--
-- 'vPCId', 'disassociateResolverRule_vPCId' - The ID of the VPC that you want to disassociate the Resolver rule from.
--
-- 'resolverRuleId', 'disassociateResolverRule_resolverRuleId' - The ID of the Resolver rule that you want to disassociate from the
-- specified VPC.
newDisassociateResolverRule ::
  -- | 'vPCId'
  Prelude.Text ->
  -- | 'resolverRuleId'
  Prelude.Text ->
  DisassociateResolverRule
newDisassociateResolverRule :: Text -> Text -> DisassociateResolverRule
newDisassociateResolverRule Text
pVPCId_ Text
pResolverRuleId_ =
  DisassociateResolverRule' :: Text -> Text -> DisassociateResolverRule
DisassociateResolverRule'
    { $sel:vPCId:DisassociateResolverRule' :: Text
vPCId = Text
pVPCId_,
      $sel:resolverRuleId:DisassociateResolverRule' :: Text
resolverRuleId = Text
pResolverRuleId_
    }

-- | The ID of the VPC that you want to disassociate the Resolver rule from.
disassociateResolverRule_vPCId :: Lens.Lens' DisassociateResolverRule Prelude.Text
disassociateResolverRule_vPCId :: (Text -> f Text)
-> DisassociateResolverRule -> f DisassociateResolverRule
disassociateResolverRule_vPCId = (DisassociateResolverRule -> Text)
-> (DisassociateResolverRule -> Text -> DisassociateResolverRule)
-> Lens DisassociateResolverRule DisassociateResolverRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResolverRule' {Text
vPCId :: Text
$sel:vPCId:DisassociateResolverRule' :: DisassociateResolverRule -> Text
vPCId} -> Text
vPCId) (\s :: DisassociateResolverRule
s@DisassociateResolverRule' {} Text
a -> DisassociateResolverRule
s {$sel:vPCId:DisassociateResolverRule' :: Text
vPCId = Text
a} :: DisassociateResolverRule)

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

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

instance Prelude.NFData DisassociateResolverRule

instance Core.ToHeaders DisassociateResolverRule where
  toHeaders :: DisassociateResolverRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateResolverRule -> 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.DisassociateResolverRule" ::
                          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 DisassociateResolverRule where
  toJSON :: DisassociateResolverRule -> Value
toJSON DisassociateResolverRule' {Text
resolverRuleId :: Text
vPCId :: Text
$sel:resolverRuleId:DisassociateResolverRule' :: DisassociateResolverRule -> Text
$sel:vPCId:DisassociateResolverRule' :: DisassociateResolverRule -> 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
"VPCId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
vPCId),
            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 DisassociateResolverRule where
  toPath :: DisassociateResolverRule -> ByteString
toPath = ByteString -> DisassociateResolverRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DisassociateResolverRuleResponse' 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:
--
-- 'resolverRuleAssociation', 'disassociateResolverRuleResponse_resolverRuleAssociation' - Information about the @DisassociateResolverRule@ request, including the
-- status of the request.
--
-- 'httpStatus', 'disassociateResolverRuleResponse_httpStatus' - The response's http status code.
newDisassociateResolverRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisassociateResolverRuleResponse
newDisassociateResolverRuleResponse :: Int -> DisassociateResolverRuleResponse
newDisassociateResolverRuleResponse Int
pHttpStatus_ =
  DisassociateResolverRuleResponse' :: Maybe ResolverRuleAssociation
-> Int -> DisassociateResolverRuleResponse
DisassociateResolverRuleResponse'
    { $sel:resolverRuleAssociation:DisassociateResolverRuleResponse' :: Maybe ResolverRuleAssociation
resolverRuleAssociation =
        Maybe ResolverRuleAssociation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisassociateResolverRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the @DisassociateResolverRule@ request, including the
-- status of the request.
disassociateResolverRuleResponse_resolverRuleAssociation :: Lens.Lens' DisassociateResolverRuleResponse (Prelude.Maybe ResolverRuleAssociation)
disassociateResolverRuleResponse_resolverRuleAssociation :: (Maybe ResolverRuleAssociation
 -> f (Maybe ResolverRuleAssociation))
-> DisassociateResolverRuleResponse
-> f DisassociateResolverRuleResponse
disassociateResolverRuleResponse_resolverRuleAssociation = (DisassociateResolverRuleResponse -> Maybe ResolverRuleAssociation)
-> (DisassociateResolverRuleResponse
    -> Maybe ResolverRuleAssociation
    -> DisassociateResolverRuleResponse)
-> Lens
     DisassociateResolverRuleResponse
     DisassociateResolverRuleResponse
     (Maybe ResolverRuleAssociation)
     (Maybe ResolverRuleAssociation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateResolverRuleResponse' {Maybe ResolverRuleAssociation
resolverRuleAssociation :: Maybe ResolverRuleAssociation
$sel:resolverRuleAssociation:DisassociateResolverRuleResponse' :: DisassociateResolverRuleResponse -> Maybe ResolverRuleAssociation
resolverRuleAssociation} -> Maybe ResolverRuleAssociation
resolverRuleAssociation) (\s :: DisassociateResolverRuleResponse
s@DisassociateResolverRuleResponse' {} Maybe ResolverRuleAssociation
a -> DisassociateResolverRuleResponse
s {$sel:resolverRuleAssociation:DisassociateResolverRuleResponse' :: Maybe ResolverRuleAssociation
resolverRuleAssociation = Maybe ResolverRuleAssociation
a} :: DisassociateResolverRuleResponse)

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

instance
  Prelude.NFData
    DisassociateResolverRuleResponse