Stwalkerster.Bot.PhabricatorLib is a C# library which implements the Phabricator API.
While still in development, certain areas are mostly complete:
- Maniphest
- Projects
- Paste
Other areas have barely any functionality yet.
Usage
Firstly, grab yourself an API token from https://phabricator.example.com/conduit/token/
Then, create a new instance of ConduitClient:
using Stwalkerster.Bot.PhabricatorLib; private static void Main() { string phabUrl = "https://phabricator.example.com/"; string token = "api-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; var client = new ConduitClient(phabUrl, token); }
This client implements the underlying protocol of Conduit, allowing you to do things like this:
dynamic result = client.CallMethod("user.whoami", new Dictionary<string, dynamic>());
Or something more complex:
dynamic response = client.CallMethod( "phid.lookup", new Dictionary<string, dynamic> { { "names", new[] { "T112", "T439" } } });
However, that's boring. For some applications, these API calls have already been wrapped up for you!
ApplicationEditor-capable APIs (including Maniphest)
Take your client from earlier, and use it to create a new instance of Maniphest:
using Stwalkerster.Bot.PhabricatorLib.Applications.Maniphest;
var maniphest = new Maniphest(client);
Application editor APIs provide two methods to call: Edit(...) and Search(...)
Search
Search requests can pass in a base query to start the search with, or a set of constraints to apply.
To add a constraint, construct an instance of ApplicationEditorSearchConstraint like this:
var constraint = ManiphestSearchConstraintFactory.Statuses(new List<string> { "open" });
Or, if that doesn't provide you with the flexibility you need:
var constraint = new ApplicationEditorSearchConstraint {Type = "fulltext", Value = "foo bar"};
You can consult the relevant API documentation to find the constraint types you can use at https://phabricator.example.com/conduit/method/maniphest.search/ .
Once you have your constraints, you can pass the collection of them to the Search method:
var constraint = ManiphestSearchConstraintFactory.Statuses(new List<string> { "open" }); var searchConstraints = new List<ApplicationEditorSearchConstraint> { constraint }; IEnumerable<ManiphestTask> response = maniphest.Search(constraints: searchConstraints);
Edit
Editing is much simpler.
Either get yourself an instance of a ManiphestTask from the client (by search) if you want to edit, or create a new instance of ManiphestTask if you want to create a new task.
var task = new ManiphestTask();
Then, just set the properties you want to set:
task.Title = "Example task"; task.Description = "Example description";
Finally, pass your task to Maniphest:
maniphest.Edit(task);