{-# 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.Route53.GetTrafficPolicy
-- 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)
--
-- Gets information about a specific traffic policy version.
--
-- For information about how of deleting a traffic policy affects the
-- response from @GetTrafficPolicy@, see
-- <https://docs.aws.amazon.com/Route53/latest/APIReference/API_DeleteTrafficPolicy.html DeleteTrafficPolicy>.
module Amazonka.Route53.GetTrafficPolicy
  ( -- * Creating a Request
    GetTrafficPolicy (..),
    newGetTrafficPolicy,

    -- * Request Lenses
    getTrafficPolicy_id,
    getTrafficPolicy_version,

    -- * Destructuring the Response
    GetTrafficPolicyResponse (..),
    newGetTrafficPolicyResponse,

    -- * Response Lenses
    getTrafficPolicyResponse_httpStatus,
    getTrafficPolicyResponse_trafficPolicy,
  )
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.Route53.Types

-- | Gets information about a specific traffic policy version.
--
-- /See:/ 'newGetTrafficPolicy' smart constructor.
data GetTrafficPolicy = GetTrafficPolicy'
  { -- | The ID of the traffic policy that you want to get information about.
    GetTrafficPolicy -> Text
id :: Prelude.Text,
    -- | The version number of the traffic policy that you want to get
    -- information about.
    GetTrafficPolicy -> Natural
version :: Prelude.Natural
  }
  deriving (GetTrafficPolicy -> GetTrafficPolicy -> Bool
(GetTrafficPolicy -> GetTrafficPolicy -> Bool)
-> (GetTrafficPolicy -> GetTrafficPolicy -> Bool)
-> Eq GetTrafficPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTrafficPolicy -> GetTrafficPolicy -> Bool
$c/= :: GetTrafficPolicy -> GetTrafficPolicy -> Bool
== :: GetTrafficPolicy -> GetTrafficPolicy -> Bool
$c== :: GetTrafficPolicy -> GetTrafficPolicy -> Bool
Prelude.Eq, ReadPrec [GetTrafficPolicy]
ReadPrec GetTrafficPolicy
Int -> ReadS GetTrafficPolicy
ReadS [GetTrafficPolicy]
(Int -> ReadS GetTrafficPolicy)
-> ReadS [GetTrafficPolicy]
-> ReadPrec GetTrafficPolicy
-> ReadPrec [GetTrafficPolicy]
-> Read GetTrafficPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTrafficPolicy]
$creadListPrec :: ReadPrec [GetTrafficPolicy]
readPrec :: ReadPrec GetTrafficPolicy
$creadPrec :: ReadPrec GetTrafficPolicy
readList :: ReadS [GetTrafficPolicy]
$creadList :: ReadS [GetTrafficPolicy]
readsPrec :: Int -> ReadS GetTrafficPolicy
$creadsPrec :: Int -> ReadS GetTrafficPolicy
Prelude.Read, Int -> GetTrafficPolicy -> ShowS
[GetTrafficPolicy] -> ShowS
GetTrafficPolicy -> String
(Int -> GetTrafficPolicy -> ShowS)
-> (GetTrafficPolicy -> String)
-> ([GetTrafficPolicy] -> ShowS)
-> Show GetTrafficPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTrafficPolicy] -> ShowS
$cshowList :: [GetTrafficPolicy] -> ShowS
show :: GetTrafficPolicy -> String
$cshow :: GetTrafficPolicy -> String
showsPrec :: Int -> GetTrafficPolicy -> ShowS
$cshowsPrec :: Int -> GetTrafficPolicy -> ShowS
Prelude.Show, (forall x. GetTrafficPolicy -> Rep GetTrafficPolicy x)
-> (forall x. Rep GetTrafficPolicy x -> GetTrafficPolicy)
-> Generic GetTrafficPolicy
forall x. Rep GetTrafficPolicy x -> GetTrafficPolicy
forall x. GetTrafficPolicy -> Rep GetTrafficPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTrafficPolicy x -> GetTrafficPolicy
$cfrom :: forall x. GetTrafficPolicy -> Rep GetTrafficPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetTrafficPolicy' 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:
--
-- 'id', 'getTrafficPolicy_id' - The ID of the traffic policy that you want to get information about.
--
-- 'version', 'getTrafficPolicy_version' - The version number of the traffic policy that you want to get
-- information about.
newGetTrafficPolicy ::
  -- | 'id'
  Prelude.Text ->
  -- | 'version'
  Prelude.Natural ->
  GetTrafficPolicy
