{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.RoutingControl
-- 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)
module Amazonka.Route53RecoveryControlConfig.Types.RoutingControl where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryControlConfig.Types.Status

-- | 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 traffic routing.
--
-- /See:/ 'newRoutingControl' smart constructor.
data RoutingControl = RoutingControl'
  { -- | The deployment status of a routing control. Status can be one of the
    -- following: PENDING, DEPLOYED, PENDING_DELETION.
    RoutingControl -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The Amazon Resource Name (ARN) of the control panel that includes the
    -- routing control.
    RoutingControl -> Maybe Text
controlPanelArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the routing control.
    RoutingControl -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the routing control.
    RoutingControl -> Maybe Text
routingControlArn :: Prelude.Maybe Prelude.Text
  }
  deriving (RoutingControl -> RoutingControl -> Bool
(RoutingControl -> RoutingControl -> Bool)
-> (RoutingControl -> RoutingControl -> Bool) -> Eq RoutingControl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoutingControl -> RoutingControl -> Bool
$c/= :: RoutingControl -> RoutingControl -> Bool
== :: RoutingControl -> RoutingControl -> Bool
$c== :: RoutingControl -> RoutingControl -> Bool
Prelude.Eq, ReadPrec [RoutingControl]
ReadPrec RoutingControl
Int -> ReadS RoutingControl
ReadS [RoutingControl]
(Int -> ReadS RoutingControl)
-> ReadS [RoutingControl]
-> ReadPrec RoutingControl
-> ReadPrec [RoutingControl]
-> Read RoutingControl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RoutingControl]
$creadListPrec :: ReadPrec [RoutingControl]
readPrec :: ReadPrec RoutingControl
$creadPrec :: ReadPrec RoutingControl
readList :: ReadS [RoutingControl]
$creadList :: ReadS [RoutingControl]
readsPrec :: Int -> ReadS RoutingControl
$creadsPrec :: Int -> ReadS RoutingControl
Prelude.Read, Int -> RoutingControl -> ShowS
[RoutingControl] -> ShowS
RoutingControl -> String
(Int -> RoutingControl -> ShowS)
-> (RoutingControl -> String)
-> ([RoutingControl] -> ShowS)
-> Show RoutingControl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoutingControl] -> ShowS
$cshowList :: [RoutingControl] -> ShowS
show :: RoutingControl -> String
$cshow :: RoutingControl -> String
showsPrec :: Int -> RoutingControl -> ShowS
$cshowsPrec :: Int -> RoutingControl -> ShowS
Prelude.Show, (forall x. RoutingControl -> Rep RoutingControl x)
-> (forall x. Rep RoutingControl x -> RoutingControl)
-> Generic RoutingControl
forall x. Rep RoutingControl x -> RoutingControl
forall x. RoutingControl -> Rep RoutingControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoutingControl x -> RoutingControl
$cfrom :: forall x. RoutingControl -> Rep RoutingControl x
Prelude.Generic)

-- |
-- Create a value of 'RoutingControl' 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:
--
-- 'status', 'routingControl_status' - The deployment status of a routing control. Status can be one of the
-- following: PENDING, DEPLOYED, PENDING_DELETION.
--
-- 'controlPanelArn', 'routingControl_controlPanelArn' - The Amazon Resource Name (ARN) of the control panel that includes the
-- routing control.
--
-- 'name', 'routingControl_name' - The name of the routing control.
--
-- 'routingControlArn', 'routingControl_routingControlArn' - The Amazon Resource Name (ARN) of the routing control.
newRoutingControl ::
  RoutingControl
newRoutingControl :: RoutingControl
newRoutingControl =
  RoutingControl' :: Maybe Status
-> Maybe Text -> Maybe Text -> Maybe Text -> RoutingControl
RoutingControl'
    { $sel:status:RoutingControl' :: Maybe Status
status = Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:controlPanelArn:RoutingControl' :: Maybe Text
controlPanelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RoutingControl' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:routingControlArn:RoutingControl' :: Maybe Text
routingControlArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The deployment status of a routing control. Status can be one of the
-- following: PENDING, DEPLOYED, PENDING_DELETION.
routingControl_status :: Lens.Lens' RoutingControl (Prelude.Maybe Status)
routingControl_status :: (Maybe Status -> f (Maybe Status))
-> RoutingControl -> f RoutingControl
routingControl_status = (RoutingControl -> Maybe Status)
-> (RoutingControl -> Maybe Status -> RoutingControl)
-> Lens RoutingControl RoutingControl (Maybe Status) (Maybe Status)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingControl' {Maybe Status
status :: Maybe Status
$sel:status:RoutingControl' :: RoutingControl -> Maybe Status
status} -> Maybe Status
status) (\s :: RoutingControl
s@RoutingControl' {} Maybe Status
a -> RoutingControl
s {$sel:status:RoutingControl' :: Maybe Status
status = Maybe Status
a} :: RoutingControl)

