{-# 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.DirectoryService.UpdateConditionalForwarder
-- 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 a conditional forwarder that has been set up for your Amazon Web
-- Services directory.
module Amazonka.DirectoryService.UpdateConditionalForwarder
  ( -- * Creating a Request
    UpdateConditionalForwarder (..),
    newUpdateConditionalForwarder,

    -- * Request Lenses
    updateConditionalForwarder_directoryId,
    updateConditionalForwarder_remoteDomainName,
    updateConditionalForwarder_dnsIpAddrs,

    -- * Destructuring the Response
    UpdateConditionalForwarderResponse (..),
    newUpdateConditionalForwarderResponse,

    -- * Response Lenses
    updateConditionalForwarderResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.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

-- | Updates a conditional forwarder.
--
-- /See:/ 'newUpdateConditionalForwarder' smart constructor.
data UpdateConditionalForwarder = UpdateConditionalForwarder'
  { -- | The directory ID of the Amazon Web Services directory for which to
    -- update the conditional forwarder.
    UpdateConditionalForwarder -> Text
directoryId :: Prelude.Text,
    -- | The fully qualified domain name (FQDN) of the remote domain with which
    -- you will set up a trust relationship.
    UpdateConditionalForwarder -> Text
remoteDomainName :: Prelude.Text,
    -- | The updated IP addresses of the remote DNS server associated with the
    -- conditional forwarder.
    UpdateConditionalForwarder -> [Text]
dnsIpAddrs :: [Prelude.Text]
  }
  deriving (UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool
(UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool)
-> (UpdateConditionalForwarder
    -> UpdateConditionalForwarder -> Bool)
-> Eq UpdateConditionalForwarder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool
$c/= :: UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool
== :: UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool
$c== :: UpdateConditionalForwarder -> UpdateConditionalForwarder -> Bool
Prelude.Eq, ReadPrec [UpdateConditionalForwarder]
ReadPrec UpdateConditionalForwarder
Int -> ReadS UpdateConditionalForwarder
ReadS [UpdateConditionalForwarder]
(Int -> ReadS UpdateConditionalForwarder)
-> ReadS [UpdateConditionalForwarder]
-> ReadPrec UpdateConditionalForwarder
-> ReadPrec [UpdateConditionalForwarder]
-> Read UpdateConditionalForwarder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConditionalForwarder]
$creadListPrec :: ReadPrec [UpdateConditionalForwarder]
readPrec :: ReadPrec UpdateConditionalForwarder
$creadPrec :: ReadPrec UpdateConditionalForwarder
readList :: ReadS [UpdateConditionalForwarder]
$creadList :: ReadS [UpdateConditionalForwarder]
readsPrec :: Int -> ReadS UpdateConditionalForwarder
$creadsPrec :: Int -> ReadS UpdateConditionalForwarder
Prelude.Read, Int -> UpdateConditionalForwarder -> ShowS
[UpdateConditionalForwarder] -> ShowS
UpdateConditionalForwarder -> String
(Int -> UpdateConditionalForwarder -> ShowS)
-> (UpdateConditionalForwarder -> String)
-> ([UpdateConditionalForwarder] -> ShowS)
-> Show UpdateConditionalForwarder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConditionalForwarder] -> ShowS
$cshowList :: [UpdateConditionalForwarder] -> ShowS
show :: UpdateConditionalForwarder -> String
$cshow :: UpdateConditionalForwarder -> String
showsPrec :: Int -> UpdateConditionalForwarder -> ShowS
$cshowsPrec :: Int -> UpdateConditionalForwarder -> ShowS
Prelude.Show, (forall x.
 UpdateConditionalForwarder -> Rep UpdateConditionalForwarder x)
-> (forall x.
    Rep UpdateConditionalForwarder x -> UpdateConditionalForwarder)
-> Generic UpdateConditionalForwarder
forall x.
Rep UpdateConditionalForwarder x -> UpdateConditionalForwarder
forall x.
UpdateConditionalForwarder -> Rep UpdateConditionalForwarder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateConditionalForwarder x -> UpdateConditionalForwarder
$cfrom :: forall x.
UpdateConditionalForwarder -> Rep UpdateConditionalForwarder x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConditionalForwarder' 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:
--
-- 'directoryId', 'updateConditionalForwarder_directoryId' - The directory ID of the Amazon Web Services directory for which to
-- update the conditional forwarder.
--
-- 'remoteDomainName', 'updateConditionalForwarder_remoteDomainName' - The fully qualified domain name (FQDN) of the remote domain with which
-- you will set up a trust relationship.
--
-- 'dnsIpAddrs', 'updateConditionalForwarder_dnsIpAddrs' - The updated IP addresses of the remote DNS server associated with the
-- conditional forwarder.
newUpdateConditionalForwarder ::
  -- | 'directoryId'
  Prelude.Text ->
  -- | 'remoteDomainName'
  Prelude.Text ->
  UpdateConditionalForwarder
newUpdateConditionalForwarder :: Text -> Text -> UpdateConditionalForwarder
newUpdateConditionalForwarder
  Text
pDirectoryId_
  Text
pRemoteDomainName_ =
    UpdateConditionalForwarder' :: Text -> Text -> [Text] -> UpdateConditionalForwarder
UpdateConditionalForwarder'
      { $sel:directoryId:UpdateConditionalForwarder' :: Text
directoryId =
          Text
pDirectoryId_,
        $sel:remoteDomainName:UpdateConditionalForwarder' :: Text
remoteDomainName = Text
pRemoteDomainName_,
        $sel:dnsIpAddrs:UpdateConditionalForwarder' :: [Text]
dnsIpAddrs = [Text]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The directory ID of the Amazon Web Services directory for which to
-- update the conditional forwarder.
updateConditionalForwarder_directoryId :: Lens.Lens' UpdateConditionalForwarder Prelude.Text
updateConditionalForwarder_directoryId :: (Text -> f Text)
-> UpdateConditionalForwarder -> f UpdateConditionalForwarder
updateConditionalForwarder_directoryId = (UpdateConditionalForwarder -> Text)
-> (UpdateConditionalForwarder
    -> Text -> UpdateConditionalForwarder)
-> Lens
     UpdateConditionalForwarder UpdateConditionalForwarder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConditionalForwarder' {Text
directoryId :: Text
$sel:directoryId:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> Text
directoryId} -> Text
directoryId) (\s :: UpdateConditionalForwarder
s@UpdateConditionalForwarder' {} Text
a -> UpdateConditionalForwarder
s {$sel:directoryId:UpdateConditionalForwarder' :: Text
directoryId = Text
a} :: UpdateConditionalForwarder)

