[Pulp-list] (Sort of) REST Question

Mike McCune mmccune at redhat.com
Thu Sep 16 19:31:44 UTC 2010


On 09/16/2010 11:19 AM, Jason Dobies wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> The consumer history query lets you filter on event type (repo bound,
> consumer created, etc). So in the body of the query you'd pass something
> like:
>
> { 'event_type' : 'package_installed' }
>
> I understand a fair amount of the HATEOAS ideas and I know we're using
> it in a lot of ways (i.e. a repo sync returning the URL to check its
> status). But where does a client get the list of event types that can be
> queried?
>
> I have an API method to return them; that much was simple. I was going
> to add a web service call to it so our CLI could run that separately if
> the user wanted more information. But when I couldn't come up with a
> good URL to hang that list from, I figured this was probably a common
> thing we'd have to deal with.
>
> Right now the consumer history URL looks like:
>
> /consumers/<id>/history
>
> Would the event type enumeration be something like:
>
> /consumer-queries/history/event_types
>
> Or is this list of possible values something that only exists in
> documentation. I know this sort of thing isn't directly covered by
> HATEOAS, but it seems like if you're keeping the client that thin/dumb,
> you should also provide a server means for this sort of information.
>
>

perhaps for any given document that has different types you can 
represent that at the top of the list returned from the top level GET:

GET /foos/

returns:

{
'foo-types' : ['TYPE1', 'TYPE2', 'TYPE3'],
'foos' : [{'id': 'my-foo1',
   'name': 'My Foo 1'
   'foo-type': 'TYPE1'},
  {'id': 'my-foo2',
   'name': 'My Foo 2'},
   'foo-type': 'TYPE2']
}

so in your case it would be:


GET /consumers/<id>/history

{
'event_types' : ['TYPE_CONSUMER_CREATED', 'TYPE_CONSUMER_DELETED', 
'TYPE_REPO_BOUND',
          'TYPE_REPO_UNBOUND', 'TYPE_PACKAGE_INSTALLED', 
'TYPE_PACKAGE_UNINSTALLED',
          'TYPE_ERRATA_INSTALLED', 'TYPE_PROFILE_CHANGED']
'history' : [
   {"originator": "consumer", "timestamp": {"$date": 1283519842366},
     "type_name": "consumer_created", "consumer_id": "jdob", "details":
     null, "_ns": "consumer_history", "_id":
     "9b81254d-cbb3-463d-a7ba-59106e78a5fe", "id":
     "9b81254d-cbb3-463d-a7ba-59106e78a5fe"},
   {"originator": "consumer", "timestamp": {"$date": 1283519842366},
     "type_name": "repo_bound", "consumer_id": "jdob", "details":
     {"repo_id": "repo1"}, "_ns": "consumer_history", "_id":
     "53dd60e5-ca4b-47b0-8f90-325aeb0da17a", "id":
     "53dd60e5-ca4b-47b0-8f90-325aeb0da17a"}
]
}

this would illustrate to the caller the types they can filter on. Or you 
just include a link at the top of the results

'event_types' : '/pulp/api/consumers/<id>/event_types/'

or something like that.

Mike




More information about the Pulp-list mailing list