newGetTrafficPolicy :: Text -> Natural -> GetTrafficPolicy
newGetTrafficPolicy Text
pId_ Natural
pVersion_ =
  GetTrafficPolicy' :: Text -> Natural -> GetTrafficPolicy
GetTrafficPolicy' {$sel:id:GetTrafficPolicy' :: Text
id = Text
pId_, $sel:version:GetTrafficPolicy' :: Natural
version = Natural
pVersion_}

-- | The ID of the traffic policy that you want to get information about.
getTrafficPolicy_id :: Lens.Lens' GetTrafficPolicy Prelude.Text
getTrafficPolicy_id :: (Text -> f Text) -> GetTrafficPolicy -> f GetTrafficPolicy
getTrafficPolicy_id = (GetTrafficPolicy -> Text)
-> (GetTrafficPolicy -> Text -> GetTrafficPolicy)
-> Lens GetTrafficPolicy GetTrafficPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrafficPolicy' {Text
id :: Text
$sel:id:GetTrafficPolicy' :: GetTrafficPolicy -> Text
id} -> Text
id) (\s :: GetTrafficPolicy
s@GetTrafficPolicy' {} Text
a -> GetTrafficPolicy
s {$sel:id:GetTrafficPolicy' :: Text
id = Text
a} :: GetTrafficPolicy)

-- | The version number of the traffic policy that you want to get
-- information about.
getTrafficPolicy_version :: Lens.Lens' GetTrafficPolicy Prelude.Natural
getTrafficPolicy_version :: (Natural -> f Natural) -> GetTrafficPolicy -> f GetTrafficPolicy
getTrafficPolicy_version = (GetTrafficPolicy -> Natural)
-> (GetTrafficPolicy -> Natural -> GetTrafficPolicy)
-> Lens GetTrafficPolicy GetTrafficPolicy Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrafficPolicy' {Natural
version :: Natural
$sel:version:GetTrafficPolicy' :: GetTrafficPolicy -> Natural
version} -> Natural
version) (\s :: GetTrafficPolicy
s@GetTrafficPolicy' {} Natural
a -> GetTrafficPolicy
s {$sel:version:GetTrafficPolicy' :: Natural
version = Natural
a} :: GetTrafficPolicy)

instance Core.AWSRequest GetTrafficPolicy where
  type
    AWSResponse GetTrafficPolicy =
      GetTrafficPolicyResponse
  request :: GetTrafficPolicy -> Request GetTrafficPolicy
request = Service -> GetTrafficPolicy -> Request GetTrafficPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetTrafficPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetTrafficPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetTrafficPolicy))
-> Logger
-> Service
-> Proxy GetTrafficPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetTrafficPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> TrafficPolicy -> GetTrafficPolicyResponse
GetTrafficPolicyResponse'
            (Int -> TrafficPolicy -> GetTrafficPolicyResponse)
-> Either String Int
-> Either String (TrafficPolicy -> GetTrafficPolicyResponse)
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 (TrafficPolicy -> GetTrafficPolicyResponse)
-> Either String TrafficPolicy
-> Either String GetTrafficPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String TrafficPolicy
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"TrafficPolicy")
      )

instance Prelude.Hashable GetTrafficPolicy

instance Prelude.NFData GetTrafficPolicy

instance Core.ToHeaders GetTrafficPolicy where
  toHeaders :: GetTrafficPolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> GetTrafficPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetTrafficPolicy where
  toPath :: GetTrafficPolicy -> ByteString
toPath GetTrafficPolicy' {Natural
Text
version :: Natural
id :: Text
$sel:version:GetTrafficPolicy' :: GetTrafficPolicy -> Natural
$sel:id:GetTrafficPolicy' :: GetTrafficPolicy -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2013-04-01/trafficpolicy/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id,
        ByteString
"/",
        Natural -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Natural
version
      ]

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

