diff options
author | Rajamohan Raj <rajamohan.raj@intel.com> | 2020-07-16 23:12:57 +0000 |
---|---|---|
committer | Rajamohan Raj <rajamohan.raj@intel.com> | 2020-07-16 23:15:29 +0000 |
commit | 7e1ac3352cac761fe4e6052a6770d8bd77cdf046 (patch) | |
tree | 38911f1e25c51a2e021f61437ab5a62037545d20 /src/orchestrator/pkg/module/project.go | |
parent | ad02ea4b31bc3a8e32c72f4a2905bfe94194ae33 (diff) |
Implement GetAll projects handler
In this patch implement the route: /v2/projects.
Issue-ID: MULTICLOUD-1126
Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com>
Change-Id: Ia38aa560a74c26b8528d6bd579038c1b80b4d3c9
Diffstat (limited to 'src/orchestrator/pkg/module/project.go')
-rw-r--r-- | src/orchestrator/pkg/module/project.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/module/project.go b/src/orchestrator/pkg/module/project.go index a6f59254..02f6d827 100644 --- a/src/orchestrator/pkg/module/project.go +++ b/src/orchestrator/pkg/module/project.go @@ -58,6 +58,7 @@ type ProjectManager interface { CreateProject(pr Project) (Project, error) GetProject(name string) (Project, error) DeleteProject(name string) error + GetAllProjects() ([]Project, error) } // ProjectClient implements the ProjectManager @@ -123,6 +124,29 @@ func (v *ProjectClient) GetProject(name string) (Project, error) { return Project{}, pkgerrors.New("Error getting Project") } +// GetAllProjects returns all the projects +func (v *ProjectClient) GetAllProjects() ([]Project, error) { + key := ProjectKey{ + ProjectName: "", + } + + var res []Project + values, err := db.DBconn.Find(v.storeName, key, v.tagMeta) + if err != nil { + + } + + for _, value := range values { + p := Project{} + err = db.DBconn.Unmarshal(value, &p) + if err != nil { + return []Project{}, pkgerrors.Wrap(err, "Unmarshaling Project") + } + res = append(res, p) + } + return res, nil +} + // DeleteProject the Project from database func (v *ProjectClient) DeleteProject(name string) error { |