apiclient.model
index
/home/jcgregorio/projects/apiary/apiclient/model.py

Model objects for requests and responses.
 
Each API may support one or more serializations, such
as JSON, Atom, etc. The model classes are responsible
for converting between the wire format and the Python
object representation.

 
Modules
       
gflags
logging
simplejson
urllib

 
Classes
       
__builtin__.object
Model
JsonModel
LoggingJsonModel

 
class JsonModel(Model)
    Model class for JSON.
 
Serializes and de-serializes between JSON and the Python
object representation of HTTP request and response bodies.
 
 
Method resolution order:
JsonModel
Model
__builtin__.object

Methods defined here:
__init__(self, data_wrapper=False)
Construct a JsonModel
 
Args:
  data_wrapper: boolean, wrap requests and responses in a data wrapper
request(self, headers, path_params, query_params, body_value)
Updates outgoing requests with JSON bodies.
 
Args:
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query_params: dict, parameters that appear in the query
  body_value: object, the request body as a Python object, which must be
              serializable by simplejson.
Returns:
  A tuple of (headers, path_params, query, body)
 
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query: string, query part of the request URI
  body: string, the body serialized as JSON
response(self, resp, content)
Convert the response wire format into a Python object.
 
Args:
  resp: httplib2.Response, the HTTP response headers and status
  content: string, the body of the HTTP response
 
Returns:
  The body de-serialized as a Python object.
 
Raises:
  apiclient.errors.HttpError if a non 2xx response is received.

Data descriptors inherited from Model:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LoggingJsonModel(JsonModel)
    A printable JsonModel class that supports logging response info.
 
 
Method resolution order:
LoggingJsonModel
JsonModel
Model
__builtin__.object

Methods defined here:
request(self, headers, path_params, query_params, body_value)
An overloaded request method that will output debug info if requested.
 
Args:
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query_params: dict, parameters that appear in the query
  body_value: object, the request body as a Python object, which must be
              serializable by simplejson.
Returns:
  A tuple of (headers, path_params, query, body)
 
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query: string, query part of the request URI
  body: string, the body serialized as JSON
response(self, resp, content)
An overloaded response method that will output debug info if requested.
 
Args:
  resp: An httplib2.Response object.
  content: A string representing the response body.
 
Returns:
  The body de-serialized as a Python object.

Methods inherited from JsonModel:
__init__(self, data_wrapper=False)
Construct a JsonModel
 
Args:
  data_wrapper: boolean, wrap requests and responses in a data wrapper

Data descriptors inherited from Model:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Model(__builtin__.object)
    Model base class.
 
All Model classes should implement this interface.
The Model serializes and de-serializes between a wire
format such as JSON and a Python object representation.
 
  Methods defined here:
request(self, headers, path_params, query_params, body_value)
Updates outgoing requests with a deserialized body.
 
Args:
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query_params: dict, parameters that appear in the query
  body_value: object, the request body as a Python object, which must be
              serializable.
Returns:
  A tuple of (headers, path_params, query, body)
 
  headers: dict, request headers
  path_params: dict, parameters that appear in the request path
  query: string, query part of the request URI
  body: string, the body serialized in the desired wire format.
response(self, resp, content)
Convert the response wire format into a Python object.
 
Args:
  resp: httplib2.Response, the HTTP response headers and status
  content: string, the body of the HTTP response
 
Returns:
  The body de-serialized as a Python object.
 
Raises:
  apiclient.errors.HttpError if a non 2xx response is received.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        FLAGS = <gflags.FlagValues instance>
__author__ = 'jcgregorio@google.com (Joe Gregorio)'

 
Author
        jcgregorio@google.com (Joe Gregorio)