Package googleapiclient :: Module model :: Class BaseModel
[hide private]
[frames] | no frames]

Class BaseModel

source code

object --+    
         |    
     Model --+
             |
            BaseModel
Known Subclasses:

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.

Instance Methods [hide private]
 
_log_request(self, headers, path_params, query, body)
Logs debugging information about the request if requested.
source code
 
request(self, headers, path_params, query_params, body_value)
Updates outgoing requests with a serialized body.
source code
 
_build_query(self, params)
Builds a query string.
source code
 
_log_response(self, resp, content)
Logs debugging information about the response if requested.
source code
 
response(self, resp, content)
Convert the response wire format into a Python object.
source code
 
serialize(self, body_value)
Perform the actual Python object serialization.
source code
 
deserialize(self, content)
Perform the actual deserialization from response string to Python object.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  accept = None
  content_type = None
  no_content_response = None
  alt_param = None
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

request(self, headers, path_params, query_params, body_value)

source code 
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 json.
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

Overrides: Model.request

_build_query(self, params)

source code 
Builds a query string.

Args:
  params: dict, the query parameters

Returns:
  The query parameters properly encoded into an HTTP URI query string.

response(self, resp, content)

source code 
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:
  googleapiclient.errors.HttpError if a non 2xx response is received.

Overrides: Model.response

serialize(self, body_value)

source code 
Perform the actual Python object serialization.

Args:
  body_value: object, the request body as a Python object.

Returns:
  string, the body in serialized form.

deserialize(self, content)

source code 
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.