{-# 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.GetRoutingControlState
-- 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)
--
-- Get the state for a routing control. A routing control is a simple
-- on\/off switch that you can use to route traffic to cells. When the
-- state is On, traffic flows to a cell. When it\'s off, traffic does not
-- flow.
--
-- Before you can create a routing control, you first must create a cluster
-- to host the control. For more information, see
-- <https://docs.aws.amazon.com/recovery-cluster/latest/api/cluster.html CreateCluster>.
-- Access one of the endpoints for the cluster to get or update the routing
-- control state to redirect traffic.
--
-- 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.GetRoutingControlState
  ( -- * Creating a Request
    GetRoutingControlState (..),
    newGetRoutingControlState,

    -- * Request Lenses
    getRoutingControlState_routingControlArn,

    -- * Destructuring the Response
    GetRoutingControlStateResponse (..),
    newGetRoutingControlStateResponse,

    -- * Response Lenses
    getRoutingControlStateResponse_httpStatus,
    getRoutingControlStateResponse_routingControlArn,
    getRoutingControlStateResponse_routingControlState,
  )
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:/ 'newGetRoutingControlState' smart constructor.
data GetRoutingControlState = GetRoutingControlState'
  { -- | The Amazon Resource Number (ARN) for the routing control that you want
    -- to get the state for.
    GetRoutingControlState -> Text
routingControlArn :: Prelude.Text
  }
  deriving (GetRoutingControlState -> GetRoutingControlState -> Bool
(GetRoutingControlState -> GetRoutingControlState -> Bool)
-> (GetRoutingControlState -> GetRoutingControlState -> Bool)
-> Eq GetRoutingControlState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRoutingControlState -> GetRoutingControlState -> Bool
$c/= :: GetRoutingControlState -> GetRoutingControlState -> Bool
== :: GetRoutingControlState -> GetRoutingControlState -> Bool
$c== :: GetRoutingControlState -> GetRoutingControlState -> Bool
Prelude.Eq, ReadPrec [GetRoutingControlState]
ReadPrec GetRoutingControlState
Int -> ReadS GetRoutingControlState
ReadS [GetRoutingControlState]
(Int -> ReadS GetRoutingControlState)
-> ReadS [GetRoutingControlState]
-> ReadPrec GetRoutingControlState
-> ReadPrec [GetRoutingControlState]
-> Read GetRoutingControlState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRoutingControlState]
$creadListPrec :: ReadPrec [GetRoutingControlState]
readPrec :: ReadPrec GetRoutingControlState
$creadPrec :: ReadPrec GetRoutingControlState
readList :: ReadS [GetRoutingControlState]
$creadList :: ReadS [GetRoutingControlState]
readsPrec :: Int -> ReadS GetRoutingControlState
$creadsPrec :: Int -> ReadS GetRoutingControlState
Prelude.Read, Int -> GetRoutingControlState -> ShowS
[GetRoutingControlState] -> ShowS
GetRoutingControlState -> String
(Int -> GetRoutingControlState -> ShowS)
-> (GetRoutingControlState -> String)
-> ([GetRoutingControlState] -> ShowS)
-> Show GetRoutingControlState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRoutingControlState] -> ShowS
$cshowList :: [GetRoutingControlState] -> ShowS
show :: GetRoutingControlState -> String
$cshow :: GetRoutingControlState -> String
showsPrec :: Int -> GetRoutingControlState -> ShowS
$cshowsPrec :: Int -> GetRoutingControlState -> ShowS
Prelude.Show, (forall x. GetRoutingControlState -> Rep GetRoutingControlState x)
-> (forall x.
    Rep GetRoutingControlState x -> GetRoutingControlState)
-> Generic GetRoutingControlState
forall x. Rep GetRoutingControlState x -> GetRoutingControlState
forall x. GetRoutingControlState -> Rep GetRoutingControlState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRoutingControlState x -> GetRoutingControlState
$cfrom :: forall x. GetRoutingControlState -> Rep GetRoutingControlState x
Prelude.Generic)

-- |
-- Create a value of 'GetRoutingControlState' 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', 'getRoutingControlState_routingControlArn' - The Amazon Resource Number (ARN) for the routing control that you want
-- to get the state for.
newGetRoutingControlState ::
  -- | 'routingControlArn'
  Prelude.Text ->
  GetRoutingControlState
