You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
package defsecpolicies
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// UpdateRequest struct to update default security policy
|
|
type UpdateRequest struct {
|
|
// ID of the access group
|
|
// Required: true
|
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
|
|
|
// ID of the version
|
|
// Required: true
|
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
|
|
|
// Default ACL drop behavior
|
|
// Required: false
|
|
DefaultACLDrop string `url:"default_acl_drop,omitempty" json:"default_acl_drop,omitempty"`
|
|
|
|
// Default open session drop flag
|
|
// Required: false
|
|
DefaultOpenSessionDrop bool `url:"default_open_session_drop,omitempty" json:"default_open_session_drop,omitempty"`
|
|
}
|
|
|
|
// Update updates a default security policy
|
|
func (i DefaultSecurityPolicies) Update(ctx context.Context, req UpdateRequest) (*SecurityPolicy, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/sdn/default_security_policy/update"
|
|
|
|
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPatch, url, constants.MIMEJSON, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := SecurityPolicy{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|