{-# 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.GetTrafficPolicyInstance
-- 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 specified traffic policy instance.
--
-- After you submit a @CreateTrafficPolicyInstance@ or an
-- @UpdateTrafficPolicyInstance@ request, there\'s a brief delay while
-- Amazon Route 53 creates the resource record sets that are specified in
-- the traffic policy definition. For more information, see the @State@
-- response element.
--
-- In the Route 53 console, traffic policy instances are known as policy
-- records.
module Amazonka.Route53.GetTrafficPolicyInstance
  ( -- * Creating a Request
    GetTrafficPolicyInstance (..),
    newGetTrafficPolicyInstance,

    -- * Request Lenses
    getTrafficPolicyInstance_id,

    -- * Destructuring the Response
    GetTrafficPolicyInstanceResponse (..),
    newGetTrafficPolicyInstanceResponse,

    -- * Response Lenses
    getTrafficPolicyInstanceResponse_httpStatus,
    getTrafficPolicyInstanceResponse_trafficPolicyInstance,
  )
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 specified traffic policy instance.
--
-- /See:/ 'newGetTrafficPolicyInstance' smart constructor.
data GetTrafficPolicyInstance = GetTrafficPolicyInstance'
  { -- | The ID of the traffic policy instance that you want to get information
    -- about.
    GetTrafficPolicyInstance -> Text
id :: Prelude.Text
  }
  deriving (GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool
(GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool)
-> (GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool)
-> Eq GetTrafficPolicyInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool
$c/= :: GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool
== :: GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool
$c== :: GetTrafficPolicyInstance -> GetTrafficPolicyInstance -> Bool
Prelude.Eq, ReadPrec [GetTrafficPolicyInstance]
ReadPrec GetTrafficPolicyInstance
Int -> ReadS GetTrafficPolicyInstance
ReadS [GetTrafficPolicyInstance]
(Int -> ReadS GetTrafficPolicyInstance)
-> ReadS [GetTrafficPolicyInstance]
-> ReadPrec GetTrafficPolicyInstance
-> ReadPrec [GetTrafficPolicyInstance]
-> Read GetTrafficPolicyInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTrafficPolicyInstance]
$creadListPrec :: ReadPrec [GetTrafficPolicyInstance]
readPrec :: ReadPrec GetTrafficPolicyInstance
$creadPrec :: ReadPrec GetTrafficPolicyInstance
readList :: ReadS [GetTrafficPolicyInstance]
$creadList :: ReadS [GetTrafficPolicyInstance]
readsPrec :: Int -> ReadS GetTrafficPolicyInstance
$creadsPrec :: Int -> ReadS GetTrafficPolicyInstance
Prelude.Read, Int -> GetTrafficPolicyInstance -> ShowS
[GetTrafficPolicyInstance] -> ShowS
GetTrafficPolicyInstance -> String
(Int -> GetTrafficPolicyInstance -> ShowS)
-> (GetTrafficPolicyInstance -> String)
-> ([GetTrafficPolicyInstance] -> ShowS)
-> Show GetTrafficPolicyInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTrafficPolicyInstance] -> ShowS
$cshowList :: [GetTrafficPolicyInstance] -> ShowS
show :: GetTrafficPolicyInstance -> String
$cshow :: GetTrafficPolicyInstance -> String
showsPrec :: Int -> GetTrafficPolicyInstance -> ShowS
$cshowsPrec :: Int -> GetTrafficPolicyInstance -> ShowS
Prelude.Show, (forall x.
 GetTrafficPolicyInstance -> Rep GetTrafficPolicyInstance x)
-> (forall x.
    Rep GetTrafficPolicyInstance x -> GetTrafficPolicyInstance)
-> Generic GetTrafficPolicyInstance
forall x.
Rep GetTrafficPolicyInstance x -> GetTrafficPolicyInstance
forall x.
GetTrafficPolicyInstance -> Rep GetTrafficPolicyInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTrafficPolicyInstance x -> GetTrafficPolicyInstance
$cfrom :: forall x.
GetTrafficPolicyInstance -> Rep GetTrafficPolicyInstance x
Prelude.Generic)

