Page MenuHomePhabricator

Project History
ArchivedPublic

Details

Looks Like
Stwalkerster.Bot.PhabricatorLib
Hashtags
#arcanist-csharp, #sharphconduit, #stwalkerster.bot.phabricatorlib
Description

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/ .

NOTE: Some constraints expect PHIDs rather than actual names or IDs. You can find these easily by using PHIDLookup.

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);

Event Timeline

stwalkerster created this object with visibility "Project Members".
stwalkerster created this object with edit policy "Project Members".
stwalkerster created this object with join policy "No One".
stwalkerster renamed this project from Arcanist-CSharp to SharphConduit.May 29 2016, 4:18 PM
stwalkerster added a hashtag: #arcanist-csharp.
stwalkerster changed the visibility from "Project Members" to "Public (No Login Required)".
stwalkerster changed the edit policy from "Project Members" to "Community (Project)".Feb 13 2019, 11:58 AM
stwalkerster changed the join policy from "No One" to "Community (Project)".
stwalkerster renamed this project from SharphConduit to Stwalkerster.Bot.PhabricatorLib.Aug 25 2020, 10:58 PM
stwalkerster edited Description. (Show Details)
stwalkerster added a hashtag: #sharphconduit.