nuagenetworks / monolithe

generic and extendable code generator from specifications.
BSD 3-Clause "New" or "Revised" License
16 stars 28 forks source link

Entity/Attribute - label, description, codegen #51

Closed killanch closed 7 years ago

killanch commented 7 years ago

@natabal can you pls review

killanch commented 7 years ago

sample generated code NUBFDSession.j

import NUAttribute from 'service/NUAttribute';
import ServiceClassRegistry from 'service/ServiceClassRegistry';
import NUEntity from 'service/NUEntity';

/* Represents BFDSession entity
   Represents the Bidirectional Forwarding Detection session that can be configured on an uplink/BR
   connection.
*/
export default class NUBFDSession extends NUEntity {
    constructor(...args) {
        super(...args);
        this.defineProperties({
            BFDDestinationIP: null,
            BFDMultiplier: 3,
            BFDTimer: 500,
            multiHopEnabled: false,
        });
    }

    static entityDescriptor = {
        description: `Represents the Bidirectional Forwarding Detection session that can be configured on an uplink/BR connection.`,
        userlabel: 'BFD Session',
    }

    static attributeDescriptors = {
        ...NUEntity.attributeDescriptors,
        BFDDestinationIP: new NUAttribute({
            localName: 'BFDDestinationIP',
            attributeType: NUAttribute.ATTR_TYPE_STRING,
            description: `Destination IP Address used for Bidirectional Forwarding Detection.`,
            canOrder: true,
            canSearch: true,
            userlabel: 'None',
        }),
        BFDMultiplier: new NUAttribute({
            localName: 'BFDMultiplier',
            attributeType: NUAttribute.ATTR_TYPE_INTEGER,
            description: `Multiplier used for Bidirectional Forwarding Detection Timer.`,
            userlabel: 'None',
        }),
        BFDTimer: new NUAttribute({
            localName: 'BFDTimer',
            attributeType: NUAttribute.ATTR_TYPE_INTEGER,
            description: `Timer for Bidirectional Forwarding Detection. (min = 200, max = 100,000) Unit is milliseconds.`,
            userlabel: 'None',
        }),
        multiHopEnabled: new NUAttribute({
            localName: 'multiHopEnabled',
            attributeType: NUAttribute.ATTR_TYPE_BOOLEAN,
            description: `Boolean flag to indicate whether the BFD Session has single hop or multi hop capability.`,
            userlabel: 'None',
        }),
    }

    get RESTName() {
        return 'bfdsession';
    }

    get resourceName() {
        return 'bfdsessions';
    }
}

ServiceClassRegistry.register(NUBFDSession);
killanch commented 7 years ago

@natabal pls check if ok, ill push this in and get vspk regenerated

natabal commented 7 years ago

This looks good!