Orion: RESTful git API
Tomasz Żarna
Eclipse PlatformWorkspace/Orion, IBM
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST
REST explained in 5 steps:
● Give every "thing" an ID
● Link "things" to each other
● Use standard methods
● Allow multiple representations
● Communicate statelessly
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST (cntd)
Advantages
● universal support (programming languages, OSes, servers)
● proven scalability i.e. Wide Wide Web
● real machine-2-machine integration
● support for XML and other formats
Some HTTP features:
● standardized verbs and response codes
● content negotiation
● redirection
● caching
● compression
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
Server
● Jetty 6.1.x / javax.servlet 2.5
● org.eclipse.equinox.http.registry.servlets / OSGi HttpService
○ class
○ alias
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST API: GET
GET /gitapi/commit/master/file/a/?page=1
HTTP/1.1 200 OK
{
"Children" : [
{
"AuthorName" : "Tomasz Zarna",
"Children" : [{ }],
"ContentLocation" : "/gitapi/commit/6d34f45b/file/a/?
parts=body",
"Message" : "Fix for bug 345325",
"Location" : "/gitapi/commit/6d34f45b/file/a/",
"Time" : 1304073355000,
"DiffLocation" : "/gitapi/diff/6d34f45b/file/a/",
},
{ ... }
}
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST API: POST
POST /gitapi/clone/
{
"GitUrl" : "git://github.com/eclipse/orion.server.git",
"Path" : "/file/a/"
}
HTTP/1.1 201 CREATED
{
"Id" : "IOOD6ph8ABASBcDqmXX87w",
"Location" : "/task/id/IOOD6ph8ABASBcDqmXX87w",
"Message" : "Cloning git://github.com/eclipse/orion.server.git...",
"PercentComplete" : 0,
"Running" : true
}
GET {Location}
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST API: PUT
PUT /gitapi/commit/6d34f45b/file/a/
{
"TagName" : "v20110611"
}
HTTP/1.1 200 OK
{
"AuthorName" : "Tomasz Zarna",
"Children" : [{ "v20110523", "v20110611"}],
"ContentLocation" : "/gitapi/commit/6d34f45b/file/a/?parts=body",
"Message" : "Fix for bug 345325",
"Location" : "/gitapi/commit/6d34f45b/file/a/",
"Time" : 1304073355000,
"DiffLocation" : "/gitapi/diff/6d34f45b/file/a/"
}
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
REST API: DELETE
DELETE /gitapi/remote/{remoteName}/file/{id}
HTTP/1.1 200 OK
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
git commands
git-add git-commit git-mv git-show pack-pack-refs git-count-object
git-am git-describe git-notes git-stash git-prune git-difftool
git-archive git-diff git-pull git-status git-reflog git-fsck
git-bisect git-fetch git-push git-submodule git-relink git-get-tar-commit-id
git-branch git-format-patch git-rebase git-tag git-remote git-help
git-bundle git-gc git-reset git-config git-repack git-merge-tree
git-checkout git-grep git-rebase git-fast-export git-replace git-rerere
git-cherry-pick git-init git-revert git-fast-import git-annotate git-rev-parse
git-clean git-log git-rm gt-filter-branch git-blame git-verify-tag
git-clone git-merge git-shortlog git-mergetool git-cherry git-whatchanged
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
Testing
● JUnit + HttpUnit
● EclEmma coverage 84%
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
Testing
● JUnit + HttpUnit
● EclEmma coverage 84%
Orion: RESTful git API | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
That's all folks
Orion: RESTful git API| Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.
Legal Notice
● IBM and the IBM logo are trademarks or registered
trademarks of IBM Corporation, in the United States, other
countries or both.
● Java and all Java-based marks, among others, are
trademarks or registered trademarks of Sun Microsystems
in the United States, other countries or both.
● Eclipse and the Eclipse logo are trademarks of Eclipse
Foundation, Inc.
● Porky Pig image is in the public domain, see http:
//commons.wikimedia.org/wiki/File:Thats_all_folks_cl%
C3%A0ssic_-Daffy_Comando_1943_-_amb_porky.png
● Other company, product and service names may be
trademarks or service marks of others.

Orion RESTful git API

  • 1.
    Orion: RESTful gitAPI Tomasz Żarna Eclipse PlatformWorkspace/Orion, IBM
  • 2.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST REST explained in 5 steps: ● Give every "thing" an ID ● Link "things" to each other ● Use standard methods ● Allow multiple representations ● Communicate statelessly
  • 3.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST (cntd) Advantages ● universal support (programming languages, OSes, servers) ● proven scalability i.e. Wide Wide Web ● real machine-2-machine integration ● support for XML and other formats Some HTTP features: ● standardized verbs and response codes ● content negotiation ● redirection ● caching ● compression
  • 4.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. Server ● Jetty 6.1.x / javax.servlet 2.5 ● org.eclipse.equinox.http.registry.servlets / OSGi HttpService ○ class ○ alias
  • 5.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST API: GET GET /gitapi/commit/master/file/a/?page=1 HTTP/1.1 200 OK { "Children" : [ { "AuthorName" : "Tomasz Zarna", "Children" : [{ }], "ContentLocation" : "/gitapi/commit/6d34f45b/file/a/? parts=body", "Message" : "Fix for bug 345325", "Location" : "/gitapi/commit/6d34f45b/file/a/", "Time" : 1304073355000, "DiffLocation" : "/gitapi/diff/6d34f45b/file/a/", }, { ... } }
  • 6.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST API: POST POST /gitapi/clone/ { "GitUrl" : "git://github.com/eclipse/orion.server.git", "Path" : "/file/a/" } HTTP/1.1 201 CREATED { "Id" : "IOOD6ph8ABASBcDqmXX87w", "Location" : "/task/id/IOOD6ph8ABASBcDqmXX87w", "Message" : "Cloning git://github.com/eclipse/orion.server.git...", "PercentComplete" : 0, "Running" : true } GET {Location}
  • 7.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST API: PUT PUT /gitapi/commit/6d34f45b/file/a/ { "TagName" : "v20110611" } HTTP/1.1 200 OK { "AuthorName" : "Tomasz Zarna", "Children" : [{ "v20110523", "v20110611"}], "ContentLocation" : "/gitapi/commit/6d34f45b/file/a/?parts=body", "Message" : "Fix for bug 345325", "Location" : "/gitapi/commit/6d34f45b/file/a/", "Time" : 1304073355000, "DiffLocation" : "/gitapi/diff/6d34f45b/file/a/" }
  • 8.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. REST API: DELETE DELETE /gitapi/remote/{remoteName}/file/{id} HTTP/1.1 200 OK
  • 9.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. git commands git-add git-commit git-mv git-show pack-pack-refs git-count-object git-am git-describe git-notes git-stash git-prune git-difftool git-archive git-diff git-pull git-status git-reflog git-fsck git-bisect git-fetch git-push git-submodule git-relink git-get-tar-commit-id git-branch git-format-patch git-rebase git-tag git-remote git-help git-bundle git-gc git-reset git-config git-repack git-merge-tree git-checkout git-grep git-rebase git-fast-export git-replace git-rerere git-cherry-pick git-init git-revert git-fast-import git-annotate git-rev-parse git-clean git-log git-rm gt-filter-branch git-blame git-verify-tag git-clone git-merge git-shortlog git-mergetool git-cherry git-whatchanged
  • 10.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. Testing ● JUnit + HttpUnit ● EclEmma coverage 84%
  • 11.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. Testing ● JUnit + HttpUnit ● EclEmma coverage 84%
  • 12.
    Orion: RESTful gitAPI | Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. That's all folks
  • 13.
    Orion: RESTful gitAPI| Copyright © IBM Corp., 2011. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. Legal Notice ● IBM and the IBM logo are trademarks or registered trademarks of IBM Corporation, in the United States, other countries or both. ● Java and all Java-based marks, among others, are trademarks or registered trademarks of Sun Microsystems in the United States, other countries or both. ● Eclipse and the Eclipse logo are trademarks of Eclipse Foundation, Inc. ● Porky Pig image is in the public domain, see http: //commons.wikimedia.org/wiki/File:Thats_all_folks_cl% C3%A0ssic_-Daffy_Comando_1943_-_amb_porky.png ● Other company, product and service names may be trademarks or service marks of others.