apiclient.schema
index
/home/jcgregorio/projects/google-api-python-client/apiclient/schema.py

Schema processing for discovery based APIs
 
Schemas holds an APIs discovery schemas. It can return those schema as
deserialized JSON objects, or pretty print them as prototype objects that
conform to the schema.
 
For example, given the schema:
 
 schema = """{
   "Foo": {
    "type": "object",
    "properties": {
     "etag": {
      "type": "string",
      "description": "ETag of the collection."
     },
     "kind": {
      "type": "string",
      "description": "Type of the collection ('calendar#acl').",
      "default": "calendar#acl"
     },
     "nextPageToken": {
      "type": "string",
      "description": "Token used to access the next
         page of this result. Omitted if no further results are available."
     }
    }
   }
 }"""
 
 s = Schemas(schema)
 print s.prettyPrintByName('Foo')
 
 Produces the following output:
 
  {
   "nextPageToken": "A String", # Token used to access the
       # next page of this result. Omitted if no further results are available.
   "kind": "A String", # Type of the collection ('calendar#acl').
   "etag": "A String", # ETag of the collection.
  },
 
The constructor takes a discovery document in which to look up named schema.

 
Modules
       
copy
json

 
Classes
       
__builtin__.object
Schemas

 
class Schemas(__builtin__.object)
    Schemas for an API.
 
  Methods defined here:
__init__(self, discovery)
Constructor.
 
Args:
  discovery: object, Deserialized discovery document from which we pull
    out the named schema.
get(self, name)
Get deserialized JSON schema from the schema name.
 
Args:
  name: string, Schema name.
prettyPrintByName(self, name)
Get pretty printed object prototype from the schema name.
 
Args:
  name: string, Name of schema in the discovery document.
 
Returns:
  string, A string that contains a prototype object with
    comments that conforms to the given schema.
prettyPrintSchema(self, schema)
Get pretty printed object prototype of schema.
 
Args:
  schema: object, Parsed JSON schema.
 
Returns:
  string, A string that contains a prototype object with
    comments that conforms to the given schema.

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

 
Data
        __author__ = 'jcgregorio@google.com (Joe Gregorio)'

 
Author
        jcgregorio@google.com (Joe Gregorio)