class GistFile(nap.ResourceModel): content = nap.Field() size = nap.Field(readonly=True) raw_url = nap.Field(readonly=True) class Meta: root_url = 'https://api.github.com/gists'
class Tweet(nap.ResourceModel): id = nap.Field() text = nap.Field() class Meta: root_url = "https://api.twitter.com/1/" resource_name = "statuses" add_slash = False urls = (nap.nap_url("%(resource_name)s/show.json", params=('id', ), lookup=True), )
class SampleCacheableResource(nap.ResourceModel): title = nap.Field() content = nap.Field() slug = nap.Field(resource_id=True) alt_name = nap.Field(api_name='some_field') class Meta: root_url = "http://foo.com/v1/" resource_name = 'note' append_urls = (nap.lookup.nap_url(r'something/great/', collection=True, lookup=True), ) cache_backend = InMemoryCache()
class SampleResourceModel(nap.ResourceModel): title = nap.Field() content = nap.Field() slug = nap.Field(resource_id=True) alt_name = nap.Field(api_name='some_field') class Meta: root_url = "http://foo.com/v1/" resource_name = 'note' append_urls = ( nap.lookup.nap_url(r'%(hello)s/%(what)s/'), nap.lookup.nap_url(r'%(title)s/', update=True), )
class Gist(nap.ResourceModel): id = nap.Field(resource_id=True) description = nap.Field() public = nap.Field() files = nap.DictField(GistFile) url = nap.Field(readonly=True) user = nap.Field(readonly=True) html_url = nap.Field(readonly=True) class Meta: resource_name = 'gists' root_url = 'https://api.github.com/' add_slash = False update_method = 'PATCH' prepend_urls = ( # For accessing /gists/starred and /gists/public, eg. # Gist.filter(property='starred') nap_url('%(resource_name)s/%(property)s', collection=True, lookup=False), ) auth = ( FoauthAuthorization(secret.foauth_email, secret.foauth_password), )
class AuthorModel(nap.ResourceModel): name = nap.Field() email = nap.Field(default=None) class Meta: root_url = "http://foo.com/v1/"