{-# 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.Route53RecoveryCluster.UpdateRoutingControlState
-- 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)
--
-- Set the state of the routing control to reroute traffic. You can set the
-- value to be On or Off. When the state is On, traffic flows to a cell.
-- When it\'s off, traffic does not flow.
--
-- For more information about working with routing controls, see
-- <https://docs.aws.amazon.com/r53recovery/latest/dg/routing-control.html Routing control>
-- in the Route 53 Application Recovery Controller Developer Guide.
module Amazonka.Route53RecoveryCluster.UpdateRoutingControlState
  ( -- * Creating a Request
    UpdateRoutingControlState (..),
    newUpdateRoutingControlState,

    -- * Request Lenses
    updateRoutingControlState_routingControlArn,
    updateRoutingControlState_routingControlState,

    -- * Destructuring the Response
    UpdateRoutingControlStateResponse (..),
    newUpdateRoutingControlStateResponse,

    -- * Response Lenses
    updateRoutingControlStateResponse_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.Route53RecoveryCluster.Types

-- | /See:/ 'newUpdateRoutingControlState' smart constructor.
data UpdateRoutingControlState = UpdateRoutingControlState'
  { -- | The Amazon Resource Number (ARN) for the routing control that you want
    -- to update the state for.
    UpdateRoutingControlState -> Text
routingControlArn :: Prelude.Text,
    -- | The state of the routing control. You can set the value to be On or Off.
    UpdateRoutingControlState -> RoutingControlState
routingControlState :: RoutingControlState
  }
  deriving (UpdateRoutingControlState -> UpdateRoutingControlState -> Bool
(UpdateRoutingControlState -> UpdateRoutingControlState -> Bool)
-> (UpdateRoutingControlState -> UpdateRoutingControlState -> Bool)
-> Eq UpdateRoutingControlState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRoutingControlState -> UpdateRoutingControlState -> Bool
$c/= :: UpdateRoutingControlState -> UpdateRoutingControlState -> Bool
== :: UpdateRoutingControlState -> UpdateRoutingControlState -> Bool
$c== :: UpdateRoutingControlState -> UpdateRoutingControlState -> Bool
Prelude.Eq, ReadPrec [UpdateRoutingControlState]
ReadPrec UpdateRoutingControlState
Int -> ReadS UpdateRoutingControlState
ReadS [UpdateRoutingControlState]
(Int -> ReadS UpdateRoutingControlState)
-> ReadS [UpdateRoutingControlState]
-> ReadPrec UpdateRoutingControlState
-> ReadPrec [UpdateRoutingControlState]
-> Read UpdateRoutingControlState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRoutingControlState]
$creadListPrec :: ReadPrec [UpdateRoutingControlState]
readPrec :: ReadPrec UpdateRoutingControlState
$creadPrec :: ReadPrec UpdateRoutingControlState
readList :: ReadS [UpdateRoutingControlState]
$creadList :: ReadS [UpdateRoutingControlState]
readsPrec :: Int -> ReadS UpdateRoutingControlState
$creadsPrec :: Int -> ReadS UpdateRoutingControlState
Prelude.Read, Int -> UpdateRoutingControlState -> ShowS
[UpdateRoutingControlState] -> ShowS
UpdateRoutingControlState -> String
(Int -> UpdateRoutingControlState -> ShowS)
-> (UpdateRoutingControlState -> String)
-> ([UpdateRoutingControlState] -> ShowS)
-> Show UpdateRoutingControlState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRoutingControlState] -> ShowS
$cshowList :: [UpdateRoutingControlState] -> ShowS
show :: UpdateRoutingControlState -> String
$cshow :: UpdateRoutingControlState -> String
showsPrec :: Int -> UpdateRoutingControlState -> ShowS
$cshowsPrec :: Int -> UpdateRoutingControlState -> ShowS
Prelude.Show, (forall x.
 UpdateRoutingControlState -> Rep UpdateRoutingControlState x)
-> (forall x.
    Rep UpdateRoutingControlState x -> UpdateRoutingControlState)
