v15.0.0
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// NetAttachRequest struct to attach network
|
||||
@@ -53,9 +53,9 @@ type NetAttachRequest struct {
|
||||
// Required: false
|
||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||
|
||||
// SDN Object Group ID
|
||||
// SDN Object Group IDs
|
||||
// Required: false
|
||||
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
||||
|
||||
// SDN Logical Port Display Name
|
||||
// Required: false
|
||||
@@ -83,6 +83,12 @@ type NetAttachRequest struct {
|
||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperNetAttachRequest struct {
|
||||
NetAttachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// NetAttach attaches network to compute and gets info about network
|
||||
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -90,9 +96,14 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperNetAttachRequest{
|
||||
NetAttachRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/netAttach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -106,3 +117,25 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// NetAttachAsync attaches network to compute with AsyncMode
|
||||
func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperNetAttachRequest{
|
||||
NetAttachRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/netAttach"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user