Page MenuHomePhorge

Conduit API: allow phriction.edit to modify viewPolicy and editPolicy
Closed, ResolvedPublic


We have a background task running which creates wiki pages in Phorge using the phriction.create and phriction.edit Conduit API methods.
Some of these wiki pages should only be visible by some users.
Currently phriction.create and phriction.edit can only make fully public wiki pages.
It would be nice if phriction.document.edit could be extended with a viewPolicy and an editPolicy constraint.
import json
import requests
import sys

phabricator_url = sys.argv[1]
api_token = sys.argv[2]

slug = "test-1/"   # edit the wiki url to be tested

def call_conduit(method, params):
    params['__conduit__'] = {'token': api_token}
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    data = 'params={}&output=json'.format(json.dumps(params))
    response ='{phabricator_url}/api/{method}', data=data, headers=headers)

    response_json = json.loads(response.text)
    pretty_json = json.dumps(response_json, indent=2)
    print("Result conduit api call " + method + ":")
    return response_json

# Edit the document using phriction.document.edit
transactions = [{
    "type": "comment",
    "value": "yeehaa!" 
    "type": "edit",
    "value": "admin"

transaction_params = {
    "objectIdentifier": slug,
    "transactions": transactions

edit_result = call_conduit('phriction.document.edit', transaction_params)

The script above, which tests the extended phriction.document.edit api, can be executed like this:

export phorge=http://phorge.local
export api=api-zgjsay4m3vbwx23uy99v5zad5g24

python3 $phorge $api

The script will change the edit policy of wiki page /w/test-1 to admin and add a comment

Related Objects

Mentioned In
Next Up