newGetRoutingControlState :: Text -> GetRoutingControlState
newGetRoutingControlState Text
pRoutingControlArn_ =
  GetRoutingControlState' :: Text -> GetRoutingControlState
GetRoutingControlState'
    { $sel:routingControlArn:GetRoutingControlState' :: Text
routingControlArn =
        Text
pRoutingControlArn_
    }

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

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

instance Prelude.Hashable GetRoutingControlState

instance Prelude.NFData GetRoutingControlState

instance Core.ToHeaders GetRoutingControlState where
  toHeaders :: GetRoutingControlState -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRoutingControlState -> 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.GetRoutingControlState" ::
                          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 GetRoutingControlState where
  toJSON :: GetRoutingControlState -> Value
toJSON GetRoutingControlState' {Text
routingControlArn :: Text
$sel:routingControlArn:GetRoutingControlState' :: GetRoutingControlState -> 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)
          ]
      )

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

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

-- | /See:/ 'newGetRoutingControlStateResponse' smart constructor.
data GetRoutingControlStateResponse = GetRoutingControlStateResponse'
  { -- | The response's http status code.
    GetRoutingControlStateResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Resource Number (ARN) of the response.
    GetRoutingControlStateResponse -> Text
routingControlArn :: Prelude.Text,
    -- | The state of the routing control.
    GetRoutingControlStateResponse -> RoutingControlState
routingControlState :: RoutingControlState
  }
  deriving (GetRoutingControlStateResponse
-> GetRoutingControlStateResponse -> Bool
(GetRoutingControlStateResponse
 -> GetRoutingControlStateResponse -> Bool)
-> (GetRoutingControlStateResponse
    -> GetRoutingControlStateResponse -> Bool)
-> Eq GetRoutingControlStateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRoutingControlStateResponse
-> GetRoutingControlStateResponse -> Bool
$c/= :: GetRoutingControlStateResponse
-> GetRoutingControlStateResponse -> Bool
== :: GetRoutingControlStateResponse
-> GetRoutingControlStateResponse -> Bool
$c== :: GetRoutingControlStateResponse
-> GetRoutingControlStateResponse -> Bool
Prelude.Eq, ReadPrec [GetRoutingControlStateResponse]
ReadPrec GetRoutingControlStateResponse
Int -> ReadS GetRoutingControlStateResponse
ReadS [GetRoutingControlStateResponse]
(Int -> ReadS GetRoutingControlStateResponse)
-> ReadS [GetRoutingControlStateResponse]
-> ReadPrec GetRoutingControlStateResponse
-> ReadPrec [GetRoutingControlStateResponse]
-> Read GetRoutingControlStateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRoutingControlStateResponse]
$creadListPrec :: ReadPrec [GetRoutingControlStateResponse]
readPrec :: ReadPrec GetRoutingControlStateResponse
$creadPrec :: ReadPrec GetRoutingControlStateResponse
readList :: ReadS [GetRoutingControlStateResponse]
$creadList :: ReadS [GetRoutingControlStateResponse]
readsPrec :: Int -> ReadS GetRoutingControlStateResponse
$creadsPrec :: Int -> ReadS GetRoutingControlStateResponse
Prelude.Read, Int -> GetRoutingControlStateResponse -> ShowS
[GetRoutingControlStateResponse] -> ShowS
GetRoutingControlStateResponse -> String
(Int -> GetRoutingControlStateResponse -> ShowS)
-> (GetRoutingControlStateResponse -> String)
-> ([GetRoutingControlStateResponse] -> ShowS)
-> Show GetRoutingControlStateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRoutingControlStateResponse] -> ShowS
$cshowList :: [GetRoutingControlStateResponse] -> ShowS
show :: GetRoutingControlStateResponse -> String
$cshow :: GetRoutingControlStateResponse -> String
showsPrec :: Int -> GetRoutingControlStateResponse -> ShowS
$cshowsPrec :: Int -> GetRoutingControlStateResponse -> ShowS
Prelude.Show, (forall x.
 GetRoutingControlStateResponse
 -> Rep GetRoutingControlStateResponse x)
-> (forall x.
    Rep GetRoutingControlStateResponse x
    -> GetRoutingControlStateResponse)
