| |
- __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)
| |