{-# 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.Route53.Types.TrafficPolicy
-- 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.Route53.Types.TrafficPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53.Internal
import Amazonka.Route53.Types.RRType

-- | A complex type that contains settings for a traffic policy.
--
-- /See:/ 'newTrafficPolicy' smart constructor.
data TrafficPolicy = TrafficPolicy'
  { -- | The comment that you specify in the @CreateTrafficPolicy@ request, if
    -- any.
    TrafficPolicy -> Maybe Text
comment :: Prelude.Maybe Prelude.Text,
    -- | The ID that Amazon Route 53 assigned to a traffic policy when you
    -- created it.
    TrafficPolicy -> Text
id :: Prelude.Text,
    -- | The version number that Amazon Route 53 assigns to a traffic policy. For
    -- a new traffic policy, the value of @Version@ is always 1.
    TrafficPolicy -> Natural
version :: Prelude.Natural,
    -- | The name that you specified when you created the traffic policy.
    TrafficPolicy -> Text
name :: Prelude.Text,
    -- | The DNS type of the resource record sets that Amazon Route 53 creates
    -- when you use a traffic policy to create a traffic policy instance.
    TrafficPolicy -> RRType
type' :: RRType,
    -- | The definition of a traffic policy in JSON format. You specify the JSON
    -- document to use for a new traffic policy in the @CreateTrafficPolicy@
    -- request. For more information about the JSON format, see
    -- <https://docs.aws.amazon.com/Route53/latest/APIReference/api-policies-traffic-policy-document-format.html Traffic Policy Document Format>.
    TrafficPolicy -> Text
document :: Prelude.Text
  }
  deriving (TrafficPolicy -> TrafficPolicy -> Bool
(TrafficPolicy -> TrafficPolicy -> Bool)
-> (TrafficPolicy -> TrafficPolicy -> Bool) -> Eq TrafficPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrafficPolicy -> TrafficPolicy -> Bool
$c/= :: TrafficPolicy -> TrafficPolicy -> Bool
== :: TrafficPolicy -> TrafficPolicy -> Bool
$c== :: TrafficPolicy -> TrafficPolicy -> Bool
Prelude.Eq, ReadPrec [TrafficPolicy]
ReadPrec TrafficPolicy
Int -> ReadS TrafficPolicy
ReadS [TrafficPolicy]
(Int -> ReadS TrafficPolicy)
-> ReadS [TrafficPolicy]
-> ReadPrec TrafficPolicy
-> ReadPrec [TrafficPolicy]
-> Read TrafficPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrafficPolicy]
$creadListPrec :: ReadPrec [TrafficPolicy]
readPrec :: ReadPrec TrafficPolicy
$creadPrec :: ReadPrec TrafficPolicy
readList :: ReadS [TrafficPolicy]
$creadList :: ReadS [TrafficPolicy]
readsPrec :: Int -> ReadS TrafficPolicy
$creadsPrec :: Int -> ReadS TrafficPolicy
Prelude.Read, Int -> TrafficPolicy -> ShowS
[TrafficPolicy] -> ShowS
TrafficPolicy -> String
(Int -> TrafficPolicy -> ShowS)
-> (TrafficPolicy -> String)
-> ([TrafficPolicy] -> ShowS)
-> Show TrafficPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrafficPolicy] -> ShowS
$cshowList :: [TrafficPolicy] -> ShowS
show :: TrafficPolicy -> String
$cshow :: TrafficPolicy -> String
showsPrec :: Int -> TrafficPolicy -> ShowS
$cshowsPrec :: Int -> TrafficPolicy -> ShowS
Prelude.Show, (forall x. TrafficPolicy -> Rep TrafficPolicy x)
-> (forall x. Rep TrafficPolicy x -> TrafficPolicy)
-> Generic TrafficPolicy
forall x. Rep TrafficPolicy x -> TrafficPolicy
forall x. TrafficPolicy -> Rep TrafficPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrafficPolicy x -> TrafficPolicy
$cfrom :: forall x. TrafficPolicy -> Rep TrafficPolicy x
Prelude.Generic)

