Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update REST API of LookupImage & LookupSpec #444

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/api/rest/server/mcir/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func RestPutImage(c echo.Context) error {
// Request structure for RestLookupImage
type RestLookupImageRequest struct {
ConnectionName string `json:"connectionName"`
CspImageId string `json:"cspImageId"`
}

// RestLookupImage godoc
Expand All @@ -107,17 +108,16 @@ type RestLookupImageRequest struct {
// @Success 200 {object} mcir.SpiderImageInfo
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /lookupImage/{imageId} [get]
// @Router /lookupImage [get]
func RestLookupImage(c echo.Context) error {

u := &RestLookupImageRequest{}
if err := c.Bind(u); err != nil {
return err
}

imageId := c.Param("imageId")
fmt.Println("[Lookup image]" + imageId)
content, err := mcir.LookupImage(u.ConnectionName, imageId)
fmt.Println("[Lookup image]" + u.CspImageId)
content, err := mcir.LookupImage(u.ConnectionName, u.CspImageId)
if err != nil {
common.CBLog.Error(err)
return c.JSONBlob(http.StatusNotFound, []byte(err.Error()))
Expand All @@ -137,7 +137,7 @@ func RestLookupImage(c echo.Context) error {
// @Success 200 {object} mcir.SpiderImageList
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /lookupImage [get]
// @Router /lookupImages [get]
func RestLookupImageList(c echo.Context) error {

//type JsonTemplate struct {
Expand Down
10 changes: 5 additions & 5 deletions src/api/rest/server/mcir/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func RestPutSpec(c echo.Context) error {
// Request structure for RestLookupSpec
type RestLookupSpecRequest struct {
ConnectionName string `json:"connectionName"`
CspSpecName string `json:"cspSpecName"`
}

// RestLookupSpec godoc
Expand All @@ -124,17 +125,16 @@ type RestLookupSpecRequest struct {
// @Success 200 {object} mcir.SpiderSpecInfo
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /lookupSpec/{specName} [get]
// @Router /lookupSpec [get]
func RestLookupSpec(c echo.Context) error {

u := &RestLookupSpecRequest{}
if err := c.Bind(u); err != nil {
return err
}

specName := c.Param("specName")
fmt.Println("[Lookup spec]" + specName)
content, err := mcir.LookupSpec(u.ConnectionName, specName)
fmt.Println("[Lookup spec]" + u.CspSpecName)
content, err := mcir.LookupSpec(u.ConnectionName, u.CspSpecName)
if err != nil {
common.CBLog.Error(err)
return c.JSONBlob(http.StatusNotFound, []byte(err.Error()))
Expand All @@ -154,7 +154,7 @@ func RestLookupSpec(c echo.Context) error {
// @Success 200 {object} mcir.SpiderSpecList
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /lookupSpec [get]
// @Router /lookupSpecs [get]
func RestLookupSpecList(c echo.Context) error {

//type JsonTemplate struct {
Expand Down
10 changes: 5 additions & 5 deletions src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ func ApiServer() {
e.GET("/tumblebug/region", rest_common.RestGetRegionList)
e.GET("/tumblebug/region/:regionName", rest_common.RestGetRegion)

e.GET("/tumblebug/lookupSpec", rest_mcir.RestLookupSpecList)
e.GET("/tumblebug/lookupSpec/:specName", rest_mcir.RestLookupSpec)
e.GET("/tumblebug/lookupSpecs", rest_mcir.RestLookupSpecList)
e.GET("/tumblebug/lookupSpec", rest_mcir.RestLookupSpec)

e.GET("/tumblebug/lookupImage", rest_mcir.RestLookupImageList)
e.GET("/tumblebug/lookupImage/:imageId", rest_mcir.RestLookupImage)
e.GET("/tumblebug/lookupImages", rest_mcir.RestLookupImageList)
e.GET("/tumblebug/lookupImage", rest_mcir.RestLookupImage)

e.GET("/tumblebug/webadmin", webadmin.Mainpage)
e.GET("/tumblebug/webadmin/menu", webadmin.Menu)
Expand Down Expand Up @@ -148,7 +148,7 @@ func ApiServer() {
g.PUT("/:nsId/mcis/:mcisId", rest_mcis.RestPutMcis)
g.DELETE("/:nsId/mcis/:mcisId", rest_mcis.RestDelMcis)
g.DELETE("/:nsId/mcis", rest_mcis.RestDelAllMcis)

g.POST("/:nsId/mcis/:mcisId/vm", rest_mcis.RestPostMcisVm)
g.POST("/:nsId/mcis/:mcisId/vmgroup", rest_mcis.RestPostMcisVmGroup)
g.GET("/:nsId/mcis/:mcisId/vm/:vmId", rest_mcis.RestGetMcisVm)
Expand Down
Loading