-> Generic GetRoutingControlStateResponse
forall x.
Rep GetRoutingControlStateResponse x
-> GetRoutingControlStateResponse
forall x.
GetRoutingControlStateResponse
-> Rep GetRoutingControlStateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRoutingControlStateResponse x
-> GetRoutingControlStateResponse
$cfrom :: forall x.
GetRoutingControlStateResponse
-> Rep GetRoutingControlStateResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetRoutingControlStateResponse' 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', 'getRoutingControlStateResponse_httpStatus' - The response's http status code.
--
-- 'routingControlArn', 'getRoutingControlStateResponse_routingControlArn' - The Amazon Resource Number (ARN) of the response.
--
-- 'routingControlState', 'getRoutingControlStateResponse_routingControlState' - The state of the routing control.
newGetRoutingControlStateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'routingControlArn'
  Prelude.Text ->
  -- | 'routingControlState'
  RoutingControlState ->
  GetRoutingControlStateResponse
newGetRoutingControlStateResponse :: Int
-> Text -> RoutingControlState -> GetRoutingControlStateResponse
newGetRoutingControlStateResponse
  Int
pHttpStatus_
  Text
pRoutingControlArn_
  RoutingControlState
pRoutingControlState_ =
    GetRoutingControlStateResponse' :: Int
-> Text -> RoutingControlState -> GetRoutingControlStateResponse
GetRoutingControlStateResponse'
      { $sel:httpStatus:GetRoutingControlStateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:routingControlArn:GetRoutingControlStateResponse' :: Text
routingControlArn = Text
pRoutingControlArn_,
        $sel:routingControlState:GetRoutingControlStateResponse' :: RoutingControlState
routingControlState = RoutingControlState
pRoutingControlState_
      }

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

-- | The Amazon Resource Number (ARN) of the response.
getRoutingControlStateResponse_routingControlArn :: Lens.Lens' GetRoutingControlStateResponse Prelude.Text
getRoutingControlStateResponse_routingControlArn :: (Text -> f Text)
-> GetRoutingControlStateResponse
-> f GetRoutingControlStateResponse
getRoutingControlStateResponse_routingControlArn = (GetRoutingControlStateResponse -> Text)
-> (GetRoutingControlStateResponse
    -> Text -> GetRoutingControlStateResponse)
-> Lens
     GetRoutingControlStateResponse
     GetRoutingControlStateResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRoutingControlStateResponse' {Text
routingControlArn :: Text
$sel:routingControlArn:GetRoutingControlStateResponse' :: GetRoutingControlStateResponse -> Text
routingControlArn} -> Text
routingControlArn) (\s :: GetRoutingControlStateResponse
s@GetRoutingControlStateResponse' {} Text
a -> GetRoutingControlStateResponse
s {$sel:routingControlArn:GetRoutingControlStateResponse' :: Text
routingControlArn = Text
a} :: GetRoutingControlStateResponse)

-- | The state of the routing control.
getRoutingControlStateResponse_routingControlState :: Lens.Lens' GetRoutingControlStateResponse RoutingControlState
getRoutingControlStateResponse_routingControlState :: (RoutingControlState -> f RoutingControlState)
-> GetRoutingControlStateResponse
-> f GetRoutingControlStateResponse
getRoutingControlStateResponse_routingControlState = (GetRoutingControlStateResponse -> RoutingControlState)
-> (GetRoutingControlStateResponse
    -> RoutingControlState -> GetRoutingControlStateResponse)
-> Lens
     GetRoutingControlStateResponse
     GetRoutingControlStateResponse
     RoutingControlState
     RoutingControlState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRoutingControlStateResponse' {RoutingControlState
routingControlState :: RoutingControlState
$sel:routingControlState:GetRoutingControlStateResponse' :: GetRoutingControlStateResponse -> RoutingControlState
routingControlState} -> RoutingControlState
routingControlState) (\s :: GetRoutingControlStateResponse
s@GetRoutingControlStateResponse' {} RoutingControlState
a -> GetRoutingControlStateResponse
s {$sel:routingControlState:GetRoutingControlStateResponse' :: RoutingControlState
routingControlState = RoutingControlState
a} :: GetRoutingControlStateResponse)

instance
  Prelude.NFData
    GetRoutingControlStateResponse