-- |
-- Create a value of 'GetTrafficPolicyInstance' 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', 'getTrafficPolicyInstance_id' - The ID of the traffic policy instance that you want to get information
-- about.
newGetTrafficPolicyInstance ::
  -- | 'id'
  Prelude.Text ->
  GetTrafficPolicyInstance
newGetTrafficPolicyInstance :: Text -> GetTrafficPolicyInstance
newGetTrafficPolicyInstance Text
pId_ =
  GetTrafficPolicyInstance' :: Text -> GetTrafficPolicyInstance
GetTrafficPolicyInstance' {$sel:id:GetTrafficPolicyInstance' :: Text
id = Text
pId_}

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

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

instance Prelude.Hashable GetTrafficPolicyInstance

instance Prelude.NFData GetTrafficPolicyInstance

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

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

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

-- | A complex type that contains information about the resource record sets
-- that Amazon Route 53 created based on a specified traffic policy.
--
-- /See:/ 'newGetTrafficPolicyInstanceResponse' smart constructor.
data GetTrafficPolicyInstanceResponse = GetTrafficPolicyInstanceResponse'
  { -- | The response's http status code.
    GetTrafficPolicyInstanceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A complex type that contains settings for the traffic policy instance.
    GetTrafficPolicyInstanceResponse -> TrafficPolicyInstance
trafficPolicyInstance :: TrafficPolicyInstance
  }
  deriving (GetTrafficPolicyInstanceResponse
-> GetTrafficPolicyInstanceResponse -> Bool
(GetTrafficPolicyInstanceResponse
 -> GetTrafficPolicyInstanceResponse -> Bool)
-> (GetTrafficPolicyInstanceResponse
    -> GetTrafficPolicyInstanceResponse -> Bool)
-> Eq GetTrafficPolicyInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTrafficPolicyInstanceResponse
-> GetTrafficPolicyInstanceResponse -> Bool
$c/= :: GetTrafficPolicyInstanceResponse
-> GetTrafficPolicyInstanceResponse -> Bool
== :: GetTrafficPolicyInstanceResponse
-> GetTrafficPolicyInstanceResponse -> Bool
$c== :: GetTrafficPolicyInstanceResponse
-> GetTrafficPolicyInstanceResponse -> Bool
Prelude.Eq, ReadPrec [GetTrafficPolicyInstanceResponse]
ReadPrec GetTrafficPolicyInstanceResponse
Int -> ReadS GetTrafficPolicyInstanceResponse
ReadS [GetTrafficPolicyInstanceResponse]
(Int -> ReadS GetTrafficPolicyInstanceResponse)
-> ReadS [GetTrafficPolicyInstanceResponse]
-> ReadPrec GetTrafficPolicyInstanceResponse
-> ReadPrec [GetTrafficPolicyInstanceResponse]
-> Read GetTrafficPolicyInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTrafficPolicyInstanceResponse]
$creadListPrec :: ReadPrec [GetTrafficPolicyInstanceResponse]
readPrec :: ReadPrec GetTrafficPolicyInstanceResponse
$creadPrec :: ReadPrec GetTrafficPolicyInstanceResponse
readList :: ReadS [GetTrafficPolicyInstanceResponse]
$creadList :: ReadS [GetTrafficPolicyInstanceResponse]
readsPrec :: Int -> ReadS GetTrafficPolicyInstanceResponse
$creadsPrec :: Int -> ReadS GetTrafficPolicyInstanceResponse
Prelude.Read, Int -> GetTrafficPolicyInstanceResponse -> ShowS
[GetTrafficPolicyInstanceResponse] -> ShowS
GetTrafficPolicyInstanceResponse -> String
(Int -> GetTrafficPolicyInstanceResponse -> ShowS)
-> (GetTrafficPolicyInstanceResponse -> String)
-> ([GetTrafficPolicyInstanceResponse] -> ShowS)
-> Show GetTrafficPolicyInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTrafficPolicyInstanceResponse] -> ShowS
$cshowList :: [GetTrafficPolicyInstanceResponse] -> ShowS
show :: GetTrafficPolicyInstanceResponse -> String
$cshow :: GetTrafficPolicyInstanceResponse -> String
showsPrec :: Int -> GetTrafficPolicyInstanceResponse -> ShowS
$cshowsPrec :: Int -> GetTrafficPolicyInstanceResponse -> ShowS
Prelude.Show, (forall x.
 GetTrafficPolicyInstanceResponse
 -> Rep GetTrafficPolicyInstanceResponse x)
