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_revoke.go

43 lines
1.0 KiB

package trunk
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AccessRevoke struct to grant access to a trunk to some accounts
type AccessRevokeRequest struct {
// ID of the trunk to disable
// Required: true
TrunkID uint64 `url:"id" json:"id" validate:"required"`
// IDs of the accounts to revoke access from
// Required: true
AccountIDs []uint64 `url:"account_ids" json:"account_ids" validate:"required"`
}
// AccessRevoke revokes access to a trunk from accounts
func (t Trunk) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/trunk/access_revoke"
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
}