/// <reference types="node" />
import { Message, Properties } from "protobufjs/light";
import { IIdentity } from "./identity-wrapper";
/**
 * A rule will give who is allowed to use a given action
 */
export declare class Rule extends Message<Rule> {
    static readonly OR = "|";
    static readonly AND = "&";
    /**
     * @see README#Message classes
     */
    static register(): void;
    /**
     * Creates a rule given an action and an expression.
     *
     * @param action
     * @param expr
     */
    static fromActionExpr(action: string, expr: Buffer): Rule;
    readonly action: string;
    private expr;
    constructor(props?: Properties<Rule>);
    /**
     * Get a deep clone of the rule
     * @returns the new rule
     */
    clone(): Rule;
    /**
     * Appends an identity given as a string to the expression and returns a copy of the
     * new expression.
     *
     * @param identity the identity to add, given as a string
     * @param op the operator to apply to the expression
     */
    append(identity: string, op: string): Buffer;
    /**
     * Searches for the given identity and removes it from the expression. Currently only
     * expressions containing Rule.OR are supported. It returns a copy of the new expression.
     *
     * @param identity the string representation of the identity
     */
    remove(identity: string): Buffer;
    /**
     * Returns the identities in the expression, in the case it is a single identity,
     * or if the identities are ORed together. If there are brakcets '()' or AND in the
     * expression, it will throw an error.
     */
    getIdentities(): string[];
    /**
     * Returns a copy of the expression.
     */
    getExpr(): Buffer;
    /**
     * Get a string representation of the rule
     * @returns the string representation
     */
    toString(): string;
}
/**
 * Wrapper around a list of rules that provides helpers to manage
 * the rules
 */
export default class Rules extends Message<Rules> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly list: Rule[];
    constructor(properties?: Properties<Rules>);
    /**
     * Create or update a rule with the given identity
     * @param action    the name of the rule
     * @param identity  the identity to append
     * @param op        the operator to use if the rule exists
     */
    appendToRule(action: string, identity: IIdentity, op: string): void;
    /**
     * Sets a rule to correspond to the given identity. If the rule already exists, it will be
     * replaced.
     * @param action    the name of the rule
     * @param identity  the identity to append
     */
    setRule(action: string, identity: IIdentity): void;
    /**
     * Sets the expression of a rule. If the rule already exists, it will be replaced. If the
     * rule does not exist yet, it will be appended to the list of rules.
     * @param action the name of the rule
     * @param expression the expression to put in the rule
     */
    setRuleExp(action: string, expression: Buffer): void;
    /**
     * Removes a given rule from the list.
     *
     * @param action the action that will be removed.
     */
    removeRule(action: string): void;
    /**
     * getRule returns the rule with the given action
     *
     * @param action to search in the rules for.
     */
    getRule(action: string): Rule;
    /**
     * Get a deep copy of the list of rules
     * @returns the clone
     */
    clone(): Rules;
    /**
     * Get a string representation of the rules
     * @returns a string representation
     */
    toString(): string;
}
