141 lines
8.2 KiB
HTML
141 lines
8.2 KiB
HTML
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module apiclient.schema</title>
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="#7799ee">
|
|
<td valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="apiclient.html"><font color="#ffffff">apiclient</font></a>.schema</strong></big></big></font></td
|
|
><td align=right valign=bottom
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jcgregorio/projects/google-api-python-client/apiclient/schema.py">/home/jcgregorio/projects/google-api-python-client/apiclient/schema.py</a></font></td></tr></table>
|
|
<p><tt>Schema processing for discovery based APIs<br>
|
|
<br>
|
|
<a href="#Schemas">Schemas</a> holds an APIs discovery schemas. It can return those schema as<br>
|
|
deserialized JSON objects, or pretty print them as prototype objects that<br>
|
|
conform to the schema.<br>
|
|
<br>
|
|
For example, given the schema:<br>
|
|
<br>
|
|
schema = """{<br>
|
|
"Foo": {<br>
|
|
"type": "<a href="__builtin__.html#object">object</a>",<br>
|
|
"properties": {<br>
|
|
"etag": {<br>
|
|
"type": "string",<br>
|
|
"description": "ETag of the collection."<br>
|
|
},<br>
|
|
"kind": {<br>
|
|
"type": "string",<br>
|
|
"description": "Type of the collection ('calendar#acl').",<br>
|
|
"default": "calendar#acl"<br>
|
|
},<br>
|
|
"nextPageToken": {<br>
|
|
"type": "string",<br>
|
|
"description": "Token used to access the next<br>
|
|
page of this result. Omitted if no further results are available."<br>
|
|
}<br>
|
|
}<br>
|
|
}<br>
|
|
}"""<br>
|
|
<br>
|
|
s = <a href="#Schemas">Schemas</a>(schema)<br>
|
|
print s.prettyPrintByName('Foo')<br>
|
|
<br>
|
|
Produces the following output:<br>
|
|
<br>
|
|
{<br>
|
|
"nextPageToken": "A String", # Token used to access the<br>
|
|
# next page of this result. Omitted if no further results are available.<br>
|
|
"kind": "A String", # Type of the collection ('calendar#acl').<br>
|
|
"etag": "A String", # ETag of the collection.<br>
|
|
},<br>
|
|
<br>
|
|
The constructor takes a discovery document in which to look up named schema.</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#aa55cc">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="copy.html">copy</a><br>
|
|
</td><td width="25%" valign=top><a href="json.html">json</a><br>
|
|
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ee77aa">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl>
|
|
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="apiclient.schema.html#Schemas">Schemas</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
</dl>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="Schemas">class <strong>Schemas</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt><a href="#Schemas">Schemas</a> for an API.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="Schemas-__init__"><strong>__init__</strong></a>(self, discovery)</dt><dd><tt>Constructor.<br>
|
|
<br>
|
|
Args:<br>
|
|
discovery: <a href="__builtin__.html#object">object</a>, Deserialized discovery document from which we pull<br>
|
|
out the named schema.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Schemas-get"><strong>get</strong></a>(self, name)</dt><dd><tt>Get deserialized JSON schema from the schema name.<br>
|
|
<br>
|
|
Args:<br>
|
|
name: string, Schema name.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Schemas-prettyPrintByName"><strong>prettyPrintByName</strong></a>(self, name)</dt><dd><tt>Get pretty printed <a href="__builtin__.html#object">object</a> prototype from the schema name.<br>
|
|
<br>
|
|
Args:<br>
|
|
name: string, Name of schema in the discovery document.<br>
|
|
<br>
|
|
Returns:<br>
|
|
string, A string that contains a prototype <a href="__builtin__.html#object">object</a> with<br>
|
|
comments that conforms to the given schema.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Schemas-prettyPrintSchema"><strong>prettyPrintSchema</strong></a>(self, schema)</dt><dd><tt>Get pretty printed <a href="__builtin__.html#object">object</a> prototype of schema.<br>
|
|
<br>
|
|
Args:<br>
|
|
schema: <a href="__builtin__.html#object">object</a>, Parsed JSON schema.<br>
|
|
<br>
|
|
Returns:<br>
|
|
string, A string that contains a prototype <a href="__builtin__.html#object">object</a> with<br>
|
|
comments that conforms to the given schema.</tt></dd></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
</dl>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#55aa55">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
|
<td width="100%"><strong>__author__</strong> = 'jcgregorio@google.com (Joe Gregorio)'</td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#7799ee">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
|
|
<td width="100%">jcgregorio@google.com (Joe Gregorio)</td></tr></table>
|
|
</body></html> |