v1.15.0
This commit is contained in:
@@ -27,6 +27,12 @@ type ChangeSecGroupsRequest struct {
|
||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperChangeSecGroupsRequest struct {
|
||||
ChangeSecGroupsRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// ChangeSecGroups changes security groups for compute
|
||||
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -34,9 +40,14 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
||||
ChangeSecGroupsRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/change_security_groups"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -48,3 +59,25 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ChangeSecGroupsAsync changes security groups for compute with AsyncMode
|
||||
func (c Compute) ChangeSecGroupsAsync(ctx context.Context, req ChangeSecGroupsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
||||
ChangeSecGroupsRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/change_security_groups"
|
||||
|
||||
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