{-# 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.Chime.RestorePhoneNumber
-- 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)
--
-- Moves a phone number from the __Deletion queue__ back into the phone
-- number __Inventory__.
module Amazonka.Chime.RestorePhoneNumber
  ( -- * Creating a Request
    RestorePhoneNumber (..),
    newRestorePhoneNumber,

    -- * Request Lenses
    restorePhoneNumber_phoneNumberId,

    -- * Destructuring the Response
    RestorePhoneNumberResponse (..),
    newRestorePhoneNumberResponse,

    -- * Response Lenses
    restorePhoneNumberResponse_phoneNumber,
    restorePhoneNumberResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
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

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

-- |
-- Create a value of 'RestorePhoneNumber' 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:
--
-- 'phoneNumberId', 'restorePhoneNumber_phoneNumberId' - The phone number.
newRestorePhoneNumber ::
  -- | 'phoneNumberId'
  Prelude.Text ->
  RestorePhoneNumber
newRestorePhoneNumber :: Text -> RestorePhoneNumber
newRestorePhoneNumber Text
pPhoneNumberId_ =
  RestorePhoneNumber' :: Text -> RestorePhoneNumber
RestorePhoneNumber'
    { $sel:phoneNumberId:RestorePhoneNumber' :: Text
phoneNumberId =
        Text
pPhoneNumberId_
    }

-- | The phone number.
restorePhoneNumber_phoneNumberId :: Lens.Lens' RestorePhoneNumber Prelude.Text
restorePhoneNumber_phoneNumberId :: (Text -> f Text) -> RestorePhoneNumber -> f RestorePhoneNumber
restorePhoneNumber_phoneNumberId = (RestorePhoneNumber -> Text)
-> (RestorePhoneNumber -> Text -> RestorePhoneNumber)
-> Lens RestorePhoneNumber RestorePhoneNumber Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestorePhoneNumber' {Text
phoneNumberId :: Text
$sel:phoneNumberId:RestorePhoneNumber' :: RestorePhoneNumber -> Text
phoneNumberId} -> Text
phoneNumberId) (\s :: RestorePhoneNumber
s@RestorePhoneNumber' {} Text
a -> RestorePhoneNumber
s {$sel:phoneNumberId:RestorePhoneNumber' :: Text
phoneNumberId = Text
a} :: RestorePhoneNumber)

instance Core.AWSRequest RestorePhoneNumber where
  type
    AWSResponse RestorePhoneNumber =
      RestorePhoneNumberResponse
  request :: RestorePhoneNumber -> Request RestorePhoneNumber
request = Service -> RestorePhoneNumber -> Request RestorePhoneNumber
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RestorePhoneNumber
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RestorePhoneNumber)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RestorePhoneNumber))
-> Logger
-> Service
-> Proxy RestorePhoneNumber
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RestorePhoneNumber)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe PhoneNumber -> Int -> RestorePhoneNumberResponse
RestorePhoneNumberResponse'
            (Maybe PhoneNumber -> Int -> RestorePhoneNumberResponse)
-> Either String (Maybe PhoneNumber)
-> Either String (Int -> RestorePhoneNumberResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe PhoneNumber)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PhoneNumber")
            Either String (Int -> RestorePhoneNumberResponse)
-> Either String Int -> Either String RestorePhoneNumberResponse
forall (f :: * -> *) a b. Applicative f => 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 RestorePhoneNumber

instance Prelude.NFData RestorePhoneNumber

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

instance Core.ToJSON RestorePhoneNumber where
  toJSON :: RestorePhoneNumber -> Value
toJSON = Value -> RestorePhoneNumber -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath RestorePhoneNumber where
  toPath :: RestorePhoneNumber -> ByteString
toPath RestorePhoneNumber' {Text
phoneNumberId :: Text
$sel:phoneNumberId:RestorePhoneNumber' :: RestorePhoneNumber -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/phone-numbers/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
phoneNumberId]

instance Core.ToQuery RestorePhoneNumber where
  toQuery :: RestorePhoneNumber -> QueryString
toQuery =
    QueryString -> RestorePhoneNumber -> QueryString
forall a b. a -> b -> a
Prelude.const
      ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"operation=restore"])

