From bfd968024732058cf189f93f1f2df5b011906f84 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 22 Oct 2024 16:19:32 +0530 Subject: [PATCH] pod snapshot restapi added --- cmd/dfs/cmd/server.go | 1 + cmd/dfs/cmd/server_test.go | 307 ++++++++++++++++++++++++++++++++++++- pkg/api/pod_share.go | 56 ++++++- pkg/dfs/pod_api.go | 37 ++--- pkg/pod/pod.go | 15 ++ swagger/docs.go | 137 +++++++++++++++++ swagger/swagger.json | 137 +++++++++++++++++ swagger/swagger.yaml | 92 +++++++++++ 8 files changed, 754 insertions(+), 28 deletions(-) diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index 428151e7..7e6c02a9 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -297,6 +297,7 @@ func startHttpService(logger logging.Logger) *http.Server { router.HandleFunc("/public-file", handler.PublicPodGetFileHandler) router.HandleFunc("/public-dir", handler.PublicPodGetDirHandler) router.HandleFunc("/public-kv", handler.PublicPodKVEntryGetHandler) + router.HandleFunc("/public-pod-snapshot", handler.PodReceiveSnapshotHandler).Methods("GET") redirectHandler := func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, r.URL.Path+"/", http.StatusMovedPermanently) diff --git a/cmd/dfs/cmd/server_test.go b/cmd/dfs/cmd/server_test.go index 8757683c..f333c9ea 100644 --- a/cmd/dfs/cmd/server_test.go +++ b/cmd/dfs/cmd/server_test.go @@ -17,6 +17,8 @@ import ( "testing" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/acl/acl" "github.com/stretchr/testify/assert" @@ -60,7 +62,7 @@ func TestApis(t *testing.T) { mockClient := bee.NewBeeClient(beeUrl, mock.BatchOkStr, true, 0, logger) ens := mock2.NewMockNamespaceManager() - users := user.NewUsers(mockClient, ens, 500, 0, logger) + users := user.NewUsers(mockClient, ens, -1, 0, logger) dfsApi := dfs.NewMockDfsAPI(mockClient, users, logger) handler = api.NewMockHandler(dfsApi, logger, []string{"http://localhost:3000"}) defer handler.Close() @@ -1084,6 +1086,309 @@ func TestApis(t *testing.T) { } }) + t.Run("signup-login-pod-dir-file-snapshot", func(t *testing.T) { + c := http.Client{Timeout: time.Duration(1) * time.Minute} + userRequest := &common.UserSignupRequest{ + UserName: randStringRunes(16), + Password: randStringRunes(12), + } + + userTwoRequest := &common.UserSignupRequest{ + UserName: randStringRunes(16), + Password: randStringRunes(12), + } + + userBytes, err := json.Marshal(userRequest) + if err != nil { + t.Fatal(err) + } + + userTwoBytes, err := json.Marshal(userTwoRequest) + if err != nil { + t.Fatal(err) + } + + cookies := [][]string{} + + for _, user := range [][]byte{userBytes, userTwoBytes} { + signupRequestDataHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev2, string(common.UserSignup)), bytes.NewBuffer(user)) + if err != nil { + t.Fatal(err) + } + signupRequestDataHttpReq.Header.Add("Content-Type", "application/json") + signupRequestDataHttpReq.Header.Add("Content-Length", strconv.Itoa(len(user))) + signupRequestResp, err := c.Do(signupRequestDataHttpReq) + if err != nil { + t.Fatal(err) + } + + err = signupRequestResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if signupRequestResp.StatusCode != http.StatusCreated { + t.Fatal("Signup failed", signupRequestResp.StatusCode) + } + + userLoginHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev2, string(common.UserLogin)), bytes.NewBuffer(user)) + if err != nil { + t.Fatal(err) + + } + userLoginHttpReq.Header.Add("Content-Type", "application/json") + userLoginHttpReq.Header.Add("Content-Length", strconv.Itoa(len(user))) + userLoginResp, err := c.Do(userLoginHttpReq) + if err != nil { + t.Fatal(err) + } + err = userLoginResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if userLoginResp.StatusCode != http.StatusOK { + t.Fatal("user should be able to login") + } + cookie := userLoginResp.Header["Set-Cookie"] + cookies = append(cookies, cookie) + } + + // pod new + podRequest := &common.PodRequest{ + PodName: randStringRunes(16), + } + podBytes, err := json.Marshal(podRequest) + if err != nil { + t.Fatal(err) + } + podNewHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.PodNew)), bytes.NewBuffer(podBytes)) + if err != nil { + t.Fatal(err) + } + podNewHttpReq.Header.Set("Cookie", cookies[0][0]) + podNewHttpReq.Header.Add("Content-Type", "application/json") + podNewHttpReq.Header.Add("Content-Length", strconv.Itoa(len(podBytes))) + podNewResp, err := c.Do(podNewHttpReq) + if err != nil { + t.Fatal(err) + } + + err = podNewResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if podNewResp.StatusCode != 201 { + t.Fatal("pod creation failed") + } + + entries := []struct { + path string + isDir bool + size int64 + content []byte + }{ + { + path: "/dir1", + isDir: true, + }, + { + path: "/dir2", + isDir: true, + }, + { + path: "/dir3", + isDir: true, + }, + { + path: "/file1", + size: 1024 * 1024, + }, + { + path: "/dir1/file11", + size: 1024 * 512, + }, + { + path: "/dir1/file12", + size: 1024 * 1024, + }, + { + path: "/dir3/file31", + size: 1024 * 1024, + }, + { + path: "/dir3/file32", + size: 1024 * 1024, + }, + { + path: "/dir3/file33", + size: 1024, + }, + { + path: "/dir2/dir4", + isDir: true, + }, + { + path: "/dir2/dir4/dir5", + isDir: true, + }, + { + path: "/dir2/dir4/file241", + size: 5 * 1024 * 1024, + }, + { + path: "/dir2/dir4/dir5/file2451", + size: 10 * 1024 * 1024, + }, + } + + for _, v := range entries { + if v.isDir { + mkdirRqst := common.FileSystemRequest{ + PodName: podRequest.PodName, + DirectoryPath: v.path, + } + mkDirBytes, err := json.Marshal(mkdirRqst) + if err != nil { + t.Fatal(err) + } + mkDirHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.DirMkdir)), bytes.NewBuffer(mkDirBytes)) + if err != nil { + t.Fatal(err) + + } + mkDirHttpReq.Header.Set("Cookie", cookies[0][0]) + mkDirHttpReq.Header.Add("Content-Type", "application/json") + mkDirHttpReq.Header.Add("Content-Length", strconv.Itoa(len(mkDirBytes))) + mkDirResp, err := c.Do(mkDirHttpReq) + if err != nil { + t.Fatal(err) + } + err = mkDirResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if mkDirResp.StatusCode != 201 { + t.Fatal("mkdir failed") + } + } else { + body := new(bytes.Buffer) + writer := multipart.NewWriter(body) + contentLength := fmt.Sprintf("%d", v.size) + + err = writer.WriteField("podName", podRequest.PodName) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("contentLength", contentLength) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("dirPath", filepath.Dir(v.path)) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("blockSize", "1Mb") + if err != nil { + t.Fatal(err) + } + part, err := writer.CreateFormFile("files", filepath.Base(v.path)) + if err != nil { + t.Fatal(err) + } + reader := &io.LimitedReader{R: rand.Reader, N: v.size} + _, err = io.Copy(part, reader) + if err != nil { + t.Fatal(err) + } + + err = writer.Close() + if err != nil { + t.Fatal(err) + } + + uploadReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.FileUpload)), body) + if err != nil { + t.Fatal(err) + + } + uploadReq.Header.Set("Cookie", cookies[0][0]) + contentType := fmt.Sprintf("multipart/form-data;boundary=%v", writer.Boundary()) + uploadReq.Header.Add("Content-Type", contentType) + uploadResp, err := c.Do(uploadReq) + if err != nil { + t.Fatal(err) + } + err = uploadResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if uploadResp.StatusCode != 200 { + t.Fatal("upload failed") + } + } + } + <-time.After(time.Second * 2) + podShareRequest := &common.PodShareRequest{ + PodName: podRequest.PodName, + SharedPodName: "sharedPod", + } + podShareBytes, err := json.Marshal(podShareRequest) + if err != nil { + t.Fatal(err) + } + podShareHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, "/pod/share"), bytes.NewBuffer(podShareBytes)) + if err != nil { + t.Fatal(err) + } + podShareHttpReq.Header.Set("Cookie", cookies[0][0]) + podShareHttpReq.Header.Add("Content-Type", "application/json") + podShareHttpReq.Header.Add("Content-Length", strconv.Itoa(len(podShareBytes))) + podShareResp, err := c.Do(podShareHttpReq) + if err != nil { + t.Fatal(err) + } + + podShareData := &api.PodSharingReference{} + podShareRespBytes, err := io.ReadAll(podShareResp.Body) + if err != nil { + t.Fatal(err) + } + + err = json.Unmarshal(podShareRespBytes, podShareData) + if err != nil { + t.Fatal(err) + } + err = podShareResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if podShareResp.StatusCode != 200 { + t.Fatal("pod share failed") + } + podSnapHttpReq, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s%s%s", "http://localhost:9090", "/public-pod-snapshot?sharingRef=", podShareData.Reference), http.NoBody) + if err != nil { + t.Fatal(err) + } + podSnapHttpReq.Header.Add("Content-Type", "application/json") + podSnapResp, err := c.Do(podSnapHttpReq) + if err != nil { + t.Fatal(err) + } + + data, err := io.ReadAll(podSnapResp.Body) + if err != nil { + t.Fatal(err) + } + snap := &pod.DirSnapShot{} + err = json.Unmarshal(data, snap) + if err != nil { + t.Fatal(err) + } + err = podSnapResp.Body.Close() + if err != nil { + t.Fatal(err) + } + }) + t.Run("group-test", func(t *testing.T) { c := http.Client{Timeout: time.Duration(1) * time.Minute} userRequest := &common.UserSignupRequest{ diff --git a/pkg/api/pod_share.go b/pkg/api/pod_share.go index c423181b..5e480f81 100644 --- a/pkg/api/pod_share.go +++ b/pkg/api/pod_share.go @@ -21,10 +21,8 @@ import ( "fmt" "net/http" - "github.com/fairdatasociety/fairOS-dfs/pkg/auth" - "github.com/fairdatasociety/fairOS-dfs/cmd/common" - + "github.com/fairdatasociety/fairOS-dfs/pkg/auth" "github.com/fairdatasociety/fairOS-dfs/pkg/dfs" p "github.com/fairdatasociety/fairOS-dfs/pkg/pod" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -172,6 +170,58 @@ func (h *Handler) PodReceiveInfoHandler(w http.ResponseWriter, r *http.Request) jsonhttp.OK(w, shareInfo) } +// PodReceiveSnapshotHandler godoc +// +// @Summary Receive shared pod snapshot +// @Description PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference +// @ID pod-receive-snapshot-handler +// @Tags pod +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param Cookie header string true "cookie parameter" +// @Success 200 {object} pod.DirSnapShot +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /v1/pod/snapshot [get] +func (h *Handler) PodReceiveSnapshotHandler(w http.ResponseWriter, r *http.Request) { + + sharingRefString := r.URL.Query().Get("sharingRef") + if sharingRefString == "" { + h.logger.Errorf("pod receive snapshot: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "pod receive snapshot: \"sharingRef\" argument missing") + return + } + + path := r.URL.Query().Get("path") + if path == "" { + path = "/" + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("pod receive snapshot: invalid reference: %s", err) + jsonhttp.BadRequest(w, "pod receive snapshot: invalid reference:"+err.Error()) + return + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("pod receive snapshot: %v", err) + jsonhttp.InternalServerError(w, "pod receive snapshot: "+err.Error()) + return + } + snapshot, err := h.dfsAPI.PublicPodSnapshot(shareInfo, path) + if err != nil { + h.logger.Errorf("pod receive snapshot: %v", err) + jsonhttp.InternalServerError(w, "pod receive snapshot: "+err.Error()) + return + } + + w.Header().Set("Content-Type", " application/json") + jsonhttp.OK(w, snapshot) +} + // PodReceiveHandler godoc // // @Summary Receive shared pod diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index ddcbe89a..57fce41f 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -565,27 +565,14 @@ func (a *API) PublicPodDisLs(pod *pod.ShareInfo, dirPathToLs string) ([]dir.Entr return listEntries, fileEntries, nil } -type DirSnapShot struct { - Name string `json:"name"` - ContentType string `json:"contentType"` - Size string `json:"size,omitempty"` - Mode uint32 `json:"mode"` - BlockSize string `json:"blockSize,omitempty"` - CreationTime string `json:"creationTime"` - ModificationTime string `json:"modificationTime"` - AccessTime string `json:"accessTime"` - FileList []file.MetaData `json:"fileList"` - DirList []*DirSnapShot `json:"dirList"` -} - // PublicPodSnapshot Gets the current snapshot from a public pod -func (a *API) PublicPodSnapshot(pod *pod.ShareInfo, dirPathToLs string) (*DirSnapShot, error) { +func (a *API) PublicPodSnapshot(p *pod.ShareInfo, dirPathToLs string) (*pod.DirSnapShot, error) { accountInfo := &account.Info{} - address := utils.HexToAddress(pod.Address) + address := utils.HexToAddress(p.Address) accountInfo.SetAddress(address) - dirSnapShot := &DirSnapShot{ + dirSnapShot := &pod.DirSnapShot{ FileList: make([]file.MetaData, 0), - DirList: make([]*DirSnapShot, 0), + DirList: make([]*pod.DirSnapShot, 0), } fd := feed.New(accountInfo, a.client, a.feedCacheSize, a.feedCacheTTL, a.logger) @@ -594,14 +581,16 @@ func (a *API) PublicPodSnapshot(pod *pod.ShareInfo, dirPathToLs string) (*DirSna inode dir.Inode data []byte ) + fmt.Println("dirNameWithPath", dirNameWithPath) topic := utils.HashString(utils.CombinePathAndFile(dirNameWithPath, dir.IndexFileName)) - _, metaBytes, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) + _, metaBytes, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(p.Password), false) if err != nil { // skipcq: TCV-001 + fmt.Println("err", err) topic = utils.HashString(dirNameWithPath) - _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) + _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(p.Password), false) if err != nil { - return nil, fmt.Errorf("list dir : %v", err) // skipcq: TCV-001 + return nil, fmt.Errorf("list dir : %v for %s", err, dirNameWithPath) // skipcq: TCV-001 } err = inode.Unmarshal(data) if err != nil { // skipcq: TCV-001 @@ -644,14 +633,14 @@ func (a *API) PublicPodSnapshot(pod *pod.ShareInfo, dirPathToLs string) (*DirSna dirSnapShot.AccessTime = strconv.FormatInt(inode.Meta.AccessTime, 10) dirSnapShot.ModificationTime = strconv.FormatInt(inode.Meta.ModificationTime, 10) dirSnapShot.Mode = inode.Meta.Mode - err = a.getSnapShotForDir(dirSnapShot, fd, accountInfo, inode.FileOrDirNames, dirNameWithPath, pod.Password) + err = a.getSnapShotForDir(dirSnapShot, fd, accountInfo, inode.FileOrDirNames, dirNameWithPath, p.Password) if err != nil { return nil, err } return dirSnapShot, nil } -func (a *API) getSnapShotForDir(dirL *DirSnapShot, fd *feed.API, accountInfo *account.Info, fileOrDirNames []string, dirNameWithPath, password string) error { +func (a *API) getSnapShotForDir(dirL *pod.DirSnapShot, fd *feed.API, accountInfo *account.Info, fileOrDirNames []string, dirNameWithPath, password string) error { var wg sync.WaitGroup dirChan := make(chan dir.Inode, len(fileOrDirNames)) fileChan := make(chan file.MetaData, len(fileOrDirNames)) @@ -764,14 +753,14 @@ func (a *API) getSnapShotForDir(dirL *DirSnapShot, fd *feed.API, accountInfo *ac case inode, ok := <-dirChan: if ok { - dirItem := &DirSnapShot{ + dirItem := &pod.DirSnapShot{ Name: inode.Meta.Name, ContentType: dir.MimeTypeDirectory, CreationTime: strconv.FormatInt(inode.Meta.CreationTime, 10), AccessTime: strconv.FormatInt(inode.Meta.AccessTime, 10), ModificationTime: strconv.FormatInt(inode.Meta.ModificationTime, 10), Mode: inode.Meta.Mode, - DirList: make([]*DirSnapShot, 0), + DirList: make([]*pod.DirSnapShot, 0), FileList: make([]file.MetaData, 0), } dirL.DirList = append(dirL.DirList, dirItem) diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 1eb69813..2cede24f 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -21,6 +21,8 @@ import ( "sync" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/file" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" "github.com/fairdatasociety/fairOS-dfs/pkg/account" @@ -71,6 +73,19 @@ type List struct { SharedPods []SharedListItem `json:"sharedPods"` } +type DirSnapShot struct { + Name string `json:"name"` + ContentType string `json:"contentType"` + Size string `json:"size,omitempty"` + Mode uint32 `json:"mode"` + BlockSize string `json:"blockSize,omitempty"` + CreationTime string `json:"creationTime"` + ModificationTime string `json:"modificationTime"` + AccessTime string `json:"accessTime"` + FileList []file.MetaData `json:"fileList"` + DirList []*DirSnapShot `json:"dirList"` +} + // NewPod creates the main pod object which has all the methods related to the pods. func NewPod(client blockstore.Client, feed *feed.API, account *account.Account, m taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, feedCacheSize int, feedCacheTTL time.Duration, logger logging.Logger) *Pod { return &Pod{ diff --git a/swagger/docs.go b/swagger/docs.go index 8cfa54d8..e4b32007 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -4136,6 +4136,58 @@ const docTemplate = `{ } } }, + "/v1/pod/snapshot": { + "get": { + "description": "PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Receive shared pod snapshot", + "operationId": "pod-receive-snapshot-handler", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/stat": { "get": { "description": "PodStatHandler is the api handler get information about a pod", @@ -5479,6 +5531,50 @@ const docTemplate = `{ } } }, + "file.MetaData": { + "type": "object", + "properties": { + "accessTime": { + "type": "integer" + }, + "blockSize": { + "type": "integer" + }, + "compression": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "integer" + }, + "fileInodeReference": { + "type": "array", + "items": { + "type": "integer" + } + }, + "fileName": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "fileSize": { + "type": "integer" + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "integer" + }, + "version": { + "type": "integer" + } + } + }, "file.Stats": { "type": "object", "properties": { @@ -5517,6 +5613,47 @@ const docTemplate = `{ } } }, + "pod.DirSnapShot": { + "type": "object", + "properties": { + "accessTime": { + "type": "string" + }, + "blockSize": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "string" + }, + "dirList": { + "type": "array", + "items": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "fileList": { + "type": "array", + "items": { + "$ref": "#/definitions/file.MetaData" + } + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "string" + }, + "name": { + "type": "string" + }, + "size": { + "type": "string" + } + } + }, "pod.GroupItem": { "type": "object", "properties": { diff --git a/swagger/swagger.json b/swagger/swagger.json index 27c8d132..1356cf46 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -4127,6 +4127,58 @@ } } }, + "/v1/pod/snapshot": { + "get": { + "description": "PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Receive shared pod snapshot", + "operationId": "pod-receive-snapshot-handler", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/stat": { "get": { "description": "PodStatHandler is the api handler get information about a pod", @@ -5470,6 +5522,50 @@ } } }, + "file.MetaData": { + "type": "object", + "properties": { + "accessTime": { + "type": "integer" + }, + "blockSize": { + "type": "integer" + }, + "compression": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "integer" + }, + "fileInodeReference": { + "type": "array", + "items": { + "type": "integer" + } + }, + "fileName": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "fileSize": { + "type": "integer" + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "integer" + }, + "version": { + "type": "integer" + } + } + }, "file.Stats": { "type": "object", "properties": { @@ -5508,6 +5604,47 @@ } } }, + "pod.DirSnapShot": { + "type": "object", + "properties": { + "accessTime": { + "type": "string" + }, + "blockSize": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "string" + }, + "dirList": { + "type": "array", + "items": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "fileList": { + "type": "array", + "items": { + "$ref": "#/definitions/file.MetaData" + } + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "string" + }, + "name": { + "type": "string" + }, + "size": { + "type": "string" + } + } + }, "pod.GroupItem": { "type": "object", "properties": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 6097909c..5c7b77dc 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -488,6 +488,35 @@ definitions: size: type: string type: object + file.MetaData: + properties: + accessTime: + type: integer + blockSize: + type: integer + compression: + type: string + contentType: + type: string + creationTime: + type: integer + fileInodeReference: + items: + type: integer + type: array + fileName: + type: string + filePath: + type: string + fileSize: + type: integer + mode: + type: integer + modificationTime: + type: integer + version: + type: integer + type: object file.Stats: properties: accessTime: @@ -513,6 +542,33 @@ definitions: podName: type: string type: object + pod.DirSnapShot: + properties: + accessTime: + type: string + blockSize: + type: string + contentType: + type: string + creationTime: + type: string + dirList: + items: + $ref: '#/definitions/pod.DirSnapShot' + type: array + fileList: + items: + $ref: '#/definitions/file.MetaData' + type: array + mode: + type: integer + modificationTime: + type: string + name: + type: string + size: + type: string + type: object pod.GroupItem: properties: name: @@ -3391,6 +3447,42 @@ paths: summary: Share pod tags: - pod + /v1/pod/snapshot: + get: + consumes: + - application/json + description: PodReceiveSnapshotHandler is the api handler to receive shared + pod snapshot from shared reference + operationId: pod-receive-snapshot-handler + parameters: + - description: pod sharing reference + in: query + name: sharingRef + required: true + type: string + - description: cookie parameter + in: header + name: Cookie + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/pod.DirSnapShot' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: Receive shared pod snapshot + tags: + - pod /v1/pod/stat: get: consumes: