{-# 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 #-}
module Amazonka.MediaConnect.PurchaseOffering
(
PurchaseOffering (..),
newPurchaseOffering,
purchaseOffering_offeringArn,
purchaseOffering_start,
purchaseOffering_reservationName,
PurchaseOfferingResponse (..),
newPurchaseOfferingResponse,
purchaseOfferingResponse_reservation,
purchaseOfferingResponse_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
data PurchaseOffering = PurchaseOffering'
{
PurchaseOffering -> Text
offeringArn :: Prelude.Text,
PurchaseOffering -> Text
start :: Prelude.Text,
PurchaseOffering -> Text
reservationName :: Prelude.Text
}
deriving (PurchaseOffering -> PurchaseOffering -> Bool
(PurchaseOffering -> PurchaseOffering -> Bool)
-> (PurchaseOffering -> PurchaseOffering -> Bool)
-> Eq PurchaseOffering
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PurchaseOffering -> PurchaseOffering -> Bool
$c/= :: PurchaseOffering -> PurchaseOffering -> Bool
== :: PurchaseOffering -> PurchaseOffering -> Bool
$c== :: PurchaseOffering -> PurchaseOffering -> Bool
Prelude.Eq, ReadPrec [PurchaseOffering]
ReadPrec PurchaseOffering
Int -> ReadS PurchaseOffering
ReadS [PurchaseOffering]
(Int -> ReadS PurchaseOffering)
-> ReadS [PurchaseOffering]
-> ReadPrec PurchaseOffering
-> ReadPrec [PurchaseOffering]
-> Read PurchaseOffering
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PurchaseOffering]
$creadListPrec :: ReadPrec [PurchaseOffering]
readPrec :: ReadPrec PurchaseOffering
$creadPrec :: ReadPrec PurchaseOffering
readList :: ReadS [PurchaseOffering]
$creadList :: ReadS [PurchaseOffering]
readsPrec :: Int -> ReadS PurchaseOffering
$creadsPrec :: Int -> ReadS PurchaseOffering
Prelude.Read, Int -> PurchaseOffering -> ShowS
[PurchaseOffering] -> ShowS
PurchaseOffering -> String
(Int -> PurchaseOffering -> ShowS)
-> (PurchaseOffering -> String)
-> ([PurchaseOffering] -> ShowS)
-> Show PurchaseOffering
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PurchaseOffering] -> ShowS
$cshowList :: [PurchaseOffering] -> ShowS
show :: PurchaseOffering -> String
$cshow :: PurchaseOffering -> String
showsPrec :: Int -> PurchaseOffering -> ShowS
$cshowsPrec :: Int -> PurchaseOffering -> ShowS
Prelude.Show, (forall x. PurchaseOffering -> Rep PurchaseOffering x)
-> (forall x. Rep PurchaseOffering x -> PurchaseOffering)
-> Generic PurchaseOffering
forall x. Rep PurchaseOffering x -> PurchaseOffering
forall x. PurchaseOffering -> Rep PurchaseOffering x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PurchaseOffering x -> PurchaseOffering
$cfrom :: forall x. PurchaseOffering -> Rep PurchaseOffering x
Prelude.Generic)
newPurchaseOffering ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
PurchaseOffering
newPurchaseOffering :: Text -> Text -> Text -> PurchaseOffering
newPurchaseOffering
Text
pOfferingArn_
Text
pStart_
Text
pReservationName_ =
PurchaseOffering' :: Text -> Text -> Text -> PurchaseOffering
PurchaseOffering'
{ $sel:offeringArn:PurchaseOffering' :: Text
offeringArn = Text
pOfferingArn_,
$sel:start:PurchaseOffering' :: Text
start = Text
pStart_,
$sel:reservationName:PurchaseOffering' :: Text
reservationName = Text
pReservationName_
}
purchaseOffering_offeringArn :: Lens.Lens' PurchaseOffering Prelude.Text
purchaseOffering_offeringArn :: (Text -> f Text) -> PurchaseOffering -> f PurchaseOffering
purchaseOffering_offeringArn = (PurchaseOffering -> Text)
-> (PurchaseOffering -> Text -> PurchaseOffering)
-> Lens PurchaseOffering PurchaseOffering Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurchaseOffering' {Text
offeringArn :: Text
$sel:offeringArn:PurchaseOffering' :: PurchaseOffering -> Text
offeringArn} -> Text
offeringArn) (\s :: PurchaseOffering
s@PurchaseOffering' {} Text
a -> PurchaseOffering
s {$sel:offeringArn:PurchaseOffering' :: Text
offeringArn = Text
a} :: PurchaseOffering)
purchaseOffering_start :: Lens.Lens' PurchaseOffering Prelude.Text
purchaseOffering_start :: (Text -> f Text) -> PurchaseOffering -> f PurchaseOffering
purchaseOffering_start = (PurchaseOffering -> Text)
-> (PurchaseOffering -> Text -> PurchaseOffering)
-> Lens PurchaseOffering PurchaseOffering Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurchaseOffering' {Text
start :: Text
$sel:start:PurchaseOffering' :: PurchaseOffering -> Text
start} -> Text
start) (\s :: PurchaseOffering
s@PurchaseOffering' {} Text
a -> PurchaseOffering
s {$sel:start:PurchaseOffering' :: Text
start = Text
a} :: PurchaseOffering)
purchaseOffering_reservationName :: Lens.Lens' PurchaseOffering Prelude.Text
purchaseOffering_reservationName :: (Text -> f Text) -> PurchaseOffering -> f PurchaseOffering
purchaseOffering_reservationName = (PurchaseOffering -> Text)
-> (PurchaseOffering -> Text -> PurchaseOffering)
-> Lens PurchaseOffering PurchaseOffering Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurchaseOffering' {Text
reservationName :: Text
$sel:reservationName:PurchaseOffering' :: PurchaseOffering -> Text
reservationName} -> Text
reservationName) (\s :: PurchaseOffering
s@PurchaseOffering' {} Text
a -> PurchaseOffering
s {$sel:reservationName:PurchaseOffering' :: Text
reservationName = Text
a} :: PurchaseOffering)
instance Core.AWSRequest PurchaseOffering where
type
AWSResponse PurchaseOffering =
PurchaseOfferingResponse
request :: PurchaseOffering -> Request PurchaseOffering
request = Service -> PurchaseOffering -> Request PurchaseOffering
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PurchaseOffering
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PurchaseOffering)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PurchaseOffering))
-> Logger
-> Service
-> Proxy PurchaseOffering
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PurchaseOffering)))
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 -> PurchaseOfferingResponse
PurchaseOfferingResponse'
(Maybe Reservation -> Int -> PurchaseOfferingResponse)
-> Either String (Maybe Reservation)
-> Either String (Int -> PurchaseOfferingResponse)
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 -> PurchaseOfferingResponse)
-> Either String Int -> Either String PurchaseOfferingResponse
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 PurchaseOffering
instance Prelude.NFData PurchaseOffering
instance Core.ToHeaders PurchaseOffering where
toHeaders :: PurchaseOffering -> ResponseHeaders
toHeaders =
ResponseHeaders -> PurchaseOffering -> 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 PurchaseOffering where
toJSON :: PurchaseOffering -> Value
toJSON PurchaseOffering' {Text
reservationName :: Text
start :: Text
offeringArn :: Text
$sel:reservationName:PurchaseOffering' :: PurchaseOffering -> Text
$sel:start:PurchaseOffering' :: PurchaseOffering -> Text
$sel:offeringArn:PurchaseOffering' :: PurchaseOffering -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"start" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
start),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"reservationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reservationName)
]
)
instance Core.ToPath PurchaseOffering where
toPath :: PurchaseOffering -> ByteString
toPath PurchaseOffering' {Text
reservationName :: Text
start :: Text
offeringArn :: Text
$sel:reservationName:PurchaseOffering' :: PurchaseOffering -> Text
$sel:start:PurchaseOffering' :: PurchaseOffering -> Text
$sel:offeringArn:PurchaseOffering' :: PurchaseOffering -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/offerings/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
offeringArn]
instance Core.ToQuery PurchaseOffering where
toQuery :: PurchaseOffering -> QueryString
toQuery = QueryString -> PurchaseOffering -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PurchaseOfferingResponse = PurchaseOfferingResponse'
{ PurchaseOfferingResponse -> Maybe Reservation
reservation :: Prelude.Maybe Reservation,
PurchaseOfferingResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool
(PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool)
-> (PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool)
-> Eq PurchaseOfferingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool
$c/= :: PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool
== :: PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool
$c== :: PurchaseOfferingResponse -> PurchaseOfferingResponse -> Bool
Prelude.Eq, ReadPrec [PurchaseOfferingResponse]
ReadPrec PurchaseOfferingResponse
Int -> ReadS PurchaseOfferingResponse
ReadS [PurchaseOfferingResponse]
(Int -> ReadS PurchaseOfferingResponse)
-> ReadS [PurchaseOfferingResponse]
-> ReadPrec PurchaseOfferingResponse
-> ReadPrec [PurchaseOfferingResponse]
-> Read PurchaseOfferingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PurchaseOfferingResponse]
$creadListPrec :: ReadPrec [PurchaseOfferingResponse]
readPrec :: ReadPrec PurchaseOfferingResponse
$creadPrec :: ReadPrec PurchaseOfferingResponse
readList :: ReadS [PurchaseOfferingResponse]
$creadList :: ReadS [PurchaseOfferingResponse]
readsPrec :: Int -> ReadS PurchaseOfferingResponse
$creadsPrec :: Int -> ReadS PurchaseOfferingResponse
Prelude.Read, Int -> PurchaseOfferingResponse -> ShowS
[PurchaseOfferingResponse] -> ShowS
PurchaseOfferingResponse -> String
(Int -> PurchaseOfferingResponse -> ShowS)
-> (PurchaseOfferingResponse -> String)
-> ([PurchaseOfferingResponse] -> ShowS)
-> Show PurchaseOfferingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PurchaseOfferingResponse] -> ShowS
$cshowList :: [PurchaseOfferingResponse] -> ShowS
show :: PurchaseOfferingResponse -> String
$cshow :: PurchaseOfferingResponse -> String
showsPrec :: Int -> PurchaseOfferingResponse -> ShowS
$cshowsPrec :: Int -> PurchaseOfferingResponse -> ShowS
Prelude.Show, (forall x.
PurchaseOfferingResponse -> Rep PurchaseOfferingResponse x)
-> (forall x.
Rep PurchaseOfferingResponse x -> PurchaseOfferingResponse)
-> Generic PurchaseOfferingResponse
forall x.
Rep PurchaseOfferingResponse x -> PurchaseOfferingResponse
forall x.
PurchaseOfferingResponse -> Rep PurchaseOfferingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PurchaseOfferingResponse x -> PurchaseOfferingResponse
$cfrom :: forall x.
PurchaseOfferingResponse -> Rep PurchaseOfferingResponse x
Prelude.Generic)
newPurchaseOfferingResponse ::
Prelude.Int ->
PurchaseOfferingResponse
newPurchaseOfferingResponse :: Int -> PurchaseOfferingResponse
newPurchaseOfferingResponse Int
pHttpStatus_ =
PurchaseOfferingResponse' :: Maybe Reservation -> Int -> PurchaseOfferingResponse
PurchaseOfferingResponse'
{ $sel:reservation:PurchaseOfferingResponse' :: Maybe Reservation
reservation =
Maybe Reservation
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PurchaseOfferingResponse' :: Int
httpStatus = Int
pHttpStatus_
}
purchaseOfferingResponse_reservation :: Lens.Lens' PurchaseOfferingResponse (Prelude.Maybe Reservation)
purchaseOfferingResponse_reservation :: (Maybe Reservation -> f (Maybe Reservation))
-> PurchaseOfferingResponse -> f PurchaseOfferingResponse
purchaseOfferingResponse_reservation = (PurchaseOfferingResponse -> Maybe Reservation)
-> (PurchaseOfferingResponse
-> Maybe Reservation -> PurchaseOfferingResponse)
-> Lens
PurchaseOfferingResponse
PurchaseOfferingResponse
(Maybe Reservation)
(Maybe Reservation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurchaseOfferingResponse' {Maybe Reservation
reservation :: Maybe Reservation
$sel:reservation:PurchaseOfferingResponse' :: PurchaseOfferingResponse -> Maybe Reservation
reservation} -> Maybe Reservation
reservation) (\s :: PurchaseOfferingResponse
s@PurchaseOfferingResponse' {} Maybe Reservation
a -> PurchaseOfferingResponse
s {$sel:reservation:PurchaseOfferingResponse' :: Maybe Reservation
reservation = Maybe Reservation
a} :: PurchaseOfferingResponse)
purchaseOfferingResponse_httpStatus :: Lens.Lens' PurchaseOfferingResponse Prelude.Int
purchaseOfferingResponse_httpStatus :: (Int -> f Int)
-> PurchaseOfferingResponse -> f PurchaseOfferingResponse
purchaseOfferingResponse_httpStatus = (PurchaseOfferingResponse -> Int)
-> (PurchaseOfferingResponse -> Int -> PurchaseOfferingResponse)
-> Lens PurchaseOfferingResponse PurchaseOfferingResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurchaseOfferingResponse' {Int
httpStatus :: Int
$sel:httpStatus:PurchaseOfferingResponse' :: PurchaseOfferingResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PurchaseOfferingResponse
s@PurchaseOfferingResponse' {} Int
a -> PurchaseOfferingResponse
s {$sel:httpStatus:PurchaseOfferingResponse' :: Int
httpStatus = Int
a} :: PurchaseOfferingResponse)
instance Prelude.NFData PurchaseOfferingResponse