Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

#!/usr/bin/env python 

# -*- coding: utf-8 -*- 

 

############################################################################### 

#  Copyright 2013 Kitware Inc. 

# 

#  Licensed under the Apache License, Version 2.0 ( the "License" ); 

#  you may not use this file except in compliance with the License. 

#  You may obtain a copy of the License at 

# 

#    http://www.apache.org/licenses/LICENSE-2.0 

# 

#  Unless required by applicable law or agreed to in writing, software 

#  distributed under the License is distributed on an "AS IS" BASIS, 

#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

#  See the License for the specific language governing permissions and 

#  limitations under the License. 

############################################################################### 

 

from ..api_docs import Describe 

 

apis = [] 

 

apis.append({ 

    'path': '/group', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'GET', 

        'nickname': 'findGroups', 

        'responseClass': 'Group', 

        'summary': 'Search for groups or list all groups.', 

        'parameters': [ 

            Describe.param( 

                'text', "Pass this to perform a full-text search for groups.", 

                required=False), 

            Describe.param( 

                'limit', "Result set size limit (default=50).", required=False, 

                dataType='int'), 

            Describe.param( 

                'offset', "Offset into result set (default=0).", required=False, 

                dataType='int'), 

            Describe.param( 

                'sort', "Field to sort the group list by (default=name)", 

                required=False), 

            Describe.param( 

                'sortdir', "1 for ascending, -1 for descending (default=1)", 

                required=False, dataType='int') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse() 

            ] 

        }, { 

        'httpMethod': 'POST', 

        'nickname': 'createGroup', 

        'responseClass': 'Group', 

        'summary': 'Create a new group.', 

        'notes': 'Must be logged in.', 

        'parameters': [ 

            Describe.param('name', "Name of the group, must be unique."), 

            Describe.param('description', "Description of the group.", 

                           required=False), 

            Describe.param( 

                'public', "If the group should be public or private. By " 

                "default, it will be private.", 

                required=False, dataType='boolean') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse('Write access was denied on the parent', 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'GET', 

        'nickname': 'getGroupById', 

        'responseClass': 'Group', 

        'summary': 'Get a group by ID.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                'Read access was denied for the group.', 403) 

            ] 

        }, { 

        'httpMethod': 'PUT', 

        'nickname': 'updateGroupById', 

        'summary': 'Update a group by ID.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'name', 'The name to set on the group.', required=False), 

            Describe.param( 

                'description', 'The description to set on the group.', 

                required=False), 

            Describe.param( 

                'public', 'Whether group should be publicly visible', 

                dataType='boolean', required=False) 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                'Write access was denied for the group.', 403) 

            ] 

        }, { 

        'httpMethod': 'DELETE', 

        'nickname': 'deleteGroupById', 

        'summary': 'Delete a group by ID.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                'Admin access was denied for the group.', 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}/invitation', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'GET', 

        'nickname': 'showInvitations', 

        'responseClass': 'Group', 

        'summary': 'Show outstanding invitations for a group.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'limit', "Result set size limit (default=50).", required=False, 

                dataType='int'), 

            Describe.param( 

                'offset', "Offset into result set (default=0).", required=False, 

                dataType='int'), 

            Describe.param( 

                'sort', "Field to sort the invitee list by (default=lastName)", 

                required=False), 

            Describe.param( 

                'sortdir', "1 for ascending, -1 for descending (default=1)", 

                required=False, dataType='int') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                'Write access was denied for the group.', 403) 

            ] 

        }, { 

        'httpMethod': 'POST', 

        'nickname': 'inviteToGroup', 

        'responseClass': 'Group', 

        'summary': "Invite a user to join a group, or accept a user's request " 

                   " to join.", 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param('userId', 'The ID of the user to invite or accept.'), 

            Describe.param('level', 'The access level the user will be given ' 

                           'when they accept the invitation. Defaults to read ' 

                           'access (0).', required=False, dataType='int') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                'Write access was denied for the group.', 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}/member', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'GET', 

        'nickname': 'getGroupMembers', 

        'responseClass': 'Group', 

        'summary': 'List members of a group.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'limit', "Result set size limit (default=50).", required=False, 

                dataType='int'), 

            Describe.param( 

                'offset', "Offset into result set (default=0).", required=False, 

                dataType='int'), 

            Describe.param( 

                'sort', "Field to sort the member list by (default=lastName)", 

                required=False), 

            Describe.param( 

                'sortdir', "1 for ascending, -1 for descending (default=1)", 

                required=False, dataType='int') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                'You were not invited to this group.', 403) 

            ] 

        }, { 

        'httpMethod': 'POST', 

        'nickname': 'joinGroup', 

        'responseClass': 'Group', 

        'summary': 'Request to join a group, or accept an invitation to join.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                'You were not invited to this group, or do not have ' 

                'read access to it.', 403) 

            ] 

        }, { 

        'httpMethod': 'DELETE', 

        'nickname': 'removeFromGroup', 

        'responseClass': 'Group', 

        'summary': 'Remove a user from a group, or uninvite them.', 

        'notes': 'If the specified user is not yet a member of the group, this' 

                 ' will delete any oustanding invitation or membership request' 

                 ' for the user. Passing no userId parameter will assume that' 

                 ' the current user is removing himself.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'userId', 'The ID of the user to remove. If not passed, will ' 

                'remove yourself from the group.', required=False) 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                "You don't have permission to remove that user.", 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}/moderator', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'POST', 

        'nickname': 'promoteToModerator', 

        'responseClass': 'Group', 

        'summary': 'Promote a user to a moderator.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'userId', 'The ID of the user to promote.') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                "You don't have permission to promote users.", 403) 

            ] 

        }, { 

        'httpMethod': 'DELETE', 

        'nickname': 'demoteModerator', 

        'responseClass': 'Group', 

        'summary': 'Demote a group moderator to a normal member.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'userId', 'The ID of the user to demote.') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                "You don't have permission to demote users.", 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}/admin', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'POST', 

        'nickname': 'promoteToAdmin', 

        'responseClass': 'Group', 

        'summary': 'Promote a user to an administrator.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'userId', 'The ID of the user to promote.') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                "You don't have permission to promote users.", 403) 

            ] 

        }, { 

        'httpMethod': 'DELETE', 

        'nickname': 'demoteAdmin', 

        'responseClass': 'Group', 

        'summary': 'Demote a group admin to a normal member.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path'), 

            Describe.param( 

                'userId', 'The ID of the user to demote.') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse(), 

            Describe.errorResponse( 

                "You don't have permission to demote users.", 403) 

            ] 

        }] 

    }) 

 

apis.append({ 

    'path': '/group/{groupId}/access', 

    'resource': 'group', 

    'operations': [{ 

        'httpMethod': 'GET', 

        'nickname': 'getGroupAccess', 

        'responseClass': 'Group', 

        'summary': 'Get the access control list for a group.', 

        'parameters': [ 

            Describe.param( 

                'groupId', 'The ID of the group.', paramType='path') 

            ], 

        'errorResponses': [ 

            Describe.errorResponse('ID was invalid.'), 

            Describe.errorResponse( 

                'Read access was denied for the group.', 403) 

            ] 

        }] 

    }) 

 

Describe.declareApi('group', apis=apis)