lib/parsers.js
function parseMachine(entity) {
  return {
    addresses: entity.addresses ? entity.addresses.map(address => ({
      value: address.value,
      type: address.type,
      scope: address.scope
    })) : undefined,
    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,
    // Hardware characteristics are arbitrary so leave the keys as defined.
    hardwareCharacteristics: entity['hardware-characteristics'],
    hasVote: entity['has-vote'],
    id: entity.id,
    instanceID: entity['instance-id'],
    instanceStatus: entity['instance-status'] ? {
      current: entity['instance-status'].current,
      message: entity['instance-status'].message,
      since: entity['instance-status'].since,
      version: entity['instance-status'].version
    } : undefined,
    jobs: entity.jobs,
    life: entity.life,
    modelUUID: entity['model-uuid'],
    series: entity.series,
    supportedContainers: entity['supported-containers'],
    supportedContainersKnown: entity['supported-containers-known'],
    wantsVote: entity['wants-vote']
  };
}
function parseMachine(entity) {
  return {
    addresses: entity.addresses ? entity.addresses.map(address => ({
      value: address.value,
      type: address.type,
      scope: address.scope
    })) : undefined,
    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,
    // Hardware characteristics are arbitrary so leave the keys as defined.
    hardwareCharacteristics: entity['hardware-characteristics'],
    hasVote: entity['has-vote'],
    id: entity.id,
    instanceID: entity['instance-id'],
    instanceStatus: entity['instance-status'] ? {
      current: entity['instance-status'].current,
      message: entity['instance-status'].message,
      since: entity['instance-status'].since,
      version: entity['instance-status'].version
    } : undefined,
    jobs: entity.jobs,
    life: entity.life,
    modelUUID: entity['model-uuid'],
    series: entity.series,
    supportedContainers: entity['supported-containers'],
    supportedContainersKnown: entity['supported-containers-known'],
    wantsVote: entity['wants-vote']
  };
}
function parseMachine ( entity ) { return { addresses : entity . addresses ? entity . addresses . map ( address => ( { value : address . value , type : address . type , scope : address . scope } ) ) : undefined , 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 , // Hardware characteristics are arbitrary so leave the keys as defined. hardwareCharacteristics : entity [ 'hardware-characteristics' ] , hasVote : entity [ 'has-vote' ] , id : entity . id , instanceID : entity [ 'instance-id' ] , instanceStatus : entity [ 'instance-status' ] ? { current : entity [ 'instance-status' ] . current , message : entity [ 'instance-status' ] . message , since : entity [ 'instance-status' ] . since , version : entity [ 'instance-status' ] . version } : undefined , jobs : entity . jobs , life : entity . life , modelUUID : entity [ 'model-uuid' ] , series : entity . series , supportedContainers : entity [ 'supported-containers' ] , supportedContainersKnown : entity [ 'supported-containers-known' ] , wantsVote : entity [ 'wants-vote' ] } ; }
Parse a machine.
@param {Object} entity - The entity details.
@param {Object[]} entity.addresses - The list of address objects.
@param {String} entity.adresses[].value - The address.
@param {String} entity.adresses[].type - The address type.
@param {String} entity.adresses[].scope - The address scope.
@param {Object} entity.agent-status - The agent status.
@param {String} entity.agent-status.current - The current agent 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 {Object} entity.hardware-characteristics - The arbitrary machine hardware details.
@param {String} entity.hardware-characteristics."characteristic-key" - The
characteristic value.
@param {Boolean} entity.has-vote - Whether the entity has a vote.
@param {String} entity.id - The entity id.
@param {String} entity.instance-id - The instance id.
@param {Object} entity.instance-status - The instance status.
@param {String} entity.instance-status.current - The current instance status.
@param {String} entity.instance-status.message - The status message.
@param {String} entity.instance-status.since - The datetime for when the status was set.
@param {String} entity.instance-status.version - The status version.
@param {String} entity.jobs - The list of job strings.
@param {String} entity.life - The lifecycle status of the entity.
@param {String} entity.model-uuid - The model uuid this entity belongs to.
@param {String} entity.series - The entity series.
@param {String} entity.supported-containers - The list of supported container strings.
@param {Boolean} entity.supported-containers-know - Whether the supported containers
are known.
@param {Boolean} entity.wants-vote - Whether the entity wants a vote.
@returns {Object} return - The parsed entity.
@returns {Object[]} return.addresses - The list of address objects.
@returns {String} return.adresses[].value - The address.
@returns {String} return.adresses[].type - The address type.
@returns {String} return.adresses[].scope - The address scope.
@returns {Object} return.agentStatus - The agent status.
@returns {String} return.agentStatus.current - The current agent 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 {Object} return.hardwareCharacteristics - The arbitrary machine hardware details.
@returns {String} return.hardwareCharacteristics."characteristic-key" - The
characteristic value.
@returns {Boolean} return.hasVote - Whether the entity has a vote.
@returns {String} return.id - The entity id.
@returns {String} return.instanceId - The instance id.
@returns {Object} return.instanceStatus - The instance status.
@returns {String} return.instanceStatus.current - The current instance status.
@returns {String} return.instanceStatus.message - The status message.
@returns {String} return.instanceStatus.since - The datetime for when the status was set.
@returns {String} return.instanceStatus.version - The status version.
@returns {String} return.jobs - The list of job strings.
@returns {String} return.life - The lifecycle status of the entity.
@returns {String} return.modelUUID - The model uuid this entity belongs to.
@returns {String} return.series - The entity series.
@returns {String} return.supportedContainers - The list of supported container strings.
@returns {Boolean} return.supportedContainersKnow - Whether the supported containers
are known.
@returns {Boolean} entity.wantsVote - Whether the entity wants a vote.
Parse a machine .