{-# 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.Route53RecoveryControlConfig.DescribeRoutingControl
-- 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)
--
-- Displays details about a routing control. A routing control has one of
-- two states: ON and OFF. You can map the routing control state to the
-- state of an Amazon Route 53 health check, which can be used to control
-- routing.
--
-- To get or update the routing control state, see the Recovery Cluster
-- (data plane) API actions for Amazon Route 53 Application Recovery
-- Controller.
module Amazonka.Route53RecoveryControlConfig.DescribeRoutingControl
  ( -- * Creating a Request
    DescribeRoutingControl (..),
    newDescribeRoutingControl,

    -- * Request Lenses
    describeRoutingControl_routingControlArn,

    -- * Destructuring the Response
    DescribeRoutingControlResponse (..),
    newDescribeRoutingControlResponse,

    -- * Response Lenses
    describeRoutingControlResponse_routingControl,
    describeRoutingControlResponse_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.Route53RecoveryControlConfig.Types

-- | /See:/ 'newDescribeRoutingControl' smart constructor.
data DescribeRoutingControl = DescribeRoutingControl'
  { -- | The Amazon Resource Name (ARN) of the routing control that you\'re
    -- getting details for.
    DescribeRoutingControl -> Text
routingControlArn :: Prelude.Text
  }
  deriving (DescribeRoutingControl -> DescribeRoutingControl -> Bool
(DescribeRoutingControl -> DescribeRoutingControl -> Bool)
-> (DescribeRoutingControl -> DescribeRoutingControl -> Bool)
-> Eq DescribeRoutingControl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRoutingControl -> DescribeRoutingControl -> Bool
$c/= :: DescribeRoutingControl -> DescribeRoutingControl -> Bool
== :: DescribeRoutingControl -> DescribeRoutingControl -> Bool
$c== :: DescribeRoutingControl -> DescribeRoutingControl -> Bool
Prelude.Eq, ReadPrec [DescribeRoutingControl]
ReadPrec DescribeRoutingControl
Int -> ReadS DescribeRoutingControl
ReadS [DescribeRoutingControl]
(Int -> ReadS DescribeRoutingControl)
-> ReadS [DescribeRoutingControl]
-> ReadPrec DescribeRoutingControl
-> ReadPrec [DescribeRoutingControl]
-> Read DescribeRoutingControl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRoutingControl]
$creadListPrec :: ReadPrec [DescribeRoutingControl]
readPrec :: ReadPrec DescribeRoutingControl
$creadPrec :: ReadPrec DescribeRoutingControl
readList :: ReadS [DescribeRoutingControl]
$creadList :: ReadS [DescribeRoutingControl]
readsPrec :: Int -> ReadS DescribeRoutingControl
$creadsPrec :: Int -> ReadS DescribeRoutingControl
Prelude.Read, Int -> DescribeRoutingControl -> ShowS
[DescribeRoutingControl] -> ShowS
DescribeRoutingControl -> String
(Int -> DescribeRoutingControl -> ShowS)
-> (DescribeRoutingControl -> String)
-> ([DescribeRoutingControl] -> ShowS)
-> Show DescribeRoutingControl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRoutingControl] -> ShowS
$cshowList :: [DescribeRoutingControl] -> ShowS
show :: DescribeRoutingControl -> String
$cshow :: DescribeRoutingControl -> String
showsPrec :: Int -> DescribeRoutingControl -> ShowS
$cshowsPrec :: Int -> DescribeRoutingControl -> ShowS
Prelude.Show, (forall x. DescribeRoutingControl -> Rep DescribeRoutingControl x)
-> (forall x.
    Rep DescribeRoutingControl x -> DescribeRoutingControl)
-> Generic DescribeRoutingControl
forall x. Rep DescribeRoutingControl x -> DescribeRoutingControl
forall x. DescribeRoutingControl -> Rep DescribeRoutingControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRoutingControl x -> DescribeRoutingControl
$cfrom :: forall x. DescribeRoutingControl -> Rep DescribeRoutingControl x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRoutingControl' 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', 'describeRoutingControl_routingControlArn' - The Amazon Resource Name (ARN) of the routing control that you\'re
-- getting details for.
newDescribeRoutingControl ::
  -- | 'routingControlArn'
  Prelude.Text ->
  DescribeRoutingControl
