v1.8.0
This commit is contained in:
37
pkg/cloudbroker/node/restrict.go
Normal file
37
pkg/cloudbroker/node/restrict.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RestrictRequest struct to set node status to 'RESTRICTED'
|
||||
type RestrictRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// Migrate node
|
||||
// Default: false
|
||||
// Required: false
|
||||
Migrate bool `url:"migrate" json:"migrate"`
|
||||
}
|
||||
|
||||
// Restrict sets node status to 'RESTRICTED' and migrates node if migrate=True
|
||||
func (n Node) Restrict(ctx context.Context, req RestrictRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/restrict"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
Reference in New Issue
Block a user