diff --git a/pkg/apiserver-gen/.openapi-generator-ignore b/pkg/apiserver-gen/.openapi-generator-ignore index 7484ee590..bcdd67860 100644 --- a/pkg/apiserver-gen/.openapi-generator-ignore +++ b/pkg/apiserver-gen/.openapi-generator-ignore @@ -21,3 +21,6 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md + +go/routers.go +go/logger.go diff --git a/pkg/apiserver-gen/.openapi-generator/FILES b/pkg/apiserver-gen/.openapi-generator/FILES index 5d0ca3e0b..81077ed00 100644 --- a/pkg/apiserver-gen/.openapi-generator/FILES +++ b/pkg/apiserver-gen/.openapi-generator/FILES @@ -2,10 +2,10 @@ README.md api/openapi.yaml go/api.go go/api_default.go +go/api_devstate.go go/error.go go/helpers.go go/impl.go -go/logger.go go/model__component_command_post_request.go go/model__component_get_200_response.go go/model__devfile_get_200_response.go @@ -38,4 +38,3 @@ go/model_metadata.go go/model_metadata_request.go go/model_resource.go go/model_telemetry_response.go -go/routers.go diff --git a/pkg/apiserver-gen/go/api.go b/pkg/apiserver-gen/go/api.go index 1bbd1f972..222258018 100644 --- a/pkg/apiserver-gen/go/api.go +++ b/pkg/apiserver-gen/go/api.go @@ -22,6 +22,15 @@ type DefaultApiRouter interface { ComponentGet(http.ResponseWriter, *http.Request) DevfileGet(http.ResponseWriter, *http.Request) DevfilePut(http.ResponseWriter, *http.Request) + InstanceDelete(http.ResponseWriter, *http.Request) + InstanceGet(http.ResponseWriter, *http.Request) + TelemetryGet(http.ResponseWriter, *http.Request) +} + +// DevstateApiRouter defines the required methods for binding the api requests to a responses for the DevstateApi +// The DevstateApiRouter implementation should parse necessary information from the http request, +// pass the data to a DevstateApiServicer to perform the required actions, then write the service results to the http response. +type DevstateApiRouter interface { DevstateApplyCommandPost(http.ResponseWriter, *http.Request) DevstateChartGet(http.ResponseWriter, *http.Request) DevstateCommandCommandNameDelete(http.ResponseWriter, *http.Request) @@ -42,9 +51,6 @@ type DefaultApiRouter interface { DevstateQuantityValidPost(http.ResponseWriter, *http.Request) DevstateResourcePost(http.ResponseWriter, *http.Request) DevstateResourceResourceNameDelete(http.ResponseWriter, *http.Request) - InstanceDelete(http.ResponseWriter, *http.Request) - InstanceGet(http.ResponseWriter, *http.Request) - TelemetryGet(http.ResponseWriter, *http.Request) } // DefaultApiServicer defines the api actions for the DefaultApi service @@ -56,6 +62,16 @@ type DefaultApiServicer interface { ComponentGet(context.Context) (ImplResponse, error) DevfileGet(context.Context) (ImplResponse, error) DevfilePut(context.Context, DevfilePutRequest) (ImplResponse, error) + InstanceDelete(context.Context) (ImplResponse, error) + InstanceGet(context.Context) (ImplResponse, error) + TelemetryGet(context.Context) (ImplResponse, error) +} + +// DevstateApiServicer defines the api actions for the DevstateApi service +// This interface intended to stay up to date with the openapi yaml used to generate it, +// while the service implementation can be ignored with the .openapi-generator-ignore file +// and updated with the logic required for the API. +type DevstateApiServicer interface { DevstateApplyCommandPost(context.Context, DevstateApplyCommandPostRequest) (ImplResponse, error) DevstateChartGet(context.Context) (ImplResponse, error) DevstateCommandCommandNameDelete(context.Context, string) (ImplResponse, error) @@ -76,7 +92,4 @@ type DefaultApiServicer interface { DevstateQuantityValidPost(context.Context, DevstateQuantityValidPostRequest) (ImplResponse, error) DevstateResourcePost(context.Context, DevstateResourcePostRequest) (ImplResponse, error) DevstateResourceResourceNameDelete(context.Context, string) (ImplResponse, error) - InstanceDelete(context.Context) (ImplResponse, error) - InstanceGet(context.Context) (ImplResponse, error) - TelemetryGet(context.Context) (ImplResponse, error) } diff --git a/pkg/apiserver-gen/go/api_default.go b/pkg/apiserver-gen/go/api_default.go index 4e57c9f51..fe6f81cab 100644 --- a/pkg/apiserver-gen/go/api_default.go +++ b/pkg/apiserver-gen/go/api_default.go @@ -13,8 +13,6 @@ import ( "encoding/json" "net/http" "strings" - - "github.com/gorilla/mux" ) // DefaultApiController binds http requests to an api service and writes the service results to the http response @@ -74,126 +72,6 @@ func (c *DefaultApiController) Routes() Routes { "/api/v1/devfile", c.DevfilePut, }, - { - "DevstateApplyCommandPost", - strings.ToUpper("Post"), - "/api/v1/devstate/applyCommand", - c.DevstateApplyCommandPost, - }, - { - "DevstateChartGet", - strings.ToUpper("Get"), - "/api/v1/devstate/chart", - c.DevstateChartGet, - }, - { - "DevstateCommandCommandNameDelete", - strings.ToUpper("Delete"), - "/api/v1/devstate/command/{commandName}", - c.DevstateCommandCommandNameDelete, - }, - { - "DevstateCommandCommandNameMovePost", - strings.ToUpper("Post"), - "/api/v1/devstate/command/{commandName}/move", - c.DevstateCommandCommandNameMovePost, - }, - { - "DevstateCommandCommandNameSetDefaultPost", - strings.ToUpper("Post"), - "/api/v1/devstate/command/{commandName}/setDefault", - c.DevstateCommandCommandNameSetDefaultPost, - }, - { - "DevstateCommandCommandNameUnsetDefaultPost", - strings.ToUpper("Post"), - "/api/v1/devstate/command/{commandName}/unsetDefault", - c.DevstateCommandCommandNameUnsetDefaultPost, - }, - { - "DevstateCompositeCommandPost", - strings.ToUpper("Post"), - "/api/v1/devstate/compositeCommand", - c.DevstateCompositeCommandPost, - }, - { - "DevstateContainerContainerNameDelete", - strings.ToUpper("Delete"), - "/api/v1/devstate/container/{containerName}", - c.DevstateContainerContainerNameDelete, - }, - { - "DevstateContainerPost", - strings.ToUpper("Post"), - "/api/v1/devstate/container", - c.DevstateContainerPost, - }, - { - "DevstateDevfileDelete", - strings.ToUpper("Delete"), - "/api/v1/devstate/devfile", - c.DevstateDevfileDelete, - }, - { - "DevstateDevfileGet", - strings.ToUpper("Get"), - "/api/v1/devstate/devfile", - c.DevstateDevfileGet, - }, - { - "DevstateDevfilePut", - strings.ToUpper("Put"), - "/api/v1/devstate/devfile", - c.DevstateDevfilePut, - }, - { - "DevstateEventsPut", - strings.ToUpper("Put"), - "/api/v1/devstate/events", - c.DevstateEventsPut, - }, - { - "DevstateExecCommandPost", - strings.ToUpper("Post"), - "/api/v1/devstate/execCommand", - c.DevstateExecCommandPost, - }, - { - "DevstateImageImageNameDelete", - strings.ToUpper("Delete"), - "/api/v1/devstate/image/{imageName}", - c.DevstateImageImageNameDelete, - }, - { - "DevstateImagePost", - strings.ToUpper("Post"), - "/api/v1/devstate/image", - c.DevstateImagePost, - }, - { - "DevstateMetadataPut", - strings.ToUpper("Put"), - "/api/v1/devstate/metadata", - c.DevstateMetadataPut, - }, - { - "DevstateQuantityValidPost", - strings.ToUpper("Post"), - "/api/v1/devstate/quantityValid", - c.DevstateQuantityValidPost, - }, - { - "DevstateResourcePost", - strings.ToUpper("Post"), - "/api/v1/devstate/resource", - c.DevstateResourcePost, - }, - { - "DevstateResourceResourceNameDelete", - strings.ToUpper("Delete"), - "/api/v1/devstate/resource/{resourceName}", - c.DevstateResourceResourceNameDelete, - }, { "InstanceDelete", strings.ToUpper("Delete"), @@ -289,412 +167,6 @@ func (c *DefaultApiController) DevfilePut(w http.ResponseWriter, r *http.Request } -// DevstateApplyCommandPost - -func (c *DefaultApiController) DevstateApplyCommandPost(w http.ResponseWriter, r *http.Request) { - devstateApplyCommandPostRequestParam := DevstateApplyCommandPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateApplyCommandPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateApplyCommandPostRequestRequired(devstateApplyCommandPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateApplyCommandPost(r.Context(), devstateApplyCommandPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateChartGet - -func (c *DefaultApiController) DevstateChartGet(w http.ResponseWriter, r *http.Request) { - result, err := c.service.DevstateChartGet(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateCommandCommandNameDelete - -func (c *DefaultApiController) DevstateCommandCommandNameDelete(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - commandNameParam := params["commandName"] - result, err := c.service.DevstateCommandCommandNameDelete(r.Context(), commandNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateCommandCommandNameMovePost - -func (c *DefaultApiController) DevstateCommandCommandNameMovePost(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - commandNameParam := params["commandName"] - devstateCommandCommandNameMovePostRequestParam := DevstateCommandCommandNameMovePostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateCommandCommandNameMovePostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateCommandCommandNameMovePostRequestRequired(devstateCommandCommandNameMovePostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateCommandCommandNameMovePost(r.Context(), commandNameParam, devstateCommandCommandNameMovePostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateCommandCommandNameSetDefaultPost - -func (c *DefaultApiController) DevstateCommandCommandNameSetDefaultPost(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - commandNameParam := params["commandName"] - devstateCommandCommandNameSetDefaultPostRequestParam := DevstateCommandCommandNameSetDefaultPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateCommandCommandNameSetDefaultPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateCommandCommandNameSetDefaultPostRequestRequired(devstateCommandCommandNameSetDefaultPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateCommandCommandNameSetDefaultPost(r.Context(), commandNameParam, devstateCommandCommandNameSetDefaultPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateCommandCommandNameUnsetDefaultPost - -func (c *DefaultApiController) DevstateCommandCommandNameUnsetDefaultPost(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - commandNameParam := params["commandName"] - result, err := c.service.DevstateCommandCommandNameUnsetDefaultPost(r.Context(), commandNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateCompositeCommandPost - -func (c *DefaultApiController) DevstateCompositeCommandPost(w http.ResponseWriter, r *http.Request) { - devstateCompositeCommandPostRequestParam := DevstateCompositeCommandPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateCompositeCommandPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateCompositeCommandPostRequestRequired(devstateCompositeCommandPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateCompositeCommandPost(r.Context(), devstateCompositeCommandPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateContainerContainerNameDelete - -func (c *DefaultApiController) DevstateContainerContainerNameDelete(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - containerNameParam := params["containerName"] - result, err := c.service.DevstateContainerContainerNameDelete(r.Context(), containerNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateContainerPost - -func (c *DefaultApiController) DevstateContainerPost(w http.ResponseWriter, r *http.Request) { - devstateContainerPostRequestParam := DevstateContainerPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateContainerPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateContainerPostRequestRequired(devstateContainerPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateContainerPost(r.Context(), devstateContainerPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateDevfileDelete - -func (c *DefaultApiController) DevstateDevfileDelete(w http.ResponseWriter, r *http.Request) { - result, err := c.service.DevstateDevfileDelete(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateDevfileGet - -func (c *DefaultApiController) DevstateDevfileGet(w http.ResponseWriter, r *http.Request) { - result, err := c.service.DevstateDevfileGet(r.Context()) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateDevfilePut - -func (c *DefaultApiController) DevstateDevfilePut(w http.ResponseWriter, r *http.Request) { - devstateDevfilePutRequestParam := DevstateDevfilePutRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateDevfilePutRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateDevfilePutRequestRequired(devstateDevfilePutRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateDevfilePut(r.Context(), devstateDevfilePutRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateEventsPut - -func (c *DefaultApiController) DevstateEventsPut(w http.ResponseWriter, r *http.Request) { - devstateEventsPutRequestParam := DevstateEventsPutRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateEventsPutRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateEventsPutRequestRequired(devstateEventsPutRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateEventsPut(r.Context(), devstateEventsPutRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateExecCommandPost - -func (c *DefaultApiController) DevstateExecCommandPost(w http.ResponseWriter, r *http.Request) { - devstateExecCommandPostRequestParam := DevstateExecCommandPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateExecCommandPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateExecCommandPostRequestRequired(devstateExecCommandPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateExecCommandPost(r.Context(), devstateExecCommandPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateImageImageNameDelete - -func (c *DefaultApiController) DevstateImageImageNameDelete(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - imageNameParam := params["imageName"] - result, err := c.service.DevstateImageImageNameDelete(r.Context(), imageNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateImagePost - -func (c *DefaultApiController) DevstateImagePost(w http.ResponseWriter, r *http.Request) { - devstateImagePostRequestParam := DevstateImagePostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateImagePostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateImagePostRequestRequired(devstateImagePostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateImagePost(r.Context(), devstateImagePostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateMetadataPut - -func (c *DefaultApiController) DevstateMetadataPut(w http.ResponseWriter, r *http.Request) { - metadataRequestParam := MetadataRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&metadataRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertMetadataRequestRequired(metadataRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateMetadataPut(r.Context(), metadataRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateQuantityValidPost - -func (c *DefaultApiController) DevstateQuantityValidPost(w http.ResponseWriter, r *http.Request) { - devstateQuantityValidPostRequestParam := DevstateQuantityValidPostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateQuantityValidPostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateQuantityValidPostRequestRequired(devstateQuantityValidPostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateQuantityValidPost(r.Context(), devstateQuantityValidPostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateResourcePost - -func (c *DefaultApiController) DevstateResourcePost(w http.ResponseWriter, r *http.Request) { - devstateResourcePostRequestParam := DevstateResourcePostRequest{} - d := json.NewDecoder(r.Body) - d.DisallowUnknownFields() - if err := d.Decode(&devstateResourcePostRequestParam); err != nil { - c.errorHandler(w, r, &ParsingError{Err: err}, nil) - return - } - if err := AssertDevstateResourcePostRequestRequired(devstateResourcePostRequestParam); err != nil { - c.errorHandler(w, r, err, nil) - return - } - result, err := c.service.DevstateResourcePost(r.Context(), devstateResourcePostRequestParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - -// DevstateResourceResourceNameDelete - -func (c *DefaultApiController) DevstateResourceResourceNameDelete(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - resourceNameParam := params["resourceName"] - result, err := c.service.DevstateResourceResourceNameDelete(r.Context(), resourceNameParam) - // If an error occurred, encode the error with the status code - if err != nil { - c.errorHandler(w, r, err, &result) - return - } - // If no error, encode the body and the result code - EncodeJSONResponse(result.Body, &result.Code, w) - -} - // InstanceDelete - func (c *DefaultApiController) InstanceDelete(w http.ResponseWriter, r *http.Request) { result, err := c.service.InstanceDelete(r.Context()) diff --git a/pkg/apiserver-gen/go/api_devstate.go b/pkg/apiserver-gen/go/api_devstate.go new file mode 100644 index 000000000..f7386d105 --- /dev/null +++ b/pkg/apiserver-gen/go/api_devstate.go @@ -0,0 +1,580 @@ +/* + * odo dev + * + * API interface for 'odo dev' + * + * API version: 0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +import ( + "encoding/json" + "net/http" + "strings" + + "github.com/gorilla/mux" +) + +// DevstateApiController binds http requests to an api service and writes the service results to the http response +type DevstateApiController struct { + service DevstateApiServicer + errorHandler ErrorHandler +} + +// DevstateApiOption for how the controller is set up. +type DevstateApiOption func(*DevstateApiController) + +// WithDevstateApiErrorHandler inject ErrorHandler into controller +func WithDevstateApiErrorHandler(h ErrorHandler) DevstateApiOption { + return func(c *DevstateApiController) { + c.errorHandler = h + } +} + +// NewDevstateApiController creates a default api controller +func NewDevstateApiController(s DevstateApiServicer, opts ...DevstateApiOption) Router { + controller := &DevstateApiController{ + service: s, + errorHandler: DefaultErrorHandler, + } + + for _, opt := range opts { + opt(controller) + } + + return controller +} + +// Routes returns all the api routes for the DevstateApiController +func (c *DevstateApiController) Routes() Routes { + return Routes{ + { + "DevstateApplyCommandPost", + strings.ToUpper("Post"), + "/api/v1/devstate/applyCommand", + c.DevstateApplyCommandPost, + }, + { + "DevstateChartGet", + strings.ToUpper("Get"), + "/api/v1/devstate/chart", + c.DevstateChartGet, + }, + { + "DevstateCommandCommandNameDelete", + strings.ToUpper("Delete"), + "/api/v1/devstate/command/{commandName}", + c.DevstateCommandCommandNameDelete, + }, + { + "DevstateCommandCommandNameMovePost", + strings.ToUpper("Post"), + "/api/v1/devstate/command/{commandName}/move", + c.DevstateCommandCommandNameMovePost, + }, + { + "DevstateCommandCommandNameSetDefaultPost", + strings.ToUpper("Post"), + "/api/v1/devstate/command/{commandName}/setDefault", + c.DevstateCommandCommandNameSetDefaultPost, + }, + { + "DevstateCommandCommandNameUnsetDefaultPost", + strings.ToUpper("Post"), + "/api/v1/devstate/command/{commandName}/unsetDefault", + c.DevstateCommandCommandNameUnsetDefaultPost, + }, + { + "DevstateCompositeCommandPost", + strings.ToUpper("Post"), + "/api/v1/devstate/compositeCommand", + c.DevstateCompositeCommandPost, + }, + { + "DevstateContainerContainerNameDelete", + strings.ToUpper("Delete"), + "/api/v1/devstate/container/{containerName}", + c.DevstateContainerContainerNameDelete, + }, + { + "DevstateContainerPost", + strings.ToUpper("Post"), + "/api/v1/devstate/container", + c.DevstateContainerPost, + }, + { + "DevstateDevfileDelete", + strings.ToUpper("Delete"), + "/api/v1/devstate/devfile", + c.DevstateDevfileDelete, + }, + { + "DevstateDevfileGet", + strings.ToUpper("Get"), + "/api/v1/devstate/devfile", + c.DevstateDevfileGet, + }, + { + "DevstateDevfilePut", + strings.ToUpper("Put"), + "/api/v1/devstate/devfile", + c.DevstateDevfilePut, + }, + { + "DevstateEventsPut", + strings.ToUpper("Put"), + "/api/v1/devstate/events", + c.DevstateEventsPut, + }, + { + "DevstateExecCommandPost", + strings.ToUpper("Post"), + "/api/v1/devstate/execCommand", + c.DevstateExecCommandPost, + }, + { + "DevstateImageImageNameDelete", + strings.ToUpper("Delete"), + "/api/v1/devstate/image/{imageName}", + c.DevstateImageImageNameDelete, + }, + { + "DevstateImagePost", + strings.ToUpper("Post"), + "/api/v1/devstate/image", + c.DevstateImagePost, + }, + { + "DevstateMetadataPut", + strings.ToUpper("Put"), + "/api/v1/devstate/metadata", + c.DevstateMetadataPut, + }, + { + "DevstateQuantityValidPost", + strings.ToUpper("Post"), + "/api/v1/devstate/quantityValid", + c.DevstateQuantityValidPost, + }, + { + "DevstateResourcePost", + strings.ToUpper("Post"), + "/api/v1/devstate/resource", + c.DevstateResourcePost, + }, + { + "DevstateResourceResourceNameDelete", + strings.ToUpper("Delete"), + "/api/v1/devstate/resource/{resourceName}", + c.DevstateResourceResourceNameDelete, + }, + } +} + +// DevstateApplyCommandPost - +func (c *DevstateApiController) DevstateApplyCommandPost(w http.ResponseWriter, r *http.Request) { + devstateApplyCommandPostRequestParam := DevstateApplyCommandPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateApplyCommandPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateApplyCommandPostRequestRequired(devstateApplyCommandPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateApplyCommandPost(r.Context(), devstateApplyCommandPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateChartGet - +func (c *DevstateApiController) DevstateChartGet(w http.ResponseWriter, r *http.Request) { + result, err := c.service.DevstateChartGet(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateCommandCommandNameDelete - +func (c *DevstateApiController) DevstateCommandCommandNameDelete(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + commandNameParam := params["commandName"] + result, err := c.service.DevstateCommandCommandNameDelete(r.Context(), commandNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateCommandCommandNameMovePost - +func (c *DevstateApiController) DevstateCommandCommandNameMovePost(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + commandNameParam := params["commandName"] + devstateCommandCommandNameMovePostRequestParam := DevstateCommandCommandNameMovePostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateCommandCommandNameMovePostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateCommandCommandNameMovePostRequestRequired(devstateCommandCommandNameMovePostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateCommandCommandNameMovePost(r.Context(), commandNameParam, devstateCommandCommandNameMovePostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateCommandCommandNameSetDefaultPost - +func (c *DevstateApiController) DevstateCommandCommandNameSetDefaultPost(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + commandNameParam := params["commandName"] + devstateCommandCommandNameSetDefaultPostRequestParam := DevstateCommandCommandNameSetDefaultPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateCommandCommandNameSetDefaultPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateCommandCommandNameSetDefaultPostRequestRequired(devstateCommandCommandNameSetDefaultPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateCommandCommandNameSetDefaultPost(r.Context(), commandNameParam, devstateCommandCommandNameSetDefaultPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateCommandCommandNameUnsetDefaultPost - +func (c *DevstateApiController) DevstateCommandCommandNameUnsetDefaultPost(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + commandNameParam := params["commandName"] + result, err := c.service.DevstateCommandCommandNameUnsetDefaultPost(r.Context(), commandNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateCompositeCommandPost - +func (c *DevstateApiController) DevstateCompositeCommandPost(w http.ResponseWriter, r *http.Request) { + devstateCompositeCommandPostRequestParam := DevstateCompositeCommandPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateCompositeCommandPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateCompositeCommandPostRequestRequired(devstateCompositeCommandPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateCompositeCommandPost(r.Context(), devstateCompositeCommandPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateContainerContainerNameDelete - +func (c *DevstateApiController) DevstateContainerContainerNameDelete(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + containerNameParam := params["containerName"] + result, err := c.service.DevstateContainerContainerNameDelete(r.Context(), containerNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateContainerPost - +func (c *DevstateApiController) DevstateContainerPost(w http.ResponseWriter, r *http.Request) { + devstateContainerPostRequestParam := DevstateContainerPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateContainerPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateContainerPostRequestRequired(devstateContainerPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateContainerPost(r.Context(), devstateContainerPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateDevfileDelete - +func (c *DevstateApiController) DevstateDevfileDelete(w http.ResponseWriter, r *http.Request) { + result, err := c.service.DevstateDevfileDelete(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateDevfileGet - +func (c *DevstateApiController) DevstateDevfileGet(w http.ResponseWriter, r *http.Request) { + result, err := c.service.DevstateDevfileGet(r.Context()) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateDevfilePut - +func (c *DevstateApiController) DevstateDevfilePut(w http.ResponseWriter, r *http.Request) { + devstateDevfilePutRequestParam := DevstateDevfilePutRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateDevfilePutRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateDevfilePutRequestRequired(devstateDevfilePutRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateDevfilePut(r.Context(), devstateDevfilePutRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateEventsPut - +func (c *DevstateApiController) DevstateEventsPut(w http.ResponseWriter, r *http.Request) { + devstateEventsPutRequestParam := DevstateEventsPutRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateEventsPutRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateEventsPutRequestRequired(devstateEventsPutRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateEventsPut(r.Context(), devstateEventsPutRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateExecCommandPost - +func (c *DevstateApiController) DevstateExecCommandPost(w http.ResponseWriter, r *http.Request) { + devstateExecCommandPostRequestParam := DevstateExecCommandPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateExecCommandPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateExecCommandPostRequestRequired(devstateExecCommandPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateExecCommandPost(r.Context(), devstateExecCommandPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateImageImageNameDelete - +func (c *DevstateApiController) DevstateImageImageNameDelete(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + imageNameParam := params["imageName"] + result, err := c.service.DevstateImageImageNameDelete(r.Context(), imageNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateImagePost - +func (c *DevstateApiController) DevstateImagePost(w http.ResponseWriter, r *http.Request) { + devstateImagePostRequestParam := DevstateImagePostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateImagePostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateImagePostRequestRequired(devstateImagePostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateImagePost(r.Context(), devstateImagePostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateMetadataPut - +func (c *DevstateApiController) DevstateMetadataPut(w http.ResponseWriter, r *http.Request) { + metadataRequestParam := MetadataRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&metadataRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertMetadataRequestRequired(metadataRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateMetadataPut(r.Context(), metadataRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateQuantityValidPost - +func (c *DevstateApiController) DevstateQuantityValidPost(w http.ResponseWriter, r *http.Request) { + devstateQuantityValidPostRequestParam := DevstateQuantityValidPostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateQuantityValidPostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateQuantityValidPostRequestRequired(devstateQuantityValidPostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateQuantityValidPost(r.Context(), devstateQuantityValidPostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateResourcePost - +func (c *DevstateApiController) DevstateResourcePost(w http.ResponseWriter, r *http.Request) { + devstateResourcePostRequestParam := DevstateResourcePostRequest{} + d := json.NewDecoder(r.Body) + d.DisallowUnknownFields() + if err := d.Decode(&devstateResourcePostRequestParam); err != nil { + c.errorHandler(w, r, &ParsingError{Err: err}, nil) + return + } + if err := AssertDevstateResourcePostRequestRequired(devstateResourcePostRequestParam); err != nil { + c.errorHandler(w, r, err, nil) + return + } + result, err := c.service.DevstateResourcePost(r.Context(), devstateResourcePostRequestParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} + +// DevstateResourceResourceNameDelete - +func (c *DevstateApiController) DevstateResourceResourceNameDelete(w http.ResponseWriter, r *http.Request) { + params := mux.Vars(r) + resourceNameParam := params["resourceName"] + result, err := c.service.DevstateResourceResourceNameDelete(r.Context(), resourceNameParam) + // If an error occurred, encode the error with the status code + if err != nil { + c.errorHandler(w, r, err, &result) + return + } + // If no error, encode the body and the result code + EncodeJSONResponse(result.Body, &result.Code, w) + +} diff --git a/pkg/apiserver-gen/go/logger.go b/pkg/apiserver-gen/go/logger.go index 5f54be8c3..a4f259c28 100644 --- a/pkg/apiserver-gen/go/logger.go +++ b/pkg/apiserver-gen/go/logger.go @@ -10,9 +10,10 @@ package openapi import ( - "log" "net/http" "time" + + "k8s.io/klog" ) func Logger(inner http.Handler, name string) http.Handler { @@ -21,7 +22,7 @@ func Logger(inner http.Handler, name string) http.Handler { inner.ServeHTTP(w, r) - log.Printf( + klog.V(2).Infof( "%s %s %s %s", r.Method, r.RequestURI, diff --git a/pkg/apiserver-impl/api_devstate_service.go b/pkg/apiserver-impl/api_devstate_service.go new file mode 100644 index 000000000..e2ca268f0 --- /dev/null +++ b/pkg/apiserver-impl/api_devstate_service.go @@ -0,0 +1,47 @@ +package apiserver_impl + +import ( + "context" + + openapi "github.com/redhat-developer/odo/pkg/apiserver-gen/go" + "github.com/redhat-developer/odo/pkg/apiserver-impl/devstate" + "github.com/redhat-developer/odo/pkg/kclient" + "github.com/redhat-developer/odo/pkg/podman" + "github.com/redhat-developer/odo/pkg/preference" + "github.com/redhat-developer/odo/pkg/state" +) + +// DevstateApiService is a service that implements the logic for the DevstateApiServicer +// This service should implement the business logic for every endpoint for the DevstateApi API. +// Include any external packages or services that will be required by this service. +type DevstateApiService struct { + cancel context.CancelFunc + pushWatcher chan<- struct{} + kubeClient kclient.ClientInterface + podmanClient podman.Client + stateClient state.Client + preferenceClient preference.Client + + devfileState devstate.DevfileState +} + +// NewDevstateApiService creates a devstate api service +func NewDevstateApiService( + cancel context.CancelFunc, + pushWatcher chan<- struct{}, + kubeClient kclient.ClientInterface, + podmanClient podman.Client, + stateClient state.Client, + preferenceClient preference.Client, +) openapi.DevstateApiServicer { + return &DevstateApiService{ + cancel: cancel, + pushWatcher: pushWatcher, + kubeClient: kubeClient, + podmanClient: podmanClient, + stateClient: stateClient, + preferenceClient: preferenceClient, + + devfileState: devstate.NewDevfileState(), + } +} diff --git a/pkg/apiserver-impl/devstate.go b/pkg/apiserver-impl/devstate.go index e9565ce91..25f5d2a55 100644 --- a/pkg/apiserver-impl/devstate.go +++ b/pkg/apiserver-impl/devstate.go @@ -9,7 +9,7 @@ import ( "github.com/redhat-developer/odo/pkg/apiserver-impl/devstate" ) -func (s *DefaultApiService) DevstateContainerPost(ctx context.Context, container openapi.DevstateContainerPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateContainerPost(ctx context.Context, container openapi.DevstateContainerPostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddContainer( container.Name, container.Image, @@ -28,7 +28,7 @@ func (s *DefaultApiService) DevstateContainerPost(ctx context.Context, container return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateContainerContainerNameDelete(ctx context.Context, containerName string) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateContainerContainerNameDelete(ctx context.Context, containerName string) (openapi.ImplResponse, error) { newContent, err := s.devfileState.DeleteContainer(containerName) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -38,7 +38,7 @@ func (s *DefaultApiService) DevstateContainerContainerNameDelete(ctx context.Con return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateImagePost(ctx context.Context, image openapi.DevstateImagePostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateImagePost(ctx context.Context, image openapi.DevstateImagePostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddImage( image.Name, image.ImageName, @@ -55,7 +55,7 @@ func (s *DefaultApiService) DevstateImagePost(ctx context.Context, image openapi return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateImageImageNameDelete(ctx context.Context, imageName string) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateImageImageNameDelete(ctx context.Context, imageName string) (openapi.ImplResponse, error) { newContent, err := s.devfileState.DeleteImage(imageName) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -65,7 +65,7 @@ func (s *DefaultApiService) DevstateImageImageNameDelete(ctx context.Context, im return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateResourcePost(ctx context.Context, resource openapi.DevstateResourcePostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateResourcePost(ctx context.Context, resource openapi.DevstateResourcePostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddResource( resource.Name, resource.Inlined, @@ -80,7 +80,7 @@ func (s *DefaultApiService) DevstateResourcePost(ctx context.Context, resource o } -func (s *DefaultApiService) DevstateResourceResourceNameDelete(ctx context.Context, resourceName string) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateResourceResourceNameDelete(ctx context.Context, resourceName string) (openapi.ImplResponse, error) { newContent, err := s.devfileState.DeleteResource(resourceName) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -90,7 +90,7 @@ func (s *DefaultApiService) DevstateResourceResourceNameDelete(ctx context.Conte return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateApplyCommandPost(ctx context.Context, command openapi.DevstateApplyCommandPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateApplyCommandPost(ctx context.Context, command openapi.DevstateApplyCommandPostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddApplyCommand( command.Name, command.Component, @@ -103,7 +103,7 @@ func (s *DefaultApiService) DevstateApplyCommandPost(ctx context.Context, comman return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateCommandCommandNameDelete(ctx context.Context, commandName string) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateCommandCommandNameDelete(ctx context.Context, commandName string) (openapi.ImplResponse, error) { newContent, err := s.devfileState.DeleteCommand(commandName) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -113,7 +113,7 @@ func (s *DefaultApiService) DevstateCommandCommandNameDelete(ctx context.Context return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateCompositeCommandPost(ctx context.Context, command openapi.DevstateCompositeCommandPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateCompositeCommandPost(ctx context.Context, command openapi.DevstateCompositeCommandPostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddCompositeCommand( command.Name, command.Parallel, @@ -128,7 +128,7 @@ func (s *DefaultApiService) DevstateCompositeCommandPost(ctx context.Context, co } -func (s *DefaultApiService) DevstateExecCommandPost(ctx context.Context, command openapi.DevstateExecCommandPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateExecCommandPost(ctx context.Context, command openapi.DevstateExecCommandPostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.AddExecCommand( command.Name, command.Component, @@ -144,7 +144,7 @@ func (s *DefaultApiService) DevstateExecCommandPost(ctx context.Context, command return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateMetadataPut(ctx context.Context, metadata openapi.MetadataRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateMetadataPut(ctx context.Context, metadata openapi.MetadataRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.SetMetadata( metadata.Name, metadata.Version, @@ -168,7 +168,7 @@ func (s *DefaultApiService) DevstateMetadataPut(ctx context.Context, metadata op return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateChartGet(context.Context) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateChartGet(context.Context) (openapi.ImplResponse, error) { chart, err := s.devfileState.GetFlowChart() if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -180,7 +180,7 @@ func (s *DefaultApiService) DevstateChartGet(context.Context) (openapi.ImplRespo }), nil } -func (s *DefaultApiService) DevstateCommandCommandNameMovePost(ctx context.Context, commandName string, params openapi.DevstateCommandCommandNameMovePostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateCommandCommandNameMovePost(ctx context.Context, commandName string, params openapi.DevstateCommandCommandNameMovePostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.MoveCommand( params.FromGroup, params.ToGroup, @@ -195,7 +195,7 @@ func (s *DefaultApiService) DevstateCommandCommandNameMovePost(ctx context.Conte return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateCommandCommandNameSetDefaultPost(ctx context.Context, commandName string, params openapi.DevstateCommandCommandNameSetDefaultPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateCommandCommandNameSetDefaultPost(ctx context.Context, commandName string, params openapi.DevstateCommandCommandNameSetDefaultPostRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.SetDefaultCommand(commandName, params.Group) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -205,7 +205,7 @@ func (s *DefaultApiService) DevstateCommandCommandNameSetDefaultPost(ctx context return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateCommandCommandNameUnsetDefaultPost(ctx context.Context, commandName string) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateCommandCommandNameUnsetDefaultPost(ctx context.Context, commandName string) (openapi.ImplResponse, error) { newContent, err := s.devfileState.UnsetDefaultCommand(commandName) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -215,7 +215,7 @@ func (s *DefaultApiService) DevstateCommandCommandNameUnsetDefaultPost(ctx conte return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateEventsPut(ctx context.Context, params openapi.DevstateEventsPutRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateEventsPut(ctx context.Context, params openapi.DevstateEventsPutRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.UpdateEvents(params.EventName, params.Commands) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -225,7 +225,7 @@ func (s *DefaultApiService) DevstateEventsPut(ctx context.Context, params openap return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateQuantityValidPost(ctx context.Context, params openapi.DevstateQuantityValidPostRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateQuantityValidPost(ctx context.Context, params openapi.DevstateQuantityValidPostRequest) (openapi.ImplResponse, error) { result := devstate.IsQuantityValid(params.Quantity) if !result { return openapi.Response(http.StatusBadRequest, openapi.GeneralError{ @@ -237,7 +237,7 @@ func (s *DefaultApiService) DevstateQuantityValidPost(ctx context.Context, param }), nil } -func (s *DefaultApiService) DevstateDevfilePut(ctx context.Context, params openapi.DevstateDevfilePutRequest) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateDevfilePut(ctx context.Context, params openapi.DevstateDevfilePutRequest) (openapi.ImplResponse, error) { newContent, err := s.devfileState.SetDevfileContent(params.Content) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -247,7 +247,7 @@ func (s *DefaultApiService) DevstateDevfilePut(ctx context.Context, params opena return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateDevfileGet(context.Context) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateDevfileGet(context.Context) (openapi.ImplResponse, error) { newContent, err := s.devfileState.GetContent() if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ @@ -257,7 +257,7 @@ func (s *DefaultApiService) DevstateDevfileGet(context.Context) (openapi.ImplRes return openapi.Response(http.StatusOK, newContent), nil } -func (s *DefaultApiService) DevstateDevfileDelete(context.Context) (openapi.ImplResponse, error) { +func (s *DevstateApiService) DevstateDevfileDelete(context.Context) (openapi.ImplResponse, error) { newContent, err := s.devfileState.SetDevfileContent(`schemaVersion: 2.2.0`) if err != nil { return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{ diff --git a/pkg/apiserver-impl/starterserver.go b/pkg/apiserver-impl/starterserver.go index f879a1bec..49fc818d1 100644 --- a/pkg/apiserver-impl/starterserver.go +++ b/pkg/apiserver-impl/starterserver.go @@ -56,13 +56,22 @@ func StartServer( preferenceClient, ) defaultApiController := openapi.NewDefaultApiController(defaultApiService) + devstateApiService := NewDevstateApiService( + cancelFunc, + pushWatcher, + kubernetesClient, + podmanClient, + stateClient, + preferenceClient, + ) + devstateApiController := openapi.NewDevstateApiController(devstateApiService) sseNotifier, err := sse.NewNotifier(ctx, fsys, devfilePath, devfileFiles) if err != nil { return ApiServer{}, err } - router := openapi.NewRouter(sseNotifier, defaultApiController) + router := openapi.NewRouter(sseNotifier, defaultApiController, devstateApiController) fSysSwagger, err := fs.Sub(swaggerFiles, "swagger-ui") if err != nil { diff --git a/ui/src/app/api-gen/.openapi-generator/FILES b/ui/src/app/api-gen/.openapi-generator/FILES index f59295616..7361828bd 100644 --- a/ui/src/app/api-gen/.openapi-generator/FILES +++ b/ui/src/app/api-gen/.openapi-generator/FILES @@ -3,6 +3,7 @@ README.md api.module.ts api/api.ts api/default.service.ts +api/devstate.service.ts configuration.ts encoder.ts git_push.sh diff --git a/ui/src/app/api-gen/api/api.ts b/ui/src/app/api-gen/api/api.ts index 8e7661964..7762860de 100644 --- a/ui/src/app/api-gen/api/api.ts +++ b/ui/src/app/api-gen/api/api.ts @@ -1,3 +1,5 @@ export * from './default.service'; import { DefaultService } from './default.service'; -export const APIS = [DefaultService]; +export * from './devstate.service'; +import { DevstateService } from './devstate.service'; +export const APIS = [DefaultService, DevstateService]; diff --git a/ui/src/app/api-gen/api/default.service.ts b/ui/src/app/api-gen/api/default.service.ts index 030224362..856536736 100644 --- a/ui/src/app/api-gen/api/default.service.ts +++ b/ui/src/app/api-gen/api/default.service.ts @@ -23,44 +23,16 @@ import { ComponentCommandPostRequest } from '../model/componentCommandPostReques // @ts-ignore import { ComponentGet200Response } from '../model/componentGet200Response'; // @ts-ignore -import { DevfileContent } from '../model/devfileContent'; -// @ts-ignore import { DevfileGet200Response } from '../model/devfileGet200Response'; // @ts-ignore import { DevfilePutRequest } from '../model/devfilePutRequest'; // @ts-ignore -import { DevstateApplyCommandPostRequest } from '../model/devstateApplyCommandPostRequest'; -// @ts-ignore -import { DevstateChartGet200Response } from '../model/devstateChartGet200Response'; -// @ts-ignore -import { DevstateCommandCommandNameMovePostRequest } from '../model/devstateCommandCommandNameMovePostRequest'; -// @ts-ignore -import { DevstateCommandCommandNameSetDefaultPostRequest } from '../model/devstateCommandCommandNameSetDefaultPostRequest'; -// @ts-ignore -import { DevstateCompositeCommandPostRequest } from '../model/devstateCompositeCommandPostRequest'; -// @ts-ignore -import { DevstateContainerPostRequest } from '../model/devstateContainerPostRequest'; -// @ts-ignore -import { DevstateDevfilePutRequest } from '../model/devstateDevfilePutRequest'; -// @ts-ignore -import { DevstateEventsPutRequest } from '../model/devstateEventsPutRequest'; -// @ts-ignore -import { DevstateExecCommandPostRequest } from '../model/devstateExecCommandPostRequest'; -// @ts-ignore -import { DevstateImagePostRequest } from '../model/devstateImagePostRequest'; -// @ts-ignore -import { DevstateQuantityValidPostRequest } from '../model/devstateQuantityValidPostRequest'; -// @ts-ignore -import { DevstateResourcePostRequest } from '../model/devstateResourcePostRequest'; -// @ts-ignore import { GeneralError } from '../model/generalError'; // @ts-ignore import { GeneralSuccess } from '../model/generalSuccess'; // @ts-ignore import { InstanceGet200Response } from '../model/instanceGet200Response'; // @ts-ignore -import { MetadataRequest } from '../model/metadataRequest'; -// @ts-ignore import { TelemetryResponse } from '../model/telemetryResponse'; // @ts-ignore @@ -371,1246 +343,6 @@ export class DefaultService { ); } - /** - * Add a new Apply Command to the Devfile - * @param devstateApplyCommandPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/applyCommand`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateApplyCommandPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Get chart representing the Devfile cycle in mermaid format - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateChartGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateChartGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateChartGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateChartGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/chart`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Delete a command from the Devfile - * @param commandName Command name to delete - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateCommandCommandNameDelete(commandName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateCommandCommandNameDelete(commandName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameDelete(commandName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameDelete(commandName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (commandName === null || commandName === undefined) { - throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameDelete.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Move a command - * @param commandName Command name to move - * @param devstateCommandCommandNameMovePostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (commandName === null || commandName === undefined) { - throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameMovePost.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/move`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateCommandCommandNameMovePostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Set a command as default command for a group - * @param commandName Command name to set as default - * @param devstateCommandCommandNameSetDefaultPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (commandName === null || commandName === undefined) { - throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameSetDefaultPost.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/setDefault`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateCommandCommandNameSetDefaultPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Unset a command as default command for its group - * @param commandName Command name to set as default - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (commandName === null || commandName === undefined) { - throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameUnsetDefaultPost.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/unsetDefault`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Add a new Composite Command to the Devfile - * @param devstateCompositeCommandPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/compositeCommand`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateCompositeCommandPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Delete a container from the Devfile - * @param containerName Container name to delete - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateContainerContainerNameDelete(containerName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateContainerContainerNameDelete(containerName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateContainerContainerNameDelete(containerName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateContainerContainerNameDelete(containerName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (containerName === null || containerName === undefined) { - throw new Error('Required parameter containerName was null or undefined when calling devstateContainerContainerNameDelete.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/container/${this.configuration.encodeParam({name: "containerName", value: containerName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Add a new container to the Devfile - * @param devstateContainerPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/container`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateContainerPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Clear the Devfile content - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateDevfileDelete(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateDevfileDelete(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfileDelete(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfileDelete(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/devfile`; - return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Get the complete Devfile content - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateDevfileGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateDevfileGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfileGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfileGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/devfile`; - return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Updates the complete Devfile content - * @param devstateDevfilePutRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/devfile`; - return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateDevfilePutRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Updates the Events for the Devfile - * @param devstateEventsPutRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/events`; - return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateEventsPutRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Add a new Exec Command to the Devfile - * @param devstateExecCommandPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/execCommand`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateExecCommandPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Delete an image from the Devfile - * @param imageName Image name to delete - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateImageImageNameDelete(imageName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateImageImageNameDelete(imageName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateImageImageNameDelete(imageName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateImageImageNameDelete(imageName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (imageName === null || imageName === undefined) { - throw new Error('Required parameter imageName was null or undefined when calling devstateImageImageNameDelete.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/image/${this.configuration.encodeParam({name: "imageName", value: imageName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Add a new image to the Devfile - * @param devstateImagePostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/image`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateImagePostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Updates the metadata for the Devfile - * @param metadataRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateMetadataPut(metadataRequest?: MetadataRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/metadata`; - return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: metadataRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Check if a quantity is valid - * @param devstateQuantityValidPostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/quantityValid`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateQuantityValidPostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Add a new Kubernetes resource to the Devfile - * @param devstateResourcePostRequest - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - // to determine the Content-Type header - const consumes: string[] = [ - 'application/json' - ]; - const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); - if (httpContentTypeSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); - } - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/resource`; - return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - body: devstateResourcePostRequest, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - - /** - * Delete a resource from the Devfile - * @param resourceName Resource name to delete - * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. - * @param reportProgress flag to report request and response progress. - */ - public devstateResourceResourceNameDelete(resourceName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; - public devstateResourceResourceNameDelete(resourceName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateResourceResourceNameDelete(resourceName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; - public devstateResourceResourceNameDelete(resourceName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { - if (resourceName === null || resourceName === undefined) { - throw new Error('Required parameter resourceName was null or undefined when calling devstateResourceResourceNameDelete.'); - } - - let localVarHeaders = this.defaultHeaders; - - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; - if (localVarHttpHeaderAcceptSelected === undefined) { - // to determine the Accept header - const httpHeaderAccepts: string[] = [ - 'application/json' - ]; - localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); - } - if (localVarHttpHeaderAcceptSelected !== undefined) { - localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); - } - - let localVarHttpContext: HttpContext | undefined = options && options.context; - if (localVarHttpContext === undefined) { - localVarHttpContext = new HttpContext(); - } - - - let responseType_: 'text' | 'json' | 'blob' = 'json'; - if (localVarHttpHeaderAcceptSelected) { - if (localVarHttpHeaderAcceptSelected.startsWith('text')) { - responseType_ = 'text'; - } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { - responseType_ = 'json'; - } else { - responseType_ = 'blob'; - } - } - - let localVarPath = `/devstate/resource/${this.configuration.encodeParam({name: "resourceName", value: resourceName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; - return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, - { - context: localVarHttpContext, - responseType: responseType_, - withCredentials: this.configuration.withCredentials, - headers: localVarHeaders, - observe: observe, - reportProgress: reportProgress - } - ); - } - /** * Stop this \'odo dev\' instance * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. diff --git a/ui/src/app/api-gen/api/devstate.service.ts b/ui/src/app/api-gen/api/devstate.service.ts new file mode 100644 index 000000000..4691ea5a5 --- /dev/null +++ b/ui/src/app/api-gen/api/devstate.service.ts @@ -0,0 +1,1364 @@ +/** + * odo dev + * API interface for \'odo dev\' + * + * The version of the OpenAPI document: 0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent, HttpParameterCodec, HttpContext + } from '@angular/common/http'; +import { CustomHttpParameterCodec } from '../encoder'; +import { Observable } from 'rxjs'; + +// @ts-ignore +import { DevfileContent } from '../model/devfileContent'; +// @ts-ignore +import { DevstateApplyCommandPostRequest } from '../model/devstateApplyCommandPostRequest'; +// @ts-ignore +import { DevstateChartGet200Response } from '../model/devstateChartGet200Response'; +// @ts-ignore +import { DevstateCommandCommandNameMovePostRequest } from '../model/devstateCommandCommandNameMovePostRequest'; +// @ts-ignore +import { DevstateCommandCommandNameSetDefaultPostRequest } from '../model/devstateCommandCommandNameSetDefaultPostRequest'; +// @ts-ignore +import { DevstateCompositeCommandPostRequest } from '../model/devstateCompositeCommandPostRequest'; +// @ts-ignore +import { DevstateContainerPostRequest } from '../model/devstateContainerPostRequest'; +// @ts-ignore +import { DevstateDevfilePutRequest } from '../model/devstateDevfilePutRequest'; +// @ts-ignore +import { DevstateEventsPutRequest } from '../model/devstateEventsPutRequest'; +// @ts-ignore +import { DevstateExecCommandPostRequest } from '../model/devstateExecCommandPostRequest'; +// @ts-ignore +import { DevstateImagePostRequest } from '../model/devstateImagePostRequest'; +// @ts-ignore +import { DevstateQuantityValidPostRequest } from '../model/devstateQuantityValidPostRequest'; +// @ts-ignore +import { DevstateResourcePostRequest } from '../model/devstateResourcePostRequest'; +// @ts-ignore +import { GeneralError } from '../model/generalError'; +// @ts-ignore +import { GeneralSuccess } from '../model/generalSuccess'; +// @ts-ignore +import { MetadataRequest } from '../model/metadataRequest'; + +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + + + +@Injectable({ + providedIn: 'root' +}) +export class DevstateService { + + protected basePath = '/api/v1'; + public defaultHeaders = new HttpHeaders(); + public configuration = new Configuration(); + public encoder: HttpParameterCodec; + + constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { + if (configuration) { + this.configuration = configuration; + } + if (typeof this.configuration.basePath !== 'string') { + if (Array.isArray(basePath) && basePath.length > 0) { + basePath = basePath[0]; + } + + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; + } + this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); + } + + + // @ts-ignore + private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { + if (typeof value === "object" && value instanceof Date === false) { + httpParams = this.addToHttpParamsRecursive(httpParams, value); + } else { + httpParams = this.addToHttpParamsRecursive(httpParams, value, key); + } + return httpParams; + } + + private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { + if (value == null) { + return httpParams; + } + + if (typeof value === "object") { + if (Array.isArray(value)) { + (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); + } else if (value instanceof Date) { + if (key != null) { + httpParams = httpParams.append(key, (value as Date).toISOString().substr(0, 10)); + } else { + throw Error("key may not be null if value is Date"); + } + } else { + Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( + httpParams, value[k], key != null ? `${key}.${k}` : k)); + } + } else if (key != null) { + httpParams = httpParams.append(key, value); + } else { + throw Error("key may not be null if value is not object or array"); + } + return httpParams; + } + + /** + * Add a new Apply Command to the Devfile + * @param devstateApplyCommandPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateApplyCommandPost(devstateApplyCommandPostRequest?: DevstateApplyCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/applyCommand`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateApplyCommandPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Get chart representing the Devfile cycle in mermaid format + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateChartGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateChartGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateChartGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateChartGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/chart`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Delete a command from the Devfile + * @param commandName Command name to delete + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateCommandCommandNameDelete(commandName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateCommandCommandNameDelete(commandName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameDelete(commandName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameDelete(commandName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (commandName === null || commandName === undefined) { + throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameDelete.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Move a command + * @param commandName Command name to move + * @param devstateCommandCommandNameMovePostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameMovePost(commandName: string, devstateCommandCommandNameMovePostRequest?: DevstateCommandCommandNameMovePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (commandName === null || commandName === undefined) { + throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameMovePost.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/move`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateCommandCommandNameMovePostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Set a command as default command for a group + * @param commandName Command name to set as default + * @param devstateCommandCommandNameSetDefaultPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameSetDefaultPost(commandName: string, devstateCommandCommandNameSetDefaultPostRequest?: DevstateCommandCommandNameSetDefaultPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (commandName === null || commandName === undefined) { + throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameSetDefaultPost.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/setDefault`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateCommandCommandNameSetDefaultPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Unset a command as default command for its group + * @param commandName Command name to set as default + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCommandCommandNameUnsetDefaultPost(commandName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (commandName === null || commandName === undefined) { + throw new Error('Required parameter commandName was null or undefined when calling devstateCommandCommandNameUnsetDefaultPost.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/command/${this.configuration.encodeParam({name: "commandName", value: commandName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/unsetDefault`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Add a new Composite Command to the Devfile + * @param devstateCompositeCommandPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateCompositeCommandPost(devstateCompositeCommandPostRequest?: DevstateCompositeCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/compositeCommand`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateCompositeCommandPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Delete a container from the Devfile + * @param containerName Container name to delete + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateContainerContainerNameDelete(containerName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateContainerContainerNameDelete(containerName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateContainerContainerNameDelete(containerName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateContainerContainerNameDelete(containerName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (containerName === null || containerName === undefined) { + throw new Error('Required parameter containerName was null or undefined when calling devstateContainerContainerNameDelete.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/container/${this.configuration.encodeParam({name: "containerName", value: containerName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Add a new container to the Devfile + * @param devstateContainerPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateContainerPost(devstateContainerPostRequest?: DevstateContainerPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/container`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateContainerPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Clear the Devfile content + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateDevfileDelete(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateDevfileDelete(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfileDelete(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfileDelete(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/devfile`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Get the complete Devfile content + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateDevfileGet(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateDevfileGet(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfileGet(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfileGet(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/devfile`; + return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Updates the complete Devfile content + * @param devstateDevfilePutRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateDevfilePut(devstateDevfilePutRequest?: DevstateDevfilePutRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/devfile`; + return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateDevfilePutRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Updates the Events for the Devfile + * @param devstateEventsPutRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateEventsPut(devstateEventsPutRequest?: DevstateEventsPutRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/events`; + return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateEventsPutRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Add a new Exec Command to the Devfile + * @param devstateExecCommandPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateExecCommandPost(devstateExecCommandPostRequest?: DevstateExecCommandPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/execCommand`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateExecCommandPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Delete an image from the Devfile + * @param imageName Image name to delete + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateImageImageNameDelete(imageName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateImageImageNameDelete(imageName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateImageImageNameDelete(imageName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateImageImageNameDelete(imageName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (imageName === null || imageName === undefined) { + throw new Error('Required parameter imageName was null or undefined when calling devstateImageImageNameDelete.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/image/${this.configuration.encodeParam({name: "imageName", value: imageName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Add a new image to the Devfile + * @param devstateImagePostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateImagePost(devstateImagePostRequest?: DevstateImagePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/image`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateImagePostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Updates the metadata for the Devfile + * @param metadataRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateMetadataPut(metadataRequest?: MetadataRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateMetadataPut(metadataRequest?: MetadataRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/metadata`; + return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: metadataRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Check if a quantity is valid + * @param devstateQuantityValidPostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateQuantityValidPost(devstateQuantityValidPostRequest?: DevstateQuantityValidPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/quantityValid`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateQuantityValidPostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Add a new Kubernetes resource to the Devfile + * @param devstateResourcePostRequest + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateResourcePost(devstateResourcePostRequest?: DevstateResourcePostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + // to determine the Content-Type header + const consumes: string[] = [ + 'application/json' + ]; + const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/resource`; + return this.httpClient.request('post', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: devstateResourcePostRequest, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + + /** + * Delete a resource from the Devfile + * @param resourceName Resource name to delete + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public devstateResourceResourceNameDelete(resourceName: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public devstateResourceResourceNameDelete(resourceName: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateResourceResourceNameDelete(resourceName: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public devstateResourceResourceNameDelete(resourceName: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (resourceName === null || resourceName === undefined) { + throw new Error('Required parameter resourceName was null or undefined when calling devstateResourceResourceNameDelete.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/devstate/resource/${this.configuration.encodeParam({name: "resourceName", value: resourceName, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; + return this.httpClient.request('delete', `${this.configuration.basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + +}