{-# 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.MediaLive.UpdateReservation
-- 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)
--
-- Update reservation.
module Amazonka.MediaLive.UpdateReservation
  ( -- * Creating a Request
    UpdateReservation' (..),
    newUpdateReservation',

    -- * Request Lenses
    updateReservation'_name,
    updateReservation'_reservationId,

    -- * Destructuring the Response
    UpdateReservationResponse (..),
    newUpdateReservationResponse,

    -- * Response Lenses
    updateReservationResponse_reservation,
    updateReservationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Request to update a reservation
--
-- /See:/ 'newUpdateReservation'' smart constructor.
data UpdateReservation' = UpdateReservation''
  { -- | Name of the reservation
    UpdateReservation' -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Unique reservation ID, e.g. \'1234567\'
    UpdateReservation' -> Text
reservationId :: Prelude.Text
  }
  deriving (UpdateReservation' -> UpdateReservation' -> Bool
(UpdateReservation' -> UpdateReservation' -> Bool)
-> (UpdateReservation' -> UpdateReservation' -> Bool)
-> Eq UpdateReservation'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateReservation' -> UpdateReservation' -> Bool
$c/= :: UpdateReservation' -> UpdateReservation' -> Bool
== :: UpdateReservation' -> UpdateReservation' -> Bool
$c== :: UpdateReservation' -> UpdateReservation' -> Bool
Prelude.Eq, ReadPrec [UpdateReservation']
ReadPrec UpdateReservation'
Int -> ReadS UpdateReservation'
ReadS [UpdateReservation']
(Int -> ReadS UpdateReservation')
-> ReadS [UpdateReservation']
-> ReadPrec UpdateReservation'
-> ReadPrec [UpdateReservation']
-> Read UpdateReservation'
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateReservation']
$creadListPrec :: ReadPrec [UpdateReservation']
readPrec :: ReadPrec UpdateReservation'
$creadPrec :: ReadPrec UpdateReservation'
readList :: ReadS [UpdateReservation']
$creadList :: ReadS [UpdateReservation']
readsPrec :: Int -> ReadS UpdateReservation'
$creadsPrec :: Int -> ReadS UpdateReservation'
Prelude.Read, Int -> UpdateReservation' -> ShowS
[UpdateReservation'] -> ShowS
UpdateReservation' -> String
(Int -> UpdateReservation' -> ShowS)
-> (UpdateReservation' -> String)
-> ([UpdateReservation'] -> ShowS)
-> Show UpdateReservation'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateReservation'] -> ShowS
$cshowList :: [UpdateReservation'] -> ShowS
show :: UpdateReservation' -> String
$cshow :: UpdateReservation' -> String
showsPrec :: Int -> UpdateReservation' -> ShowS
$cshowsPrec :: Int -> UpdateReservation' -> ShowS
Prelude.Show, (forall x. UpdateReservation' -> Rep UpdateReservation' x)
-> (forall x. Rep UpdateReservation' x -> UpdateReservation')
-> Generic UpdateReservation'
forall x. Rep UpdateReservation' x -> UpdateReservation'
forall x. UpdateReservation' -> Rep UpdateReservation' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateReservation' x -> UpdateReservation'
$cfrom :: forall x. UpdateReservation' -> Rep UpdateReservation' x
Prelude.Generic)

-- |
-- Create a value of 'UpdateReservation'' 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:
--
-- 'name', 'updateReservation'_name' - Name of the reservation
--
-- 'reservationId', 'updateReservation'_reservationId' - Unique reservation ID, e.g. \'1234567\'
newUpdateReservation' ::
  -- | 'reservationId'
  Prelude.Text ->
  UpdateReservation'
newUpdateReservation' :: Text -> UpdateReservation'
newUpdateReservation' Text
pReservationId_ =
  UpdateReservation'' :: Maybe Text -> Text -> UpdateReservation'
UpdateReservation''
    { $sel:name:UpdateReservation'' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reservationId:UpdateReservation'' :: Text
reservationId = Text
pReservationId_
    }

-- | Name of the reservation
updateReservation'_name :: Lens.Lens' UpdateReservation' (Prelude.Maybe Prelude.Text)
updateReservation'_name :: (Maybe Text -> f (Maybe Text))
-> UpdateReservation' -> f UpdateReservation'
updateReservation'_name = (UpdateReservation' -> Maybe Text)
-> (UpdateReservation' -> Maybe Text -> UpdateReservation')
-> Lens
     UpdateReservation' UpdateReservation' (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateReservation'' {Maybe Text
name :: Maybe Text
$sel:name:UpdateReservation'' :: UpdateReservation' -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateReservation'
s@UpdateReservation'' {} Maybe Text
a -> UpdateReservation'
s {$sel:name:UpdateReservation'' :: Maybe Text
name = Maybe Text
a} :: UpdateReservation')

-- | Unique reservation ID, e.g. \'1234567\'
updateReservation'_reservationId :: Lens.Lens' UpdateReservation' Prelude.Text
updateReservation'_reservationId :: (Text -> f Text) -> UpdateReservation' -> f UpdateReservation'
updateReservation'_reservationId = (UpdateReservation' -> Text)
-> (UpdateReservation' -> Text -> UpdateReservation')
-> Lens UpdateReservation' UpdateReservation' Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateReservation'' {Text
reservationId :: Text
$sel:reservationId:UpdateReservation'' :: UpdateReservation' -> Text
reservationId} -> Text
reservationId) (\s :: UpdateReservation'
s@UpdateReservation'' {} Text
a -> UpdateReservation'
s {$sel:reservationId:UpdateReservation'' :: Text
reservationId = Text
a} :: UpdateReservation')

instance Core.AWSRequest UpdateReservation' where
  type
    AWSResponse UpdateReservation' =
      UpdateReservationResponse
  request :: UpdateReservation' -> Request UpdateReservation'
request = Service -> UpdateReservation' -> Request UpdateReservation'
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateReservation'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateReservation')))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateReservation'))
-> Logger
-> Service
-> Proxy UpdateReservation'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateReservation')))
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 Reservation -> Int -> UpdateReservationResponse
UpdateReservationResponse'
            (Maybe Reservation -> Int -> UpdateReservationResponse)
-> Either String (Maybe Reservation)
-> Either String (Int -> UpdateReservationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Reservation)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"reservation")
            Either String (Int -> UpdateReservationResponse)
-> Either String Int -> Either String UpdateReservationResponse
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 UpdateReservation'

instance Prelude.NFData UpdateReservation'

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

instance Core.ToJSON UpdateReservation' where
  toJSON :: UpdateReservation' -> Value
toJSON UpdateReservation'' {Maybe Text
Text
reservationId :: Text
name :: Maybe Text
$sel:reservationId:UpdateReservation'' :: UpdateReservation' -> Text
$sel:name:UpdateReservation'' :: UpdateReservation' -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name]
      )

instance Core.ToPath UpdateReservation' where
  toPath :: UpdateReservation' -> ByteString
toPath UpdateReservation'' {Maybe Text
Text
reservationId :: Text
name :: Maybe Text
$sel:reservationId:UpdateReservation'' :: UpdateReservation' -> Text
$sel:name:UpdateReservation'' :: UpdateReservation' -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/prod/reservations/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
reservationId]

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

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

-- |
-- Create a value of 'UpdateReservationResponse' 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:
--
-- 'reservation', 'updateReservationResponse_reservation' - Undocumented member.
--
-- 'httpStatus', 'updateReservationResponse_httpStatus' - The response's http status code.
newUpdateReservationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateReservationResponse
newUpdateReservationResponse :: Int -> UpdateReservationResponse
newUpdateReservationResponse Int
pHttpStatus_ =
  UpdateReservationResponse' :: Maybe Reservation -> Int -> UpdateReservationResponse
UpdateReservationResponse'
    { $sel:reservation:UpdateReservationResponse' :: Maybe Reservation
reservation =
        Maybe Reservation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateReservationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateReservationResponse_reservation :: Lens.Lens' UpdateReservationResponse (Prelude.Maybe Reservation)
updateReservationResponse_reservation :: (Maybe Reservation -> f (Maybe Reservation))
-> UpdateReservationResponse -> f UpdateReservationResponse
updateReservationResponse_reservation = (UpdateReservationResponse -> Maybe Reservation)
-> (UpdateReservationResponse
    -> Maybe Reservation -> UpdateReservationResponse)
-> Lens
     UpdateReservationResponse
     UpdateReservationResponse
     (Maybe Reservation)
     (Maybe Reservation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateReservationResponse' {Maybe Reservation
reservation :: Maybe Reservation
$sel:reservation:UpdateReservationResponse' :: UpdateReservationResponse -> Maybe Reservation
reservation} -> Maybe Reservation
reservation) (\s :: UpdateReservationResponse
s@UpdateReservationResponse' {} Maybe Reservation
a -> UpdateReservationResponse
s {$sel:reservation:UpdateReservationResponse' :: Maybe Reservation
reservation = Maybe Reservation
a} :: UpdateReservationResponse)

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

instance Prelude.NFData UpdateReservationResponse