module Network.AWS.ImportExport.Types
(
ImportExport
, RESTError
, ns
, JobType (..)
, Artifact
, artifact
, aDescription
, aURL
, Job
, job
, jobCreationDate
, jobIsCanceled
, jobJobId
, jobJobType
) where
import Network.AWS.Prelude
import Network.AWS.Signing
import qualified GHC.Exts
data ImportExport
instance AWSService ImportExport where
type Sg ImportExport = V2
type Er ImportExport = RESTError
service = service'
where
service' :: Service ImportExport
service' = Service
{ _svcAbbrev = "ImportExport"
, _svcPrefix = "importexport"
, _svcVersion = "2010-06-01"
, _svcTargetPrefix = Nothing
, _svcJSONVersion = Nothing
, _svcHandle = handle
, _svcRetry = retry
}
handle :: Status
-> Maybe (LazyByteString -> ServiceError RESTError)
handle = restError statusSuccess service'
retry :: Retry ImportExport
retry = Exponential
{ _retryBase = 0.05
, _retryGrowth = 2
, _retryAttempts = 5
, _retryCheck = check
}
check :: Status
-> RESTError
-> Bool
check (statusCode -> s) (awsErrorCode -> e)
| s == 500 = True
| s == 509 = True
| s == 503 = True
| otherwise = False
ns :: Text
ns = "http://importexport.amazonaws.com/doc/2010-06-01/"
data JobType
= Export'
| Import'
deriving (Eq, Ord, Read, Show, Generic, Enum)
instance Hashable JobType
instance FromText JobType where
parser = takeLowerText >>= \case
"export" -> pure Export'
"import" -> pure Import'
e -> fail $
"Failure parsing JobType from " ++ show e
instance ToText JobType where
toText = \case
Export' -> "Export"
Import' -> "Import"
instance ToByteString JobType
instance ToHeader JobType
instance ToQuery JobType
instance FromXML JobType where
parseXML = parseXMLText "JobType"
data Artifact = Artifact
{ _aDescription :: Maybe Text
, _aURL :: Maybe Text
} deriving (Eq, Ord, Read, Show)
artifact :: Artifact
artifact = Artifact
{ _aDescription = Nothing
, _aURL = Nothing
}
aDescription :: Lens' Artifact (Maybe Text)
aDescription = lens _aDescription (\s a -> s { _aDescription = a })
aURL :: Lens' Artifact (Maybe Text)
aURL = lens _aURL (\s a -> s { _aURL = a })
instance FromXML Artifact where
parseXML x = Artifact
<$> x .@? "Description"
<*> x .@? "URL"
instance ToQuery Artifact where
toQuery Artifact{..} = mconcat
[ "Description" =? _aDescription
, "URL" =? _aURL
]
data Job = Job
{ _jobCreationDate :: ISO8601
, _jobIsCanceled :: Bool
, _jobJobId :: Text
, _jobJobType :: JobType
} deriving (Eq, Read, Show)
job :: Text
-> UTCTime
-> Bool
-> JobType
-> Job
job p1 p2 p3 p4 = Job
{ _jobJobId = p1
, _jobCreationDate = withIso _Time (const id) p2
, _jobIsCanceled = p3
, _jobJobType = p4
}
jobCreationDate :: Lens' Job UTCTime
jobCreationDate = lens _jobCreationDate (\s a -> s { _jobCreationDate = a }) . _Time
jobIsCanceled :: Lens' Job Bool
jobIsCanceled = lens _jobIsCanceled (\s a -> s { _jobIsCanceled = a })
jobJobId :: Lens' Job Text
jobJobId = lens _jobJobId (\s a -> s { _jobJobId = a })
jobJobType :: Lens' Job JobType
jobJobType = lens _jobJobType (\s a -> s { _jobJobType = a })
instance FromXML Job where
parseXML x = Job
<$> x .@ "CreationDate"
<*> x .@ "IsCanceled"
<*> x .@ "JobId"
<*> x .@ "JobType"
instance ToQuery Job where
toQuery Job{..} = mconcat
[ "CreationDate" =? _jobCreationDate
, "IsCanceled" =? _jobIsCanceled
, "JobId" =? _jobJobId
, "JobType" =? _jobJobType
]