Giter Club home page Giter Club logo

go-conduit's Introduction

Conduit

A Go package for connecting to Phabricator via the Conduit API.

Originally created to help develop Merlin, an Arcanist like tool written in Go.

Documentation

Getting a conduit certificate

This library uses conduit.connect to establish an authenticated session. You'll need to have a valid username and conduit certificate in order to use this API.

To get your conduit certificate, go to https://{MY_PHABRICATOR_URL}/settings/panel/conduit and copy/paste.

Usage

Connecting

conn, err := conduit.Dial("https://secure.phabricator.com")

err = conn.Connect("USERNAME", "CERTIFICATE")

Errors

Any conduit error response will be returned as a conduit.ConduitError type

conn, err := conduit.Dial("https://secure.phabricator.com")
err = conn.Connect("USERNAME", "CERTIFICATE")

ce, ok := err.(*conduit.ConduitError)
if ok {
	println("code: " + ce.Code())
	println("info: " + ce.Info())
}

// Or
if conduit.IsConduitError(err) {
	// do something else
}

phid.lookup

result, err := conduit.PHIDLookup([]string{"T1", "D1"})
result, err := conduit.PHIDLookupSingle("T1")

phid.query

result, err := conduit.PHIDQuery([]string{"PHID-DREV-gumr6ra5wm32ez46qo3f", "..."})
result, err := conduit.PHIDQuerySingle("PHID-DREV-gumr6ra5wm32ez46qo3f")

Arbitrary calls

You can use the conn.Call() method to make arbitrary conduit method calls that aren't specifically supported by the package.

type params struct {
	Names   []string         `json:"names"`
	Session *conduit.Session `json:"__conduit__"`
}

type result map[string]*struct{
	URI      string `json:"uri"`
	FullName string `json:"fullName"`
	Status   string `json:"status"`
}

p := &params {
	Names: []string{"T1"},
	Session: conn.Session,
}
var r result

err := conn.Call("phid.lookup", p, &r)

go-conduit's People

Contributors

jpoehls avatar marceldegraaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-conduit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.