summaryrefslogtreecommitdiffstats
path: root/docs/02_rpc.mkd
blob: 4a547d00803c7007f76a563c3a586769fa496b31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
## JSON Remote Procedure Call (RPC) Interface

*SINCE 0.7.0*

Gitblit optionally allows a remote client to administer the Gitblit server.  This client could be a Java-based tool or perhaps a tool written in another language.

    web.enableRpcServlet=true
    web.enableRpcAdministration=false

**https** is strongly recommended because passwords are insecurely transmitted form your browser/rpc client using Basic authentication!

The Gitblit RPC mechanism, like the Gitblit JGit servlet, syndication/feed servlet, etc, supports request-based authentication.  Making an *admin* request will trigger Gitblit's basic authentication mechanism.  Listing of repositories, generally, will not trigger this authentication mechanism unless *web.authenticateViewPages=true*.  That means its possible to allow anonymous enumeration of repositories that are not *view restricted* or *clone restricted*.  Of course, if credentials are provided then all private repositories that are available to the user account will be enumerated in the JSON response.

### RPC Requests

<table>
<tr><th colspan='2'>url parameters</th><th rowspan='2'>required<br/>permission</th><th colspan='2'>json</th></tr>
<tr><th>req=</th><th>name=</th><th>post body</th><th>response body</th></tr>
<tr><td>LIST_REPOSITORIES</td><td>-</td><td>-</td><td>-</td><td>Map String, RepositoryModel </td></tr>
<tr><td>CREATE_REPOSITORY</td><td>repository name</td><td><em>admin</em></td><td>RepositoryModel</td><td>-</td></tr>
<tr><td>EDIT_REPOSITORY</td><td>repository name</td><td><em>admin</em></td><td>RepositoryModel</td><td>-</td></tr>
<tr><td>DELETE_REPOSITORY</td><td>repository name</td><td><em>admin</em></td><td>-</td><td>-</td></tr>
<tr><td>LIST_USERS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List UserModel </td></tr>
<tr><td>CREATE_USER</td><td>user name</td><td><em>admin</em></td><td>UserModel</td><td>-</td></tr>
<tr><td>EDIT_USER</td><td>user name</td><td><em>admin</em></td><td>UserModel</td><td>-</td></tr>
<tr><td>DELETE_USER</td><td>user name</td><td><em>admin</em></td><td>-</td><td>-</td></tr>
<tr><td>LIST_REPOSITORY_MEMBERS</td><td>repository name</td><td><em>admin</em></td><td>-</td><td>List String</td></tr>
<tr><td>SET_REPOSITORY_MEMBERS</td><td>repository name</td><td><em>admin</em></td><td>List String</td><td>-</td></tr>
<tr><td>LIST_FEDERATION_REGISTRATIONS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List FederationModel</td></tr>
<tr><td>LIST_FEDERATION_RESULTS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List FederationModel</td></tr>
<tr><td>LIST_FEDERATION_PROPOSALS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List FederationProposal </td></tr>
<tr><td>LIST_FEDERATION_SETS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List FederationSet </td></tr>
<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>-</td><td>Properties</td></tr>
</table>

### RPC Client

An example Java Swing [RPC Client application](http://code.google.com/p/gitblit/downloads/detail?name=rpcclient-%VERSION%.zip) is available and allows remote administration of repositories and users.  
This application exercises most methods from the utility class `com.gitblit.utils.RpcUtils`.

### EGit "Import from Gitblit" Feature (Planning)

One obvious goal of a Gitblit RPC mechanism would be to have an EGit Feature that allows authentication and enumeration of Gitblit repositories from the Eclipse *Import...* menu.  Cloning (hopefully batch) would be delegated to EGit.

This particular project should not be difficult as the only external dependency for `com.gitblit.utils.RpcUtils` is [google-gson](http://google-gson.googlecode.com) which is already a dependency of the EGit/GitHub Mylyn feature.

Currently this project is in the planning stage.

### Example: LIST_REPOSITORIES

**url**: https://localhost/rpc?req=LIST_REPOSITORIES  
**response body**: Map&lt;String, RepositoryModel&gt; where the map key is the clone url of the repository
<pre>
{
  "https://localhost/git/libraries/xmlapache.git": {
    "name": "libraries/xmlapache.git",
    "description": "apache xmlrpc client and server",
    "owner": "admin",
    "lastChange": "2010-01-28T22:12:06Z",
    "hasCommits": true,
    "showRemoteBranches": false,
    "useTickets": false,
    "useDocs": false,
    "accessRestriction": "VIEW",
    "isFrozen": false,
    "showReadme": false,
    "federationStrategy": "FEDERATE_THIS",
    "federationSets": [
      "libraries"
    ],
    "isFederated": false,
    "size": "102 KB"
  },
  "https://localhost/git/libraries/smack.git": {
    "name": "libraries/smack.git",
    "description": "smack xmpp client",
    "owner": "admin",
    "lastChange": "2009-01-28T18:38:14Z",
    "hasCommits": true,
    "showRemoteBranches": false,
    "useTickets": false,
    "useDocs": false,
    "accessRestriction": "VIEW",
    "isFrozen": false,
    "showReadme": false,
    "federationStrategy": "FEDERATE_THIS",
    "federationSets": [],
    "isFederated": false,
    "size": "4.8 MB"
  }
}
</pre>

### Example: EDIT_REPOSITORY (rename)

The original repository name is specified in the *name* url parameter.  The new name is set within the JSON object.

**url**: https://localhost/rpc?req=EDIT_REPOSITORY&name=libraries/xmlapache.git  
**post body**: RepositoryModel
<pre>
{
    "name": "libraries/xmlapache-renamed.git",
    "description": "apache xmlrpc client and server",
    "owner": "admin",
    "lastChange": "2010-01-28T22:12:06Z",
    "hasCommits": true,
    "showRemoteBranches": false,
    "useTickets": false,
    "useDocs": false,
    "accessRestriction": "VIEW",
    "isFrozen": false,
    "showReadme": false,
    "federationStrategy": "FEDERATE_THIS",
    "federationSets": [
      "libraries"
    ],
    "isFederated": false,
    "size": "102 KB"
}
</pre>

### Example: LIST_USERS
**url**: https://localhost/rpc?req=LIST_USERS  
**response body**: List&lt;UserModel&gt;
<pre>
[
  {
    "username": "admin",
    "password": "admin",
    "canAdmin": true,
    "excludeFromFederation": true,
    "repositories": []
  },
  {
    "username": "test",
    "password": "test",
    "canAdmin": false,
    "excludeFromFederation": false,
    "repositories": [
      "libraries/xmlapache.git",
      "libraries/smack.git"
    ]
  }
]
</pre>