module Network.Globus.Transfer where
import Data.Aeson
import Data.Char (toUpper)
import Data.Tagged
import Data.Text (Text, pack)
import Data.Text qualified as T
import Data.Text.Encoding (encodeUtf8)
import Effectful (MonadIO)
import GHC.Generics (Generic, Rep)
import Network.Globus.Types
import Network.HTTP.Req as Req
fetchSubmissionId :: (MonadIO m) => Token Access -> m (Id Submission)
fetchSubmissionId :: forall (m :: * -> *).
MonadIO m =>
Token 'Access -> m (Id 'Submission)
fetchSubmissionId Token 'Access
access =
HttpConfig -> Req (Id 'Submission) -> m (Id 'Submission)
forall (m :: * -> *) a. MonadIO m => HttpConfig -> Req a -> m a
runReq HttpConfig
defaultHttpConfig (Req (Id 'Submission) -> m (Id 'Submission))
-> Req (Id 'Submission) -> m (Id 'Submission)
forall a b. (a -> b) -> a -> b
$ do
JsonResponse IdResponse
res <- GET
-> Url 'Https
-> NoReqBody
-> Proxy (JsonResponse IdResponse)
-> Option 'Https
-> Req (JsonResponse IdResponse)
forall (m :: * -> *) method body response (scheme :: Scheme).
(MonadHttp m, HttpMethod method, HttpBody body,
HttpResponse response,
HttpBodyAllowed (AllowsBody method) (ProvidesBody body)) =>
method
-> Url scheme
-> body
-> Proxy response
-> Option scheme
-> m response
req GET
GET (Url 'Https
transferEndpoint Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"submission_id") NoReqBody
NoReqBody Proxy (JsonResponse IdResponse)
forall a. Proxy (JsonResponse a)
jsonResponse (Token 'Access -> Option 'Https
transferAuth Token 'Access
access)
let idRes :: IdResponse
idRes = JsonResponse IdResponse
-> HttpResponseBody (JsonResponse IdResponse)
forall response.
HttpResponse response =>
response -> HttpResponseBody response
responseBody JsonResponse IdResponse
res :: IdResponse
Id 'Submission -> Req (Id 'Submission)
forall a. a -> Req a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Id 'Submission -> Req (Id 'Submission))
-> Id 'Submission -> Req (Id 'Submission)
forall a b. (a -> b) -> a -> b
$ Text -> Id 'Submission
forall {k} (s :: k) b. b -> Tagged s b
Tagged IdResponse
idRes.value
transferAuth :: Token Access -> Option Https
transferAuth :: Token 'Access -> Option 'Https
transferAuth (Tagged Text
access) = ByteString -> Option 'Https
oAuth2Bearer (Text -> ByteString
encodeUtf8 Text
access)
transferEndpoint :: Req.Url 'Https
transferEndpoint :: Url 'Https
transferEndpoint = Text -> Url 'Https
https Text
"transfer.api.globus.org" Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"v0.10"
sendTransfer :: (MonadIO m) => Token Access -> TransferRequest -> m TransferResponse
sendTransfer :: forall (m :: * -> *).
MonadIO m =>
Token 'Access -> TransferRequest -> m TransferResponse
sendTransfer Token 'Access
access TransferRequest
request =
HttpConfig -> Req TransferResponse -> m TransferResponse
forall (m :: * -> *) a. MonadIO m => HttpConfig -> Req a -> m a
runReq HttpConfig
defaultHttpConfig (Req TransferResponse -> m TransferResponse)
-> Req TransferResponse -> m TransferResponse
forall a b. (a -> b) -> a -> b
$ do
JsonResponse TransferResponse
res <- POST
-> Url 'Https
-> ReqBodyJson TransferRequest
-> Proxy (JsonResponse TransferResponse)
-> Option 'Https
-> Req (JsonResponse TransferResponse)
forall (m :: * -> *) method body response (scheme :: Scheme).
(MonadHttp m, HttpMethod method, HttpBody body,
HttpResponse response,
HttpBodyAllowed (AllowsBody method) (ProvidesBody body)) =>
method
-> Url scheme
-> body
-> Proxy response
-> Option scheme
-> m response
req POST
POST (Url 'Https
transferEndpoint Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"transfer") (TransferRequest -> ReqBodyJson TransferRequest
forall a. a -> ReqBodyJson a
ReqBodyJson TransferRequest
request) Proxy (JsonResponse TransferResponse)
forall a. Proxy (JsonResponse a)
jsonResponse (Token 'Access -> Option 'Https
transferAuth Token 'Access
access)
let tr :: TransferResponse
tr = JsonResponse TransferResponse
-> HttpResponseBody (JsonResponse TransferResponse)
forall response.
HttpResponse response =>
response -> HttpResponseBody response
responseBody JsonResponse TransferResponse
res :: TransferResponse
TransferResponse -> Req TransferResponse
forall a. a -> Req a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TransferResponse
tr
fetchTask :: (MonadIO m) => Token Access -> Id Task -> m Task
fetchTask :: forall (m :: * -> *).
MonadIO m =>
Token 'Access -> Id Task -> m Task
fetchTask Token 'Access
access (Tagged Text
ti) = do
HttpConfig -> Req Task -> m Task
forall (m :: * -> *) a. MonadIO m => HttpConfig -> Req a -> m a
runReq HttpConfig
defaultHttpConfig (Req Task -> m Task) -> Req Task -> m Task
forall a b. (a -> b) -> a -> b
$ do
JsonResponse Task
res <- GET
-> Url 'Https
-> NoReqBody
-> Proxy (JsonResponse Task)
-> Option 'Https
-> Req (JsonResponse Task)
forall (m :: * -> *) method body response (scheme :: Scheme).
(MonadHttp m, HttpMethod method, HttpBody body,
HttpResponse response,
HttpBodyAllowed (AllowsBody method) (ProvidesBody body)) =>
method
-> Url scheme
-> body
-> Proxy response
-> Option scheme
-> m response
req GET
GET (Url 'Https
transferEndpoint Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"task" Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
ti) NoReqBody
NoReqBody Proxy (JsonResponse Task)
forall a. Proxy (JsonResponse a)
jsonResponse (Token 'Access -> Option 'Https
transferAuth Token 'Access
access)
Task -> Req Task
forall a. a -> Req a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (JsonResponse Task -> HttpResponseBody (JsonResponse Task)
forall response.
HttpResponse response =>
response -> HttpResponseBody response
responseBody JsonResponse Task
res)
newtype TaskFilters = TaskFilters
{ TaskFilters -> [TaskStatus]
status :: [TaskStatus]
}
deriving (Int -> TaskFilters -> ShowS
[TaskFilters] -> ShowS
TaskFilters -> String
(Int -> TaskFilters -> ShowS)
-> (TaskFilters -> String)
-> ([TaskFilters] -> ShowS)
-> Show TaskFilters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TaskFilters -> ShowS
showsPrec :: Int -> TaskFilters -> ShowS
$cshow :: TaskFilters -> String
show :: TaskFilters -> String
$cshowList :: [TaskFilters] -> ShowS
showList :: [TaskFilters] -> ShowS
Show, TaskFilters -> TaskFilters -> Bool
(TaskFilters -> TaskFilters -> Bool)
-> (TaskFilters -> TaskFilters -> Bool) -> Eq TaskFilters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TaskFilters -> TaskFilters -> Bool
== :: TaskFilters -> TaskFilters -> Bool
$c/= :: TaskFilters -> TaskFilters -> Bool
/= :: TaskFilters -> TaskFilters -> Bool
Eq)
instance Monoid TaskFilters where
mempty :: TaskFilters
mempty = [TaskStatus] -> TaskFilters
TaskFilters []
instance Semigroup TaskFilters where
TaskFilters
tf1 <> :: TaskFilters -> TaskFilters -> TaskFilters
<> TaskFilters
tf2 = TaskFilters{$sel:status:TaskFilters :: [TaskStatus]
status = TaskFilters
tf1.status [TaskStatus] -> [TaskStatus] -> [TaskStatus]
forall a. Semigroup a => a -> a -> a
<> TaskFilters
tf2.status}
fetchTasks :: (MonadIO m) => Token Access -> TaskFilters -> m TaskList
fetchTasks :: forall (m :: * -> *).
MonadIO m =>
Token 'Access -> TaskFilters -> m TaskList
fetchTasks Token 'Access
access TaskFilters
tf = do
HttpConfig -> Req TaskList -> m TaskList
forall (m :: * -> *) a. MonadIO m => HttpConfig -> Req a -> m a
runReq HttpConfig
defaultHttpConfig (Req TaskList -> m TaskList) -> Req TaskList -> m TaskList
forall a b. (a -> b) -> a -> b
$ do
JsonResponse TaskList
res <-
GET
-> Url 'Https
-> NoReqBody
-> Proxy (JsonResponse TaskList)
-> Option 'Https
-> Req (JsonResponse TaskList)
forall (m :: * -> *) method body response (scheme :: Scheme).
(MonadHttp m, HttpMethod method, HttpBody body,
HttpResponse response,
HttpBodyAllowed (AllowsBody method) (ProvidesBody body)) =>
method
-> Url scheme
-> body
-> Proxy response
-> Option scheme
-> m response
req GET
GET (Url 'Https
transferEndpoint Url 'Https -> Text -> Url 'Https
forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"task_list") NoReqBody
NoReqBody Proxy (JsonResponse TaskList)
forall a. Proxy (JsonResponse a)
jsonResponse (Option 'Https -> Req (JsonResponse TaskList))
-> Option 'Https -> Req (JsonResponse TaskList)
forall a b. (a -> b) -> a -> b
$
Token 'Access -> Option 'Https
transferAuth Token 'Access
access
Option 'Https -> Option 'Https -> Option 'Https
forall a. Semigroup a => a -> a -> a
<> Text
"filter" Text -> Text -> Option 'Https
forall param a.
(QueryParam param, ToHttpApiData a) =>
Text -> a -> param
=: [TaskStatus] -> Text
status TaskFilters
tf.status
TaskList -> Req TaskList
forall a. a -> Req a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (JsonResponse TaskList -> HttpResponseBody (JsonResponse TaskList)
forall response.
HttpResponse response =>
response -> HttpResponseBody response
responseBody JsonResponse TaskList
res)
where
status :: [TaskStatus] -> Text
status :: [TaskStatus] -> Text
status [] = Text
""
status [TaskStatus]
ss = Text
"status:" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> [Text] -> Text
T.intercalate Text
"," ((TaskStatus -> Text) -> [TaskStatus] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> Text
T.toUpper (Text -> Text) -> (TaskStatus -> Text) -> TaskStatus -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Text) -> (TaskStatus -> String) -> TaskStatus -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TaskStatus -> String
forall a. Show a => a -> String
show) [TaskStatus]
ss)
activityUrl :: Id Task -> Uri App
activityUrl :: Id Task -> Uri 'App
activityUrl (Tagged Text
t) =
Scheme -> Text -> [Text] -> Query -> Uri 'App
forall (a :: Endpoint). Scheme -> Text -> [Text] -> Query -> Uri a
Uri Scheme
Https Text
"app.globus.org" [Text
"activity", Text
t] ([(Text, Maybe Text)] -> Query
Query [])
taskPercentComplete :: Task -> Float
taskPercentComplete :: Task -> Float
taskPercentComplete Task
t
| Task
t.status TaskStatus -> TaskStatus -> Bool
forall a. Eq a => a -> a -> Bool
== TaskStatus
Succeeded = Float
1
| Bool
otherwise = Float -> Float -> Float
forall a. Ord a => a -> a -> a
max Float
bytesProgress Float
filesProgress
where
bytesProgress :: Float
bytesProgress
| Task
t.bytes_checksummed Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Float
0
| Bool
otherwise = Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Task
t.bytes_transferred Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Task
t.bytes_checksummed
filesProgress :: Float
filesProgress
| Task
t.files Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Float
0
| Bool
otherwise = Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Task
t.files_skipped Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Task
t.files_transferred) Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Task
t.files
data IdResponse = IdResponse
{ IdResponse -> Text
value :: Text
}
deriving ((forall x. IdResponse -> Rep IdResponse x)
-> (forall x. Rep IdResponse x -> IdResponse) -> Generic IdResponse
forall x. Rep IdResponse x -> IdResponse
forall x. IdResponse -> Rep IdResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IdResponse -> Rep IdResponse x
from :: forall x. IdResponse -> Rep IdResponse x
$cto :: forall x. Rep IdResponse x -> IdResponse
to :: forall x. Rep IdResponse x -> IdResponse
Generic, Maybe IdResponse
Value -> Parser [IdResponse]
Value -> Parser IdResponse
(Value -> Parser IdResponse)
-> (Value -> Parser [IdResponse])
-> Maybe IdResponse
-> FromJSON IdResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser IdResponse
parseJSON :: Value -> Parser IdResponse
$cparseJSONList :: Value -> Parser [IdResponse]
parseJSONList :: Value -> Parser [IdResponse]
$comittedField :: Maybe IdResponse
omittedField :: Maybe IdResponse
FromJSON, Int -> IdResponse -> ShowS
[IdResponse] -> ShowS
IdResponse -> String
(Int -> IdResponse -> ShowS)
-> (IdResponse -> String)
-> ([IdResponse] -> ShowS)
-> Show IdResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IdResponse -> ShowS
showsPrec :: Int -> IdResponse -> ShowS
$cshow :: IdResponse -> String
show :: IdResponse -> String
$cshowList :: [IdResponse] -> ShowS
showList :: [IdResponse] -> ShowS
Show)
data Task = Task
{ Task -> TaskStatus
status :: TaskStatus
, Task -> Id Task
task_id :: Id Task
, Task -> Text
label :: Text
,
Task -> Int
files :: Int
, Task -> Int
directories :: Int
, Task -> Int
files_skipped :: Int
, Task -> Int
files_transferred :: Int
, Task -> Int
bytes_transferred :: Int
, Task -> Int
bytes_checksummed :: Int
, Task -> Int
effective_bytes_per_second :: Int
, Task -> Maybe Text
nice_status :: Maybe Text
, Task -> Id 'Collection
source_endpoint_id :: Id Collection
, Task -> Id 'Collection
destination_endpoint_id :: Id Collection
}
deriving ((forall x. Task -> Rep Task x)
-> (forall x. Rep Task x -> Task) -> Generic Task
forall x. Rep Task x -> Task
forall x. Task -> Rep Task x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Task -> Rep Task x
from :: forall x. Task -> Rep Task x
$cto :: forall x. Rep Task x -> Task
to :: forall x. Rep Task x -> Task
Generic, Maybe Task
Value -> Parser [Task]
Value -> Parser Task
(Value -> Parser Task)
-> (Value -> Parser [Task]) -> Maybe Task -> FromJSON Task
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Task
parseJSON :: Value -> Parser Task
$cparseJSONList :: Value -> Parser [Task]
parseJSONList :: Value -> Parser [Task]
$comittedField :: Maybe Task
omittedField :: Maybe Task
FromJSON, Int -> Task -> ShowS
[Task] -> ShowS
Task -> String
(Int -> Task -> ShowS)
-> (Task -> String) -> ([Task] -> ShowS) -> Show Task
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Task -> ShowS
showsPrec :: Int -> Task -> ShowS
$cshow :: Task -> String
show :: Task -> String
$cshowList :: [Task] -> ShowS
showList :: [Task] -> ShowS
Show, Task -> Task -> Bool
(Task -> Task -> Bool) -> (Task -> Task -> Bool) -> Eq Task
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Task -> Task -> Bool
== :: Task -> Task -> Bool
$c/= :: Task -> Task -> Bool
/= :: Task -> Task -> Bool
Eq)
data TaskStatus
= Active
| Inactive
| Succeeded
| Failed
deriving ((forall x. TaskStatus -> Rep TaskStatus x)
-> (forall x. Rep TaskStatus x -> TaskStatus) -> Generic TaskStatus
forall x. Rep TaskStatus x -> TaskStatus
forall x. TaskStatus -> Rep TaskStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TaskStatus -> Rep TaskStatus x
from :: forall x. TaskStatus -> Rep TaskStatus x
$cto :: forall x. Rep TaskStatus x -> TaskStatus
to :: forall x. Rep TaskStatus x -> TaskStatus
Generic, Int -> TaskStatus -> ShowS
[TaskStatus] -> ShowS
TaskStatus -> String
(Int -> TaskStatus -> ShowS)
-> (TaskStatus -> String)
-> ([TaskStatus] -> ShowS)
-> Show TaskStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TaskStatus -> ShowS
showsPrec :: Int -> TaskStatus -> ShowS
$cshow :: TaskStatus -> String
show :: TaskStatus -> String
$cshowList :: [TaskStatus] -> ShowS
showList :: [TaskStatus] -> ShowS
Show, TaskStatus -> TaskStatus -> Bool
(TaskStatus -> TaskStatus -> Bool)
-> (TaskStatus -> TaskStatus -> Bool) -> Eq TaskStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TaskStatus -> TaskStatus -> Bool
== :: TaskStatus -> TaskStatus -> Bool
$c/= :: TaskStatus -> TaskStatus -> Bool
/= :: TaskStatus -> TaskStatus -> Bool
Eq)
instance FromJSON TaskStatus where
parseJSON :: Value -> Parser TaskStatus
parseJSON = Options -> Value -> Parser TaskStatus
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON Options
defaultOptions{constructorTagModifier :: ShowS
constructorTagModifier = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper}
data TaskList = TaskList
{ TaskList -> Int
length :: Int
, TaskList -> Int
limit :: Int
, TaskList -> Int
offset :: Int
, TaskList -> Int
total :: Int
, TaskList -> [Task]
data_ :: [Task]
}
deriving ((forall x. TaskList -> Rep TaskList x)
-> (forall x. Rep TaskList x -> TaskList) -> Generic TaskList
forall x. Rep TaskList x -> TaskList
forall x. TaskList -> Rep TaskList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TaskList -> Rep TaskList x
from :: forall x. TaskList -> Rep TaskList x
$cto :: forall x. Rep TaskList x -> TaskList
to :: forall x. Rep TaskList x -> TaskList
Generic, Int -> TaskList -> ShowS
[TaskList] -> ShowS
TaskList -> String
(Int -> TaskList -> ShowS)
-> (TaskList -> String) -> ([TaskList] -> ShowS) -> Show TaskList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TaskList -> ShowS
showsPrec :: Int -> TaskList -> ShowS
$cshow :: TaskList -> String
show :: TaskList -> String
$cshowList :: [TaskList] -> ShowS
showList :: [TaskList] -> ShowS
Show)
instance FromJSON TaskList where
parseJSON :: Value -> Parser TaskList
parseJSON = Options -> Value -> Parser TaskList
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON Options
defaultOptions{fieldLabelModifier :: ShowS
fieldLabelModifier = ShowS
dataLabels}
data TransferResponse = TransferResponse
{ TransferResponse -> Id Task
task_id :: Id Task
, TransferResponse -> Id 'Submission
submission_id :: Token Submission
,
TransferResponse -> Text
message :: Text
, TransferResponse -> Text
resource :: Text
, TransferResponse -> Token 'Request
request_id :: Token Request
}
deriving ((forall x. TransferResponse -> Rep TransferResponse x)
-> (forall x. Rep TransferResponse x -> TransferResponse)
-> Generic TransferResponse
forall x. Rep TransferResponse x -> TransferResponse
forall x. TransferResponse -> Rep TransferResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TransferResponse -> Rep TransferResponse x
from :: forall x. TransferResponse -> Rep TransferResponse x
$cto :: forall x. Rep TransferResponse x -> TransferResponse
to :: forall x. Rep TransferResponse x -> TransferResponse
Generic, Maybe TransferResponse
Value -> Parser [TransferResponse]
Value -> Parser TransferResponse
(Value -> Parser TransferResponse)
-> (Value -> Parser [TransferResponse])
-> Maybe TransferResponse
-> FromJSON TransferResponse
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TransferResponse
parseJSON :: Value -> Parser TransferResponse
$cparseJSONList :: Value -> Parser [TransferResponse]
parseJSONList :: Value -> Parser [TransferResponse]
$comittedField :: Maybe TransferResponse
omittedField :: Maybe TransferResponse
FromJSON, Int -> TransferResponse -> ShowS
[TransferResponse] -> ShowS
TransferResponse -> String
(Int -> TransferResponse -> ShowS)
-> (TransferResponse -> String)
-> ([TransferResponse] -> ShowS)
-> Show TransferResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TransferResponse -> ShowS
showsPrec :: Int -> TransferResponse -> ShowS
$cshow :: TransferResponse -> String
show :: TransferResponse -> String
$cshowList :: [TransferResponse] -> ShowS
showList :: [TransferResponse] -> ShowS
Show)
data TransferRequest = TransferRequest
{ TransferRequest -> DataType "transfer"
data_type :: DataType "transfer"
, TransferRequest -> Id 'Submission
submission_id :: Id Submission
, TransferRequest -> Maybe Text
label :: Maybe Text
,
TransferRequest -> Id 'Collection
source_endpoint :: Id Collection
, TransferRequest -> Id 'Collection
destination_endpoint :: Id Collection
, TransferRequest -> [TransferItem]
data_ :: [TransferItem]
,
TransferRequest -> SyncLevel
sync_level :: SyncLevel
,
TransferRequest -> Bool
store_base_path_info :: Bool
}
deriving ((forall x. TransferRequest -> Rep TransferRequest x)
-> (forall x. Rep TransferRequest x -> TransferRequest)
-> Generic TransferRequest
forall x. Rep TransferRequest x -> TransferRequest
forall x. TransferRequest -> Rep TransferRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TransferRequest -> Rep TransferRequest x
from :: forall x. TransferRequest -> Rep TransferRequest x
$cto :: forall x. Rep TransferRequest x -> TransferRequest
to :: forall x. Rep TransferRequest x -> TransferRequest
Generic)
instance ToJSON TransferRequest where
toJSON :: TransferRequest -> Value
toJSON = TransferRequest -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
dataLabelsJson
data TransferItem = TransferItem
{ TransferItem -> DataType "transfer_item"
data_type :: DataType "transfer_item"
, TransferItem -> String
source_path :: FilePath
, TransferItem -> String
destination_path :: FilePath
, TransferItem -> Bool
recursive :: Bool
}
deriving ((forall x. TransferItem -> Rep TransferItem x)
-> (forall x. Rep TransferItem x -> TransferItem)
-> Generic TransferItem
forall x. Rep TransferItem x -> TransferItem
forall x. TransferItem -> Rep TransferItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TransferItem -> Rep TransferItem x
from :: forall x. TransferItem -> Rep TransferItem x
$cto :: forall x. Rep TransferItem x -> TransferItem
to :: forall x. Rep TransferItem x -> TransferItem
Generic)
instance ToJSON TransferItem where
toJSON :: TransferItem -> Value
toJSON = TransferItem -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
dataLabelsJson
data SyncLevel
= SyncExists
| SyncSize
| SyncTimestamp
| SyncChecksum
instance ToJSON SyncLevel where
toJSON :: SyncLevel -> Value
toJSON = Scientific -> Value
Number (Scientific -> Value)
-> (SyncLevel -> Scientific) -> SyncLevel -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SyncLevel -> Scientific
forall {a}. Num a => SyncLevel -> a
toInt
where
toInt :: SyncLevel -> a
toInt SyncLevel
SyncExists = a
0
toInt SyncLevel
SyncSize = a
1
toInt SyncLevel
SyncTimestamp = a
2
toInt SyncLevel
SyncChecksum = a
3
dataLabelsJson :: (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
dataLabelsJson :: forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
dataLabelsJson = Options -> a -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
defaultOptions{fieldLabelModifier :: ShowS
fieldLabelModifier = ShowS
dataLabels}
dataLabels :: String -> String
dataLabels :: ShowS
dataLabels String
"data_" = String
"DATA"
dataLabels String
"data_type" = String
"DATA_TYPE"
dataLabels String
f = String
f