{-# 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.UpdateRoutingControlStates
-- 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 multiple routing control states. You can set the value for each
-- state 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.UpdateRoutingControlStates
  ( -- * Creating a Request
    UpdateRoutingControlStates (..),
    newUpdateRoutingControlStates,

    -- * Request Lenses
    updateRoutingControlStates_updateRoutingControlStateEntries,

    -- * Destructuring the Response
    UpdateRoutingControlStatesResponse (..),
    newUpdateRoutingControlStatesResponse,

    -- * Response Lenses
    updateRoutingControlStatesResponse_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:/ 'newUpdateRoutingControlStates' smart constructor.
data UpdateRoutingControlStates = UpdateRoutingControlStates'
  { -- | A set of routing control entries that you want to update.
    UpdateRoutingControlStates -> [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries :: [UpdateRoutingControlStateEntry]
  }
  deriving (UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool
(UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool)
-> (UpdateRoutingControlStates
    -> UpdateRoutingControlStates -> Bool)
-> Eq UpdateRoutingControlStates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool
$c/= :: UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool
== :: UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool
$c== :: UpdateRoutingControlStates -> UpdateRoutingControlStates -> Bool
Prelude.Eq, ReadPrec [UpdateRoutingControlStates]
ReadPrec UpdateRoutingControlStates
Int -> ReadS UpdateRoutingControlStates
ReadS [UpdateRoutingControlStates]
(Int -> ReadS UpdateRoutingControlStates)
-> ReadS [UpdateRoutingControlStates]
-> ReadPrec UpdateRoutingControlStates
-> ReadPrec [UpdateRoutingControlStates]
-> Read UpdateRoutingControlStates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRoutingControlStates]
$creadListPrec :: ReadPrec [UpdateRoutingControlStates]
readPrec :: ReadPrec UpdateRoutingControlStates
$creadPrec :: ReadPrec UpdateRoutingControlStates
readList :: ReadS [UpdateRoutingControlStates]
$creadList :: ReadS [UpdateRoutingControlStates]
readsPrec :: Int -> ReadS UpdateRoutingControlStates
$creadsPrec :: Int -> ReadS UpdateRoutingControlStates
Prelude.Read, Int -> UpdateRoutingControlStates -> ShowS
[UpdateRoutingControlStates] -> ShowS
UpdateRoutingControlStates -> String
(Int -> UpdateRoutingControlStates -> ShowS)
-> (UpdateRoutingControlStates -> String)
-> ([UpdateRoutingControlStates] -> ShowS)
-> Show UpdateRoutingControlStates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRoutingControlStates] -> ShowS
$cshowList :: [UpdateRoutingControlStates] -> ShowS
show :: UpdateRoutingControlStates -> String
$cshow :: UpdateRoutingControlStates -> String
showsPrec :: Int -> UpdateRoutingControlStates -> ShowS
$cshowsPrec :: Int -> UpdateRoutingControlStates -> ShowS
Prelude.Show, (forall x.
 UpdateRoutingControlStates -> Rep UpdateRoutingControlStates x)
-> (forall x.
    Rep UpdateRoutingControlStates x -> UpdateRoutingControlStates)
-> Generic UpdateRoutingControlStates
forall x.
Rep UpdateRoutingControlStates x -> UpdateRoutingControlStates
forall x.
UpdateRoutingControlStates -> Rep UpdateRoutingControlStates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRoutingControlStates x -> UpdateRoutingControlStates
$cfrom :: forall x.
UpdateRoutingControlStates -> Rep UpdateRoutingControlStates x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRoutingControlStates' 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:
--
-- 'updateRoutingControlStateEntries', 'updateRoutingControlStates_updateRoutingControlStateEntries' - A set of routing control entries that you want to update.
newUpdateRoutingControlStates ::
  UpdateRoutingControlStates
newUpdateRoutingControlStates :: UpdateRoutingControlStates
newUpdateRoutingControlStates =
  UpdateRoutingControlStates' :: [UpdateRoutingControlStateEntry] -> UpdateRoutingControlStates
UpdateRoutingControlStates'
    { $sel:updateRoutingControlStateEntries:UpdateRoutingControlStates' :: [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries =
        [UpdateRoutingControlStateEntry]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A set of routing control entries that you want to update.
updateRoutingControlStates_updateRoutingControlStateEntries :: Lens.Lens' UpdateRoutingControlStates [UpdateRoutingControlStateEntry]
updateRoutingControlStates_updateRoutingControlStateEntries :: ([UpdateRoutingControlStateEntry]
 -> f [UpdateRoutingControlStateEntry])
-> UpdateRoutingControlStates -> f UpdateRoutingControlStates
updateRoutingControlStates_updateRoutingControlStateEntries = (UpdateRoutingControlStates -> [UpdateRoutingControlStateEntry])
-> (UpdateRoutingControlStates
    -> [UpdateRoutingControlStateEntry] -> UpdateRoutingControlStates)
-> Lens
     UpdateRoutingControlStates
     UpdateRoutingControlStates
     [UpdateRoutingControlStateEntry]
     [UpdateRoutingControlStateEntry]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRoutingControlStates' {[UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries :: [UpdateRoutingControlStateEntry]
$sel:updateRoutingControlStateEntries:UpdateRoutingControlStates' :: UpdateRoutingControlStates -> [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries} -> [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries) (\s :: UpdateRoutingControlStates
s@UpdateRoutingControlStates' {} [UpdateRoutingControlStateEntry]
a -> UpdateRoutingControlStates
s {$sel:updateRoutingControlStateEntries:UpdateRoutingControlStates' :: [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries = [UpdateRoutingControlStateEntry]
a} :: UpdateRoutingControlStates) (([UpdateRoutingControlStateEntry]
  -> f [UpdateRoutingControlStateEntry])
 -> UpdateRoutingControlStates -> f UpdateRoutingControlStates)
-> (([UpdateRoutingControlStateEntry]
     -> f [UpdateRoutingControlStateEntry])
    -> [UpdateRoutingControlStateEntry]
    -> f [UpdateRoutingControlStateEntry])
-> ([UpdateRoutingControlStateEntry]
    -> f [UpdateRoutingControlStateEntry])
-> UpdateRoutingControlStates
-> f UpdateRoutingControlStates
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UpdateRoutingControlStateEntry]
 -> f [UpdateRoutingControlStateEntry])
-> [UpdateRoutingControlStateEntry]
-> f [UpdateRoutingControlStateEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData UpdateRoutingControlStates

instance Core.ToHeaders UpdateRoutingControlStates where
  toHeaders :: UpdateRoutingControlStates -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateRoutingControlStates -> 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.UpdateRoutingControlStates" ::
                          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 UpdateRoutingControlStates where
  toJSON :: UpdateRoutingControlStates -> Value
toJSON UpdateRoutingControlStates' {[UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries :: [UpdateRoutingControlStateEntry]
$sel:updateRoutingControlStateEntries:UpdateRoutingControlStates' :: UpdateRoutingControlStates -> [UpdateRoutingControlStateEntry]
..} =
    [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
"UpdateRoutingControlStateEntries"
                  Text -> [UpdateRoutingControlStateEntry] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [UpdateRoutingControlStateEntry]
updateRoutingControlStateEntries
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateRoutingControlStatesResponse