50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package validator_controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.itzana.me/strafesnet/go-grpc/validator"
|
|
"git.itzana.me/strafesnet/maps-service/pkg/service"
|
|
)
|
|
|
|
type Operations struct {
|
|
*validator.UnimplementedValidatorOperationServiceServer
|
|
inner *service.Service
|
|
}
|
|
func NewOperationsController(
|
|
inner *service.Service,
|
|
) Operations {
|
|
return Operations{
|
|
inner: inner,
|
|
}
|
|
}
|
|
|
|
func (svc *Operations) Success(ctx context.Context, params *validator.OperationSuccessRequest) (*validator.NullResponse, error) {
|
|
success_params := service.NewOperationCompleteParams(
|
|
params.Path,
|
|
)
|
|
err := svc.inner.CompleteOperation(ctx, int32(params.OperationID), success_params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &validator.NullResponse{}, nil
|
|
}
|
|
|
|
// ActionOperationFailed implements actionOperationFailed operation.
|
|
//
|
|
// Fail the specified OperationID with a StatusMessage.
|
|
//
|
|
// POST /operations/{OperationID}/status/operation-failed
|
|
func (svc *Operations) Fail(ctx context.Context, params *validator.OperationFailRequest) (*validator.NullResponse, error) {
|
|
fail_params := service.NewOperationFailParams(
|
|
params.StatusMessage,
|
|
)
|
|
err := svc.inner.FailOperation(ctx, int32(params.OperationID), fail_params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &validator.NullResponse{}, nil
|
|
}
|