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/cloudbroker/trunk/access_grant.go

43 lines
1007 B

package trunk
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessGrant struct to grant access to a trunk to some accounts
type AccessGrantRequest struct {
// ID of the trunk to disable
// Required: true
TrunkID uint64 `url:"id" json:"id" validate:"required"`
// IDs of the accounts to grant access to
// Required: true
AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"`
}
// AccessGrant grants access to a trunk
func (t Trunk) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/trunk/access_grant"
res, err := t.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}