-> (forall x.
    Rep GetTrafficPolicyInstanceResponse x
    -> GetTrafficPolicyInstanceResponse)
-> Generic GetTrafficPolicyInstanceResponse
forall x.
Rep GetTrafficPolicyInstanceResponse x
-> GetTrafficPolicyInstanceResponse
forall x.
GetTrafficPolicyInstanceResponse
-> Rep GetTrafficPolicyInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTrafficPolicyInstanceResponse x
-> GetTrafficPolicyInstanceResponse
$cfrom :: forall x.
GetTrafficPolicyInstanceResponse
-> Rep GetTrafficPolicyInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTrafficPolicyInstanceResponse' 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', 'getTrafficPolicyInstanceResponse_httpStatus' - The response's http status code.
--
-- 'trafficPolicyInstance', 'getTrafficPolicyInstanceResponse_trafficPolicyInstance' - A complex type that contains settings for the traffic policy instance.
newGetTrafficPolicyInstanceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'trafficPolicyInstance'
  TrafficPolicyInstance ->
  GetTrafficPolicyInstanceResponse
newGetTrafficPolicyInstanceResponse :: Int -> TrafficPolicyInstance -> GetTrafficPolicyInstanceResponse
newGetTrafficPolicyInstanceResponse
  Int
pHttpStatus_
  TrafficPolicyInstance
pTrafficPolicyInstance_ =
    GetTrafficPolicyInstanceResponse' :: Int -> TrafficPolicyInstance -> GetTrafficPolicyInstanceResponse
GetTrafficPolicyInstanceResponse'
      { $sel:httpStatus:GetTrafficPolicyInstanceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:trafficPolicyInstance:GetTrafficPolicyInstanceResponse' :: TrafficPolicyInstance
trafficPolicyInstance =
          TrafficPolicyInstance
pTrafficPolicyInstance_
      }

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

-- | A complex type that contains settings for the traffic policy instance.
getTrafficPolicyInstanceResponse_trafficPolicyInstance :: Lens.Lens' GetTrafficPolicyInstanceResponse TrafficPolicyInstance
getTrafficPolicyInstanceResponse_trafficPolicyInstance :: (TrafficPolicyInstance -> f TrafficPolicyInstance)
-> GetTrafficPolicyInstanceResponse
-> f GetTrafficPolicyInstanceResponse
getTrafficPolicyInstanceResponse_trafficPolicyInstance = (GetTrafficPolicyInstanceResponse -> TrafficPolicyInstance)
-> (GetTrafficPolicyInstanceResponse
    -> TrafficPolicyInstance -> GetTrafficPolicyInstanceResponse)
-> Lens
     GetTrafficPolicyInstanceResponse
     GetTrafficPolicyInstanceResponse
     TrafficPolicyInstance
     TrafficPolicyInstance
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTrafficPolicyInstanceResponse' {TrafficPolicyInstance
trafficPolicyInstance :: TrafficPolicyInstance
$sel:trafficPolicyInstance:GetTrafficPolicyInstanceResponse' :: GetTrafficPolicyInstanceResponse -> TrafficPolicyInstance
trafficPolicyInstance} -> TrafficPolicyInstance
trafficPolicyInstance) (\s :: GetTrafficPolicyInstanceResponse
s@GetTrafficPolicyInstanceResponse' {} TrafficPolicyInstance
a -> GetTrafficPolicyInstanceResponse
s {$sel:trafficPolicyInstance:GetTrafficPolicyInstanceResponse' :: TrafficPolicyInstance
trafficPolicyInstance = TrafficPolicyInstance
a} :: GetTrafficPolicyInstanceResponse)

instance
  Prelude.NFData
    GetTrafficPolicyInstanceResponse