Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement API endpoints #6915

Prev Previous commit
Next Next commit
DELETE /instance implementation
feloy committed Jun 25, 2023
commit ef96c2afed261cbede5f2203154adb60d43cc173
19 changes: 10 additions & 9 deletions pkg/apiserver-impl/api_default_service.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package apiserver_impl
import (
"context"
"errors"
"fmt"
"net/http"

openapi "github.com/redhat-developer/odo/pkg/apiserver-gen/go"
@@ -13,11 +14,14 @@ import (
// This service should implement the business logic for every endpoint for the DefaultApi API.
// Include any external packages or services that will be required by this service.
type DefaultApiService struct {
cancel context.CancelFunc
}

// NewDefaultApiService creates a default api service
func NewDefaultApiService() openapi.DefaultApiServicer {
return &DefaultApiService{}
func NewDefaultApiService(cancel context.CancelFunc) openapi.DefaultApiServicer {
return &DefaultApiService{
cancel: cancel,
}
}

// ComponentCommandPost -
@@ -44,13 +48,10 @@ func (s *DefaultApiService) ComponentGet(ctx context.Context) (openapi.ImplRespo

// InstanceDelete -
func (s *DefaultApiService) InstanceDelete(ctx context.Context) (openapi.ImplResponse, error) {
// TODO - update InstanceDelete with the required logic for this service method.
// Add api_default_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.

// TODO: Uncomment the next line to return response Response(200, GeneralSuccess{}) or use other options such as http.Ok ...
// return Response(200, GeneralSuccess{}), nil

return openapi.Response(http.StatusNotImplemented, nil), errors.New("InstanceDelete method not implemented")
s.cancel()
return openapi.Response(http.StatusOK, openapi.GeneralSuccess{
Message: fmt.Sprintf("'odo dev' instance with pid: %d is shuting down.", odocontext.GetPID(ctx)),
}), nil
}

// InstanceGet -
2 changes: 1 addition & 1 deletion pkg/apiserver-impl/starterserver.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (

func StartServer(ctx context.Context, cancelFunc context.CancelFunc, port int, stateClient state.Client) {

defaultApiService := NewDefaultApiService()
defaultApiService := NewDefaultApiService(cancelFunc)
defaultApiController := openapi.NewDefaultApiController(defaultApiService)

router := openapi.NewRouter(defaultApiController)