PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/js/models/KeypairModel.js

http://github.com/ging/horizon-js
JavaScript | 40 lines | 33 code | 7 blank | 0 comment | 1 complexity | 0d1db4574b223480a5dadd668a9401f9 MD5 | raw file
  1. var Keypair = Backbone.Model.extend({
  2. initialize: function() {
  3. this.id = this.get("name");
  4. },
  5. sync: function(method, model, options) {
  6. switch(method) {
  7. case "create":
  8. JSTACK.Nova.createkeypair(model.get("name"), model.get("public_key"), options.success);
  9. break;
  10. case "delete":
  11. JSTACK.Nova.deletekeypair(model.get("name"), options.success);
  12. break;
  13. }
  14. }
  15. });
  16. var Keypairs = Backbone.Collection.extend({
  17. model: Keypair,
  18. sync: function(method, model, options) {
  19. switch(method) {
  20. case "read":
  21. JSTACK.Nova.getkeypairlist(options.success);
  22. break;
  23. }
  24. },
  25. parse: function(resp) {
  26. var list = [];
  27. for (var index in resp.keypairs) {
  28. var keypair = resp.keypairs[index];
  29. list.push(keypair.keypair);
  30. }
  31. return list;
  32. }
  33. });