50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package v1
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.badhouseplants.net/softplayer/softplayer-backend/internal/controllers"
|
|
proto "git.badhouseplants.net/softplayer/softplayer-go-proto/pkg/environments"
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
)
|
|
|
|
func NewapiGrpcImpl() *EnvironmentsServer {
|
|
return &EnvironmentsServer{}
|
|
}
|
|
|
|
type EnvironmentsServer struct {
|
|
proto.UnimplementedEnvironmentsServer
|
|
}
|
|
|
|
func (e *EnvironmentsServer) Create(ctx context.Context, in *proto.EnvironmentData) (*proto.EnvironmentFull, error) {
|
|
data := &controllers.EnvironemntData{
|
|
Name: in.GetName(),
|
|
Provider: in.GetProvider().String(),
|
|
}
|
|
environment := &controllers.Environemnt{
|
|
Controller: nil,
|
|
Data: data,
|
|
}
|
|
err := environment.Create(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (e *EnvironmentsServer) Update(ctx context.Context, in *proto.EnvironmentFull) (*proto.EnvironmentFull, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (e *EnvironmentsServer) Delete(ctx context.Context, in *proto.EnvironmentFull) (*empty.Empty, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (e *EnvironmentsServer) Get(ctx context.Context, in *proto.EnvironmentId) (*proto.EnvironmentFull, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (e *EnvironmentsServer) List(in *empty.Empty, stream proto.Environments_ListServer) error {
|
|
return nil
|
|
}
|