def _addCommonGetTagProperties(usage, category): possibleActions = ', '.join(permissions.actionsByCategory[category]) usage.addArgument(Argument( actionArg, """The action whose permissions information is sought. Possible values are: """ + possibleActions + '.', 'string', mandatory=True)) apiDoc.addMissingIntermediateNs(usage) apiDoc.addNoSuchTag(usage) apiDoc.addNeedTagPermOrAdmin(usage, apiDoc.CONTROL) usage.addReturn(Return( apiDoc.BAD_REQUEST, 'If the %s argument is missing or invalid.' % actionArg)) apiDoc.addCannotRespondWithPayload(usage) apiDoc.addOkOtherwise(usage) responsePayload = JSONPayload() responsePayload.addField(PayloadField( 'policy', unicode, """The policy (either 'open' or 'closed').""")) responsePayload.addField(PayloadField( 'exceptions', list, 'The names of the users who are exceptions to the policy.', listType=unicode)) usage.addResponsePayload(responsePayload)
def _addCommonGetTagProperties(usage, category): possibleActions = ', '.join(permissions.actionsByCategory[category]) usage.addArgument( Argument(actionArg, """The action whose permissions information is sought. Possible values are: """ + possibleActions + '.', 'string', mandatory=True)) apiDoc.addMissingIntermediateNs(usage) apiDoc.addNoSuchTag(usage) apiDoc.addNeedTagPermOrAdmin(usage, apiDoc.CONTROL) usage.addReturn( Return(apiDoc.BAD_REQUEST, 'If the %s argument is missing or invalid.' % actionArg)) apiDoc.addCannotRespondWithPayload(usage) apiDoc.addOkOtherwise(usage) responsePayload = JSONPayload() responsePayload.addField( PayloadField('policy', unicode, """The policy (either 'open' or 'closed').""")) responsePayload.addField( PayloadField( 'exceptions', list, 'The names of the users who are exceptions to the policy.', listType=unicode)) usage.addResponsePayload(responsePayload)
usage.addReturn(Return(apiDoc.BAD_REQUEST, 'If no query is given.')) usage.addReturn(Return(apiDoc.BAD_REQUEST, 'The query string was not valid UTF-8.')) usage.addReturn(Return(apiDoc.BAD_REQUEST, 'If the query string could not be parsed.')) usage.addReturn(Return(apiDoc.BAD_REQUEST, 'If the query returns to many objects.')) usage.addReturn(Return(apiDoc.NOT_FOUND, 'If one or more of the tags or namespaces present ' 'in the query do not exist.')) usage.addReturn(Return(apiDoc.UNAUTHORIZED, 'If the user does not have ' + apiDoc.READ + ' permission on a tag whose value is needed ' 'to satisfy the query.')) apiDoc.addOkOtherwise(usage) # GET on /recent/objects/<id> usage = HTTPUsage('/objects/' + apiDoc.ID, dedent(""" To request information on the latest tag values on a particular object given its objectID""")) usage.resourceClass = RecentObjectActivityResource topLevel.addUsage(usage) # Example request = dedent(""" GET /recent/objects/5a4823a4-26b4-495c-9a29-a1e830a1b153 HTTP/1.1 Authorization: Basic XXXXXXXX""") response = dedent("""
listType=unicode)) usage.addResponsePayload(responsePayload) apiDoc.addNoSuchNs(usage) apiDoc.addMissingIntermediateNs(usage) usage.addReturn( Return( apiDoc.UNAUTHORIZED, 'If the requesting user does not have ' + apiDoc.LIST + ' permission on the namespace.')) apiDoc.addCannotRespondWithPayload(usage) apiDoc.addOkOtherwise(usage) request = ('''GET /namespaces/test/people?returnDescription=True''' '''&returnNamespaces=True&returnTags=True HTTP/1.1 Authorization: Basic XXXXXXXX''') response = '''HTTP/1.1 200 OK Content-Length: 118 Date: Mon, 02 Aug 2010 12:43:05 GMT Content-Type: application/json {"tagNames": [], "namespaceNames": [], ''' '''"id": "e9c97fa8-05ed-4905-9f72-8d00b7390f9b", "description": "A namespace for tags I\'m using to add to people"}''' description = "Retrieve information about the test/people namespace." usage.addExample(HTTPExample(request, response, description))