-- |
-- Create a value of 'TrafficPolicy' 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:
--
-- 'comment', 'trafficPolicy_comment' - The comment that you specify in the @CreateTrafficPolicy@ request, if
-- any.
--
-- 'id', 'trafficPolicy_id' - The ID that Amazon Route 53 assigned to a traffic policy when you
-- created it.
--
-- 'version', 'trafficPolicy_version' - The version number that Amazon Route 53 assigns to a traffic policy. For
-- a new traffic policy, the value of @Version@ is always 1.
--
-- 'name', 'trafficPolicy_name' - The name that you specified when you created the traffic policy.
--
-- 'type'', 'trafficPolicy_type' - The DNS type of the resource record sets that Amazon Route 53 creates
-- when you use a traffic policy to create a traffic policy instance.
--
-- 'document', 'trafficPolicy_document' - The definition of a traffic policy in JSON format. You specify the JSON
-- document to use for a new traffic policy in the @CreateTrafficPolicy@
-- request. For more information about the JSON format, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/api-policies-traffic-policy-document-format.html Traffic Policy Document Format>.
newTrafficPolicy ::
  -- | 'id'
  Prelude.Text ->
  -- | 'version'
  Prelude.Natural ->
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  RRType ->
  -- | 'document'
  Prelude.Text ->
  TrafficPolicy
newTrafficPolicy :: Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy
newTrafficPolicy
  Text
pId_
  Natural
pVersion_
  Text
pName_
  RRType
pType_
  Text
pDocument_ =
    TrafficPolicy' :: Maybe Text
-> Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy
TrafficPolicy'
      { $sel:comment:TrafficPolicy' :: Maybe Text
comment = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:id:TrafficPolicy' :: Text
id = Text
pId_,
        $sel:version:TrafficPolicy' :: Natural
version = Natural
pVersion_,
        $sel:name:TrafficPolicy' :: Text
name = Text
pName_,
        $sel:type':TrafficPolicy' :: RRType
type' = RRType
pType_,
        $sel:document:TrafficPolicy' :: Text
document = Text
pDocument_
      }

-- | The comment that you specify in the @CreateTrafficPolicy@ request, if
-- any.
trafficPolicy_comment :: Lens.Lens' TrafficPolicy (Prelude.Maybe Prelude.Text)
trafficPolicy_comment :: (Maybe Text -> f (Maybe Text)) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_comment = (TrafficPolicy -> Maybe Text)
-> (TrafficPolicy -> Maybe Text -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {Maybe Text
comment :: Maybe Text
$sel:comment:TrafficPolicy' :: TrafficPolicy -> Maybe Text
comment} -> Maybe Text
comment) (\s :: TrafficPolicy
s@TrafficPolicy' {} Maybe Text
a -> TrafficPolicy
s {$sel:comment:TrafficPolicy' :: Maybe Text
comment = Maybe Text
a} :: TrafficPolicy)

-- | The ID that Amazon Route 53 assigned to a traffic policy when you
-- created it.
trafficPolicy_id :: Lens.Lens' TrafficPolicy Prelude.Text
trafficPolicy_id :: (Text -> f Text) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_id = (TrafficPolicy -> Text)
-> (TrafficPolicy -> Text -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {Text
id :: Text
$sel:id:TrafficPolicy' :: TrafficPolicy -> Text
id} -> Text
id) (\s :: TrafficPolicy
s@TrafficPolicy' {} Text
a -> TrafficPolicy
s {$sel:id:TrafficPolicy' :: Text
id = Text
a} :: TrafficPolicy)

