{-# 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.UpdateResolverRule
-- 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)
--
-- Updates settings for a specified Resolver rule. @ResolverRuleId@ is
-- required, and all other parameters are optional. If you don\'t specify a
-- parameter, it retains its current value.
module Amazonka.Route53Resolver.UpdateResolverRule
  ( -- * Creating a Request
    UpdateResolverRule (..),
    newUpdateResolverRule,

    -- * Request Lenses
    updateResolverRule_resolverRuleId,
    updateResolverRule_config,

    -- * Destructuring the Response
    UpdateResolverRuleResponse (..),
    newUpdateResolverRuleResponse,

    -- * Response Lenses
    updateResolverRuleResponse_resolverRule,
    updateResolverRuleResponse_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:/ 'newUpdateResolverRule' smart constructor.
data UpdateResolverRule = UpdateResolverRule'
  { -- | The ID of the Resolver rule that you want to update.
    UpdateResolverRule -> Text
resolverRuleId :: Prelude.Text,
    -- | The new settings for the Resolver rule.
    UpdateResolverRule -> ResolverRuleConfig
config :: ResolverRuleConfig
  }
  deriving (UpdateResolverRule -> UpdateResolverRule -> Bool
(UpdateResolverRule -> UpdateResolverRule -> Bool)
-> (UpdateResolverRule -> UpdateResolverRule -> Bool)
-> Eq UpdateResolverRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResolverRule -> UpdateResolverRule -> Bool
$c/= :: UpdateResolverRule -> UpdateResolverRule -> Bool
== :: UpdateResolverRule -> UpdateResolverRule -> Bool
$c== :: UpdateResolverRule -> UpdateResolverRule -> Bool
Prelude.Eq, ReadPrec [UpdateResolverRule]
ReadPrec UpdateResolverRule
Int -> ReadS UpdateResolverRule
ReadS [UpdateResolverRule]
(Int -> ReadS UpdateResolverRule)
-> ReadS [UpdateResolverRule]
-> ReadPrec UpdateResolverRule
-> ReadPrec [UpdateResolverRule]
-> Read UpdateResolverRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateResolverRule]
$creadListPrec :: ReadPrec [UpdateResolverRule]
readPrec :: ReadPrec UpdateResolverRule
$creadPrec :: ReadPrec UpdateResolverRule
readList :: ReadS [UpdateResolverRule]
$creadList :: ReadS [UpdateResolverRule]
readsPrec :: Int -> ReadS UpdateResolverRule
$creadsPrec :: Int -> ReadS UpdateResolverRule
Prelude.Read, Int -> UpdateResolverRule -> ShowS
[UpdateResolverRule] -> ShowS
UpdateResolverRule -> String
(Int -> UpdateResolverRule -> ShowS)
-> (UpdateResolverRule -> String)
-> ([UpdateResolverRule] -> ShowS)
-> Show UpdateResolverRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResolverRule] -> ShowS
$cshowList :: [UpdateResolverRule] -> ShowS
show :: UpdateResolverRule -> String
$cshow :: UpdateResolverRule -> String
showsPrec :: Int -> UpdateResolverRule -> ShowS
$cshowsPrec :: Int -> UpdateResolverRule -> ShowS
Prelude.Show, (forall x. UpdateResolverRule -> Rep UpdateResolverRule x)
-> (forall x. Rep UpdateResolverRule x -> UpdateResolverRule)
-> Generic UpdateResolverRule
forall x. Rep UpdateResolverRule x -> UpdateResolverRule
forall x. UpdateResolverRule -> Rep UpdateResolverRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateResolverRule x -> UpdateResolverRule
$cfrom :: forall x. UpdateResolverRule -> Rep UpdateResolverRule x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResolverRule' 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', 'updateResolverRule_resolverRuleId' - The ID of the Resolver rule that you want to update.
--
-- 'config', 'updateResolverRule_config' - The new settings for the Resolver rule.
newUpdateResolverRule ::
  -- | 'resolverRuleId'
  Prelude.Text ->
  -- | 'config'
  ResolverRuleConfig ->
  UpdateResolverRule
newUpdateResolverRule :: Text -> ResolverRuleConfig -> UpdateResolverRule
newUpdateResolverRule Text
pResolverRuleId_ ResolverRuleConfig
pConfig_ =
  UpdateResolverRule' :: Text -> ResolverRuleConfig -> UpdateResolverRule
