v15.0.0
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// PFWAddRequest struct to add port forward rule
|
||||
@@ -33,6 +33,12 @@ type PFWAddRequest struct {
|
||||
Proto string `url:"proto" json:"proto" validate:"proto"`
|
||||
}
|
||||
|
||||
type wrapperPFWAddRequest struct {
|
||||
PFWAddRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// PFWAdd add port forward rule
|
||||
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -40,9 +46,14 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPFWAddRequest{
|
||||
PFWAddRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pfwAdd"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -54,3 +65,25 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// PFWAddAsync adds port forward rule with AsyncMode
|
||||
func (c Compute) PFWAddAsync(ctx context.Context, req PFWAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperPFWAddRequest{
|
||||
PFWAddRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/pfwAdd"
|
||||
|
||||
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