newDescribeRoutingControl :: Text -> DescribeRoutingControl
newDescribeRoutingControl Text
pRoutingControlArn_ =
  DescribeRoutingControl' :: Text -> DescribeRoutingControl
DescribeRoutingControl'
    { $sel:routingControlArn:DescribeRoutingControl' :: Text
routingControlArn =
        Text
pRoutingControlArn_
    }

-- | The Amazon Resource Name (ARN) of the routing control that you\'re
-- getting details for.
describeRoutingControl_routingControlArn :: Lens.Lens' DescribeRoutingControl Prelude.Text
describeRoutingControl_routingControlArn :: (Text -> f Text)
-> DescribeRoutingControl -> f DescribeRoutingControl
describeRoutingControl_routingControlArn = (DescribeRoutingControl -> Text)
-> (DescribeRoutingControl -> Text -> DescribeRoutingControl)
-> Lens DescribeRoutingControl DescribeRoutingControl Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoutingControl' {Text
routingControlArn :: Text
$sel:routingControlArn:DescribeRoutingControl' :: DescribeRoutingControl -> Text
routingControlArn} -> Text
routingControlArn) (\s :: DescribeRoutingControl
s@DescribeRoutingControl' {} Text
a -> DescribeRoutingControl
s {$sel:routingControlArn:DescribeRoutingControl' :: Text
routingControlArn = Text
a} :: DescribeRoutingControl)

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

instance Prelude.NFData DescribeRoutingControl

instance Core.ToHeaders DescribeRoutingControl where
  toHeaders :: DescribeRoutingControl -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRoutingControl -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DescribeRoutingControl where
  toPath :: DescribeRoutingControl -> ByteString
toPath DescribeRoutingControl' {Text
routingControlArn :: Text
$sel:routingControlArn:DescribeRoutingControl' :: DescribeRoutingControl -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/routingcontrol/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
routingControlArn]

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

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

-- |
-- Create a value of 'DescribeRoutingControlResponse' 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:
--
-- 'routingControl', 'describeRoutingControlResponse_routingControl' - Information about the routing control.
--
-- 'httpStatus', 'describeRoutingControlResponse_httpStatus' - The response's http status code.
newDescribeRoutingControlResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRoutingControlResponse
newDescribeRoutingControlResponse :: Int -> DescribeRoutingControlResponse
newDescribeRoutingControlResponse Int
pHttpStatus_ =
  DescribeRoutingControlResponse' :: Maybe RoutingControl -> Int -> DescribeRoutingControlResponse
DescribeRoutingControlResponse'
    { $sel:routingControl:DescribeRoutingControlResponse' :: Maybe RoutingControl
routingControl =
        Maybe RoutingControl
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRoutingControlResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the routing control.
describeRoutingControlResponse_routingControl :: Lens.Lens' DescribeRoutingControlResponse (Prelude.Maybe RoutingControl)
describeRoutingControlResponse_routingControl :: (Maybe RoutingControl -> f (Maybe RoutingControl))
-> DescribeRoutingControlResponse
-> f DescribeRoutingControlResponse
describeRoutingControlResponse_routingControl = (DescribeRoutingControlResponse -> Maybe RoutingControl)
-> (DescribeRoutingControlResponse
    -> Maybe RoutingControl -> DescribeRoutingControlResponse)
-> Lens
     DescribeRoutingControlResponse
     DescribeRoutingControlResponse
     (Maybe RoutingControl)
     (Maybe RoutingControl)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoutingControlResponse' {Maybe RoutingControl
routingControl :: Maybe RoutingControl
$sel:routingControl:DescribeRoutingControlResponse' :: DescribeRoutingControlResponse -> Maybe RoutingControl
routingControl} -> Maybe RoutingControl
routingControl) (\s :: DescribeRoutingControlResponse
s@DescribeRoutingControlResponse' {} Maybe RoutingControl
a -> DescribeRoutingControlResponse
s {$sel:routingControl:DescribeRoutingControlResponse' :: Maybe RoutingControl
routingControl = Maybe RoutingControl
a} :: DescribeRoutingControlResponse)

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

instance
  Prelude.NFData
    DescribeRoutingControlResponse