{-# 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.DeleteTrafficPolicy
-- 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)
--
-- Deletes a traffic policy.
--
-- When you delete a traffic policy, Route 53 sets a flag on the policy to
-- indicate that it has been deleted. However, Route 53 never fully deletes
-- the traffic policy. Note the following:
--
-- -   Deleted traffic policies aren\'t listed if you run
--     <https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListTrafficPolicies.html ListTrafficPolicies>.
--
-- -   There\'s no way to get a list of deleted policies.
--
-- -   If you retain the ID of the policy, you can get information about
--     the policy, including the traffic policy document, by running
--     <https://docs.aws.amazon.com/Route53/latest/APIReference/API_GetTrafficPolicy.html GetTrafficPolicy>.
module Amazonka.Route53.DeleteTrafficPolicy
  ( -- * Creating a Request
    DeleteTrafficPolicy (..),
    newDeleteTrafficPolicy,

    -- * Request Lenses
    deleteTrafficPolicy_id,
    deleteTrafficPolicy_version,

    -- * Destructuring the Response
    DeleteTrafficPolicyResponse (..),
    newDeleteTrafficPolicyResponse,

    -- * Response Lenses
    deleteTrafficPolicyResponse_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.Route53.Types

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

-- |
-- Create a value of 'DeleteTrafficPolicy' 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', 'deleteTrafficPolicy_id' - The ID of the traffic policy that you want to delete.
--
-- 'version', 'deleteTrafficPolicy_version' - The version number of the traffic policy that you want to delete.
newDeleteTrafficPolicy ::
  -- | 'id'
  Prelude.Text ->
  -- | 'version'
  Prelude.Natural ->
  DeleteTrafficPolicy
newDeleteTrafficPolicy :: Text -> Natural -> DeleteTrafficPolicy
newDeleteTrafficPolicy Text
pId_ Natural
pVersion_ =
  DeleteTrafficPolicy' :: Text -> Natural -> DeleteTrafficPolicy
DeleteTrafficPolicy'
    { $sel:id:DeleteTrafficPolicy' :: Text
id = Text
pId_,
      $sel:version:DeleteTrafficPolicy' :: Natural
version = Natural
pVersion_
    }

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

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

instance Core.AWSRequest DeleteTrafficPolicy where
  type
    AWSResponse DeleteTrafficPolicy =
      DeleteTrafficPolicyResponse
  request :: DeleteTrafficPolicy -> Request DeleteTrafficPolicy
request = Service -> DeleteTrafficPolicy -> Request DeleteTrafficPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTrafficPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteTrafficPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteTrafficPolicy))
-> Logger
-> Service
-> Proxy DeleteTrafficPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteTrafficPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteTrafficPolicyResponse
DeleteTrafficPolicyResponse'
            (Int -> DeleteTrafficPolicyResponse)
-> Either String Int -> Either String DeleteTrafficPolicyResponse
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))
      )

instance Prelude.Hashable DeleteTrafficPolicy

instance Prelude.NFData DeleteTrafficPolicy

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

instance Core.ToPath DeleteTrafficPolicy where
  toPath :: DeleteTrafficPolicy -> ByteString
toPath DeleteTrafficPolicy' {Natural
Text
version :: Natural
id :: Text
$sel:version:DeleteTrafficPolicy' :: DeleteTrafficPolicy -> Natural
$sel:id:DeleteTrafficPolicy' :: DeleteTrafficPolicy -> 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 DeleteTrafficPolicy where
  toQuery :: DeleteTrafficPolicy -> QueryString
toQuery = QueryString -> DeleteTrafficPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeleteTrafficPolicyResponse' 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', 'deleteTrafficPolicyResponse_httpStatus' - The response's http status code.
newDeleteTrafficPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTrafficPolicyResponse
newDeleteTrafficPolicyResponse :: Int -> DeleteTrafficPolicyResponse
newDeleteTrafficPolicyResponse Int
pHttpStatus_ =
  DeleteTrafficPolicyResponse' :: Int -> DeleteTrafficPolicyResponse
DeleteTrafficPolicyResponse'
    { $sel:httpStatus:DeleteTrafficPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteTrafficPolicyResponse