{-# 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.Connect.ReleasePhoneNumber
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Releases a phone number previously claimed to an Amazon Connect instance
-- or traffic distribution group. You can call this API only in the Amazon
-- Web Services Region where the number was claimed.
--
-- To release phone numbers from a traffic distribution group, use the
-- @ReleasePhoneNumber@ API, not the Amazon Connect console.
--
-- After releasing a phone number, the phone number enters into a cooldown
-- period of 30 days. It cannot be searched for or claimed again until the
-- period has ended. If you accidentally release a phone number, contact
-- Amazon Web Services Support.
module Amazonka.Connect.ReleasePhoneNumber
  ( -- * Creating a Request
    ReleasePhoneNumber (..),
    newReleasePhoneNumber,

    -- * Request Lenses
    releasePhoneNumber_clientToken,
    releasePhoneNumber_phoneNumberId,

    -- * Destructuring the Response
    ReleasePhoneNumberResponse (..),
    newReleasePhoneNumberResponse,
  )
where

import Amazonka.Connect.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newReleasePhoneNumber' smart constructor.
data ReleasePhoneNumber = ReleasePhoneNumber'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If not provided, the Amazon Web Services SDK
    -- populates this field. For more information about idempotency, see
    -- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
    ReleasePhoneNumber -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the phone number.
    ReleasePhoneNumber -> Text
phoneNumberId :: Prelude.Text
  }
  deriving (ReleasePhoneNumber -> ReleasePhoneNumber -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReleasePhoneNumber -> ReleasePhoneNumber -> Bool
$c/= :: ReleasePhoneNumber -> ReleasePhoneNumber -> Bool
== :: ReleasePhoneNumber -> ReleasePhoneNumber -> Bool
$c== :: ReleasePhoneNumber -> ReleasePhoneNumber -> Bool
Prelude.Eq, ReadPrec [ReleasePhoneNumber]
ReadPrec ReleasePhoneNumber
Int -> ReadS ReleasePhoneNumber
ReadS [ReleasePhoneNumber]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReleasePhoneNumber]
$creadListPrec :: ReadPrec [ReleasePhoneNumber]
readPrec :: ReadPrec ReleasePhoneNumber
$creadPrec :: ReadPrec ReleasePhoneNumber
readList :: ReadS [ReleasePhoneNumber]
$creadList :: ReadS [ReleasePhoneNumber]
readsPrec :: Int -> ReadS ReleasePhoneNumber
$creadsPrec :: Int -> ReadS ReleasePhoneNumber
Prelude.Read, Int -> ReleasePhoneNumber -> ShowS
[ReleasePhoneNumber] -> ShowS
ReleasePhoneNumber -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReleasePhoneNumber] -> ShowS
$cshowList :: [ReleasePhoneNumber] -> ShowS
show :: ReleasePhoneNumber -> String
$cshow :: ReleasePhoneNumber -> String
showsPrec :: Int -> ReleasePhoneNumber -> ShowS
$cshowsPrec :: Int -> ReleasePhoneNumber -> ShowS
Prelude.Show, forall x. Rep ReleasePhoneNumber x -> ReleasePhoneNumber
forall x. ReleasePhoneNumber -> Rep ReleasePhoneNumber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReleasePhoneNumber x -> ReleasePhoneNumber
$cfrom :: forall x. ReleasePhoneNumber -> Rep ReleasePhoneNumber x
Prelude.Generic)

-- |
-- Create a value of 'ReleasePhoneNumber' 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:
--
-- 'clientToken', 'releasePhoneNumber_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
--
-- 'phoneNumberId', 'releasePhoneNumber_phoneNumberId' - A unique identifier for the phone number.
newReleasePhoneNumber ::
  -- | 'phoneNumberId'
  Prelude.Text ->
  ReleasePhoneNumber
newReleasePhoneNumber :: Text -> ReleasePhoneNumber
newReleasePhoneNumber Text
pPhoneNumberId_ =
  ReleasePhoneNumber'
    { $sel:clientToken:ReleasePhoneNumber' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumberId:ReleasePhoneNumber' :: Text
phoneNumberId = Text
pPhoneNumberId_
    }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
releasePhoneNumber_clientToken :: Lens.Lens' ReleasePhoneNumber (Prelude.Maybe Prelude.Text)
releasePhoneNumber_clientToken :: Lens' ReleasePhoneNumber (Maybe Text)
releasePhoneNumber_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReleasePhoneNumber' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:ReleasePhoneNumber' :: ReleasePhoneNumber -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: ReleasePhoneNumber
s@ReleasePhoneNumber' {} Maybe Text
a -> ReleasePhoneNumber
s {$sel:clientToken:ReleasePhoneNumber' :: Maybe Text
clientToken = Maybe Text
a} :: ReleasePhoneNumber)

-- | A unique identifier for the phone number.
releasePhoneNumber_phoneNumberId :: Lens.Lens' ReleasePhoneNumber Prelude.Text
releasePhoneNumber_phoneNumberId :: Lens' ReleasePhoneNumber Text
releasePhoneNumber_phoneNumberId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReleasePhoneNumber' {Text
phoneNumberId :: Text
$sel:phoneNumberId:ReleasePhoneNumber' :: ReleasePhoneNumber -> Text
phoneNumberId} -> Text
phoneNumberId) (\s :: ReleasePhoneNumber
s@ReleasePhoneNumber' {} Text
a -> ReleasePhoneNumber
s {$sel:phoneNumberId:ReleasePhoneNumber' :: Text
phoneNumberId = Text
a} :: ReleasePhoneNumber)

