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.
50 lines
1.2 KiB
50 lines
1.2 KiB
package acsgroups
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// PatchRequest struct to update access group
|
|
type PatchRequest struct {
|
|
// Access group ID
|
|
// Required: true
|
|
AccessGroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
|
|
|
|
// Comment of the acces group
|
|
// Required: false
|
|
Comment string `url:"comment,omitempty" json:"comment,omitempty"`
|
|
|
|
// Name of acces group
|
|
// Required: false
|
|
DisplayName string `url:"display_name,omitempty" json:"display_name,omitempty"`
|
|
}
|
|
|
|
// Update updates a access groups
|
|
func (i AccessGroups) Patch(ctx context.Context, req PatchRequest) (*AccessGroup, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/sdn/access_group/patch"
|
|
|
|
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPatch, url, constants.MIMEJSON, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
info := AccessGroup{}
|
|
|
|
err = json.Unmarshal(res, &info)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &info, nil
|
|
}
|