-- | The version number that Amazon Route 53 assigns to a traffic policy. For
-- a new traffic policy, the value of @Version@ is always 1.
trafficPolicy_version :: Lens.Lens' TrafficPolicy Prelude.Natural
trafficPolicy_version :: (Natural -> f Natural) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_version = (TrafficPolicy -> Natural)
-> (TrafficPolicy -> Natural -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {Natural
version :: Natural
$sel:version:TrafficPolicy' :: TrafficPolicy -> Natural
version} -> Natural
version) (\s :: TrafficPolicy
s@TrafficPolicy' {} Natural
a -> TrafficPolicy
s {$sel:version:TrafficPolicy' :: Natural
version = Natural
a} :: TrafficPolicy)

-- | The name that you specified when you created the traffic policy.
trafficPolicy_name :: Lens.Lens' TrafficPolicy Prelude.Text
trafficPolicy_name :: (Text -> f Text) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_name = (TrafficPolicy -> Text)
-> (TrafficPolicy -> Text -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {Text
name :: Text
$sel:name:TrafficPolicy' :: TrafficPolicy -> Text
name} -> Text
name) (\s :: TrafficPolicy
s@TrafficPolicy' {} Text
a -> TrafficPolicy
s {$sel:name:TrafficPolicy' :: Text
name = Text
a} :: TrafficPolicy)

-- | The DNS type of the resource record sets that Amazon Route 53 creates
-- when you use a traffic policy to create a traffic policy instance.
trafficPolicy_type :: Lens.Lens' TrafficPolicy RRType
trafficPolicy_type :: (RRType -> f RRType) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_type = (TrafficPolicy -> RRType)
-> (TrafficPolicy -> RRType -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy RRType RRType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {RRType
type' :: RRType
$sel:type':TrafficPolicy' :: TrafficPolicy -> RRType
type'} -> RRType
type') (\s :: TrafficPolicy
s@TrafficPolicy' {} RRType
a -> TrafficPolicy
s {$sel:type':TrafficPolicy' :: RRType
type' = RRType
a} :: TrafficPolicy)

-- | The definition of a traffic policy in JSON format. You specify the JSON
-- document to use for a new traffic policy in the @CreateTrafficPolicy@
-- request. For more information about the JSON format, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/api-policies-traffic-policy-document-format.html Traffic Policy Document Format>.
trafficPolicy_document :: Lens.Lens' TrafficPolicy Prelude.Text
trafficPolicy_document :: (Text -> f Text) -> TrafficPolicy -> f TrafficPolicy
trafficPolicy_document = (TrafficPolicy -> Text)
-> (TrafficPolicy -> Text -> TrafficPolicy)
-> Lens TrafficPolicy TrafficPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficPolicy' {Text
document :: Text
$sel:document:TrafficPolicy' :: TrafficPolicy -> Text
document} -> Text
document) (\s :: TrafficPolicy
s@TrafficPolicy' {} Text
a -> TrafficPolicy
s {$sel:document:TrafficPolicy' :: Text
document = Text
a} :: TrafficPolicy)

instance Core.FromXML TrafficPolicy where
  parseXML :: [Node] -> Either String TrafficPolicy
parseXML [Node]
x =
    Maybe Text
-> Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy
TrafficPolicy'
      (Maybe Text
 -> Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy)
-> Either String (Maybe Text)
-> Either
     String (Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Comment")
      Either
  String (Text -> Natural -> Text -> RRType -> Text -> TrafficPolicy)
-> Either String Text
-> Either
     String (Natural -> Text -> RRType -> Text -> TrafficPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Natural -> Text -> RRType -> Text -> TrafficPolicy)
-> Either String Natural
-> Either String (Text -> RRType -> Text -> TrafficPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Natural
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Version")
      Either String (Text -> RRType -> Text -> TrafficPolicy)
-> Either String Text
-> Either String (RRType -> Text -> TrafficPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Name")
      Either String (RRType -> Text -> TrafficPolicy)
-> Either String RRType -> Either String (Text -> TrafficPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String RRType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Type")
      Either String (Text -> TrafficPolicy)
-> Either String Text -> Either String TrafficPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Document")

instance Prelude.Hashable TrafficPolicy

instance Prelude.NFData TrafficPolicy