diff --git a/pkg/modules/migration/vikunja-file/vikunja.go b/pkg/modules/migration/vikunja-file/vikunja.go index dfd6be277..7005744f4 100644 --- a/pkg/modules/migration/vikunja-file/vikunja.go +++ b/pkg/modules/migration/vikunja-file/vikunja.go @@ -37,10 +37,30 @@ const logPrefix = "[Vikunja File Import] " type FileMigrator struct { } +// Name is used to get the name of the vikunja-file migration - we're using the docs here to annotate the status route. +// @Summary Get migration status +// @Description Returns if the current user already did the migation or not. This is useful to show a confirmation message in the frontend if the user is trying to do the same migration again. +// @tags migration +// @Produce json +// @Security JWTKeyAuth +// @Success 200 {object} migration.Status "The migration status" +// @Failure 500 {object} models.Message "Internal server error" +// @Router /migration/vikunja-file/status [get] func (v *FileMigrator) Name() string { return "vikunja-file" } +// Migrate takes a vikunja file export, parses it and imports everything in it into Vikunja. +// @Summary Import all lists, tasks etc. from a Vikunja data export +// @Description Imports all projects, tasks, notes, reminders, subtasks and files from a Vikunjda data export into Vikunja. +// @tags migration +// @Accept json +// @Produce json +// @Security JWTKeyAuth +// @Param import formData string true "The Vikunja export zip file." +// @Success 200 {object} models.Message "A message telling you everything was migrated successfully." +// @Failure 500 {object} models.Message "Internal server error" +// @Router /migration/vikunja-file/migrate [post] func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) error { r, err := zip.NewReader(file, size) if err != nil { diff --git a/pkg/swagger/docs.go b/pkg/swagger/docs.go index fbbce3706..fc3f9079c 100644 --- a/pkg/swagger/docs.go +++ b/pkg/swagger/docs.go @@ -2921,6 +2921,80 @@ var doc = `{ } } }, + "/migration/vikunja-file/migrate": { + "post": { + "security": [ + { + "JWTKeyAuth": [] + } + ], + "description": "Imports all projects, tasks, notes, reminders, subtasks and files from a Vikunjda data export into Vikunja.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "migration" + ], + "summary": "Import all lists, tasks etc. from a Vikunja data export", + "parameters": [ + { + "type": "string", + "description": "The Vikunja export zip file.", + "name": "import", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "A message telling you everything was migrated successfully.", + "schema": { + "$ref": "#/definitions/models.Message" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, + "/migration/vikunja-file/status": { + "get": { + "security": [ + { + "JWTKeyAuth": [] + } + ], + "description": "Returns if the current user already did the migation or not. This is useful to show a confirmation message in the frontend if the user is trying to do the same migration again.", + "produces": [ + "application/json" + ], + "tags": [ + "migration" + ], + "summary": "Get migration status", + "responses": { + "200": { + "description": "The migration status", + "schema": { + "$ref": "#/definitions/migration.Status" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, "/migration/wunderlist/auth": { "get": { "security": [ diff --git a/pkg/swagger/swagger.json b/pkg/swagger/swagger.json index 64c179a9f..7c456a910 100644 --- a/pkg/swagger/swagger.json +++ b/pkg/swagger/swagger.json @@ -2904,6 +2904,80 @@ } } }, + "/migration/vikunja-file/migrate": { + "post": { + "security": [ + { + "JWTKeyAuth": [] + } + ], + "description": "Imports all projects, tasks, notes, reminders, subtasks and files from a Vikunjda data export into Vikunja.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "migration" + ], + "summary": "Import all lists, tasks etc. from a Vikunja data export", + "parameters": [ + { + "type": "string", + "description": "The Vikunja export zip file.", + "name": "import", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "A message telling you everything was migrated successfully.", + "schema": { + "$ref": "#/definitions/models.Message" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, + "/migration/vikunja-file/status": { + "get": { + "security": [ + { + "JWTKeyAuth": [] + } + ], + "description": "Returns if the current user already did the migation or not. This is useful to show a confirmation message in the frontend if the user is trying to do the same migration again.", + "produces": [ + "application/json" + ], + "tags": [ + "migration" + ], + "summary": "Get migration status", + "responses": { + "200": { + "description": "The migration status", + "schema": { + "$ref": "#/definitions/migration.Status" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, "/migration/wunderlist/auth": { "get": { "security": [ diff --git a/pkg/swagger/swagger.yaml b/pkg/swagger/swagger.yaml index 9aee0b2cf..edc002702 100644 --- a/pkg/swagger/swagger.yaml +++ b/pkg/swagger/swagger.yaml @@ -3287,6 +3287,55 @@ paths: summary: Get migration status tags: - migration + /migration/vikunja-file/migrate: + post: + consumes: + - application/json + description: Imports all projects, tasks, notes, reminders, subtasks and files + from a Vikunjda data export into Vikunja. + parameters: + - description: The Vikunja export zip file. + in: formData + name: import + required: true + type: string + produces: + - application/json + responses: + "200": + description: A message telling you everything was migrated successfully. + schema: + $ref: '#/definitions/models.Message' + "500": + description: Internal server error + schema: + $ref: '#/definitions/models.Message' + security: + - JWTKeyAuth: [] + summary: Import all lists, tasks etc. from a Vikunja data export + tags: + - migration + /migration/vikunja-file/status: + get: + description: Returns if the current user already did the migation or not. This + is useful to show a confirmation message in the frontend if the user is trying + to do the same migration again. + produces: + - application/json + responses: + "200": + description: The migration status + schema: + $ref: '#/definitions/migration.Status' + "500": + description: Internal server error + schema: + $ref: '#/definitions/models.Message' + security: + - JWTKeyAuth: [] + summary: Get migration status + tags: + - migration /migration/wunderlist/auth: get: description: Returns the auth url where the user needs to get its auth code.