{"id":2429,"date":"2015-04-26T22:07:26","date_gmt":"2015-04-26T22:07:26","guid":{"rendered":"http:\/\/blog.soton.ac.uk\/smallworld\/?p=2429"},"modified":"2015-04-30T17:52:55","modified_gmt":"2015-04-30T17:52:55","slug":"rest-api","status":"publish","type":"post","link":"https:\/\/blog.soton.ac.uk\/smallworld\/2015\/04\/26\/rest-api\/","title":{"rendered":"REST API"},"content":{"rendered":"<h2><\/h2>\n<p>As\u00a0Small.World\u00a0was\u00a0designed\u00a0to\u00a0be\u00a0relatively\u00a0simple\u00a0to\u00a0integrate\u00a0into\u00a0other\u00a0systems,<br \/>\na\u00a0method of\u00a0communicating\u00a0with\u00a0the\u00a0coordinator\u00a0was\u00a0required.\u00a0A\u00a0REST\u00a0API\u00a0was chosen\u00a0for this\u00a0as\u00a0REST\u00a0makes\u00a0use\u00a0of\u00a0standard\u00a0HTTP\u00a0protocol\u00a0for\u00a0sending\u00a0commands (via\u00a0the message\u00a0body)<br \/>\nand\u00a0requesting\u00a0information (Masse, 2011),\u00a0allowing\u00a0developers\u00a0to\u00a0work with\u00a0a widely used\u00a0and\u00a0familiar\u00a0protocol\u00a0rather\u00a0than\u00a0one\u00a0tailor\u00a0made\u00a0for\u00a0Small.World. It\u00a0was\u00a0decided that commands\u00a0themselves\u00a0would\u00a0be\u00a0formatted\u00a0as JavaScript\u00a0Object Notation (JSON),chosen\u00a0because\u00a0it\u00a0is\u00a0lightweight\u00a0and\u00a0used\u00a0in\u00a0many\u00a0other\u00a0web\u00a0services.<\/p>\n<p><span style=\"color: #339966\"><em><b>Jobs\u00a0Functionality<\/b><\/em><\/span><\/p>\n<p>The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0single\u00a0job\u00a0(specied\u00a0by\u00a0its\u00a0ID).\u00a0It\u00a0can\u00a0also\u00a0request\u00a0a collection\u00a0of\u00a0all\u00a0jobs\u00a0(or\u00a0all\u00a0job\u00a0IDs)\u00a0currently\u00a0in\u00a0the\u00a0system (Maximilien \u00a0et al, 2007). The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0timestamp\u00a0indicating\u00a0the\u00a0last\u00a0time\u00a0that\u00a0any\u00a0job\u00a0was added\u00a0or deleted(but\u00a0not\u00a0modified).\u00a0There\u00a0is\u00a0also\u00a0a\u00a0method\u00a0that\u00a0returns\u00a0a\u00a0collection of\u00a0all\u00a0jobs which\u00a0have\u00a0been modified\u00a0since\u00a0a\u00a0specified\u00a0time.The\u00a0REST\u00a0API\u00a0can also\u00a0call\u00a0a\u00a0method\u00a0to\u00a0delete\u00a0a\u00a0single\u00a0job,\u00a0specified\u00a0by its\u00a0ID.<\/p>\n<p><span style=\"color: #339966\"><em><b>Agents\u00a0Functionality<\/b><\/em><\/span><\/p>\n<p>The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0single\u00a0Agent\u00a0by\u00a0specifying\u00a0its\u00a0ID.\u00a0It\u00a0can\u00a0also\u00a0request a\u00a0collection\u00a0of\u00a0all\u00a0Agents\u00a0currently\u00a0in\u00a0the\u00a0database\u00a0(not\u00a0just\u00a0the\u00a0currently\u00a0connected Agents).\u00a0There\u00a0is\u00a0a\u00a0method\u00a0which\u00a0returns\u00a0a\u00a0collection\u00a0of\u00a0all\u00a0jobs\u00a0currently\u00a0assigned\u00a0a specified\u00a0Agent\u00a0(on\u00a0any\u00a0of\u00a0its\u00a0cores). There\u00a0is\u00a0also\u00a0a\u00a0method\u00a0which\u00a0allows\u00a0the\u00a0REST\u00a0API\u00a0to\u00a0manually\u00a0delete\u00a0an\u00a0Agent from the system.\u00a0This\u00a0will\u00a0force\u00a0the\u00a0Agent\u00a0to\u00a0disconnect(if\u00a0it\u00a0is\u00a0currently\u00a0connected), will\u00a0unassign\u00a0all\u00a0of\u00a0its\u00a0currently\u00a0allocated\u00a0jobs,\u00a0and will\u00a0remove\u00a0the\u00a0Agent (and\u00a0all\u00a0of\u00a0its\u00a0cores)\u00a0from\u00a0the\u00a0database. For\u00a0a\u00a0specific\u00a0Agent,\u00a0the\u00a0REST\u00a0API\u00a0is\u00a0able\u00a0to\u00a0request\u00a0the\u00a0number\u00a0of\u00a0jobs\u00a0which are currently\u00a0allocated\u00a0to\u00a0that\u00a0Agent&#8217;s\u00a0cores,\u00a0and\u00a0is\u00a0able\u00a0to\u00a0request\u00a0a\u00a0collection including those jobs.\u00a0It\u00a0can\u00a0also\u00a0request\u00a0a\u00a0boolean\u00a0indicating\u00a0whether\u00a0or\u00a0not\u00a0the\u00a0Agent is\u00a0currently online.<\/p>\n<p><em><span style=\"color: #339966\"><b>Languages\u00a0Functionality<\/b><\/span><\/em><\/p>\n<p>The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0collection\u00a0of\u00a0all\u00a0languages\u00a0currently\u00a0supported\u00a0by Small.World\u00a0and\u00a0its\u00a0Agents.\u00a0An\u00a0assumption\u00a0is\u00a0made\u00a0that\u00a0all\u00a0Agents\u00a0support\u00a0the\u00a0same languages,\u00a0since\u00a0language\u00a0support\u00a0is\u00a0determined\u00a0by\u00a0Small.World.<\/p>\n<p><strong>References:<\/strong><\/p>\n<p>Masse,\u00a0M.\u00a0(2011).\u00a0<i>REST\u00a0API\u00a0design\u00a0rulebook<\/i>.\u00a0&#8221;\u00a0O&#8217;Reilly\u00a0Media,\u00a0Inc.&#8221;.<\/p>\n<p>Maximilien,\u00a0E.\u00a0M.,\u00a0Wilkinson,\u00a0H.,\u00a0Desai,\u00a0N.,\u00a0&amp;\u00a0Tai,\u00a0S.\u00a0(2007).\u00a0<i>A\u00a0domain-specific\u00a0language\u00a0for\u00a0web\u00a0apis\u00a0and\u00a0services\u00a0mashups<\/i>\u00a0(pp.\u00a013-26).\u00a0Springer\u00a0Berlin\u00a0Heidelberg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As\u00a0Small.World\u00a0was\u00a0designed\u00a0to\u00a0be\u00a0relatively\u00a0simple\u00a0to\u00a0integrate\u00a0into\u00a0other\u00a0systems, a\u00a0method of\u00a0communicating\u00a0with\u00a0the\u00a0coordinator\u00a0was\u00a0required.\u00a0A\u00a0REST\u00a0API\u00a0was chosen\u00a0for this\u00a0as\u00a0REST\u00a0makes\u00a0use\u00a0of\u00a0standard\u00a0HTTP\u00a0protocol\u00a0for\u00a0sending\u00a0commands (via\u00a0the message\u00a0body) and\u00a0requesting\u00a0information (Masse, 2011),\u00a0allowing\u00a0developers\u00a0to\u00a0work with\u00a0a widely used\u00a0and\u00a0familiar\u00a0protocol\u00a0rather\u00a0than\u00a0one\u00a0tailor\u00a0made\u00a0for\u00a0Small.World. It\u00a0was\u00a0decided that commands\u00a0themselves\u00a0would\u00a0be\u00a0formatted\u00a0as JavaScript\u00a0Object Notation (JSON),chosen\u00a0because\u00a0it\u00a0is\u00a0lightweight\u00a0and\u00a0used\u00a0in\u00a0many\u00a0other\u00a0web\u00a0services. Jobs\u00a0Functionality The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0single\u00a0job\u00a0(specied\u00a0by\u00a0its\u00a0ID).\u00a0It\u00a0can\u00a0also\u00a0request\u00a0a collection\u00a0of\u00a0all\u00a0jobs\u00a0(or\u00a0all\u00a0job\u00a0IDs)\u00a0currently\u00a0in\u00a0the\u00a0system (Maximilien \u00a0et al, 2007). The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0timestamp\u00a0indicating\u00a0the\u00a0last\u00a0time\u00a0that\u00a0any\u00a0job\u00a0was added\u00a0or deleted(but\u00a0not\u00a0modified).\u00a0There\u00a0is\u00a0also\u00a0a\u00a0method\u00a0that\u00a0returns\u00a0a\u00a0collection of\u00a0all\u00a0jobs which\u00a0have\u00a0been modified\u00a0since\u00a0a\u00a0specified\u00a0time.The\u00a0REST\u00a0API\u00a0can also\u00a0call\u00a0a\u00a0method\u00a0to\u00a0delete\u00a0a\u00a0single\u00a0job,\u00a0specified\u00a0by its\u00a0ID. Agents\u00a0Functionality The\u00a0REST\u00a0API\u00a0can\u00a0request\u00a0a\u00a0single\u00a0Agent\u00a0by\u00a0specifying\u00a0its\u00a0ID.\u00a0It\u00a0can\u00a0also\u00a0request a\u00a0collection\u00a0of\u00a0all\u00a0Agents\u00a0currently\u00a0in\u00a0the\u00a0database\u00a0(not\u00a0just\u00a0the\u00a0currently\u00a0connected Agents).\u00a0There\u00a0is\u00a0a\u00a0method\u00a0which\u00a0returns\u00a0a\u00a0collection\u00a0of\u00a0all\u00a0jobs\u00a0currently\u00a0assigned\u00a0a specified\u00a0Agent\u00a0(on\u00a0any\u00a0of\u00a0its\u00a0cores). There\u00a0is\u00a0also\u00a0a\u00a0method\u00a0which\u00a0allows\u00a0the\u00a0REST\u00a0API\u00a0to\u00a0manually\u00a0delete\u00a0an\u00a0Agent &hellip; <a href=\"https:\/\/blog.soton.ac.uk\/smallworld\/2015\/04\/26\/rest-api\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":97423,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10539],"tags":[6477,720636,974819,717361],"class_list":["post-2429","post","type-post","status-publish","format-standard","hentry","category-overview-of-standards-and-protocols","tag-api","tag-protocol","tag-restful","tag-standard"],"_links":{"self":[{"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/posts\/2429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/users\/97423"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/comments?post=2429"}],"version-history":[{"count":12,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/posts\/2429\/revisions"}],"predecessor-version":[{"id":2638,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/posts\/2429\/revisions\/2638"}],"wp:attachment":[{"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/media?parent=2429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/categories?post=2429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.soton.ac.uk\/smallworld\/wp-json\/wp\/v2\/tags?post=2429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}