v1.12.3
This commit is contained in:
39
pkg/cloudbroker/node/get_ssh_identity.go
Normal file
39
pkg/cloudbroker/node/get_ssh_identity.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetSSHIdentityRequest struct to get node ssh information
|
||||
type GetSSHIdentityRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetSSHIdentity gets node ssh information
|
||||
func (n Node) GetSSHIdentity(ctx context.Context, req GetSSHIdentityRequest) (*SSHIdentity, error) {
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/get_ssh_identity"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := SSHIdentity{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
Reference in New Issue
Block a user