-- | The fully qualified domain name (FQDN) of the remote domain with which
-- you will set up a trust relationship.
updateConditionalForwarder_remoteDomainName :: Lens.Lens' UpdateConditionalForwarder Prelude.Text
updateConditionalForwarder_remoteDomainName :: (Text -> f Text)
-> UpdateConditionalForwarder -> f UpdateConditionalForwarder
updateConditionalForwarder_remoteDomainName = (UpdateConditionalForwarder -> Text)
-> (UpdateConditionalForwarder
    -> Text -> UpdateConditionalForwarder)
-> Lens
     UpdateConditionalForwarder UpdateConditionalForwarder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConditionalForwarder' {Text
remoteDomainName :: Text
$sel:remoteDomainName:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> Text
remoteDomainName} -> Text
remoteDomainName) (\s :: UpdateConditionalForwarder
s@UpdateConditionalForwarder' {} Text
a -> UpdateConditionalForwarder
s {$sel:remoteDomainName:UpdateConditionalForwarder' :: Text
remoteDomainName = Text
a} :: UpdateConditionalForwarder)

-- | The updated IP addresses of the remote DNS server associated with the
-- conditional forwarder.
updateConditionalForwarder_dnsIpAddrs :: Lens.Lens' UpdateConditionalForwarder [Prelude.Text]
updateConditionalForwarder_dnsIpAddrs :: ([Text] -> f [Text])
-> UpdateConditionalForwarder -> f UpdateConditionalForwarder
updateConditionalForwarder_dnsIpAddrs = (UpdateConditionalForwarder -> [Text])
-> (UpdateConditionalForwarder
    -> [Text] -> UpdateConditionalForwarder)
-> Lens
     UpdateConditionalForwarder UpdateConditionalForwarder [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConditionalForwarder' {[Text]
dnsIpAddrs :: [Text]
$sel:dnsIpAddrs:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> [Text]
dnsIpAddrs} -> [Text]
dnsIpAddrs) (\s :: UpdateConditionalForwarder
s@UpdateConditionalForwarder' {} [Text]
a -> UpdateConditionalForwarder
s {$sel:dnsIpAddrs:UpdateConditionalForwarder' :: [Text]
dnsIpAddrs = [Text]
a} :: UpdateConditionalForwarder) (([Text] -> f [Text])
 -> UpdateConditionalForwarder -> f UpdateConditionalForwarder)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> UpdateConditionalForwarder
-> f UpdateConditionalForwarder
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateConditionalForwarder where
  type
    AWSResponse UpdateConditionalForwarder =
      UpdateConditionalForwarderResponse
  request :: UpdateConditionalForwarder -> Request UpdateConditionalForwarder
request = Service
-> UpdateConditionalForwarder -> Request UpdateConditionalForwarder
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateConditionalForwarder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConditionalForwarder)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateConditionalForwarder))
-> Logger
-> Service
-> Proxy UpdateConditionalForwarder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateConditionalForwarder)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateConditionalForwarderResponse
UpdateConditionalForwarderResponse'
            (Int -> UpdateConditionalForwarderResponse)
-> Either String Int
-> Either String UpdateConditionalForwarderResponse
forall (f :: * -> *) a b. Functor 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 UpdateConditionalForwarder

instance Prelude.NFData UpdateConditionalForwarder

instance Core.ToHeaders UpdateConditionalForwarder where
  toHeaders :: UpdateConditionalForwarder -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateConditionalForwarder -> 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
"DirectoryService_20150416.UpdateConditionalForwarder" ::
                          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 UpdateConditionalForwarder where
  toJSON :: UpdateConditionalForwarder -> Value
toJSON UpdateConditionalForwarder' {[Text]
Text
dnsIpAddrs :: [Text]
remoteDomainName :: Text
directoryId :: Text
$sel:dnsIpAddrs:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> [Text]
$sel:remoteDomainName:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> Text
$sel:directoryId:UpdateConditionalForwarder' :: UpdateConditionalForwarder -> 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
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RemoteDomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
remoteDomainName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DnsIpAddrs" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
dnsIpAddrs)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateConditionalForwarderResponse' 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:
--
-- 'httpStatus', 'updateConditionalForwarderResponse_httpStatus' - The response's http status code.
newUpdateConditionalForwarderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateConditionalForwarderResponse
newUpdateConditionalForwarderResponse :: Int -> UpdateConditionalForwarderResponse
newUpdateConditionalForwarderResponse Int
pHttpStatus_ =
  UpdateConditionalForwarderResponse' :: Int -> UpdateConditionalForwarderResponse
UpdateConditionalForwarderResponse'
    { $sel:httpStatus:UpdateConditionalForwarderResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    UpdateConditionalForwarderResponse