def as_dict(self): representation = HALRepresentation({}) representation.add_embed('events', [ HALEventRepresentation(e, 'events.event').as_dict() for e in self.events ]) if self.day and self.month and self.year: representation.add_links( get_nav_links(self.endpoint, self.start, self.count, self.size, day=self.day, month=self.month, year=self.year)) representation.add_link( 'self', url_for(self.endpoint, day=self.day, month=self.month, year=self.year)) else: representation.add_links( get_nav_links(self.endpoint, self.start, self.count, self.size)) representation.add_link('self', url_for(self.endpoint)) return representation.as_dict()
def as_dict(self): values = {} values[<XXX>] = <XXX> values['_attribution'] = self.attribution values['_last_updated'] = self.last_updated representation = HALRepresentation(values) representation.add_link('self', url_for(self.endpoint)) return representation.as_dict()
def as_dict(self): representation = HALRepresentation({}) representation.add_embed('webcams', [ HALWebcamRepresentation(w, 'webcams.webcam').as_dict() for w in self.webcams ]) representation.add_link('self', url_for('webcams.webcams')) return representation.as_dict()
def as_dict(self): base = super(HALWebcamRepresentation, self).as_dict() representation = HALRepresentation(base) representation.add_link('self', url_for(self.endpoint, slug=self.webcam.slug)) if self.webcam.poi: # TODO remove hardcoded endpoint for places representation.add_link( 'poi', url_for('places.poidetail', ident=self.webcam.poi)) return representation.as_dict()
def get_routes(): path = request.path representation = HALRepresentation({}) representation.add_curie( 'hl', 'http://moxie.readthedocs.org/en/latest/http_api/events.html#{rel}') representation.add_link('self', '{bp}'.format(bp=path)) representation.add_link('hl:search', '{bp}search'.format(bp=path), title="Search events") representation.add_link('hl:event', '{bp}event/{{id}}'.format(bp=path), templated=True, title="Event") response = make_response(representation.as_json(), 200) response.headers['Content-Type'] = "application/json" return response
def as_dict(self): base = super(HALEventRepresentation, self).as_dict() representation = HALRepresentation(base) representation.add_link( 'self', url_for(self.endpoint, ident=self.event.signature)) return representation.as_dict()
def as_dict(self): rivers = RiversStatusRepresentation(self.rivers, self.last_updated).as_dict() representation = HALRepresentation(rivers) representation.add_link('self', url_for(self.endpoint)) return representation.as_dict()