{-# 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.MediaConnect.DescribeReservation
-- 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)
--
-- Displays the details of a reservation. The response includes the
-- reservation name, state, start date and time, and the details of the
-- offering that make up the rest of the reservation (such as price,
-- duration, and outbound bandwidth).
module Amazonka.MediaConnect.DescribeReservation
  ( -- * Creating a Request
    DescribeReservation (..),
    newDescribeReservation,

    -- * Request Lenses
    describeReservation_reservationArn,

    -- * Destructuring the Response
    DescribeReservationResponse (..),
    newDescribeReservationResponse,

    -- * Response Lenses
    describeReservationResponse_reservation,
    describeReservationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeReservation' smart constructor.
data DescribeReservation = DescribeReservation'
  { -- | The Amazon Resource Name (ARN) of the reservation.
    DescribeReservation -> Text
reservationArn :: Prelude.Text
  }
  deriving (DescribeReservation -> DescribeReservation -> Bool
(DescribeReservation -> DescribeReservation -> Bool)
-> (DescribeReservation -> DescribeReservation -> Bool)
-> Eq DescribeReservation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeReservation -> DescribeReservation -> Bool
$c/= :: DescribeReservation -> DescribeReservation -> Bool
== :: DescribeReservation -> DescribeReservation -> Bool
$c== :: DescribeReservation -> DescribeReservation -> Bool
Prelude.Eq, ReadPrec [DescribeReservation]
ReadPrec DescribeReservation
Int -> ReadS DescribeReservation
ReadS [DescribeReservation]
(Int -> ReadS DescribeReservation)
-> ReadS [DescribeReservation]
-> ReadPrec DescribeReservation
-> ReadPrec [DescribeReservation]
-> Read DescribeReservation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeReservation]
$creadListPrec :: ReadPrec [DescribeReservation]
readPrec :: ReadPrec DescribeReservation
$creadPrec :: ReadPrec DescribeReservation
readList :: ReadS [DescribeReservation]
$creadList :: ReadS [DescribeReservation]
readsPrec :: Int -> ReadS DescribeReservation
$creadsPrec :: Int -> ReadS DescribeReservation
Prelude.Read, Int -> DescribeReservation -> ShowS
[DescribeReservation] -> ShowS
DescribeReservation -> String
(Int -> DescribeReservation -> ShowS)
-> (DescribeReservation -> String)
-> ([DescribeReservation] -> ShowS)
-> Show DescribeReservation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeReservation] -> ShowS
$cshowList :: [DescribeReservation] -> ShowS
show :: DescribeReservation -> String
$cshow :: DescribeReservation -> String
showsPrec :: Int -> DescribeReservation -> ShowS
$cshowsPrec :: Int -> DescribeReservation -> ShowS
Prelude.Show, (forall x. DescribeReservation -> Rep DescribeReservation x)
-> (forall x. Rep DescribeReservation x -> DescribeReservation)
-> Generic DescribeReservation
forall x. Rep DescribeReservation x -> DescribeReservation
forall x. DescribeReservation -> Rep DescribeReservation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeReservation x -> DescribeReservation
$cfrom :: forall x. DescribeReservation -> Rep DescribeReservation x
Prelude.Generic)

-- |
-- Create a value of 'DescribeReservation' 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:
--
-- 'reservationArn', 'describeReservation_reservationArn' - The Amazon Resource Name (ARN) of the reservation.
newDescribeReservation ::
  -- | 'reservationArn'
  Prelude.Text ->
  DescribeReservation
newDescribeReservation :: Text -> DescribeReservation
newDescribeReservation Text
pReservationArn_ =
  DescribeReservation' :: Text -> DescribeReservation
DescribeReservation'
    { $sel:reservationArn:DescribeReservation' :: Text
reservationArn =
        Text
pReservationArn_
    }

-- | The Amazon Resource Name (ARN) of the reservation.
describeReservation_reservationArn :: Lens.Lens' DescribeReservation Prelude.Text
describeReservation_reservationArn :: (Text -> f Text) -> DescribeReservation -> f DescribeReservation
describeReservation_reservationArn = (DescribeReservation -> Text)
-> (DescribeReservation -> Text -> DescribeReservation)
-> Lens DescribeReservation DescribeReservation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeReservation' {Text
reservationArn :: Text
$sel:reservationArn:DescribeReservation' :: DescribeReservation -> Text
reservationArn} -> Text
reservationArn) (\s :: DescribeReservation
s@DescribeReservation' {} Text
a -> DescribeReservation
s {$sel:reservationArn:DescribeReservation' :: Text
reservationArn = Text
a} :: DescribeReservation)

instance Core.AWSRequest DescribeReservation where
  type
    AWSResponse DescribeReservation =
      DescribeReservationResponse
  request :: DescribeReservation -> Request DescribeReservation
request = Service -> DescribeReservation -> Request DescribeReservation
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeReservation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReservation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeReservation))
-> Logger
-> Service
-> Proxy DescribeReservation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeReservation)))
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 -> DescribeReservationResponse
DescribeReservationResponse'
            (Maybe Reservation -> Int -> DescribeReservationResponse)
-> Either String (Maybe Reservation)
-> Either String (Int -> DescribeReservationResponse)
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 -> DescribeReservationResponse)
-> Either String Int -> Either String DescribeReservationResponse
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 DescribeReservation

instance Prelude.NFData DescribeReservation

instance Core.ToHeaders DescribeReservation where
  toHeaders :: DescribeReservation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeReservation -> 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.ToPath DescribeReservation where
  toPath :: DescribeReservation -> ByteString
toPath DescribeReservation' {Text
reservationArn :: Text
$sel:reservationArn:DescribeReservation' :: DescribeReservation -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/reservations/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
reservationArn]

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

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

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

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

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

instance Prelude.NFData DescribeReservationResponse