{-# 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.UpdateResolverEndpoint
-- 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 the name of an inbound or an outbound Resolver endpoint.
module Amazonka.Route53Resolver.UpdateResolverEndpoint
  ( -- * Creating a Request
    UpdateResolverEndpoint (..),
    newUpdateResolverEndpoint,

    -- * Request Lenses
    updateResolverEndpoint_name,
    updateResolverEndpoint_resolverEndpointId,

    -- * Destructuring the Response
    UpdateResolverEndpointResponse (..),
    newUpdateResolverEndpointResponse,

    -- * Response Lenses
    updateResolverEndpointResponse_resolverEndpoint,
    updateResolverEndpointResponse_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:/ 'newUpdateResolverEndpoint' smart constructor.
data UpdateResolverEndpoint = UpdateResolverEndpoint'
  { -- | The name of the Resolver endpoint that you want to update.
    UpdateResolverEndpoint -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Resolver endpoint that you want to update.
    UpdateResolverEndpoint -> Text
resolverEndpointId :: Prelude.Text
  }
  deriving (UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool
(UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool)
-> (UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool)
-> Eq UpdateResolverEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool
$c/= :: UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool
== :: UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool
$c== :: UpdateResolverEndpoint -> UpdateResolverEndpoint -> Bool
Prelude.Eq, ReadPrec [UpdateResolverEndpoint]
ReadPrec UpdateResolverEndpoint
Int -> ReadS UpdateResolverEndpoint
ReadS [UpdateResolverEndpoint]
(Int -> ReadS UpdateResolverEndpoint)
-> ReadS [UpdateResolverEndpoint]
-> ReadPrec UpdateResolverEndpoint
-> ReadPrec [UpdateResolverEndpoint]
-> Read UpdateResolverEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateResolverEndpoint]
$creadListPrec :: ReadPrec [UpdateResolverEndpoint]
readPrec :: ReadPrec UpdateResolverEndpoint
$creadPrec :: ReadPrec UpdateResolverEndpoint
readList :: ReadS [UpdateResolverEndpoint]
$creadList :: ReadS [UpdateResolverEndpoint]
readsPrec :: Int -> ReadS UpdateResolverEndpoint
$creadsPrec :: Int -> ReadS UpdateResolverEndpoint
Prelude.Read, Int -> UpdateResolverEndpoint -> ShowS
[UpdateResolverEndpoint] -> ShowS
UpdateResolverEndpoint -> String
(Int -> UpdateResolverEndpoint -> ShowS)
-> (UpdateResolverEndpoint -> String)
-> ([UpdateResolverEndpoint] -> ShowS)
-> Show UpdateResolverEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResolverEndpoint] -> ShowS
$cshowList :: [UpdateResolverEndpoint] -> ShowS
show :: UpdateResolverEndpoint -> String
$cshow :: UpdateResolverEndpoint -> String
showsPrec :: Int -> UpdateResolverEndpoint -> ShowS
$cshowsPrec :: Int -> UpdateResolverEndpoint -> ShowS
Prelude.Show, (forall x. UpdateResolverEndpoint -> Rep UpdateResolverEndpoint x)
-> (forall x.
    Rep UpdateResolverEndpoint x -> UpdateResolverEndpoint)
-> Generic UpdateResolverEndpoint
forall x. Rep UpdateResolverEndpoint x -> UpdateResolverEndpoint
forall x. UpdateResolverEndpoint -> Rep UpdateResolverEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateResolverEndpoint x -> UpdateResolverEndpoint
$cfrom :: forall x. UpdateResolverEndpoint -> Rep UpdateResolverEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResolverEndpoint' 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', 'updateResolverEndpoint_name' - The name of the Resolver endpoint that you want to update.
--
-- 'resolverEndpointId', 'updateResolverEndpoint_resolverEndpointId' - The ID of the Resolver endpoint that you want to update.
newUpdateResolverEndpoint ::
  -- | 'resolverEndpointId'
  Prelude.Text ->
  UpdateResolverEndpoint
newUpdateResolverEndpoint :: Text -> UpdateResolverEndpoint
newUpdateResolverEndpoint Text
pResolverEndpointId_ =
  UpdateResolverEndpoint' :: Maybe Text -> Text -> UpdateResolverEndpoint
UpdateResolverEndpoint'
    { $sel:name:UpdateResolverEndpoint' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resolverEndpointId:UpdateResolverEndpoint' :: Text
resolverEndpointId = Text
pResolverEndpointId_
    }

-- | The name of the Resolver endpoint that you want to update.
updateResolverEndpoint_name :: Lens.Lens' UpdateResolverEndpoint (Prelude.Maybe Prelude.Text)
updateResolverEndpoint_name :: (Maybe Text -> f (Maybe Text))
-> UpdateResolverEndpoint -> f UpdateResolverEndpoint
updateResolverEndpoint_name = (UpdateResolverEndpoint -> Maybe Text)
-> (UpdateResolverEndpoint -> Maybe Text -> UpdateResolverEndpoint)
-> Lens
     UpdateResolverEndpoint
     UpdateResolverEndpoint
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResolverEndpoint' {Maybe Text
name :: Maybe Text
$sel:name:UpdateResolverEndpoint' :: UpdateResolverEndpoint -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateResolverEndpoint
s@UpdateResolverEndpoint' {} Maybe Text
a -> UpdateResolverEndpoint
s {$sel:name:UpdateResolverEndpoint' :: Maybe Text
name = Maybe Text
a} :: UpdateResolverEndpoint)

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

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