-- | /See:/ 'newRestorePhoneNumberResponse' smart constructor.
data RestorePhoneNumberResponse = RestorePhoneNumberResponse'
  { -- | The phone number details.
    RestorePhoneNumberResponse -> Maybe PhoneNumber
phoneNumber :: Prelude.Maybe PhoneNumber,
    -- | The response's http status code.
    RestorePhoneNumberResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool
(RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool)
-> (RestorePhoneNumberResponse
    -> RestorePhoneNumberResponse -> Bool)
-> Eq RestorePhoneNumberResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool
$c/= :: RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool
== :: RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool
$c== :: RestorePhoneNumberResponse -> RestorePhoneNumberResponse -> Bool
Prelude.Eq, Int -> RestorePhoneNumberResponse -> ShowS
[RestorePhoneNumberResponse] -> ShowS
RestorePhoneNumberResponse -> String
(Int -> RestorePhoneNumberResponse -> ShowS)
-> (RestorePhoneNumberResponse -> String)
-> ([RestorePhoneNumberResponse] -> ShowS)
-> Show RestorePhoneNumberResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestorePhoneNumberResponse] -> ShowS
$cshowList :: [RestorePhoneNumberResponse] -> ShowS
show :: RestorePhoneNumberResponse -> String
$cshow :: RestorePhoneNumberResponse -> String
showsPrec :: Int -> RestorePhoneNumberResponse -> ShowS
$cshowsPrec :: Int -> RestorePhoneNumberResponse -> ShowS
Prelude.Show, (forall x.
 RestorePhoneNumberResponse -> Rep RestorePhoneNumberResponse x)
-> (forall x.
    Rep RestorePhoneNumberResponse x -> RestorePhoneNumberResponse)
-> Generic RestorePhoneNumberResponse
forall x.
Rep RestorePhoneNumberResponse x -> RestorePhoneNumberResponse
forall x.
RestorePhoneNumberResponse -> Rep RestorePhoneNumberResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RestorePhoneNumberResponse x -> RestorePhoneNumberResponse
$cfrom :: forall x.
RestorePhoneNumberResponse -> Rep RestorePhoneNumberResponse x
Prelude.Generic)

-- |
-- Create a value of 'RestorePhoneNumberResponse' 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:
--
-- 'phoneNumber', 'restorePhoneNumberResponse_phoneNumber' - The phone number details.
--
-- 'httpStatus', 'restorePhoneNumberResponse_httpStatus' - The response's http status code.
newRestorePhoneNumberResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RestorePhoneNumberResponse
newRestorePhoneNumberResponse :: Int -> RestorePhoneNumberResponse
newRestorePhoneNumberResponse Int
pHttpStatus_ =
  RestorePhoneNumberResponse' :: Maybe PhoneNumber -> Int -> RestorePhoneNumberResponse
RestorePhoneNumberResponse'
    { $sel:phoneNumber:RestorePhoneNumberResponse' :: Maybe PhoneNumber
phoneNumber =
        Maybe PhoneNumber
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RestorePhoneNumberResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The phone number details.
restorePhoneNumberResponse_phoneNumber :: Lens.Lens' RestorePhoneNumberResponse (Prelude.Maybe PhoneNumber)
restorePhoneNumberResponse_phoneNumber :: (Maybe PhoneNumber -> f (Maybe PhoneNumber))
-> RestorePhoneNumberResponse -> f RestorePhoneNumberResponse
restorePhoneNumberResponse_phoneNumber = (RestorePhoneNumberResponse -> Maybe PhoneNumber)
-> (RestorePhoneNumberResponse
    -> Maybe PhoneNumber -> RestorePhoneNumberResponse)
-> Lens
     RestorePhoneNumberResponse
     RestorePhoneNumberResponse
     (Maybe PhoneNumber)
     (Maybe PhoneNumber)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestorePhoneNumberResponse' {Maybe PhoneNumber
phoneNumber :: Maybe PhoneNumber
$sel:phoneNumber:RestorePhoneNumberResponse' :: RestorePhoneNumberResponse -> Maybe PhoneNumber
phoneNumber} -> Maybe PhoneNumber
phoneNumber) (\s :: RestorePhoneNumberResponse
s@RestorePhoneNumberResponse' {} Maybe PhoneNumber
a -> RestorePhoneNumberResponse
s {$sel:phoneNumber:RestorePhoneNumberResponse' :: Maybe PhoneNumber
phoneNumber = Maybe PhoneNumber
a} :: RestorePhoneNumberResponse)

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

instance Prelude.NFData RestorePhoneNumberResponse