UpdateResolverRule'
    { $sel:resolverRuleId:UpdateResolverRule' :: Text
resolverRuleId =
        Text
pResolverRuleId_,
      $sel:config:UpdateResolverRule' :: ResolverRuleConfig
config = ResolverRuleConfig
pConfig_
    }

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

-- | The new settings for the Resolver rule.
updateResolverRule_config :: Lens.Lens' UpdateResolverRule ResolverRuleConfig
updateResolverRule_config :: (ResolverRuleConfig -> f ResolverRuleConfig)
-> UpdateResolverRule -> f UpdateResolverRule
updateResolverRule_config = (UpdateResolverRule -> ResolverRuleConfig)
-> (UpdateResolverRule -> ResolverRuleConfig -> UpdateResolverRule)
-> Lens
     UpdateResolverRule
     UpdateResolverRule
     ResolverRuleConfig
     ResolverRuleConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResolverRule' {ResolverRuleConfig
config :: ResolverRuleConfig
$sel:config:UpdateResolverRule' :: UpdateResolverRule -> ResolverRuleConfig
config} -> ResolverRuleConfig
config) (\s :: UpdateResolverRule
s@UpdateResolverRule' {} ResolverRuleConfig
a -> UpdateResolverRule
s {$sel:config:UpdateResolverRule' :: ResolverRuleConfig
config = ResolverRuleConfig
a} :: UpdateResolverRule)

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

instance Prelude.NFData UpdateResolverRule

instance Core.ToHeaders UpdateResolverRule where
  toHeaders :: UpdateResolverRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateResolverRule -> 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.UpdateResolverRule" ::
                          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 UpdateResolverRule where
  toJSON :: UpdateResolverRule -> Value
toJSON UpdateResolverRule' {Text
ResolverRuleConfig
config :: ResolverRuleConfig
resolverRuleId :: Text
$sel:config:UpdateResolverRule' :: UpdateResolverRule -> ResolverRuleConfig
$sel:resolverRuleId:UpdateResolverRule' :: UpdateResolverRule -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Config" Text -> ResolverRuleConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResolverRuleConfig
config)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateResolverRuleResponse' 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', 'updateResolverRuleResponse_resolverRule' - The response to an @UpdateResolverRule@ request.
--
-- 'httpStatus', 'updateResolverRuleResponse_httpStatus' - The response's http status code.
newUpdateResolverRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateResolverRuleResponse
newUpdateResolverRuleResponse :: Int -> UpdateResolverRuleResponse
newUpdateResolverRuleResponse Int
pHttpStatus_ =
  UpdateResolverRuleResponse' :: Maybe ResolverRule -> Int -> UpdateResolverRuleResponse
UpdateResolverRuleResponse'
    { $sel:resolverRule:UpdateResolverRuleResponse' :: Maybe ResolverRule
resolverRule =
        Maybe ResolverRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateResolverRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The response to an @UpdateResolverRule@ request.
updateResolverRuleResponse_resolverRule :: Lens.Lens' UpdateResolverRuleResponse (Prelude.Maybe ResolverRule)
updateResolverRuleResponse_resolverRule :: (Maybe ResolverRule -> f (Maybe ResolverRule))
-> UpdateResolverRuleResponse -> f UpdateResolverRuleResponse
updateResolverRuleResponse_resolverRule = (UpdateResolverRuleResponse -> Maybe ResolverRule)
-> (UpdateResolverRuleResponse
    -> Maybe ResolverRule -> UpdateResolverRuleResponse)
-> Lens
     UpdateResolverRuleResponse
     UpdateResolverRuleResponse
     (Maybe ResolverRule)
     (Maybe ResolverRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResolverRuleResponse' {Maybe ResolverRule
resolverRule :: Maybe ResolverRule
$sel:resolverRule:UpdateResolverRuleResponse' :: UpdateResolverRuleResponse -> Maybe ResolverRule
resolverRule} -> Maybe ResolverRule
resolverRule) (\s :: UpdateResolverRuleResponse
s@UpdateResolverRuleResponse' {} Maybe ResolverRule
a -> UpdateResolverRuleResponse
s {$sel:resolverRule:UpdateResolverRuleResponse' :: Maybe ResolverRule
resolverRule = Maybe ResolverRule
a} :: UpdateResolverRuleResponse)

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

instance Prelude.NFData UpdateResolverRuleResponse