[racktables-users] Re: writing a restful API in php for Racktables

  • From: Ian Bettinger <ibettinger@xxxxxxxxx>
  • To: racktables-users@xxxxxxxxxxxxx
  • Date: Fri, 13 Jul 2012 11:15:32 -0700

Hey Philip,

No, the page / methods don't map 1:1. I might change that, not sure.

As you can see in the code, only the following methods are implemented so far:

get_8021q
get_ipv4space
get_ipaddress
get_rackspace
get_depot
get_object
add_object
get_chapter

Some of the methods require additional arguments, some don't. Again
see the source code for details on that.

Some example URIs that work would be:

http://racktables.foo.com/apiv0.php?method=get_chapter&chapter_no=13
http://racktables.foo.com/apiv0.php?method=get_depot
http://racktables.foo.com/apiv0.php?method=get_depot
http://racktables.foo.com/apiv0.php?method=get_object&object_id=923

Again, this is super-preliminary code because I want to make sure it
fits in with how the Racktables contributors like to lay things out.
So don't expect too much from it just yet.

Cheers,
Ian





On Fri, Jul 13, 2012 at 10:51 AM, Philip Durbin <philipdurbin@xxxxxxxxx> wrote:
> On 07/13/2012 12:41 PM, Ian Bettinger wrote:
>>
>> Thanks for the input. I've taken a first stab at a skeleton version of
>> the api.php file, adding just a couple of methods for now.
>>
>> Can you take a look and see if this approach makes sense to you? I'm
>> not totally familiar with RT's coding style, how you organize things,
>> etc, so let me know what needs to change and I'll incorporate it going
>> forward.
>
>
> Thanks for api.php, Ian!  I have a couple questions.
>
> If I'm used to going to http://racktables.foo.com/index.php?page=rackspace
> in the web GUI, is http://racktables.foo.com/api.php?method=rackspace the
> equivalent API URL?
>
> I'm getting this:
>
> "Assertion failed
>
> Argument 'method' of value 'rackspace' is invalid."
>
> Is this working code?  Does it require a version newer than PHP 5.2?
>
> Thanks,
>
> Phil
>
> p.s. It looks like your code isn't archived at
> //www.freelists.org/post/racktables-users/writing-a-restful-API-in-php-for-Racktables,11
> but Gmane has it:
> http://cache.gmane.org//gmane/comp/misc/racktables/user/1766-001.bin
>
>

Other related posts: