-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-5023
- Loading branch information
Showing
125 changed files
with
16,266 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/rancher/go-rancher/api" | ||
|
||
"github.com/rancher/go-rancher/client" | ||
) | ||
|
||
func (s *Server) SystemBackupCreate(w http.ResponseWriter, req *http.Request) error { | ||
var input SystemBackupInput | ||
var err error | ||
|
||
apiContext := api.GetApiContext(req) | ||
if err := apiContext.Read(&input); err != nil { | ||
return err | ||
} | ||
|
||
systemBackup, err := s.m.CreateSystemBackup(input.Name) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to create SystemBackup") | ||
} | ||
|
||
apiContext.Write(toSystemBackupResource(systemBackup)) | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemBackupDelete(w http.ResponseWriter, req *http.Request) error { | ||
name := mux.Vars(req)["name"] | ||
|
||
err := s.m.DeleteSystemBackup(name) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to delete SystemBackup") | ||
} | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemBackupGet(rw http.ResponseWriter, req *http.Request) error { | ||
apiContext := api.GetApiContext(req) | ||
|
||
name := mux.Vars(req)["name"] | ||
|
||
systemBackup, err := s.m.GetSystemBackup(name) | ||
if err != nil { | ||
return errors.Wrapf(err, "error get SystemBackup '%s'", name) | ||
} | ||
apiContext.Write(toSystemBackupResource(systemBackup)) | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemBackupList(w http.ResponseWriter, req *http.Request) error { | ||
systemBackups, err := s.m.ListSystemBackupsSorted() | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to list SystemBackups") | ||
} | ||
|
||
apiContext := api.GetApiContext(req) | ||
apiContext.Write(toSystemBackupCollection(systemBackups)) | ||
return nil | ||
} | ||
|
||
func (s *Server) systemBackupList(apiContext *api.ApiContext) (*client.GenericCollection, error) { | ||
systemBackups, err := s.m.ListSystemBackupsSorted() | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "failed to list SystemBackups") | ||
} | ||
return toSystemBackupCollection(systemBackups), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/rancher/go-rancher/api" | ||
"github.com/rancher/go-rancher/client" | ||
) | ||
|
||
func (s *Server) SystemRestoreCreate(w http.ResponseWriter, req *http.Request) error { | ||
var input SystemRestoreInput | ||
var err error | ||
|
||
apiContext := api.GetApiContext(req) | ||
if err := apiContext.Read(&input); err != nil { | ||
return err | ||
} | ||
|
||
systemRestore, err := s.m.CreateSystemRestore(input.Name, input.SystemBackup) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to create SystemRestore %v", input.Name) | ||
} | ||
|
||
apiContext.Write(toSystemRestoreResource(systemRestore)) | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemRestoreDelete(w http.ResponseWriter, req *http.Request) error { | ||
name := mux.Vars(req)["name"] | ||
|
||
err := s.m.DeleteSystemRestore(name) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to delete SystemRestore %v", name) | ||
} | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemRestoreGet(rw http.ResponseWriter, req *http.Request) error { | ||
name := mux.Vars(req)["name"] | ||
systemRestore, err := s.m.GetSystemRestore(name) | ||
if err != nil { | ||
return errors.Wrapf(err, "error get SystemRestore '%s'", name) | ||
} | ||
|
||
apiContext := api.GetApiContext(req) | ||
apiContext.Write(toSystemRestoreResource(systemRestore)) | ||
return nil | ||
} | ||
|
||
func (s *Server) SystemRestoreList(w http.ResponseWriter, req *http.Request) error { | ||
systemRestores, err := s.m.ListSystemRestoresSorted() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to list SystemRestores") | ||
} | ||
|
||
apiContext := api.GetApiContext(req) | ||
apiContext.Write(toSystemRestoreCollection(systemRestores)) | ||
return nil | ||
} | ||
|
||
func (s *Server) systemRestoreList(apiContext *api.ApiContext) (*client.GenericCollection, error) { | ||
systemRestores, err := s.m.ListSystemRestoresSorted() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to list SystemRestores") | ||
} | ||
return toSystemRestoreCollection(systemRestores), nil | ||
} |
Oops, something went wrong.