instance Prelude.NFData UpdateResolverEndpoint

instance Core.ToHeaders UpdateResolverEndpoint where
  toHeaders :: UpdateResolverEndpoint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateResolverEndpoint -> 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.UpdateResolverEndpoint" ::
                          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 UpdateResolverEndpoint where
  toJSON :: UpdateResolverEndpoint -> Value
toJSON UpdateResolverEndpoint' {Maybe Text
Text
resolverEndpointId :: Text
name :: Maybe Text
$sel:resolverEndpointId:UpdateResolverEndpoint' :: UpdateResolverEndpoint -> Text
$sel:name:UpdateResolverEndpoint' :: UpdateResolverEndpoint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ResolverEndpointId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resolverEndpointId)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateResolverEndpointResponse' 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:
--
-- 'resolverEndpoint', 'updateResolverEndpointResponse_resolverEndpoint' - The response to an @UpdateResolverEndpoint@ request.
--
-- 'httpStatus', 'updateResolverEndpointResponse_httpStatus' - The response's http status code.
newUpdateResolverEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateResolverEndpointResponse
newUpdateResolverEndpointResponse :: Int -> UpdateResolverEndpointResponse
newUpdateResolverEndpointResponse Int
pHttpStatus_ =
  UpdateResolverEndpointResponse' :: Maybe ResolverEndpoint -> Int -> UpdateResolverEndpointResponse
UpdateResolverEndpointResponse'
    { $sel:resolverEndpoint:UpdateResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint =
        Maybe ResolverEndpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateResolverEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The response to an @UpdateResolverEndpoint@ request.
updateResolverEndpointResponse_resolverEndpoint :: Lens.Lens' UpdateResolverEndpointResponse (Prelude.Maybe ResolverEndpoint)
updateResolverEndpointResponse_resolverEndpoint :: (Maybe ResolverEndpoint -> f (Maybe ResolverEndpoint))
-> UpdateResolverEndpointResponse
-> f UpdateResolverEndpointResponse
updateResolverEndpointResponse_resolverEndpoint = (UpdateResolverEndpointResponse -> Maybe ResolverEndpoint)
-> (UpdateResolverEndpointResponse
    -> Maybe ResolverEndpoint -> UpdateResolverEndpointResponse)
-> Lens
     UpdateResolverEndpointResponse
     UpdateResolverEndpointResponse
     (Maybe ResolverEndpoint)
     (Maybe ResolverEndpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResolverEndpointResponse' {Maybe ResolverEndpoint
resolverEndpoint :: Maybe ResolverEndpoint
$sel:resolverEndpoint:UpdateResolverEndpointResponse' :: UpdateResolverEndpointResponse -> Maybe ResolverEndpoint
resolverEndpoint} -> Maybe ResolverEndpoint
resolverEndpoint) (\s :: UpdateResolverEndpointResponse
s@UpdateResolverEndpointResponse' {} Maybe ResolverEndpoint
a -> UpdateResolverEndpointResponse
s {$sel:resolverEndpoint:UpdateResolverEndpointResponse' :: Maybe ResolverEndpoint
resolverEndpoint = Maybe ResolverEndpoint
a} :: UpdateResolverEndpointResponse)

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

instance
  Prelude.NFData
    UpdateResolverEndpointResponse