apiclient.model | index /usr/local/google/home/jcgregorio/projects/apiclient/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 BaseModel JsonModel ProtocolBufferModel
class BaseModel(Model)
`` | `Base model class. Subclasses should provide implementations for the "serialize" and "deserialize" methods, as well as values for the following class attributes. Attributes: accept: The value to use for the HTTP Accept header. content_type: The value to use for the HTTP Content-type header. no_content_response: The value to return when deserializing a 204 "No Content" response. alt_param: The value to supply as the "alt" query parameter for requests.`
| Method resolution order: BaseModel Model __builtin__.object Methods defined here: deserialize(self, content) `Perform the actual deserialization from response string to Python object. Args: content: string, the body of the HTTP response Returns: The body de-serialized as a Python object.` request(self, headers, path_params, query_params, body_value) `Updates outgoing requests with a serialized 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 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.` serialize(self, body_value) `Perform the actual Python object serialization. Args: body_value: object, the request body as a Python object. Returns: string, the body in serialized form.` Data and other attributes defined here: accept = None alt_param = None content_type = None no_content_response = None Data descriptors inherited from Model: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`
class JsonModel(BaseModel)
`` | `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 BaseModel 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` deserialize(self, content) serialize(self, body_value) Data descriptors defined here: no_content_response Data and other attributes defined here: accept = 'application/json' alt_param = 'json' content_type = 'application/json' Methods inherited from BaseModel: request(self, headers, path_params, query_params, body_value) `Updates outgoing requests with a serialized 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 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 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 serialized 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)`
class ProtocolBufferModel(BaseModel)
`` | `Model class for protocol buffers. Serializes and de-serializes the binary protocol buffer sent in the HTTP request and response bodies.`
| Method resolution order: ProtocolBufferModel BaseModel Model __builtin__.object Methods defined here: __init__(self, protocol_buffer) `Constructs a ProtocolBufferModel. The serialzed protocol buffer returned in an HTTP response will be de-serialized using the given protocol buffer class. Args: protocol_buffer: The protocol buffer class used to de-serialize a response from the API.` deserialize(self, content) serialize(self, body_value) Data descriptors defined here: no_content_response Data and other attributes defined here: accept = 'application/x-protobuf' alt_param = 'proto' content_type = 'application/x-protobuf' Methods inherited from BaseModel: request(self, headers, path_params, query_params, body_value) `Updates outgoing requests with a serialized 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 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)`

Functions
`` |  | makepatch(original, modified) `Create a patch object. Some methods support PATCH, an efficient way to send updates to a resource. This method allows the easy construction of patch bodies by looking at the differences between a resource before and after it was modified. Args: original: object, the original deserialized resource modified: object, the modified deserialized resource Returns: An object that contains only the changes from original to modified, in a form suitable to pass to a PATCH method. Example usage: item = service.activities().get(postid=postid, userid=userid).execute() original = copy.deepcopy(item) item['object']['content'] = 'This is updated.' service.activities.patch(postid=postid, userid=userid, body=makepatch(original, item)).execute()`

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

Author
`` |  | jcgregorio@google.com (Joe Gregorio)