Skip to content
rpedde edited this page Nov 14, 2012 · 6 revisions

API Requests

Can't Be Solved

  • Backend
    • Return 403 (Forbidden) -- Request understood but cannot be fulfilled as-requested
    • Return friendly message explaining why:
      • { friendly: ["Because", "Because", "Of the wonderful things he does"] }
  • Frontend
    • Display friendly messages somehow
    • Insult user for stupidity

Doesn't Require Solver

  • Backend
    • Execute requested function
    • Return 202 (Accepted) -- Request is accepted for processing but not yet completed
    • Return body should indicate resource (task?) to obtain status:
      • { node: { /* consequences applied */ } } <- includes node_adventure
  • Frontend
    • Display pending success until/unless notified otherwise
    • Subscribe to results (or poll until pub/sub available)
    • Update status when task succeeds/fails

Requires Solver

  • Backend
    • Run solver
    • Determine no input required
    • Execute solution (?)
    • Return 202 (Accepted) -- Request is accepted for processing but not yet completed
      • { node: { /* consequences applied */ } } <- includes node_adventure
  • Frontend
    • Display pending success until/unless notified otherwise
    • Subscribe to results (or poll until pub/sub available)
    • Update status when task succeeds/fails

Requires Additional Input

  • Backend
    • Return 409 (Conflict) -- Resource requires additional information for request to proceed
    • Return information about what information is required:
      • { args: {primitive_id: { name: {type: "", desc: "", choices: [...] }}, primitive_id: {...} } }
  • Frontend
    • Modal dialog with input fields from returned information
    • Submit/cancel information according to JSON winmode blob below

RANDOM JSON EXEMPLIFICATION

(Not for consumption)

// Solver request return body (INPUT REQUIRED) { "args": { 1: { "chef-server": { "type": "interface", "name": "chef-server", "desc": "Node providing chef-server interface", "choices": [ "2", "3" ], }, "nova-controller": { "type": "interface", "name": "nova-controller", "desc": "Node providing Nova-Controller services", "choices": [ "4", "5" ] } }, 2: { "hostname": { "type": "string", "desc": "Hostname" } } } }

// POST request body (PROVIDING INPUT REQUESTED) { "args": { 1: { "chef-server": "2", "nova-controller": "5" }, 2: { "hostname": "host1" } } }

// UPDATE/POST/PUT/PATCH/SPLICE/INJECT/TOUCH/TICKLE request body { "node": // Object type { "id": 5, "parent_id": 3 }, "args": // ARGUMENTATIONS+ { } }