{"action":"created","comment":{"url":"https://api.github.com/repos/coursera/naptime/pulls/comments/71433086","id":71433086,"diff_hunk":"@@ -0,0 +1,87 @@\n+package org.coursera.naptime.ari\n+\n+import com.linkedin.data.DataMap\n+import org.coursera.naptime.ResourceName\n+import org.coursera.naptime.schema.Resource\n+import play.api.libs.json.JsValue\n+import play.api.mvc.RequestHeader\n+\n+import scala.concurrent.Future\n+\n+/**\n+ * The engine layer presents this EngineAPI to the presentation layer. The engine layer handles query validation,\n+ * execution planning & optimization, and finally orchestrates the fetching of data by leveraging the [[FetcherApi]].\n+ *\n+ * Engine's must be threadsafe as they are called from multiple threads simultaneously.\n+ */\n+trait EngineApi {\n+  /**\n+   * Fetches all data needed to formulate a response to the query.\n+   *\n+   * TODO: Consider returning an `Either[Set[Errors], Future[Response]]` instead for more structured validation errors\n+   *\n+   * @param request The resource request to execute.\n+   * @return A future of all available data needed to construct a response to the query. It is up to the presentation\n+   *         layer to turn that into the response format as required.\n+   */\n+  def execute(request: Request): Future[Response]\n+\n+  /**\n+   * Gets the Naptime schema currently in use by the presentation layer.\n+   *\n+   * TODO: include the Courier model schemas\n+   */\n+  def schema: Seq[Resource]\n+}\n+\n+/**\n+ * The fetcher calls the Naptime APIs (either local or remote) to acquire all of the data necessary.\n+ */\n+trait FetcherApi {\n+  // TODO: use better types here\n+  def data(request: Request): Future[Response]\n+}\n+\n+/**\n+ * This encapsulates all of the information needed to compute a response.\n+ *\n+ * @param requestHeader The request header is used for authentication parsing in the underlying requests made. Path\n+ *                      and query parameters included in the request header are ignored in favor of the data within the\n+ *                      topLevelRequests fields.\n+ * @param topLevelRequests A non-empty list of \"roots\" used to begin queries. Every query begins with a \"base\" resource\n+ *                         and related models are joined upon it from there.\n+ */\n+case class Request(\n+  requestHeader: RequestHeader,\n+  topLevelRequests: Seq[(ResourceName, RequestField)]\n+)\n+\n+/**\n+ * Represents a requested field within a requested resource.\n+ *\n+ * @param name The name of the requested field.\n+ * @param alias The name the field should be renamed to in the response.\n+ * @param args If the field takes parameters, they are encapsulated here.\n+ * @param relatedResource The list of fields in the related resource.\n+ */\n+case class RequestField(\n+  name: String,\n+  alias: Option[String],\n+  args: Set[(String, JsValue)],\n+  relatedResource: List[RequestField])\n+\n+// TODO: Should JsValue be a specific ARI type?\n+\n+/**\n+ * All of the data required to assemble a response to an automatic includes query.\n+ *\n+ * @param output A map from resource name to a response\n+ */\n+case class Response(\n+  output: Map[ResourceName, ResourceResponse]\n+)\n+\n+// TODO: figure out directives\n+\n+// TODO: key may change to a more sophisticated type. It should be a ResourceName, but with hydrated path parameters.\n+case class ResourceResponse(key: String, models: Seq[DataMap])","path":"naptime/src/main/scala/org/coursera/naptime/ari/models.scala","position":87,"original_position":87,"commit_id":"d74beeadf0f25fe7582752188d27d4542924524b","original_commit_id":"d74beeadf0f25fe7582752188d27d4542924524b","user":{"login":"bryan-coursera","id":4421444,"avatar_url":"https://avatars.githubusercontent.com/u/4421444?v=3","gravatar_id":"","url":"https://api.github.com/users/bryan-coursera","html_url":"https://github.com/bryan-coursera","followers_url":"https://api.github.com/users/bryan-coursera/followers","following_url":"https://api.github.com/users/bryan-coursera/following{/other_user}","gists_url":"https://api.github.com/users/bryan-coursera/gists{/gist_id}","starred_url":"https://api.github.com/users/bryan-coursera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryan-coursera/subscriptions","organizations_url":"https://api.github.com/users/bryan-coursera/orgs","repos_url":"https://api.github.com/users/bryan-coursera/repos","events_url":"https://api.github.com/users/bryan-coursera/events{/privacy}","received_events_url":"https://api.github.com/users/bryan-coursera/received_events","type":"User","site_admin":false},"body":"should this also include pagination / other response metadata?","created_at":"2016-07-19T22:05:32Z","updated_at":"2016-07-19T22:05:32Z","html_url":"https://github.com/coursera/naptime/pull/64#discussion_r71433086","pull_request_url":"https://api.github.com/repos/coursera/naptime/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/coursera/naptime/pulls/comments/71433086"},"html":{"href":"https://github.com/coursera/naptime/pull/64#discussion_r71433086"},"pull_request":{"href":"https://api.github.com/repos/coursera/naptime/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/coursera/naptime/pulls/64","id":78056309,"html_url":"https://github.com/coursera/naptime/pull/64","diff_url":"https://github.com/coursera/naptime/pull/64.diff","patch_url":"https://github.com/coursera/naptime/pull/64.patch","issue_url":"https://api.github.com/repos/coursera/naptime/issues/64","number":64,"state":"open","locked":false,"title":"Proposal automatic resource inclusion abstractions","user":{"login":"saeta","id":1284535,"avatar_url":"https://avatars.githubusercontent.com/u/1284535?v=3","gravatar_id":"","url":"https://api.github.com/users/saeta","html_url":"https://github.com/saeta","followers_url":"https://api.github.com/users/saeta/followers","following_url":"https://api.github.com/users/saeta/following{/other_user}","gists_url":"https://api.github.com/users/saeta/gists{/gist_id}","starred_url":"https://api.github.com/users/saeta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saeta/subscriptions","organizations_url":"https://api.github.com/users/saeta/orgs","repos_url":"https://api.github.com/users/saeta/repos","events_url":"https://api.github.com/users/saeta/events{/privacy}","received_events_url":"https://api.github.com/users/saeta/received_events","type":"User","site_admin":false},"body":"Define key abstractions that will form the basis for the automatic\r\nresource inclusion and GraphQL work.","created_at":"2016-07-19T21:56:22Z","updated_at":"2016-07-19T22:05:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8df8d72b05b9638539b5ddd6772e73bcaac781d5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coursera/naptime/pulls/64/commits","review_comments_url":"https://api.github.com/repos/coursera/naptime/pulls/64/comments","review_comment_url":"https://api.github.com/repos/coursera/naptime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coursera/naptime/issues/64/comments","statuses_url":"https://api.github.com/repos/coursera/naptime/statuses/d74beeadf0f25fe7582752188d27d4542924524b","head":{"label":"saeta:graphql-model","ref":"graphql-model","sha":"d74beeadf0f25fe7582752188d27d4542924524b","user":{"login":"saeta","id":1284535,"avatar_url":"https://avatars.githubusercontent.com/u/1284535?v=3","gravatar_id":"","url":"https://api.github.com/users/saeta","html_url":"https://github.com/saeta","followers_url":"https://api.github.com/users/saeta/followers","following_url":"https://api.github.com/users/saeta/following{/other_user}","gists_url":"https://api.github.com/users/saeta/gists{/gist_id}","starred_url":"https://api.github.com/users/saeta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saeta/subscriptions","organizations_url":"https://api.github.com/users/saeta/orgs","repos_url":"https://api.github.com/users/saeta/repos","events_url":"https://api.github.com/users/saeta/events{/privacy}","received_events_url":"https://api.github.com/users/saeta/received_events","type":"User","site_admin":false},"repo":{"id":57408936,"name":"naptime","full_name":"saeta/naptime","owner":{"login":"saeta","id":1284535,"avatar_url":"https://avatars.githubusercontent.com/u/1284535?v=3","gravatar_id":"","url":"https://api.github.com/users/saeta","html_url":"https://github.com/saeta","followers_url":"https://api.github.com/users/saeta/followers","following_url":"https://api.github.com/users/saeta/following{/other_user}","gists_url":"https://api.github.com/users/saeta/gists{/gist_id}","starred_url":"https://api.github.com/users/saeta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saeta/subscriptions","organizations_url":"https://api.github.com/users/saeta/orgs","repos_url":"https://api.github.com/users/saeta/repos","events_url":"https://api.github.com/users/saeta/events{/privacy}","received_events_url":"https://api.github.com/users/saeta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/saeta/naptime","description":"Making REST APIs so easy, you can build them in your sleep!","fork":true,"url":"https://api.github.com/repos/saeta/naptime","forks_url":"https://api.github.com/repos/saeta/naptime/forks","keys_url":"https://api.github.com/repos/saeta/naptime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saeta/naptime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saeta/naptime/teams","hooks_url":"https://api.github.com/repos/saeta/naptime/hooks","issue_events_url":"https://api.github.com/repos/saeta/naptime/issues/events{/number}","events_url":"https://api.github.com/repos/saeta/naptime/events","assignees_url":"https://api.github.com/repos/saeta/naptime/assignees{/user}","branches_url":"https://api.github.com/repos/saeta/naptime/branches{/branch}","tags_url":"https://api.github.com/repos/saeta/naptime/tags","blobs_url":"https://api.github.com/repos/saeta/naptime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saeta/naptime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saeta/naptime/git/refs{/sha}","trees_url":"https://api.github.com/repos/saeta/naptime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saeta/naptime/statuses/{sha}","languages_url":"https://api.github.com/repos/saeta/naptime/languages","stargazers_url":"https://api.github.com/repos/saeta/naptime/stargazers","contributors_url":"https://api.github.com/repos/saeta/naptime/contributors","subscribers_url":"https://api.github.com/repos/saeta/naptime/subscribers","subscription_url":"https://api.github.com/repos/saeta/naptime/subscription","commits_url":"https://api.github.com/repos/saeta/naptime/commits{/sha}","git_commits_url":"https://api.github.com/repos/saeta/naptime/git/commits{/sha}","comments_url":"https://api.github.com/repos/saeta/naptime/comments{/number}","issue_comment_url":"https://api.github.com/repos/saeta/naptime/issues/comments{/number}","contents_url":"https://api.github.com/repos/saeta/naptime/contents/{+path}","compare_url":"https://api.github.com/repos/saeta/naptime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saeta/naptime/merges","archive_url":"https://api.github.com/repos/saeta/naptime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saeta/naptime/downloads","issues_url":"https://api.github.com/repos/saeta/naptime/issues{/number}","pulls_url":"https://api.github.com/repos/saeta/naptime/pulls{/number}","milestones_url":"https://api.github.com/repos/saeta/naptime/milestones{/number}","notifications_url":"https://api.github.com/repos/saeta/naptime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saeta/naptime/labels{/name}","releases_url":"https://api.github.com/repos/saeta/naptime/releases{/id}","deployments_url":"https://api.github.com/repos/saeta/naptime/deployments","created_at":"2016-04-29T19:45:40Z","updated_at":"2016-04-29T19:45:41Z","pushed_at":"2016-07-19T21:56:06Z","git_url":"git://github.com/saeta/naptime.git","ssh_url":"git@github.com:saeta/naptime.git","clone_url":"https://github.com/saeta/naptime.git","svn_url":"https://github.com/saeta/naptime","homepage":"","size":596,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"coursera:graphql","ref":"graphql","sha":"52ee3553cf9474678c05787da566319344ec0b81","user":{"login":"coursera","id":1744549,"avatar_url":"https://avatars.githubusercontent.com/u/1744549?v=3","gravatar_id":"","url":"https://api.github.com/users/coursera","html_url":"https://github.com/coursera","followers_url":"https://api.github.com/users/coursera/followers","following_url":"https://api.github.com/users/coursera/following{/other_user}","gists_url":"https://api.github.com/users/coursera/gists{/gist_id}","starred_url":"https://api.github.com/users/coursera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coursera/subscriptions","organizations_url":"https://api.github.com/users/coursera/orgs","repos_url":"https://api.github.com/users/coursera/repos","events_url":"https://api.github.com/users/coursera/events{/privacy}","received_events_url":"https://api.github.com/users/coursera/received_events","type":"Organization","site_admin":false},"repo":{"id":57407978,"name":"naptime","full_name":"coursera/naptime","owner":{"login":"coursera","id":1744549,"avatar_url":"https://avatars.githubusercontent.com/u/1744549?v=3","gravatar_id":"","url":"https://api.github.com/users/coursera","html_url":"https://github.com/coursera","followers_url":"https://api.github.com/users/coursera/followers","following_url":"https://api.github.com/users/coursera/following{/other_user}","gists_url":"https://api.github.com/users/coursera/gists{/gist_id}","starred_url":"https://api.github.com/users/coursera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coursera/subscriptions","organizations_url":"https://api.github.com/users/coursera/orgs","repos_url":"https://api.github.com/users/coursera/repos","events_url":"https://api.github.com/users/coursera/events{/privacy}","received_events_url":"https://api.github.com/users/coursera/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coursera/naptime","description":"Making REST APIs so easy, you can build them in your sleep!","fork":false,"url":"https://api.github.com/repos/coursera/naptime","forks_url":"https://api.github.com/repos/coursera/naptime/forks","keys_url":"https://api.github.com/repos/coursera/naptime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coursera/naptime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coursera/naptime/teams","hooks_url":"https://api.github.com/repos/coursera/naptime/hooks","issue_events_url":"https://api.github.com/repos/coursera/naptime/issues/events{/number}","events_url":"https://api.github.com/repos/coursera/naptime/events","assignees_url":"https://api.github.com/repos/coursera/naptime/assignees{/user}","branches_url":"https://api.github.com/repos/coursera/naptime/branches{/branch}","tags_url":"https://api.github.com/repos/coursera/naptime/tags","blobs_url":"https://api.github.com/repos/coursera/naptime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coursera/naptime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coursera/naptime/git/refs{/sha}","trees_url":"https://api.github.com/repos/coursera/naptime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coursera/naptime/statuses/{sha}","languages_url":"https://api.github.com/repos/coursera/naptime/languages","stargazers_url":"https://api.github.com/repos/coursera/naptime/stargazers","contributors_url":"https://api.github.com/repos/coursera/naptime/contributors","subscribers_url":"https://api.github.com/repos/coursera/naptime/subscribers","subscription_url":"https://api.github.com/repos/coursera/naptime/subscription","commits_url":"https://api.github.com/repos/coursera/naptime/commits{/sha}","git_commits_url":"https://api.github.com/repos/coursera/naptime/git/commits{/sha}","comments_url":"https://api.github.com/repos/coursera/naptime/comments{/number}","issue_comment_url":"https://api.github.com/repos/coursera/naptime/issues/comments{/number}","contents_url":"https://api.github.com/repos/coursera/naptime/contents/{+path}","compare_url":"https://api.github.com/repos/coursera/naptime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coursera/naptime/merges","archive_url":"https://api.github.com/repos/coursera/naptime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coursera/naptime/downloads","issues_url":"https://api.github.com/repos/coursera/naptime/issues{/number}","pulls_url":"https://api.github.com/repos/coursera/naptime/pulls{/number}","milestones_url":"https://api.github.com/repos/coursera/naptime/milestones{/number}","notifications_url":"https://api.github.com/repos/coursera/naptime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coursera/naptime/labels{/name}","releases_url":"https://api.github.com/repos/coursera/naptime/releases{/id}","deployments_url":"https://api.github.com/repos/coursera/naptime/deployments","created_at":"2016-04-29T19:27:17Z","updated_at":"2016-07-08T15:39:04Z","pushed_at":"2016-07-19T21:56:22Z","git_url":"git://github.com/coursera/naptime.git","ssh_url":"git@github.com:coursera/naptime.git","clone_url":"https://github.com/coursera/naptime.git","svn_url":"https://github.com/coursera/naptime","homepage":"","size":655,"stargazers_count":17,"watchers_count":17,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":8,"forks":6,"open_issues":8,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coursera/naptime/pulls/64"},"html":{"href":"https://github.com/coursera/naptime/pull/64"},"issue":{"href":"https://api.github.com/repos/coursera/naptime/issues/64"},"comments":{"href":"https://api.github.com/repos/coursera/naptime/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/coursera/naptime/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/coursera/naptime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coursera/naptime/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/coursera/naptime/statuses/d74beeadf0f25fe7582752188d27d4542924524b"}}}}
{"actor":{"display_login":"bryan-coursera"}}