summaryrefslogtreecommitdiff
path: root/opendc-common/src/main/kotlin/org/opendc/common/api/AssetsController.kt
blob: c6f34d195ef08a448a90982c29f4816e2e9be4cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.opendc.common.api

import org.opendc.common.annotations.Endpoint
import io.javalin.http.Handler

/**
 * This class represents the `/assets` endpoint.
 *
 * @author Mateusz Kwiatkowski
 *
 * */


//TODO: fix -> this is all wrong.
// Sending the experiment file is completely useless.
// You need to send tasks.parquet
public class AssetsController {
    /**
     * Returns a concatenated JSON string of all assets.
     */
    @Endpoint("GET","/assets")
    public fun getAssets() : Handler {
        return Handler { ctx -> ctx.status(200)
            println(ctx.body())
        }
    }

    /**
     * Returns an asset with `id` as a JSON string.
     */
    @Endpoint("GET", "/assets/{id}")
    public fun getAssetsId(): Handler {
        return Handler { ctx -> ctx.status(200) }
    }

    /**
     * Saves the asset specified in the HTTP body.
     * Returns the asset `id`.
     */
    @Endpoint("POST", "/assets")
    public fun postAsset() : Handler {
        return Handler { ctx -> ctx.status(200)
            println(ctx.body())
        }
    }

    /**
     * Modifies the specified asset.
     * Deletes all results from experiments with this asset.
     */
    @Endpoint("PUT", "/assets/{id}")
    public fun putAssetId() : Handler {
        return Handler { ctx -> ctx.status(200) }
    }

    /**
     * Deletes an asset with `id`.
     * Deletes all results from experiments with this asset.
     */
    @Endpoint("DELETE", "/assets/{id}")
    public fun deleteAssetId() : Handler {
        return Handler { ctx -> ctx.status(200) }
    }

    /**
     * Deletes all assets
     */
    @Endpoint("DELETE", "/assets")
    public fun deleteAsset() : Handler {
        return Handler { ctx -> ctx.status(200) }
    }
}