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.
81 lines
2.2 KiB
81 lines
2.2 KiB
|
4 days ago
|
package secpolicies
|
||
|
|
|
||
|
|
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 security policy
|
||
|
|
type UpdateRequest struct {
|
||
|
|
// ID a security policy
|
||
|
|
// Required: true
|
||
|
|
SecurityPolicyID string `url:"security_policy_id" json:"security_policy_id" validate:"required"`
|
||
|
|
|
||
|
|
// Required: true
|
||
|
|
VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`
|
||
|
|
|
||
|
|
// Applied to net object group ID
|
||
|
|
// Required: true
|
||
|
|
AppliedToNetObjectGroupID string `url:"applied_to_net_object_group_id" json:"applied_to_net_object_group_id" validate:"required"`
|
||
|
|
|
||
|
|
// Description of the schedule rule
|
||
|
|
// Required: true
|
||
|
|
Description string `url:"description" json:"description"`
|
||
|
|
|
||
|
|
// Display name of the schedule rule
|
||
|
|
// Required: true
|
||
|
|
DisplayName string `url:"display_name" json:"display_name"`
|
||
|
|
|
||
|
|
// Enabled status of the schedule rule
|
||
|
|
// Required: true
|
||
|
|
Enabled bool `url:"enabled" json:"enabled"`
|
||
|
|
|
||
|
|
// End date and time for the schedule rule
|
||
|
|
// Required: false
|
||
|
|
EndDateTime string `url:"end_date_time,omitempty" json:"end_date_time,omitempty"`
|
||
|
|
|
||
|
|
// Insert up reference
|
||
|
|
// Required: false
|
||
|
|
InsertUp string `url:"insert_up,omitempty" json:"insert_up,omitempty"`
|
||
|
|
|
||
|
|
// Locked at timestamp
|
||
|
|
// Required: false
|
||
|
|
LockedAt string `url:"locked_at,omitempty" json:"locked_at,omitempty"`
|
||
|
|
|
||
|
|
// Schedule cron expression
|
||
|
|
// Required: false
|
||
|
|
ScheduleCron string `url:"schedule_cron,omitempty" json:"schedule_cron,omitempty"`
|
||
|
|
|
||
|
|
// Start date and time for the schedule rule
|
||
|
|
// Required: false
|
||
|
|
StartDateTime string `url:"start_date_time,omitempty" json:"start_date_time,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update updates a security policy
|
||
|
|
func (i SecurityPolicies) Update(ctx context.Context, req UpdateRequest) (*SecurityPolicySummary, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/sdn/security_policy/update"
|
||
|
|
|
||
|
|
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPut, url, constants.MIMEJSON, req)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
info := SecurityPolicySummary{}
|
||
|
|
|
||
|
|
err = json.Unmarshal(res, &info)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
|
||
|
|
return &info, nil
|
||
|
|
}
|