mirror of
https://github.com/paralus/paralus.git
synced 2026-05-09 18:06:38 +00:00
* restructure rcloud-base as a single base controller * updated master.rest * moved sentry from internal to pkg as it is used by relay * removing unused rpc and it's dependencies * Fix usermgmt tests * Don't redefine variables in rest file Co-authored-by: Abin Simon <abin.simon@rafay.co>
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/RafaySystems/rcloud-base/pkg/service"
|
|
systemrpc "github.com/RafaySystems/rcloud-base/proto/rpc/system"
|
|
systempbv3 "github.com/RafaySystems/rcloud-base/proto/types/systempb/v3"
|
|
)
|
|
|
|
type organizationServer struct {
|
|
service.OrganizationService
|
|
}
|
|
|
|
// NewOrganizationServer returns new organization server implementation
|
|
func NewOrganizationServer(ps service.OrganizationService) systemrpc.OrganizationServer {
|
|
return &organizationServer{ps}
|
|
}
|
|
|
|
func (s *organizationServer) CreateOrganization(ctx context.Context, o *systempbv3.Organization) (*systempbv3.Organization, error) {
|
|
organization, err := s.Create(ctx, o)
|
|
if err != nil {
|
|
return o, err
|
|
}
|
|
return organization, nil
|
|
}
|
|
|
|
func (s *organizationServer) GetOrganizations(ctx context.Context, o *systempbv3.Organization) (*systempbv3.OrganizationList, error) {
|
|
organizations, err := s.List(ctx, o)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return organizations, nil
|
|
}
|
|
|
|
func (s *organizationServer) GetOrganization(ctx context.Context, o *systempbv3.Organization) (*systempbv3.Organization, error) {
|
|
|
|
organization, err := s.GetByName(ctx, o.Metadata.Name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return organization, nil
|
|
}
|
|
|
|
func (s *organizationServer) DeleteOrganization(ctx context.Context, o *systempbv3.Organization) (*systempbv3.Organization, error) {
|
|
organization, err := s.Delete(ctx, o)
|
|
if err != nil {
|
|
return o, err
|
|
}
|
|
return organization, nil
|
|
}
|
|
|
|
func (s *organizationServer) UpdateOrganization(ctx context.Context, o *systempbv3.Organization) (*systempbv3.Organization, error) {
|
|
organization, err := s.Update(ctx, o)
|
|
if err != nil {
|
|
return o, err
|
|
}
|
|
return organization, nil
|
|
}
|