From 716f240fde60374955d02cb67721b76056cc036f Mon Sep 17 00:00:00 2001 From: heedaeshin Date: Mon, 26 Aug 2024 14:38:51 +0900 Subject: [PATCH] =?UTF-8?q?merge=20:=20=ED=86=B5=ED=95=A9=EA=B3=BC?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/css/styles.css | 85 ++++++++++-------- web/js/scripts.js | 43 +++++++++ web/templates/back-backup.html | 57 ++++++++++++ web/templates/content.html | 9 ++ web/templates/gen-data.html | 2 +- web/templates/index.html | 21 +++-- websrc/controllers/backupHandlers.go | 95 ++++++++++++++++++++ websrc/controllers/pageHandlers.go | 14 +++ websrc/docs/docs.go | 78 ++++++++++++++++ websrc/docs/swagger.json | 78 ++++++++++++++++ websrc/docs/swagger.yaml | 49 ++++++++++ websrc/routes/backupRoutes.go | 130 +++++++++++++++++++++++++++ websrc/serve/serve.go | 3 + 13 files changed, 619 insertions(+), 45 deletions(-) create mode 100644 web/templates/back-backup.html create mode 100644 websrc/controllers/backupHandlers.go create mode 100644 websrc/routes/backupRoutes.go diff --git a/web/css/styles.css b/web/css/styles.css index 2ac9d24..cecd6c0 100644 --- a/web/css/styles.css +++ b/web/css/styles.css @@ -1,4 +1,5 @@ @charset "UTF-8"; + /*! * Start Bootstrap - SB Admin v7.0.7 (https://startbootstrap.com/template/sb-admin) * Copyright 2013-2023 Start Bootstrap @@ -10,6 +11,10 @@ * Copyright 2011-2022 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ + /* @import url('./font.css'); */ + @import url(//spoqa.github.io/spoqa-han-sans/css/SpoqaHanSansNeo.css); + + :root { --bs-blue: #0d6efd; --bs-indigo: #6610f2; @@ -49,15 +54,15 @@ --bs-warning-rgb: 255, 193, 7; --bs-danger-rgb: 220, 53, 69; --bs-light-rgb: 248, 249, 250; - --bs-dark-rgb: 33, 37, 41; + --bs-dark-rgb: 228, 143, 0; --bs-white-rgb: 255, 255, 255; --bs-black-rgb: 0, 0, 0; --bs-body-color-rgb: 33, 37, 41; --bs-body-bg-rgb: 255, 255, 255; --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; - --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + --bs-font-monospace: 'Spoqa Han Sans Neo', sans-serif, 'MeiryoUI', 'YaHei', Arial; --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0)); - --bs-body-font-family: var(--bs-font-sans-serif); + --bs-body-font-family: var(--bs-font-monospace); --bs-body-font-size: 1rem; --bs-body-font-weight: 400; --bs-body-line-height: 1.5; @@ -77,6 +82,8 @@ --bs-link-hover-color: #0a58ca; --bs-code-color: #d63384; --bs-highlight-bg: #fff3cd; + --bs-nav-bg: #E48F00; + --bs-nav-footer-bg: #F9AA25; } *, @@ -2004,7 +2011,6 @@ progress { -webkit-appearance: none; -moz-appearance: none; appearance: none; - border-radius: 0.375rem; transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; } @media (prefers-reduced-motion: reduce) { @@ -2156,7 +2162,7 @@ textarea.form-control-lg { background-position: right 0.75rem center; background-size: 16px 12px; border: 1px solid #ced4da; - border-radius: 0.375rem; + /* border-radius: 0.375rem; */ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; -webkit-appearance: none; -moz-appearance: none; @@ -2189,7 +2195,7 @@ textarea.form-control-lg { padding-bottom: 0.25rem; padding-left: 0.5rem; font-size: 0.875rem; - border-radius: 0.25rem; + /* border-radius: 0.25rem; */ } .form-select-lg { @@ -2239,7 +2245,7 @@ textarea.form-control-lg { print-color-adjust: exact; } .form-check-input[type=checkbox] { - border-radius: 0.25em; + /* border-radius: 0.25em; */ } .form-check-input[type=radio] { border-radius: 50%; @@ -2539,7 +2545,6 @@ textarea.form-control-lg { white-space: nowrap; background-color: #e9ecef; border: 1px solid #ced4da; - border-radius: 0.375rem; } .input-group-lg > .form-control, .input-group-lg > .datatable-input, @@ -2813,7 +2818,7 @@ textarea.form-control-lg { -moz-user-select: none; user-select: none; border: var(--bs-btn-border-width) solid var(--bs-btn-border-color); - border-radius: var(--bs-btn-border-radius); + /* border-radius: var(--bs-btn-border-radius); */ background-color: var(--bs-btn-bg); transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; } @@ -2862,19 +2867,19 @@ textarea.form-control-lg { .btn-primary { --bs-btn-color: #fff; - --bs-btn-bg: #0d6efd; - --bs-btn-border-color: #0d6efd; + --bs-btn-bg: #E48F00; + --bs-btn-border-color: #E48F00; --bs-btn-hover-color: #fff; - --bs-btn-hover-bg: #0b5ed7; - --bs-btn-hover-border-color: #0a58ca; + --bs-btn-hover-bg: #B97400; + --bs-btn-hover-border-color: #985F00; --bs-btn-focus-shadow-rgb: 49, 132, 253; --bs-btn-active-color: #fff; - --bs-btn-active-bg: #0a58ca; - --bs-btn-active-border-color: #0a53be; + --bs-btn-active-bg: #985F00; + --bs-btn-active-border-color: #B97400; --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); --bs-btn-disabled-color: #fff; - --bs-btn-disabled-bg: #0d6efd; - --bs-btn-disabled-border-color: #0d6efd; + --bs-btn-disabled-bg: #E48F00; + --bs-btn-disabled-border-color: #E48F00; } .btn-secondary { @@ -4192,7 +4197,6 @@ textarea.form-control-lg { background-color: var(--bs-card-bg); background-clip: border-box; border: var(--bs-card-border-width) solid var(--bs-card-border-color); - border-radius: var(--bs-card-border-radius); } .card > hr { margin-right: 0; @@ -4247,9 +4251,6 @@ textarea.form-control-lg { background-color: var(--bs-card-cap-bg); border-bottom: var(--bs-card-border-width) solid var(--bs-card-border-color); } -.card-header:first-child { - border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0; -} .card-footer { padding: var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x); @@ -4437,23 +4438,23 @@ textarea.form-control-lg { border: var(--bs-accordion-border-width) solid var(--bs-accordion-border-color); } .accordion-item:first-of-type { - border-top-left-radius: var(--bs-accordion-border-radius); - border-top-right-radius: var(--bs-accordion-border-radius); + /* border-top-left-radius: var(--bs-accordion-border-radius); + border-top-right-radius: var(--bs-accordion-border-radius); */ } .accordion-item:first-of-type .accordion-button { - border-top-left-radius: var(--bs-accordion-inner-border-radius); - border-top-right-radius: var(--bs-accordion-inner-border-radius); + /* border-top-left-radius: var(--bs-accordion-inner-border-radius); + border-top-right-radius: var(--bs-accordion-inner-border-radius); */ } .accordion-item:not(:first-of-type) { border-top: 0; } .accordion-item:last-of-type { - border-bottom-right-radius: var(--bs-accordion-border-radius); - border-bottom-left-radius: var(--bs-accordion-border-radius); + /* border-bottom-right-radius: var(--bs-accordion-border-radius); + border-bottom-left-radius: var(--bs-accordion-border-radius); */ } .accordion-item:last-of-type .accordion-button.collapsed { - border-bottom-right-radius: var(--bs-accordion-inner-border-radius); - border-bottom-left-radius: var(--bs-accordion-inner-border-radius); + /* border-bottom-right-radius: var(--bs-accordion-inner-border-radius); + border-bottom-left-radius: var(--bs-accordion-inner-border-radius); */ } .accordion-item:last-of-type .accordion-collapse { border-bottom-right-radius: var(--bs-accordion-border-radius); @@ -4650,7 +4651,6 @@ textarea.form-control-lg { color: var(--bs-alert-color); background-color: var(--bs-alert-bg); border: var(--bs-alert-border); - border-radius: var(--bs-alert-border-radius); } .alert-heading { @@ -10927,7 +10927,11 @@ body { padding-top: 56px; } .sb-nav-fixed #layoutSidenav #layoutSidenav_nav .sb-sidenav .sb-sidenav-menu { - overflow-y: auto; + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} +.sb-nav-fixed #layoutSidenav #layoutSidenav_nav .sb-sidenav .sb-sidenav-menu::-webkit-scrollbar { + display: none; /* Chrome, Safari, Opera*/ } .sb-nav-fixed #layoutSidenav #layoutSidenav_content { padding-left: 225px; @@ -11016,23 +11020,24 @@ body { .sb-sidenav .sb-sidenav-footer { padding: 0.75rem; flex-shrink: 0; + white-space: nowrap; } .sb-sidenav-dark { - background-color: #212529; - color: rgba(255, 255, 255, 0.5); + background-color: var(--bs-nav-bg); + color: rgba(255, 255, 255, 0.7); } .sb-sidenav-dark .sb-sidenav-menu .sb-sidenav-menu-heading { - color: rgba(255, 255, 255, 0.25); + color: rgba(255, 255, 255, 0.5); } .sb-sidenav-dark .sb-sidenav-menu .nav-link { - color: rgba(255, 255, 255, 0.5); + color: rgba(255, 255, 255, 0.7); } .sb-sidenav-dark .sb-sidenav-menu .nav-link .sb-nav-link-icon { - color: rgba(255, 255, 255, 0.25); + color: rgba(255, 255, 255, 0.5); } .sb-sidenav-dark .sb-sidenav-menu .nav-link .sb-sidenav-collapse-arrow { - color: rgba(255, 255, 255, 0.25); + color: rgba(255, 255, 255, 0.5); } .sb-sidenav-dark .sb-sidenav-menu .nav-link:hover { color: #fff; @@ -11044,7 +11049,7 @@ body { color: #fff; } .sb-sidenav-dark .sb-sidenav-footer { - background-color: #343a40; + background-color: var(--bs-nav-footer-bg); } .sb-sidenav-light { @@ -11240,4 +11245,8 @@ body { width: 20px !important; font-size: 0.75rem; border-radius: 0.375rem !important; +} + +.data-txt { + background-color: var(--bs-gray-800); } \ No newline at end of file diff --git a/web/js/scripts.js b/web/js/scripts.js index ab32f48..b8e41c7 100644 --- a/web/js/scripts.js +++ b/web/js/scripts.js @@ -29,6 +29,9 @@ window.addEventListener('DOMContentLoaded', event => { if (document.getElementById('migForm')) { migrationFormSubmit(); } + if (document.getElementById('backForm')) { + backUpFormSubmit(); + } }); @@ -123,6 +126,46 @@ function migrationFormSubmit() { }); } +function backUpFormSubmit() { + const form = document.getElementById('backForm'); + + form.addEventListener('submit', (e) => { + e.preventDefault(); + loadingButtonOn(); + resultCollpase(); + + const payload = new FormData(form); + const dest = document.getElementById('backDest').value; + const source = document.getElementById('backSource').value; + let url = "/backup/" + source; + + console.log(url); + + fetch(url, { + method: 'POST', + body: payload + }) + .then(response => { + return response.json(); + }) + .then(json => { + const resultText = document.getElementById('resultText'); + resultText.value = json.Result; + console.log(json); + console.log("backup done."); + }) + .catch(reason => { + console.log(reason); + alert(reason); + }) + .finally(() => { + loadingButtonOff(); + }); + + console.log("backup progressing..."); + }); +} + function loadingButtonOn() { let btn = document.getElementById('submitBtn'); btn.disabled = true; diff --git a/web/templates/back-backup.html b/web/templates/back-backup.html new file mode 100644 index 0000000..000a8e4 --- /dev/null +++ b/web/templates/back-backup.html @@ -0,0 +1,57 @@ +

백업

+ + +
+
+ + Back Up +
+
+ +
+ + + + + +
+ + +
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/web/templates/content.html b/web/templates/content.html index 378dd03..91647a6 100644 --- a/web/templates/content.html +++ b/web/templates/content.html @@ -42,7 +42,11 @@ {{ if eq .Content "Generate-MongoDB" }} {{ template "gen-mongodb.html" . }} {{ end }} + + {{ if eq .Content "Backup" }} + {{ template "back-backup.html" . }} + {{ end }} @@ -153,6 +157,11 @@ {{ if eq .Content "Migration-MongoDB-Firestore" }} {{ template "mig-mongodbToFirestore.html" . }} {{ end }} + + + {{ if eq .Content "BackUp" }} + {{ template "back-backup.html" . }} + {{ end }} {{ if ne .Content "main" }} {{ template "result.html" . }} diff --git a/web/templates/gen-data.html b/web/templates/gen-data.html index e06e5a0..de47f4b 100644 --- a/web/templates/gen-data.html +++ b/web/templates/gen-data.html @@ -31,7 +31,7 @@
- TXT + TXT GB
diff --git a/web/templates/index.html b/web/templates/index.html index d9b23a2..f56445c 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -33,7 +33,7 @@ @@ -46,7 +46,7 @@ @@ -110,7 +110,7 @@ @@ -172,7 +172,7 @@ @@ -185,7 +185,7 @@ @@ -228,6 +228,15 @@ + +
Back Up
+ + + + @@ -235,7 +244,7 @@ diff --git a/websrc/controllers/backupHandlers.go b/websrc/controllers/backupHandlers.go new file mode 100644 index 0000000..9bdf453 --- /dev/null +++ b/websrc/controllers/backupHandlers.go @@ -0,0 +1,95 @@ +/* +Copyright 2023 The Cloud-Barista Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +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, + }) + } + + // 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/controllers/pageHandlers.go b/websrc/controllers/pageHandlers.go index eb1cb0b..b109272 100644 --- a/websrc/controllers/pageHandlers.go +++ b/websrc/controllers/pageHandlers.go @@ -140,6 +140,20 @@ func GenerateMongoDBGetHandler(ctx echo.Context) error { }) } +/////////////////////////////////////////////////////////////////////////////////////////////// +// Page handlers related to backup data + +func BackupHandler(ctx echo.Context) error { + logger := getLogger("backup") + logger.Info("backup get page accessed") + return ctx.Render(http.StatusOK, "index.html", models.BasicPageResponse{ + Content: "Backup", + Regions: GetAWSRegions(), + OS: runtime.GOOS, + Error: nil, + }) +} + /////////////////////////////////////////////////////////////////////////////////////////////// // Page handlers related to migration data diff --git a/websrc/docs/docs.go b/websrc/docs/docs.go index fa5f8d1..f0c54ad 100644 --- a/websrc/docs/docs.go +++ b/websrc/docs/docs.go @@ -23,6 +23,84 @@ 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 6ed954f..5b1ca10 100644 --- a/websrc/docs/swagger.json +++ b/websrc/docs/swagger.json @@ -16,6 +16,84 @@ }, "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 3d655d2..5b120ab 100644 --- a/websrc/docs/swagger.yaml +++ b/websrc/docs/swagger.yaml @@ -219,6 +219,55 @@ 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: diff --git a/websrc/routes/backupRoutes.go b/websrc/routes/backupRoutes.go new file mode 100644 index 0000000..517bac6 --- /dev/null +++ b/websrc/routes/backupRoutes.go @@ -0,0 +1,130 @@ +/* +Copyright 2023 The Cloud-Barista Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package routes + +import ( + "github.com/cloud-barista/mc-data-manager/websrc/controllers" + "github.com/labstack/echo/v4" +) + +func BackupRoutes(g *echo.Group) { + // Backup URL + BackupRoot(g) + // Backup From On-premise (Linux, Windows) to Object Storage + BackupFromOnpremiseToObjectStorage(g) + + // Backup MySQL to MySQL + BackupMySQL(g) + + // Backup From Object Storage to Other Object Storage + BackupFromS3Routes(g) + BackupFromGCPRoutes(g) + BackupFromNCPRoutes(g) + + // Backup No-SQL to the other No-SQL + BackupNoSQLRoutes(g) +} + +func BackupRoot(g *echo.Group) { + g.GET("", controllers.BackupHandler) +} + +func BackupFromOnpremiseToObjectStorage(g *echo.Group) { + g.GET("/linux/s3", controllers.MigrationLinuxToS3GetHandler) + g.POST("/linux/s3", controllers.MigrationLinuxToS3PostHandler) + + g.GET("/linux/gcp", controllers.MigrationLinuxToGCPGetHandler) + g.POST("/linux/gcp", controllers.MigrationLinuxToGCPPostHandler) + + g.GET("/linux/ncp", controllers.MigrationLinuxToNCPGetHandler) + g.POST("/linux/ncp", controllers.MigrationLinuxToNCPPostHandler) + + g.GET("/windows/s3", controllers.MigrationWindowsToS3GetHandler) + g.POST("/windows/s3", controllers.MigrationWindowsToS3PostHandler) + + g.GET("/windows/gcp", controllers.MigrationWindowsToGCPGetHandler) + g.POST("/windows/gcp", controllers.MigrationWindowsToGCPPostHandler) + + g.GET("/windows/ncp", controllers.MigrationWindowsToNCPGetHandler) + g.POST("/windows/ncp", controllers.MigrationWindowsToNCPPostHandler) +} + +func BackupMySQL(g *echo.Group) { + g.GET("/mysql", controllers.MigrationMySQLGetHandler) + g.POST("/mysql", controllers.MigrationMySQLPostHandler) +} + +func BackupFromS3Routes(g *echo.Group) { + g.GET("/s3/linux", controllers.MigrationS3ToLinuxGetHandler) + g.POST("/s3/linux", controllers.MigrationS3ToLinuxPostHandler) + + g.GET("/s3/windows", controllers.MigrationS3ToWindowsGetHandler) + g.POST("/s3/windows", controllers.MigrationS3ToWindowsPostHandler) + + g.GET("/s3/gcp", controllers.MigrationS3ToGCPGetHandler) + g.POST("/s3/gcp", controllers.MigrationS3ToGCPPostHandler) + + g.GET("/s3/ncp", controllers.MigrationS3ToNCPGetHandler) + g.POST("/s3/ncp", controllers.MigrationS3ToNCPPostHandler) +} + +func BackupFromGCPRoutes(g *echo.Group) { + g.GET("/gcp/linux", controllers.MigrationGCPToLinuxGetHandler) + g.POST("/gcp/linux", controllers.MigrationGCPToLinuxPostHandler) + + g.GET("/gcp/windows", controllers.MigrationGCPToWindowsGetHandler) + g.POST("/gcp/windows", controllers.MigrationGCPToWindowsPostHandler) + + g.GET("/gcp/s3", controllers.MigrationGCPToS3GetHandler) + g.POST("/gcp/s3", controllers.MigrationGCPToS3PostHandler) + + g.GET("/gcp/ncp", controllers.MigrationGCPToNCPGetHandler) + g.POST("/gcp/ncp", controllers.MigrationGCPToNCPPostHandler) +} + +func BackupFromNCPRoutes(g *echo.Group) { + g.GET("/ncp/linux", controllers.MigrationNCPToLinuxGetHandler) + g.POST("/ncp/linux", controllers.MigrationNCPToLinuxPostHandler) + + g.GET("/ncp/windows", controllers.MigrationNCPToWindowsGetHandler) + g.POST("/ncp/windows", controllers.MigrationNCPToWindowsPostHandler) + + g.GET("/ncp/s3", controllers.MigrationNCPToS3GetHandler) + g.POST("/ncp/s3", controllers.MigrationNCPToS3PostHandler) + + g.GET("/ncp/gcp", controllers.MigrationNCPToGCPGetHandler) + g.POST("/ncp/gcp", controllers.MigrationNCPToGCPPostHandler) +} + +func BackupNoSQLRoutes(g *echo.Group) { + g.GET("/dynamodb/firestore", controllers.MigrationDynamoDBToFirestoreGetHandler) + g.POST("/dynamodb/firestore", controllers.MigrationDynamoDBToFirestorePostHandler) + + g.GET("/dynamodb/mongodb", controllers.MigrationDynamoDBToMongoDBGetHandler) + g.POST("/dynamodb/mongodb", controllers.MigrationDynamoDBToMongoDBPostHandler) + + g.GET("/firestore/dynamodb", controllers.MigrationFirestoreToDynamoDBGetHandler) + g.POST("/firestore/dynamodb", controllers.MigrationFirestoreToDynamoDBPostHandler) + + g.GET("/firestore/mongodb", controllers.MigrationFirestoreToMongoDBGetHandler) + g.POST("/firestore/mongodb", controllers.MigrationFirestoreToMongoDBPostHandler) + + g.GET("/mongodb/dynamodb", controllers.MigrationMongoDBToDynamoDBGetHandler) + g.POST("/mongodb/dynamodb", controllers.MigrationMongoDBToDynamoDBPostHandler) + + g.GET("/mongodb/firestore", controllers.MigrationMongoDBToFirestoreGetHandler) + g.POST("/mongodb/firestore", controllers.MigrationMongoDBToFirestorePostHandler) +} diff --git a/websrc/serve/serve.go b/websrc/serve/serve.go index d43d449..d24f2cb 100644 --- a/websrc/serve/serve.go +++ b/websrc/serve/serve.go @@ -129,6 +129,9 @@ func InitServer(port string, addIP ...string) *echo.Echo { e.GET("/", controllers.MainGetHandler) + backupGroup := e.Group("/backup") + routes.BackupRoutes(backupGroup) + generateGroup := e.Group("/generate") routes.GenerateRoutes(generateGroup)