module Aws.ElasticTranscoder.Commands.CreateJob
( CreateJob(..)
, CreateJobResponse(..)
, createJob
, defaultJSInput
, defaultJSOutput
) where
import Aws.Core
import Aws.ElasticTranscoder.Core
import Control.Applicative
import Data.Aeson
data CreateJob
= CreateJob
{ cjInput :: JSInput
, cjOutput :: JSOutput
, cjPipelineId :: PipelineId
}
deriving (Show,Eq)
data CreateJobResponse
= CreateJobResponse
{ cjrId :: JobId
, cjrInput :: JSInput
, cjrOutput :: JSOutputStatus
, cjrPipelineId :: PipelineId
}
deriving (Show,Eq)
createJob :: S3Object -> S3Object -> PresetId -> PipelineId -> CreateJob
createJob inb oub pri pli = CreateJob cji cjo pli
where
cji = defaultJSInput inb
cjo = defaultJSOutput oub pri
defaultJSInput :: S3Object -> JSInput
defaultJSInput inb = JSInput inb FRauto Rauto ARauto ABauto Cauto
defaultJSOutput :: S3Object -> PresetId -> JSOutput
defaultJSOutput oub pri = JSOutput oub "" ROTauto pri
instance SignQuery CreateJob where
type ServiceConfiguration CreateJob = EtsConfiguration
signQuery CreateJob {..} = etsSignQuery EtsQuery
{ etsqMethod = Post
, etsqRequest = "jobs"
, etsqQuery = []
, etsqBody = Just $ toJSON $ JobSpec cjInput cjOutput cjPipelineId
}
instance ResponseConsumer CreateJob CreateJobResponse where
type ResponseMetadata CreateJobResponse = EtsMetadata
responseConsumer _ mref = etsResponseConsumer mref $ \rsp ->
cnv <$> jsonConsumer rsp
where
cnv (JobSingle(JobSpecId a b c d)) = CreateJobResponse a b c d
instance Transaction CreateJob CreateJobResponse
instance AsMemoryResponse CreateJobResponse where
type MemoryResponse CreateJobResponse = CreateJobResponse
loadToMemory = return