This is an automated email from the ASF dual-hosted git repository. miaoliyao pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git
The following commit(s) were added to refs/heads/main by this push: new 047e5d6 feat(pitr): agent server api output (#218) 047e5d6 is described below commit 047e5d6e97093d57d5389a96895424ef4d595eda Author: lltgo <llt.git...@outlook.com> AuthorDate: Tue Feb 21 19:06:19 2023 +0800 feat(pitr): agent server api output (#218) --- pitr/agent/internal/cons/error.go | 1 + pitr/agent/internal/handler/view/backup.go | 29 ++++++++++++++++++-------- pitr/agent/internal/handler/view/restore.go | 5 +++++ pitr/agent/internal/handler/view/show.go | 32 +++++++++++++++++++++-------- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/pitr/agent/internal/cons/error.go b/pitr/agent/internal/cons/error.go index d3969c6..cf9ef6a 100644 --- a/pitr/agent/internal/cons/error.go +++ b/pitr/agent/internal/cons/error.go @@ -43,4 +43,5 @@ var ( MissingInstance = xerror.New(10018, "Missing instance.") MissingDnBackupId = xerror.New(10019, "Missing dn backup id.") BodyParseFailed = xerror.New(10020, "Invalid http request body.") + MissingDbName = xerror.New(10021, "Missing db name.") ) diff --git a/pitr/agent/internal/handler/view/backup.go b/pitr/agent/internal/handler/view/backup.go index d379e79..9ab7e21 100644 --- a/pitr/agent/internal/handler/view/backup.go +++ b/pitr/agent/internal/handler/view/backup.go @@ -19,15 +19,22 @@ package view import "github.com/apache/shardingsphere-on-cloud/pitr/agent/internal/cons" -type BackupIn struct { - DbPort uint16 `json:"db_port"` - Username string `json:"username"` - Password string `json:"password"` - DnBackupPath string `json:"dn_backup_path"` - DnThreadsNum uint8 `json:"dn_threads_num"` - DnBackupMode string `json:"dn_backup_mode"` - Instance string `json:"instance"` -} +type ( + BackupIn struct { + DbPort uint16 `json:"db_port"` + DbName string `json:"db_name"` + Username string `json:"username"` + Password string `json:"password"` + DnBackupPath string `json:"dn_backup_path"` + DnThreadsNum uint8 `json:"dn_threads_num"` + DnBackupMode string `json:"dn_backup_mode"` + Instance string `json:"instance"` + } + + BackupOut struct { + ID string `json:"backup_id"` + } +) func (in *BackupIn) Validate() error { if in == nil { @@ -38,6 +45,10 @@ func (in *BackupIn) Validate() error { return cons.InvalidDbPort } + if in.DbName == "" { + return cons.MissingDbName + } + if in.Username == "" { return cons.MissingUsername } diff --git a/pitr/agent/internal/handler/view/restore.go b/pitr/agent/internal/handler/view/restore.go index 75d3ba5..632db61 100644 --- a/pitr/agent/internal/handler/view/restore.go +++ b/pitr/agent/internal/handler/view/restore.go @@ -21,6 +21,7 @@ import "github.com/apache/shardingsphere-on-cloud/pitr/agent/internal/cons" type RestoreIn struct { DbPort uint16 `json:"db_port"` + DbName string `json:"db_name"` Username string `json:"username"` Password string `json:"password"` Instance string `json:"instance"` @@ -37,6 +38,10 @@ func (in *RestoreIn) Validate() error { return cons.InvalidDbPort } + if in.DbName == "" { + return cons.MissingDbName + } + if in.Username == "" { return cons.MissingUsername } diff --git a/pitr/agent/internal/handler/view/show.go b/pitr/agent/internal/handler/view/show.go index 5551187..5952bce 100644 --- a/pitr/agent/internal/handler/view/show.go +++ b/pitr/agent/internal/handler/view/show.go @@ -19,14 +19,26 @@ package view import "github.com/apache/shardingsphere-on-cloud/pitr/agent/internal/cons" -type ShowIn struct { - DbPort uint16 `json:"db_port"` - Username string `json:"username"` - Password string `json:"password"` - DnBackupId string `json:"dn_backup_id"` - DnBackupPath string `json:"dn_backup_path"` - Instance string `json:"instance"` -} +type ( + ShowIn struct { + DbPort uint16 `json:"db_port"` + DbName string `json:"db_name"` + Username string `json:"username"` + Password string `json:"password"` + DnBackupId string `json:"dn_backup_id"` + DnBackupPath string `json:"dn_backup_path"` + Instance string `json:"instance"` + } + + BackupInfo struct { + Id string `json:"dn_backup_id"` + Path string `json:"dn_backup_path"` + Instance string `json:"instance"` + StartTime string `json:"start_time"` + EndTime string `json:"end_time"` + Status string `json:"status"` + } +) func (in *ShowIn) Validate() error { if in == nil { @@ -37,6 +49,10 @@ func (in *ShowIn) Validate() error { return cons.InvalidDbPort } + if in.DbName == "" { + return cons.MissingDbName + } + if in.Username == "" { return cons.MissingUsername }