-- | A complex type that contains the response information for the request.
--
-- /See:/ 'newGetTrafficPolicyResponse' smart constructor.
data GetTrafficPolicyResponse = GetTrafficPolicyResponse'
  { -- | The response's http status code.
    GetTrafficPolicyResponse -> Int
httpStatus :: Prelude.Int,
    -- | A complex type that contains settings for the specified traffic policy.
    GetTrafficPolicyResponse -> TrafficPolicy
trafficPolicy :: TrafficPolicy
  }
  deriving (GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool
(GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool)
-> (GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool)
-> Eq GetTrafficPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool
$c/= :: GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool
== :: GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool
$c== :: GetTrafficPolicyResponse -> GetTrafficPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetTrafficPolicyResponse]
ReadPrec GetTrafficPolicyResponse
Int -> ReadS GetTrafficPolicyResponse
ReadS [GetTrafficPolicyResponse]
(Int -> ReadS GetTrafficPolicyResponse)
-> ReadS [GetTrafficPolicyResponse]
-> ReadPrec GetTrafficPolicyResponse
-> ReadPrec [GetTrafficPolicyResponse]
-> Read GetTrafficPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTrafficPolicyResponse]
$creadListPrec :: ReadPrec [GetTrafficPolicyResponse]
readPrec :: ReadPrec GetTrafficPolicyResponse
$creadPrec :: ReadPrec GetTrafficPolicyResponse
readList :: ReadS [GetTrafficPolicyResponse]
$creadList :: ReadS [GetTrafficPolicyResponse]
readsPrec :: Int -> ReadS GetTrafficPolicyResponse
$creadsPrec :: Int -> ReadS GetTrafficPolicyResponse
Prelude.Read, Int -> GetTrafficPolicyResponse -> ShowS
[GetTrafficPolicyResponse] -> ShowS
GetTrafficPolicyResponse -> String
(Int -> GetTrafficPolicyResponse -> ShowS)
-> (GetTrafficPolicyResponse -> String)
-> ([GetTrafficPolicyResponse] -> ShowS)
-> Show GetTrafficPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTrafficPolicyResponse] -> ShowS
$cshowList :: [GetTrafficPolicyResponse] -> ShowS
show :: GetTrafficPolicyResponse -> String
$cshow :: GetTrafficPolicyResponse -> String
showsPrec :: Int -> GetTrafficPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetTrafficPolicyResponse -> ShowS
Prelude.Show, (forall x.
 GetTrafficPolicyResponse -> Rep GetTrafficPolicyResponse x)
-> (forall x.
    Rep GetTrafficPolicyResponse x -> GetTrafficPolicyResponse)
-> Generic GetTrafficPolicyResponse
forall x.
Rep GetTrafficPolicyResponse x -> GetTrafficPolicyResponse
forall x.
GetTrafficPolicyResponse -> Rep GetTrafficPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTrafficPolicyResponse x -> GetTrafficPolicyResponse
$cfrom :: forall x.
GetTrafficPolicyResponse -> Rep GetTrafficPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTrafficPolicyResponse' 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', 'getTrafficPolicyResponse_httpStatus' - The response's http status code.
--
-- 'trafficPolicy', 'getTrafficPolicyResponse_trafficPolicy' - A complex type that contains settings for the specified traffic policy.
newGetTrafficPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'trafficPolicy'
  TrafficPolicy ->
  GetTrafficPolicyResponse
newGetTrafficPolicyResponse :: Int -> TrafficPolicy -> GetTrafficPolicyResponse
newGetTrafficPolicyResponse
  Int
pHttpStatus_
  TrafficPolicy
pTrafficPolicy_ =
    GetTrafficPolicyResponse' :: Int -> TrafficPolicy -> GetTrafficPolicyResponse
GetTrafficPolicyResponse'
      { $sel:httpStatus:GetTrafficPolicyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:trafficPolicy:GetTrafficPolicyResponse' :: TrafficPolicy
trafficPolicy = TrafficPolicy
pTrafficPolicy_
      }

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

-- | A complex type that contains settings for the specified traffic policy.
getTrafficPolicyResponse_trafficPolicy :: Lens.Lens' GetTrafficPolicyResponse TrafficPolicy
getTrafficPolicyResponse_trafficPolicy :: (TrafficPolicy -> f TrafficPolicy)
-> GetTrafficPolicyResponse -> f GetTrafficPolicyResponse
getTrafficPolicyResponse_trafficPolicy = (GetTrafficPolicyResponse -> TrafficPolicy)
-> (GetTrafficPolicyResponse
    -> TrafficPolicy -> GetTrafficPolicyResponse)
-> Lens
     GetTrafficPolicyResponse
     GetTrafficPolicyResponse
     TrafficPolicy
     TrafficPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrafficPolicyResponse' {TrafficPolicy
trafficPolicy :: TrafficPolicy
$sel:trafficPolicy:GetTrafficPolicyResponse' :: GetTrafficPolicyResponse -> TrafficPolicy
trafficPolicy} -> TrafficPolicy
trafficPolicy) (\s :: GetTrafficPolicyResponse
s@GetTrafficPolicyResponse' {} TrafficPolicy
a -> GetTrafficPolicyResponse
s {$sel:trafficPolicy:GetTrafficPolicyResponse' :: TrafficPolicy
trafficPolicy = TrafficPolicy
a} :: GetTrafficPolicyResponse)

instance Prelude.NFData GetTrafficPolicyResponse