Skip to content

Commit

Permalink
chore(misc): introduce version 3.0.0 and API v3 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Oct 22, 2024
1 parent 77785ce commit b633617
Show file tree
Hide file tree
Showing 51 changed files with 320 additions and 291 deletions.
2 changes: 1 addition & 1 deletion api/client/conversion_client/pipeline_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (cl *PipelineClient) Run(opts *PipelineRunOptions) error {
if err != nil {
return err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/pipelines/run", cl.config.ConversionURL), bytes.NewBuffer(body))
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/pipelines/run", cl.config.ConversionURL), bytes.NewBuffer(body))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion api/client/language_client/language_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (cl *LanguageClient) GetEntities(opts GetEntitiesOptions) ([]InsightsEntity
if err != nil {
return []InsightsEntity{}, err
}
resp, err := http.Post(fmt.Sprintf("%s/v2/entities", cl.config.LanguageURL), "application/json", bytes.NewBuffer(b))
resp, err := http.Post(fmt.Sprintf("%s/v3/entities", cl.config.LanguageURL), "application/json", bytes.NewBuffer(b))
if err != nil {
return []InsightsEntity{}, err
}
Expand Down
8 changes: 4 additions & 4 deletions api/client/mosaic_client/mosaic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (cl *MosaicClient) Create(opts MosaicCreateOptions) (*MosaicMetadata, error
if err := mw.Close(); err != nil {
return nil, err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/mosaics", cl.config.MosaicURL), buf)
req, err := http.NewRequest("POST", fmt.Sprintf("%s/3/mosaics", cl.config.MosaicURL), buf)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -127,7 +127,7 @@ type MosaicGetMetadataOptions struct {
}

func (cl *MosaicClient) GetMetadata(opts MosaicGetMetadataOptions) (*MosaicMetadata, error) {
resp, err := http.Get(fmt.Sprintf("%s/v2/mosaics/%s/%s/metadata", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key))
resp, err := http.Get(fmt.Sprintf("%s/v3/mosaics/%s/%s/metadata", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -161,7 +161,7 @@ type MosaicDeleteOptions struct {
}

func (cl *MosaicClient) Delete(opts MosaicDeleteOptions) error {
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v2/mosaics/%s/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key), nil)
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v3/mosaics/%s/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key), nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -190,7 +190,7 @@ type MosaicDownloadTileOptions struct {
}

func (cl *MosaicClient) DownloadTileBuffer(opts MosaicDownloadTileOptions) (*bytes.Buffer, error) {
resp, err := http.Get(fmt.Sprintf("%s/v2/mosaics/%s/%s/zoom_level/%d/row/%d/col/%d/ext/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key, opts.ZoomLevel, opts.Row, opts.Col, opts.Ext))
resp, err := http.Get(fmt.Sprintf("%s/v3/mosaics/%s/%s/zoom_level/%d/row/%d/col/%d/ext/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key, opts.ZoomLevel, opts.Row, opts.Col, opts.Ext))
if err != nil {
return nil, err
}
Expand Down
198 changes: 99 additions & 99 deletions api/docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
basePath: /v2
basePath: /v3
definitions:
conversion_client.PipelineRunOptions:
properties:
Expand Down Expand Up @@ -948,7 +948,7 @@ definitions:
info:
contact: {}
title: Voltaserve API
version: 2.0.0
version: 3.0.0
paths:
/files:
delete:
Expand Down
30 changes: 15 additions & 15 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
)

// @title Voltaserve API
// @version 2.0.0
// @BasePath /v2
// @version 3.0.0
// @BasePath /v3
//
// .
func main() {
Expand All @@ -55,35 +55,35 @@ func main() {
AllowOrigins: strings.Join(cfg.Security.CORSOrigins, ","),
}))

v2 := app.Group("v2")
v3 := app.Group("v3")

health := router.NewHealthRouter()
health.AppendRoutes(v2)
health.AppendRoutes(v3)

version := router.NewVersionRouter()
version.AppendRoutes(app)

filesGroup := v2.Group("files")
filesGroup := v3.Group("files")
files := router.NewFileRouter()
files.AppendNonJWTRoutes(filesGroup)

snapshotsGroup := v2.Group("snapshots")
snapshotsGroup := v3.Group("snapshots")
snapshots := router.NewSnapshotRouter()
snapshots.AppendNonJWTRoutes(snapshotsGroup)

insightsGroup := v2.Group("insights")
insightsGroup := v3.Group("insights")
insights := router.NewInsightsRouter()
insights.AppendNonJWTRoutes(insightsGroup)

mosaicGroup := v2.Group("mosaics")
mosaicGroup := v3.Group("mosaics")
mosaic := router.NewMosaicRouter()
mosaic.AppendNonJWTRoutes(mosaicGroup)

tasksGroup := v2.Group("tasks")
tasksGroup := v3.Group("tasks")
tasks := router.NewTaskRouter()
tasks.AppendNonJWTRoutes(tasksGroup)

usersGroup := v2.Group("users")
usersGroup := v3.Group("users")
users := router.NewUserRouter()
users.AppendNonJWTRoutes(usersGroup)

Expand All @@ -99,19 +99,19 @@ func main() {
users.AppendRoutes(usersGroup)

invitations := router.NewInvitationRouter()
invitations.AppendRoutes(v2.Group("invitations"))
invitations.AppendRoutes(v3.Group("invitations"))

organizations := router.NewOrganizationRouter()
organizations.AppendRoutes(v2.Group("organizations"))
organizations.AppendRoutes(v3.Group("organizations"))

storage := router.NewStorageRouter()
storage.AppendRoutes(v2.Group("storage"))
storage.AppendRoutes(v3.Group("storage"))

workspaces := router.NewWorkspaceRouter()
workspaces.AppendRoutes(v2.Group("workspaces"))
workspaces.AppendRoutes(v3.Group("workspaces"))

groups := router.NewGroupRouter()
groups.AppendRoutes(v2.Group("groups"))
groups.AppendRoutes(v3.Group("groups"))

if err := app.Listen(fmt.Sprintf(":%d", cfg.Port)); err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion api/router/version_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ func (r *VersionRouter) AppendRoutes(g fiber.Router) {
// @Router /version [get]
func (r *VersionRouter) Read(c *fiber.Ctx) error {
return c.JSON(map[string]string{
"version": "2.1.0",
"version": "3.0.0",
})
}
2 changes: 1 addition & 1 deletion console/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def custom_http_exception_handler(request: Request, exc: HTTPException):


app = FastAPI(
root_path="/v1",
root_path="/v3",
debug=False,
responses={
status.HTTP_204_NO_CONTENT: {"model": None},
Expand Down
2 changes: 1 addition & 1 deletion console/api/routers/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def get_internal_version(data: Annotated[VersionRequest, Depends()]):
async with ClientSession() as sess:
response = await get_dockerhub_version(sess, data.id, response, params)
if data.id == "console":
response["currentVersion"] = "2.1.0"
response["currentVersion"] = "3.0.0"
elif data.id == "ui":
response["currentVersion"] = ""
else:
Expand Down
2 changes: 2 additions & 0 deletions conversion/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Voltaserve Conversion

## Getting Started

Prerequisites:
- [golangci-lint](https://github.com/golangci/golangci-lint)
- [gci](https://github.com/daixiang0/gci)
Expand Down
2 changes: 1 addition & 1 deletion conversion/client/api_client/health_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewHealthClient() *HealthClient {
}

func (cl *HealthClient) Get() (string, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v2/health", cl.config.APIURL), nil)
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v3/health", cl.config.APIURL), nil)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion conversion/client/api_client/snapshot_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (cl *SnapshotClient) Patch(opts SnapshotPatchOptions) error {
if err != nil {
return err
}
req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/v2/snapshots/%s?api_key=%s", cl.config.APIURL, opts.Options.SnapshotID, cl.config.Security.APIKey), bytes.NewBuffer(body))
req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/v3/snapshots/%s?api_key=%s", cl.config.APIURL, opts.Options.SnapshotID, cl.config.Security.APIKey), bytes.NewBuffer(body))
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions conversion/client/api_client/task_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (cl *TaskClient) Create(opts TaskCreateOptions) error {
if err != nil {
return err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/tasks?api_key=%s", cl.config.APIURL, cl.config.Security.APIKey), bytes.NewBuffer(body))
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/tasks?api_key=%s", cl.config.APIURL, cl.config.Security.APIKey), bytes.NewBuffer(body))
if err != nil {
return err
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func (cl *TaskClient) Patch(id string, opts TaskPatchOptions) error {
if err != nil {
return err
}
req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/v2/tasks/%s?api_key=%s", cl.config.APIURL, id, cl.config.Security.APIKey), bytes.NewBuffer(body))
req, err := http.NewRequest("PATCH", fmt.Sprintf("%s/v3/tasks/%s?api_key=%s", cl.config.APIURL, id, cl.config.Security.APIKey), bytes.NewBuffer(body))
if err != nil {
return err
}
Expand All @@ -116,7 +116,7 @@ func (cl *TaskClient) Patch(id string, opts TaskPatchOptions) error {
}

func (cl *TaskClient) Delete(id string) error {
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v2/tasks/%s?api_key=%s", cl.config.APIURL, id, cl.config.Security.APIKey), nil)
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v3/tasks/%s?api_key=%s", cl.config.APIURL, id, cl.config.Security.APIKey), nil)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion conversion/client/language_client/language_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (cl *LanguageClient) GetEntities(opts GetEntitiesOptions) ([]InsightsEntity
if err != nil {
return []InsightsEntity{}, err
}
resp, err := http.Post(fmt.Sprintf("%s/v2/entities", cl.config.LanguageURL), "application/json", bytes.NewBuffer(b))
resp, err := http.Post(fmt.Sprintf("%s/v3/entities", cl.config.LanguageURL), "application/json", bytes.NewBuffer(b))
if err != nil {
return []InsightsEntity{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions conversion/client/mosaic_client/mosaic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (cl *MosaicClient) Create(opts MosaicCreateOptions) (*MosaicMetadata, error
if err := mw.Close(); err != nil {
return nil, err
}
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v2/mosaics", cl.config.MosaicURL), buf)
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/mosaics", cl.config.MosaicURL), buf)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ type MosaicDeleteOptions struct {
}

func (cl *MosaicClient) Delete(opts MosaicDeleteOptions) error {
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v2/mosaics/%s/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key), nil)
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v3/mosaics/%s/%s", cl.config.MosaicURL, opts.S3Bucket, opts.S3Key), nil)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit b633617

Please sign in to comment.