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.
decort-golang-sdk/pkg/sdn/acsgroups/create.go

46 lines
1.1 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"
)
// CreateRequest struct to create access group
type CreateRequest struct {
// Comment of the access group
// Required: true
Comment string `url:"comment" json:"comment" validate:"required"`
// Name of acces group
// Required: true
DisplayName string `url:"display_name" json:"display_name" validate:"required"`
}
// Create creates a access groups
func (i AccessGroups) Create(ctx context.Context, req CreateRequest) (*AccessGroupItem, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/access_group/create"
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return nil, err
}
info := AccessGroupItem{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}