v1.3.0
This commit is contained in:
@@ -2,35 +2,30 @@ package k8ci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for delete K8CI
|
||||
type DeleteRequest struct {
|
||||
// K8CI ID
|
||||
// Required: true
|
||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId"`
|
||||
K8CIID uint64 `url:"k8ciId" json:"k8ciId" validate:"required"`
|
||||
|
||||
// Delete permanently or not
|
||||
// Required: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
func (krq DeleteRequest) validate() error {
|
||||
if krq.K8CIID == 0 {
|
||||
return errors.New("validation-error: field K8CIID must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete deletes K8CI by ID
|
||||
func (k K8CI) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/k8ci/delete"
|
||||
|
||||
Reference in New Issue
Block a user