43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
|
|
package node
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"net/http"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// RemoveSSHIdentityRequest to remove an ssh identity from a node
|
||
|
|
type RemoveSSHIdentityRequest struct {
|
||
|
|
// Node ID
|
||
|
|
// Required: true
|
||
|
|
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||
|
|
|
||
|
|
// Key to remove
|
||
|
|
// Required: true
|
||
|
|
ClientPublicKey string `url:"client_public_key" json:"client_public_key" validate:"required"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// RemoveSSHIdentity removes an ssh identity from a node
|
||
|
|
func (n Node) RemoveSSHIdentity(ctx context.Context, req RemoveSSHIdentityRequest) (bool, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/cloudbroker/node/remove_ssh_identity"
|
||
|
|
|
||
|
|
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||
|
|
if err != nil {
|
||
|
|
return false, err
|
||
|
|
}
|
||
|
|
|
||
|
|
result, err := strconv.ParseBool(string(res))
|
||
|
|
if err != nil {
|
||
|
|
return false, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return result, nil
|
||
|
|
}
|