instance Core.AWSRequest ReleasePhoneNumber where
  type
    AWSResponse ReleasePhoneNumber =
      ReleasePhoneNumberResponse
  request :: (Service -> Service)
-> ReleasePhoneNumber -> Request ReleasePhoneNumber
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ReleasePhoneNumber
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ReleasePhoneNumber)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull ReleasePhoneNumberResponse
ReleasePhoneNumberResponse'

instance Prelude.Hashable ReleasePhoneNumber where
  hashWithSalt :: Int -> ReleasePhoneNumber -> Int
hashWithSalt Int
_salt ReleasePhoneNumber' {Maybe Text
Text
phoneNumberId :: Text
clientToken :: Maybe Text
$sel:phoneNumberId:ReleasePhoneNumber' :: ReleasePhoneNumber -> Text
$sel:clientToken:ReleasePhoneNumber' :: ReleasePhoneNumber -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
phoneNumberId

instance Prelude.NFData ReleasePhoneNumber where
  rnf :: ReleasePhoneNumber -> ()
rnf ReleasePhoneNumber' {Maybe Text
Text
phoneNumberId :: Text
clientToken :: Maybe Text
$sel:phoneNumberId:ReleasePhoneNumber' :: ReleasePhoneNumber -> Text
$sel:clientToken:ReleasePhoneNumber' :: ReleasePhoneNumber -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
phoneNumberId

instance Data.ToHeaders ReleasePhoneNumber where
  toHeaders :: ReleasePhoneNumber -> [Header]
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ReleasePhoneNumber where
  toPath :: ReleasePhoneNumber -> ByteString
toPath ReleasePhoneNumber' {Maybe Text
Text
phoneNumberId :: Text
clientToken :: Maybe Text
$sel:phoneNumberId:ReleasePhoneNumber' :: ReleasePhoneNumber -> Text
$sel:clientToken:ReleasePhoneNumber' :: ReleasePhoneNumber -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/phone-number/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
phoneNumberId]

instance Data.ToQuery ReleasePhoneNumber where
  toQuery :: ReleasePhoneNumber -> QueryString
toQuery ReleasePhoneNumber' {Maybe Text
Text
phoneNumberId :: Text
clientToken :: Maybe Text
$sel:phoneNumberId:ReleasePhoneNumber' :: ReleasePhoneNumber -> Text
$sel:clientToken:ReleasePhoneNumber' :: ReleasePhoneNumber -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"clientToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
clientToken]

-- | /See:/ 'newReleasePhoneNumberResponse' smart constructor.
data ReleasePhoneNumberResponse = ReleasePhoneNumberResponse'
  {
  }
  deriving (ReleasePhoneNumberResponse -> ReleasePhoneNumberResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReleasePhoneNumberResponse -> ReleasePhoneNumberResponse -> Bool
$c/= :: ReleasePhoneNumberResponse -> ReleasePhoneNumberResponse -> Bool
== :: ReleasePhoneNumberResponse -> ReleasePhoneNumberResponse -> Bool
$c== :: ReleasePhoneNumberResponse -> ReleasePhoneNumberResponse -> Bool
Prelude.Eq, ReadPrec [ReleasePhoneNumberResponse]
ReadPrec ReleasePhoneNumberResponse
Int -> ReadS ReleasePhoneNumberResponse
ReadS [ReleasePhoneNumberResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReleasePhoneNumberResponse]
$creadListPrec :: ReadPrec [ReleasePhoneNumberResponse]
readPrec :: ReadPrec ReleasePhoneNumberResponse
$creadPrec :: ReadPrec ReleasePhoneNumberResponse
readList :: ReadS [ReleasePhoneNumberResponse]
$creadList :: ReadS [ReleasePhoneNumberResponse]
readsPrec :: Int -> ReadS ReleasePhoneNumberResponse
$creadsPrec :: Int -> ReadS ReleasePhoneNumberResponse
Prelude.Read, Int -> ReleasePhoneNumberResponse -> ShowS
[ReleasePhoneNumberResponse] -> ShowS
ReleasePhoneNumberResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReleasePhoneNumberResponse] -> ShowS
$cshowList :: [ReleasePhoneNumberResponse] -> ShowS
show :: ReleasePhoneNumberResponse -> String
$cshow :: ReleasePhoneNumberResponse -> String
showsPrec :: Int -> ReleasePhoneNumberResponse -> ShowS
$cshowsPrec :: Int -> ReleasePhoneNumberResponse -> ShowS
Prelude.Show, forall x.
Rep ReleasePhoneNumberResponse x -> ReleasePhoneNumberResponse
forall x.
ReleasePhoneNumberResponse -> Rep ReleasePhoneNumberResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReleasePhoneNumberResponse x -> ReleasePhoneNumberResponse
$cfrom :: forall x.
ReleasePhoneNumberResponse -> Rep ReleasePhoneNumberResponse x
Prelude.Generic)

-- |
-- Create a value of 'ReleasePhoneNumberResponse' 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.
newReleasePhoneNumberResponse ::
  ReleasePhoneNumberResponse
newReleasePhoneNumberResponse :: ReleasePhoneNumberResponse
newReleasePhoneNumberResponse =
  ReleasePhoneNumberResponse
ReleasePhoneNumberResponse'

instance Prelude.NFData ReleasePhoneNumberResponse where
  rnf :: ReleasePhoneNumberResponse -> ()
rnf ReleasePhoneNumberResponse
_ = ()