-> Generic UpdateRoutingControlState
forall x.
Rep UpdateRoutingControlState x -> UpdateRoutingControlState
forall x.
UpdateRoutingControlState -> Rep UpdateRoutingControlState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRoutingControlState x -> UpdateRoutingControlState
$cfrom :: forall x.
UpdateRoutingControlState -> Rep UpdateRoutingControlState x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRoutingControlState' 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:
--
-- 'routingControlArn', 'updateRoutingControlState_routingControlArn' - The Amazon Resource Number (ARN) for the routing control that you want
-- to update the state for.
--
-- 'routingControlState', 'updateRoutingControlState_routingControlState' - The state of the routing control. You can set the value to be On or Off.
newUpdateRoutingControlState ::
  -- | 'routingControlArn'
  Prelude.Text ->
  -- | 'routingControlState'
  RoutingControlState ->
  UpdateRoutingControlState
newUpdateRoutingControlState :: Text -> RoutingControlState -> UpdateRoutingControlState
newUpdateRoutingControlState
  Text
pRoutingControlArn_
  RoutingControlState
pRoutingControlState_ =
    UpdateRoutingControlState' :: Text -> RoutingControlState -> UpdateRoutingControlState
UpdateRoutingControlState'
      { $sel:routingControlArn:UpdateRoutingControlState' :: Text
routingControlArn =
          Text
pRoutingControlArn_,
        $sel:routingControlState:UpdateRoutingControlState' :: RoutingControlState
routingControlState = RoutingControlState
pRoutingControlState_
      }

-- | The Amazon Resource Number (ARN) for the routing control that you want
-- to update the state for.
updateRoutingControlState_routingControlArn :: Lens.Lens' UpdateRoutingControlState Prelude.Text
updateRoutingControlState_routingControlArn :: (Text -> f Text)
-> UpdateRoutingControlState -> f UpdateRoutingControlState
updateRoutingControlState_routingControlArn = (UpdateRoutingControlState -> Text)
-> (UpdateRoutingControlState -> Text -> UpdateRoutingControlState)
-> Lens
     UpdateRoutingControlState UpdateRoutingControlState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRoutingControlState' {Text
routingControlArn :: Text
$sel:routingControlArn:UpdateRoutingControlState' :: UpdateRoutingControlState -> Text
routingControlArn} -> Text
routingControlArn) (\s :: UpdateRoutingControlState
s@UpdateRoutingControlState' {} Text
a -> UpdateRoutingControlState
s {$sel:routingControlArn:UpdateRoutingControlState' :: Text
routingControlArn = Text
a} :: UpdateRoutingControlState)

-- | The state of the routing control. You can set the value to be On or Off.
updateRoutingControlState_routingControlState :: Lens.Lens' UpdateRoutingControlState RoutingControlState
updateRoutingControlState_routingControlState :: (RoutingControlState -> f RoutingControlState)
-> UpdateRoutingControlState -> f UpdateRoutingControlState
updateRoutingControlState_routingControlState = (UpdateRoutingControlState -> RoutingControlState)
-> (UpdateRoutingControlState
    -> RoutingControlState -> UpdateRoutingControlState)
-> Lens
     UpdateRoutingControlState
     UpdateRoutingControlState
     RoutingControlState
     RoutingControlState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRoutingControlState' {RoutingControlState
routingControlState :: RoutingControlState
$sel:routingControlState:UpdateRoutingControlState' :: UpdateRoutingControlState -> RoutingControlState
routingControlState} -> RoutingControlState
routingControlState) (\s :: UpdateRoutingControlState
s@UpdateRoutingControlState' {} RoutingControlState
a -> UpdateRoutingControlState
s {$sel:routingControlState:UpdateRoutingControlState' :: RoutingControlState
routingControlState = RoutingControlState
a} :: UpdateRoutingControlState)

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

instance Prelude.NFData UpdateRoutingControlState

instance Core.ToHeaders UpdateRoutingControlState where
  toHeaders :: UpdateRoutingControlState -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateRoutingControlState -> 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
"ToggleCustomerAPI.UpdateRoutingControlState" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateRoutingControlState where
  toJSON :: UpdateRoutingControlState -> Value
toJSON UpdateRoutingControlState' {Text
RoutingControlState
routingControlState :: RoutingControlState
routingControlArn :: Text
$sel:routingControlState:UpdateRoutingControlState' :: UpdateRoutingControlState -> RoutingControlState
$sel:routingControlArn:UpdateRoutingControlState' :: UpdateRoutingControlState -> 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
"RoutingControlArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
routingControlArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RoutingControlState" Text -> RoutingControlState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RoutingControlState
routingControlState)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateRoutingControlStateResponse