diff --git a/websrc/controllers/backupHandlers.go b/websrc/controllers/backupHandlers.go index 9bdf453..3b828ec 100644 --- a/websrc/controllers/backupHandlers.go +++ b/websrc/controllers/backupHandlers.go @@ -16,80 +16,9 @@ limitations under the License. package controllers import ( - "net/http" - "os" - "time" - - "github.com/cloud-barista/mc-data-manager/websrc/models" "github.com/labstack/echo/v4" ) -// MigrationDynamoDBToFirestorePostHandler godoc -// @Summary Migrate data from DynamoDB to Firestore -// @Description Migrate data stored in AWS DynamoDB to Google Cloud Firestore. -// @Tags [Data Migration] -// @Accept multipart/form-data -// @Produce json -// @Param AWSMigrationParams formData AWSMigrationParams true "Parameters required for Linux migration" -// @Param GCPMigrationParams formData GCPMigrationParams true "Parameters required for GCP migration" -// @Param gcpCredential formData file true "Parameters required to generate test data" -// @Success 200 {object} models.BasicResponse "Successfully migrated data" -// @Failure 500 {object} models.BasicResponse "Internal Server Error" -// @Router /backup [post] -func BackupRootHandler(ctx echo.Context) error { - - start := time.Now() - - logger, logstrings := pageLogInit("migDNFS", "Export dynamoDB data to firestoreDB", start) - - params := MigrationForm{} - if !getDataWithBind(logger, start, ctx, ¶ms) { - return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) - } - - credTmpDir, credFileName, ok := gcpCreateCredFile(logger, start, ctx) - if !ok && params.GCPCredentialJson == "" { - return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) - } - defer os.RemoveAll(credTmpDir) - - awsNRDB := getDynamoNRDBC(logger, start, "mig", params) - if awsNRDB == nil { - return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) - } - - gcpNRDB := getFirestoreNRDBC(logger, start, "mig", params, credFileName) - if gcpNRDB == nil { - return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) - } - - if err := awsNRDB.Copy(gcpNRDB); err != nil { - end := time.Now() - logger.Errorf("NRDBController copy failed : %v", err) - logger.Infof("End time : %s", end.Format("2006-01-02T15:04:05-07:00")) - logger.Infof("Elapsed time : %s", end.Sub(start).String()) - return ctx.JSON(http.StatusInternalServerError, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) - } +func BackupRootHandler(ctx echo.Context) { - // migration success. Send result to client - jobEnd(logger, "Successfully migrated data from dynamoDB to firestoreDB", start) - return ctx.JSON(http.StatusOK, models.BasicResponse{ - Result: logstrings.String(), - Error: nil, - }) } diff --git a/websrc/docs/docs.go b/websrc/docs/docs.go index f29de46..4874f0b 100644 --- a/websrc/docs/docs.go +++ b/websrc/docs/docs.go @@ -23,84 +23,6 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/backup": { - "post": { - "description": "Migrate data stored in AWS DynamoDB to Google Cloud Firestore.", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "[Data Migration]" - ], - "summary": "Migrate data from DynamoDB to Firestore", - "parameters": [ - { - "type": "string", - "name": "awsAccessKey", - "in": "formData" - }, - { - "type": "string", - "name": "awsBucket", - "in": "formData" - }, - { - "type": "string", - "name": "awsRegion", - "in": "formData" - }, - { - "type": "string", - "name": "awsSecretKey", - "in": "formData" - }, - { - "type": "string", - "name": "databaseId", - "in": "formData" - }, - { - "type": "string", - "name": "gcpBucket", - "in": "formData" - }, - { - "type": "string", - "name": "gcpRegion", - "in": "formData" - }, - { - "type": "string", - "name": "projectId", - "in": "formData" - }, - { - "type": "file", - "description": "Parameters required to generate test data", - "name": "gcpCredential", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "Successfully migrated data", - "schema": { - "$ref": "#/definitions/models.BasicResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/models.BasicResponse" - } - } - } - } - }, "/generate/dynamodb": { "post": { "description": "Generate test data on AWS DynamoDB.", diff --git a/websrc/docs/swagger.json b/websrc/docs/swagger.json index 0b06754..5309942 100644 --- a/websrc/docs/swagger.json +++ b/websrc/docs/swagger.json @@ -16,84 +16,6 @@ }, "basePath": "/", "paths": { - "/backup": { - "post": { - "description": "Migrate data stored in AWS DynamoDB to Google Cloud Firestore.", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "[Data Migration]" - ], - "summary": "Migrate data from DynamoDB to Firestore", - "parameters": [ - { - "type": "string", - "name": "awsAccessKey", - "in": "formData" - }, - { - "type": "string", - "name": "awsBucket", - "in": "formData" - }, - { - "type": "string", - "name": "awsRegion", - "in": "formData" - }, - { - "type": "string", - "name": "awsSecretKey", - "in": "formData" - }, - { - "type": "string", - "name": "databaseId", - "in": "formData" - }, - { - "type": "string", - "name": "gcpBucket", - "in": "formData" - }, - { - "type": "string", - "name": "gcpRegion", - "in": "formData" - }, - { - "type": "string", - "name": "projectId", - "in": "formData" - }, - { - "type": "file", - "description": "Parameters required to generate test data", - "name": "gcpCredential", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "Successfully migrated data", - "schema": { - "$ref": "#/definitions/models.BasicResponse" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/models.BasicResponse" - } - } - } - } - }, "/generate/dynamodb": { "post": { "description": "Generate test data on AWS DynamoDB.", diff --git a/websrc/docs/swagger.yaml b/websrc/docs/swagger.yaml index 052bf46..56ad40b 100644 --- a/websrc/docs/swagger.yaml +++ b/websrc/docs/swagger.yaml @@ -221,55 +221,6 @@ info: title: MC-Data-Manager REST API version: latest paths: - /backup: - post: - consumes: - - multipart/form-data - description: Migrate data stored in AWS DynamoDB to Google Cloud Firestore. - parameters: - - in: formData - name: awsAccessKey - type: string - - in: formData - name: awsBucket - type: string - - in: formData - name: awsRegion - type: string - - in: formData - name: awsSecretKey - type: string - - in: formData - name: databaseId - type: string - - in: formData - name: gcpBucket - type: string - - in: formData - name: gcpRegion - type: string - - in: formData - name: projectId - type: string - - description: Parameters required to generate test data - in: formData - name: gcpCredential - required: true - type: file - produces: - - application/json - responses: - "200": - description: Successfully migrated data - schema: - $ref: '#/definitions/models.BasicResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/models.BasicResponse' - summary: Migrate data from DynamoDB to Firestore - tags: - - '[Data Migration]' /generate/dynamodb: post: consumes: