lib/parsers.js
function parseUnit(entity) {
  return {
    agentStatus: entity['agent-status'] ? {
      current: entity['agent-status'].current,
      message: entity['agent-status'].message,
      since: entity['agent-status'].since,
      version: entity['agent-status'].version
    } : undefined,
    application: entity.application,
    charmURL: entity['charm-url'],
    machineID: entity['machine-id'],
    modelUUID: entity['model-uuid'],
    name: entity.name,
    portRanges: entity['port-ranges'] ? entity['port-ranges'].map(range => ({
      fromPort: range['from-port'],
      toPort: range['to-port'],
      protocol: range.protocol
    })) : undefined,
    ports: entity.ports ? entity.ports.map(port => ({
      protocol: port.protocol,
      number: port.number
    })) : undefined,
    privateAddress: entity['private-address'],
    publicAddress: entity['public-address'],
    series: entity.series,
    subordinate: entity.subordinate,
    workloadStatus: entity['workload-status'] ? {
      current: entity['workload-status'].current,
      message: entity['workload-status'].message,
      since: entity['workload-status'].since,
      version: entity['workload-status'].version
    } : undefined
  };
}
function parseUnit(entity) {
  return {
    agentStatus: entity['agent-status'] ? {
      current: entity['agent-status'].current,
      message: entity['agent-status'].message,
      since: entity['agent-status'].since,
      version: entity['agent-status'].version
    } : undefined,
    application: entity.application,
    charmURL: entity['charm-url'],
    machineID: entity['machine-id'],
    modelUUID: entity['model-uuid'],
    name: entity.name,
    portRanges: entity['port-ranges'] ? entity['port-ranges'].map(range => ({
      fromPort: range['from-port'],
      toPort: range['to-port'],
      protocol: range.protocol
    })) : undefined,
    ports: entity.ports ? entity.ports.map(port => ({
      protocol: port.protocol,
      number: port.number
    })) : undefined,
    privateAddress: entity['private-address'],
    publicAddress: entity['public-address'],
    series: entity.series,
    subordinate: entity.subordinate,
    workloadStatus: entity['workload-status'] ? {
      current: entity['workload-status'].current,
      message: entity['workload-status'].message,
      since: entity['workload-status'].since,
      version: entity['workload-status'].version
    } : undefined
  };
}
function parseUnit ( entity ) { return { agentStatus : entity [ 'agent-status' ] ? { current : entity [ 'agent-status' ] . current , message : entity [ 'agent-status' ] . message , since : entity [ 'agent-status' ] . since , version : entity [ 'agent-status' ] . version } : undefined , application : entity . application , charmURL : entity [ 'charm-url' ] , machineID : entity [ 'machine-id' ] , modelUUID : entity [ 'model-uuid' ] , name : entity . name , portRanges : entity [ 'port-ranges' ] ? entity [ 'port-ranges' ] . map ( range => ( { fromPort : range [ 'from-port' ] , toPort : range [ 'to-port' ] , protocol : range . protocol } ) ) : undefined , ports : entity . ports ? entity . ports . map ( port => ( { protocol : port . protocol , number : port . number } ) ) : undefined , privateAddress : entity [ 'private-address' ] , publicAddress : entity [ 'public-address' ] , series : entity . series , subordinate : entity . subordinate , workloadStatus : entity [ 'workload-status' ] ? { current : entity [ 'workload-status' ] . current , message : entity [ 'workload-status' ] . message , since : entity [ 'workload-status' ] . since , version : entity [ 'workload-status' ] . version } : undefined } ; }
Parse a unit.
@param entity {Object} The entity details.
@param {Object} entity.agent-status - The agent status.
@param {String} entity.agent-status.current - The current status.
@param {String} entity.agent-status.message - The status message.
@param {String} entity.agent-status.since - The datetime for when the status was set.
@param {String} entity.agent-status.version - The status version.
@param {String} entity.application - The application this entity belongs to.
@param {String} entity.charm-url - The charm URL for this unit.
@param {String} entity.machine-id - The id of the machine this unit is on.
@param {String} entity.model-uuid - The model uuid this entity belongs to.
@param {String} entity.name - The name of the unit.
@param {Object[]} entity.port-ranges[] - The collection of port range objects.
@param {Integer} entity.port-ranges[].from-port - The start of the port range.
@param {Integer} entity.port-ranges[].to-port - The end of the port range.
@param {String} entity.port-ranges[].protocol - The port protocol.
@param {Object[]} entity.ports - The collection of port objects.
@param {String} entity.ports[].protocol - The port protocol.
@param {Integer} entity.ports[].number - The port number.
@param {String} entity.private-address - The unit's private address.
@param {String} entity.public-address - The unit's public address.
@param {String} entity.series - The series of the unit.
@param {Boolean} entity.subordinate - Whether the unit is a subordinate.
@param {Object} entity.workload-status - The workload status.
@param {String} entity.workload-status.current - The current status.
@param {String} entity.workload-status.message - The status message.
@param {String} entity.workload-status.since - The datetime for when the status was set.
@param {String} entity.workload-status.version - The status version.
@returns {Object} return The parsed entity.
@returns {Object} return.agentStatus - The agent status.
@returns {String} return.agentStatus.current - The current status.
@returns {String} return.agentStatus.message - The status message.
@returns {String} return.agentStatus.since - The datetime for when the status was set.
@returns {String} return.agentStatus.version - The status version.
@returns {String} return.application - The application this entity belongs to.
@returns {String} return.charmURL - The charm URL for this unit.
@returns {String} return.machineID - The id of the machine this unit is on.
@returns {String} return.modelUUID - The model uuid this entity belongs to.
@returns {String} return.name - The name of the unit.
@returns {Object[]} return.portRanges - The collection of port range objects.
@returns {Integer} return.portRanges[].fromPort - The start of the port range.
@returns {Integer} return.portRanges[].toPort - The end of the port range.
@returns {String} return.portRanges[].protocol - The port protocol.
@returns {Object[]} return.ports - The collection of port objects.
@returns {String} return.ports[].protocol - The port protocol.
@returns {Integer} return.ports[].number - The port number.
@returns {String} return.privateAddress - The unit's private address.
@returns {String} return.publicAddress - The unit's public address.
@returns {String} return.series - The series of the unit.
@returns {Boolean} return.subordinate - Whether the unit is a subordinate.
@returns {Object} return.workloadStatus - The workload status.
@returns {String} return.workloadStatus.current - The current status.
@returns {String} return.workloadStatus.message - The status message.
@returns {String} return.workloadStatus.since - The datetime for when the status was set.
@returns {String} return.workloadStatus.version - The status version.
Parse a unit .