-- | The Amazon Resource Name (ARN) of the control panel that includes the
-- routing control.
routingControl_controlPanelArn :: Lens.Lens' RoutingControl (Prelude.Maybe Prelude.Text)
routingControl_controlPanelArn :: (Maybe Text -> f (Maybe Text))
-> RoutingControl -> f RoutingControl
routingControl_controlPanelArn = (RoutingControl -> Maybe Text)
-> (RoutingControl -> Maybe Text -> RoutingControl)
-> Lens RoutingControl RoutingControl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingControl' {Maybe Text
controlPanelArn :: Maybe Text
$sel:controlPanelArn:RoutingControl' :: RoutingControl -> Maybe Text
controlPanelArn} -> Maybe Text
controlPanelArn) (\s :: RoutingControl
s@RoutingControl' {} Maybe Text
a -> RoutingControl
s {$sel:controlPanelArn:RoutingControl' :: Maybe Text
controlPanelArn = Maybe Text
a} :: RoutingControl)

-- | The name of the routing control.
routingControl_name :: Lens.Lens' RoutingControl (Prelude.Maybe Prelude.Text)
routingControl_name :: (Maybe Text -> f (Maybe Text))
-> RoutingControl -> f RoutingControl
routingControl_name = (RoutingControl -> Maybe Text)
-> (RoutingControl -> Maybe Text -> RoutingControl)
-> Lens RoutingControl RoutingControl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingControl' {Maybe Text
name :: Maybe Text
$sel:name:RoutingControl' :: RoutingControl -> Maybe Text
name} -> Maybe Text
name) (\s :: RoutingControl
s@RoutingControl' {} Maybe Text
a -> RoutingControl
s {$sel:name:RoutingControl' :: Maybe Text
name = Maybe Text
a} :: RoutingControl)

-- | The Amazon Resource Name (ARN) of the routing control.
routingControl_routingControlArn :: Lens.Lens' RoutingControl (Prelude.Maybe Prelude.Text)
routingControl_routingControlArn :: (Maybe Text -> f (Maybe Text))
-> RoutingControl -> f RoutingControl
routingControl_routingControlArn = (RoutingControl -> Maybe Text)
-> (RoutingControl -> Maybe Text -> RoutingControl)
-> Lens RoutingControl RoutingControl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingControl' {Maybe Text
routingControlArn :: Maybe Text
$sel:routingControlArn:RoutingControl' :: RoutingControl -> Maybe Text
routingControlArn} -> Maybe Text
routingControlArn) (\s :: RoutingControl
s@RoutingControl' {} Maybe Text
a -> RoutingControl
s {$sel:routingControlArn:RoutingControl' :: Maybe Text
routingControlArn = Maybe Text
a} :: RoutingControl)

instance Core.FromJSON RoutingControl where
  parseJSON :: Value -> Parser RoutingControl
parseJSON =
    String
-> (Object -> Parser RoutingControl)
-> Value
-> Parser RoutingControl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RoutingControl"
      ( \Object
x ->
          Maybe Status
-> Maybe Text -> Maybe Text -> Maybe Text -> RoutingControl
RoutingControl'
            (Maybe Status
 -> Maybe Text -> Maybe Text -> Maybe Text -> RoutingControl)
-> Parser (Maybe Status)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> RoutingControl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Status)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> RoutingControl)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> RoutingControl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ControlPanelArn")
            Parser (Maybe Text -> Maybe Text -> RoutingControl)
-> Parser (Maybe Text) -> Parser (Maybe Text -> RoutingControl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe Text -> RoutingControl)
-> Parser (Maybe Text) -> Parser RoutingControl
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RoutingControlArn")
      )

instance Prelude.Hashable RoutingControl

instance Prelude.NFData RoutingControl