summaryrefslogtreecommitdiffstats
path: root/src/main/thrift/bwlp.thrift
blob: 4d2a5885f19ff16fd08d58fb809b0054c5f8dbd0 (plain) (blame)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
 * Define some namespace/package name for our stuff
 */
namespace java org.openslx.bwlp.thrift.iface
 
typedef i64 int

typedef string ID
typedef string Token
typedef string UUID
typedef string UserID
typedef i64 UnixTimestamp

// ################# ENUM ################

enum AuthorizationError {
	GENERIC_ERROR,
	NOT_AUTHENTICATED,
	NO_PERMISSION
}

enum AuthenticationError {
	GENERIC_ERROR,
	INVALID_CREDENTIALS,
	ACCOUNT_SUSPENDED,
	INVALID_ORGANIZATION,
	INVALID_KEY,
	CHALLENGE_FAILED,
	BANNED_NETWORK
}

enum ImageDataError {
	INVALID_DATA,
	UNKNOWN_IMAGE
}

enum UploadError {
	INVALID_CRC,
	BROKEN_BLOCK,
	GENERIC_ERROR,
	INVALID_METADATA,
	ALREADY_COMPLETE
}

// ############## STRUCT ###############

struct UserInfo {
	1: string userId,
	2: string firstName,
	3: string lastName,
	4: string eMail,
	5: string organizationId
}

struct OrganizationData {
	1: string organizationId,
	2: string displayName,
	3: string ecpUrl,
	4: list<string> suffixList,
}

struct SessionData {
	1: ID sessionId,
	2: Token authToken,
	3: string serverAddress
}

struct ServerSessionData {
	1: ID sessionId
}

struct OperatingSystem {
	1: i32 osId,
	2: string osName,
	3: map<string, string> virtualizerOsId,
	4: string architecture,
}

struct ImagePermission {
	1: bool read
	2: bool write
	3: bool admin
	4: bool link
}

struct LecturePermission {
	1: bool write
	2: bool admin
}

struct ImageBaseData {
	1: UUID imageBaseId,
	3: string imageName,
   10: string description,
	5: i32 osId,
	6: UnixTimestamp createTime,
	7: UnixTimestamp updateTime,
	9: string isTemplate,
}
struct ImagePermissionCombined {
	1: Image image,
	2: ImagePermission permission,
}

struct Lecture {
	1: optional UUID lectureId,
	2: string lectureName,
	3: string isActive,
	4: UnixTimestamp startTime,
	5: UnixTimestamp endTime,
	6: UnixTimestamp lastUsed,
	7: string description,
	8: UUID imageId
}
struct LecturePermissionCombined {
	1: Lecture lecture,
	2: LecturePermission permission,
}

struct TransferInformation {
	1: string token,
	2: i32 plainPort,
	3: i32 sslPort,
}

// ############ EXCEPTION ######################

exception TUploadFinishException {
	1: string reason,
}

exception TUploadRejectedException {
	1: string reason,
}

exception TAuthorizationException {
	1: AuthorizationError number,
	2: string message
}

exception TAuthenticationException {
	1: AuthenticationError number,
	2: string message
}

exception TInvalidTokenException {
}

exception TImageDataException {
	1: ImageDataError number,
	2: string message
}

exception TDownloadRejectedException {
	1: UploadError number,
	2: string message
}

// #############################################

service SatelliteServer {
	int getVersion(),
	
	// File transfer related
	TransferInformation requestUpload(1: string userToken, 2: i64 fileSize, 3: list<binary> blockHashes)
		throws (1:TUploadRejectedException rejection),
	void cancelUpload(1: string uploadToken),
	TransferInformation requestDownload(1: string userToken, 2: string imageId),
	void cancelDownload(1: string downloadToken),
	
	// Authentication
	bool authenticated(1: Token userToken),
	bool setSessionInvalid(1: Token userToken),
	
	// Misc
    list<OperatingSystem> getOperatingSystems(),
    list<string> getAllOrganizations(1: Token userToken),
	
	// Image related
    string finishImageUpload(1: string imageName, 2: string description, 10: bool license, 11: bool internet, 17: int shareMode, 18: string os, 22: Token uploadToken)
    	throws (1:TUploadFinishException failure),
    list<ImagePermissionCombined> getImageList(1: Token userToken),
	ImagePermissionCombined getImageData(1: UUID imageId, 3: Token userToken),
	bool updateImageData(1: Token userToken, 9: Image image),
	
	// Lecture related
    bool writeLecture(1: Token userToken, 2: Lecture lecture),
    list<Lecture> getLectureList(1: Token userToken),
	Lecture getLectureData(1: UUID lectureId, 2: Token userToken),
	bool deleteImage(1: string id, 2: string version, 3: string token),
	bool connectedToLecture(1: string id, 2: string version, 3: string token),
	bool deleteLecture(1: string lectureId, 2: string token),
	bool checkUser(1: string username, 2: string token),
	bool writeImagePermissions(1: Token userToken, 2: UUID imageId, 3: list<ImagePermission> permissions),
	bool writeLecturePermissions(1: Token userToken, 2: UUID lectureId, 3: list<LecturePermission> permissions),
	map<UserID, UserInfo> getImagePermissions(1: Token userToken, 2: UUID imageId),
	map<UserID, UserInfo> getLecturePermissions(1: Token userToken, 2: UUID lectureId),
	void deleteAllAdditionalImagePermissions(1: UUID imageID, 2: Token userToken),
	void deleteAllAdditionalLecturePermissions(1: UUID lectureID, 2: Token userToken),
}

// Central master server

service MasterServer {

/*
 * Client (User's Desktop App) calls
 */
	bool ping(),

	SessionData authenticate(1:string login, 2:string password) throws (1:AuthenticationException failure),
	
	list<OrganizationData> getOrganizations(),
	
	list<UserInfo> findUser(1:ID sessionId, 2:string organizationId, 3:string searchTerm) throws (1:AuthorizationException failure),
	
	list<ImageData> getPublicImages(1:ID sessionId, 2:i32 page) throws (1:AuthorizationException failure),
	
	list<OperatingSystem> getOperatingSystems(),

/*
 * Server (Satellite) calls
 */
	UserInfo getUserFromToken(1:Token token) throws (1:InvalidTokenException failure),
	
	bool isServerAuthenticated(1:string serverSessionId),
	
	binary startServerAuthentication(1:string organization) throws (1: AuthenticationException failure),
	
	ServerSessionData serverAuthenticate(1:string organizationId, 2:binary challengeResponse) throws (1:AuthenticationException failure),
	
	UploadData submitImage(1:ID serverSessionId, 2:ImageData imageDescription, 3:list<i32> crcSums) throws (1:AuthorizationException failure, 2: ImageDataException failure2, 3: UploadException failure3),
	
	DownloadData getImage(2:ID serverSessionId, 1:UUID uuid) throws (1:AuthorizationException failure, 2: ImageDataException failure2),
	
	bool publishUser(1:ID serverSessionId, 2:UserInfo user) throws (1:AuthorizationException failure),

	bool registerSatellite(1:string organizationId, 2:string address, 3:string modulus, 4:string exponent),

	bool updateSatelliteAddress(1:ID serverSessionId, 2:string address),

}